Bug 1285

Summary: IPv6 Localhost is marked as GLOBAL instead of HOST
Product: ns-3 Reporter: Tommaso Pecorella <tommaso.pecorella>
Component: internetAssignee: George Riley <riley>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs
Priority: P3    
Version: pre-release   
Hardware: All   
OS: All   

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