[Ns-bugs] [Bug 634] New: [PATCH] Feature to grab Network Length out of Ipv4Mask
code at nsnam.ece.gatech.edu
Thu Jul 9 05:59:33 PDT 2009
Summary: [PATCH] Feature to grab Network Length out of Ipv4Mask
AssignedTo: ns-bugs at isi.edu
ReportedBy: zarhan at cc.hut.fi
Estimated Hours: 0.0
Created an attachment (id=524)
For some stuff, I need to check what size a given network is, "prefix length",
ie. the CIDR notation, or 22.214.171.124/24 and similar. This patch adds a
GetMaskLength() method to Ipv4Mask that obtains it. Documentation included.
This notation is also used in IPv6 prefixes. (Weirdly, there is no Ipv4Prefix
std::cout << Ipv4Mask ("255.255.255.255").GetMaskLength()
std::cout << Ipv4Mask ("255.255.255.240").GetMaskLength()
std::cout << Ipv4Mask ("126.96.36.199").GetMaskLength()
std::cout << Ipv4Mask ("0.0.0.0").GetMaskLength()
Anyway, just in case it seems a good addition.
Unfortunately, the constructor for Ipv4Mask that takes an integer as a
parameter, thus it cannot easily be adapted into specifying length instead,
it's simply copying a 32-bit number as the mask. I would like to enter
Ipv4masks in prefix format.
(Ipv6Prefix::Ipv6Prefix(uint8_t) DOES exist).
Also Ipv6Prefix class didn't seem to have a convention for function name to
simply get the length, so I used this one.
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Ns-bugs