diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2015-11-05 12:48:52 +0100 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2015-11-05 12:48:52 +0100 |
commit | fe9f1a6dedda6bab23cbb605d1cd5db6cd3e2468 (patch) | |
tree | d6ea417b7ed16c90b29634fe075e51508dec87d9 /lib/bitops.c | |
parent | 8eb8e546dc8cc647fcfa4a3a17dfa8ab36b00958 (diff) |
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.
Diffstat (limited to 'lib/bitops.c')
-rw-r--r-- | lib/bitops.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/bitops.c b/lib/bitops.c index 81586e87..efb8710e 100644 --- a/lib/bitops.c +++ b/lib/bitops.c @@ -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; } |