Bug 794 - Ipv4Mask constructor for "/yy"-notation is wrong
Ipv4Mask constructor for "/yy"-notation is wrong
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: network
pre-release
All All
: P2 normal
Assigned To: Craig Dowell
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-01-20 03:23 EST by Antti Mäkelä
Modified: 2010-02-05 13:04 EST (History)
3 users (show)

See Also:


Attachments
patch to fix (840 bytes, patch)
2010-01-21 23:02 EST, Tom Henderson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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