[bug 634] patch to grab prefix length from Ipv4Mask

This commit is contained in:
Antti Makela committed 2009-08-22 14:58:27 -07:00
1 parent 2b2a54b189
commit 291bd3db0c
2 files changed
+18

No files matched your search

+14
View File
@@ -133,6 +133,20 @@ Ipv4Mask::GetOnes (void)
return ones;
}
uint16_t
Ipv4Mask::GetPrefixLength (void) const
{
uint16_t tmp = 0;
uint32_t mask = m_mask;
while (mask != 0 )
{
mask = mask << 1;
tmp++;
}
return tmp;
}
Ipv4Address::Ipv4Address ()
: m_address (0x66666666)
{}
+4
View File
@@ -237,6 +237,10 @@ public:
* \param os The output stream to which this Ipv4Address is printed
*/
void Print (std::ostream &os) const;
/**
* \return the prefix length of mask (the yy in x.x.x.x/yy notation)
*/
uint16_t GetPrefixLength (void) const;
/**
* \return the 255.0.0.0 mask corresponding to a typical loopback address
*/