mirror of
https://gitlab.labs.nic.cz/labs/bird.git
synced 2024-05-11 16:54:54 +00:00
Initial commit on integrated BIRD
New data types net_addr and variants (in lib/net.h) describing network addresses (prefix/pxlen). Modifications of FIB structures to handle these data types and changing everything to use these data types instead of prefix/pxlen pairs where possible. The commit is WiP, some protocols are not yet updated (BGP, Kernel), and the code contains some temporary scaffolding. Comments are welcome.
This commit is contained in:
@@ -28,15 +28,15 @@ u32_mkmask(uint n)
|
||||
*
|
||||
* This function checks whether the given integer @x represents
|
||||
* a valid bit mask (binary representation contains first ones, then
|
||||
* zeroes) and returns the number of ones or -1 if the mask is invalid.
|
||||
* zeroes) and returns the number of ones or 255 if the mask is invalid.
|
||||
*/
|
||||
int
|
||||
uint
|
||||
u32_masklen(u32 x)
|
||||
{
|
||||
int l = 0;
|
||||
u32 n = ~x;
|
||||
|
||||
if (n & (n+1)) return -1;
|
||||
if (n & (n+1)) return 255;
|
||||
if (x & 0x0000ffff) { x &= 0x0000ffff; l += 16; }
|
||||
if (x & 0x00ff00ff) { x &= 0x00ff00ff; l += 8; }
|
||||
if (x & 0x0f0f0f0f) { x &= 0x0f0f0f0f; l += 4; }
|
||||
|
Reference in New Issue
Block a user