Bug 1285 - IPv6 Localhost is marked as GLOBAL instead of HOST
IPv6 Localhost is marked as GLOBAL instead of HOST
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: internet
pre-release
All All
: P3 normal
Assigned To: George Riley
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-10-23 13:19 UTC by Tommaso Pecorella
Modified: 2011-10-23 13:33 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tommaso Pecorella 2011-10-23 13:19:39 UTC
In ipv6-interface-address.cc, in the function:
void Ipv6InterfaceAddress::SetAddress (Ipv6Address address)

there is an if( address is localhost) {} if( address is link-local) {} else {}

The end result is that the host address is first marked as HOST, then as GLOBAL (right, it isn't a LINKLOCAL, so it's GLOBAL).

Quite wrong.

The obvious solution is to change the if as follows:

void Ipv6InterfaceAddress::SetAddress (Ipv6Address address)
{
  NS_LOG_FUNCTION (this << address);
  m_address = address;

  if (address.IsLocalhost ())
    {
      m_scope = HOST;
      /* localhost address is always /128 prefix */
      m_prefix = Ipv6Prefix (128);
    }
  else if (address.IsLinkLocal ())
    {
      m_scope = LINKLOCAL;
      /* link-local address is always /64 prefix */
      m_prefix = Ipv6Prefix (64);
    }
  else
    {
      m_scope = GLOBAL;
    }
}

as is to change the second "if" in an "else if"

Trivial, no need to submit a patch.
Comment 1 Tommaso Pecorella 2011-10-23 13:33:43 UTC
Fixed in changeset 487ec929a633