[Ns-bugs] [Bug 634] New: [PATCH] Feature to grab Network Length out of Ipv4Mask
code@nsnam.ece.gatech.edu
code at nsnam.ece.gatech.edu
Thu Jul 9 05:59:33 PDT 2009
http://www.nsnam.org/bugzilla/show_bug.cgi?id=634
Summary: [PATCH] Feature to grab Network Length out of Ipv4Mask
Product: ns-3
Version: ns-3-dev
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P5
Component: internet-stack
AssignedTo: ns-bugs at isi.edu
ReportedBy: zarhan at cc.hut.fi
Estimated Hours: 0.0
Created an attachment (id=524)
--> (http://www.nsnam.org/bugzilla/attachment.cgi?id=524)
Adds GetMaskLength-method.
For some stuff, I need to check what size a given network is, "prefix length",
ie. the CIDR notation, or 1.2.3.0/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
class).
For example,
std::cout << Ipv4Mask ("255.255.255.255").GetMaskLength()
prints 32,
std::cout << Ipv4Mask ("255.255.255.240").GetMaskLength()
prints 28
std::cout << Ipv4Mask ("128.0.0.0").GetMaskLength()
prints 1
std::cout << Ipv4Mask ("0.0.0.0").GetMaskLength()
prints 0.
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
mailing list