Bug 794

Summary: Ipv4Mask constructor for "/yy"-notation is wrong
Product: ns-3 Reporter: Antti Mäkelä <antti.makela>
Component: networkAssignee: Craig Dowell <craigdo>
Status: RESOLVED FIXED    
Severity: normal CC: jpelkey, ns-bugs, tomh
Priority: P2    
Version: pre-release   
Hardware: All   
OS: All   
Attachments: patch to fix

Description Antti Mäkelä 2010-01-20 03:23:30 EST
In src/node/ipv4-address.cc, line 71 and onwards,

The constructor should be:

Ipv4Mask::Ipv4Mask (char const *mask)
{
  if (*mask == ASCII_SLASH)
    {
      uint32_t plen = static_cast<uint32_t> (atoi (++mask));
      NS_ASSERT (plen <= 32);
      m_mask = 0xffffffff >> (32-plen);
    }
  else
    {
      m_mask = AsciiToIpv4Host (mask);
    }
}

Right now it just places the prefix length, as is, to m_mask, ending up with some rather weird results.
Comment 1 Antti Mäkelä 2010-01-20 04:45:14 EST
Whoops, obviously the bit-shift should be to other direction, so 

m_mask = 0xffffffff << (32-plen);

is correct.
Comment 2 Tom Henderson 2010-01-21 23:02:27 EST
Created attachment 733 [details]
patch to fix

IMO, this is ready to commit.  Tested (does not change any existing test output).  I made a slight adjustment to what was previously posted for the boundary condition of "/0".
Comment 3 Craig Dowell 2010-01-22 02:01:14 EST
+1 on readiness.

This is a P5 bug, so theoretically we should not commit until release unless the priority is bumped.
Comment 4 Josh Pelkey 2010-01-31 15:48:14 EST
(In reply to comment #3)
> +1 on readiness.
> 
> This is a P5 bug, so theoretically we should not commit until release unless
> the priority is bumped.

Craig, can you push this one?
Comment 5 Craig Dowell 2010-02-05 13:04:08 EST
changeset 8dcb272f3c00