summaryrefslogtreecommitdiffstats
path: root/lib/prefix.c
diff options
context:
space:
mode:
authorPaul Jakma <paul@quagga.net>2011-04-08 13:44:43 +0200
committerPaul Jakma <paul@quagga.net>2012-01-06 17:18:18 +0100
commitf63f06da2e7be6b17c72dd6110aae179f42f3700 (patch)
treea36b625a9ea06d0720a240276ed1b8af33193ed7 /lib/prefix.c
parentdoc: update BGP RFC references (diff)
downloadfrr-f63f06da2e7be6b17c72dd6110aae179f42f3700.tar.xz
frr-f63f06da2e7be6b17c72dd6110aae179f42f3700.zip
general: remove inline qualifiers and move in-header functions to objects
* (general) Move functions in headers into files, to be compiled into shared object files. Remove inline qualifier from functions. Let the compiler do the work.
Diffstat (limited to 'lib/prefix.c')
-rw-r--r--lib/prefix.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/prefix.c b/lib/prefix.c
index 1b1c66267..3ab67f3d5 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -2317,6 +2317,21 @@ static const char map64kto17_nbo[0xffff + 1] =
#define MASKBIT(offset) ((0xff << (PNBBY - (offset))) & 0xff)
+unsigned int
+prefix_bit (const u_char *prefix, const u_char prefixlen)
+{
+ unsigned int offset = prefixlen / 8;
+ unsigned int shift = 7 - (prefixlen % 8);
+
+ return (prefix[offset] >> shift) & 1;
+}
+
+unsigned int
+prefix6_bit (const struct in6_addr *prefix, const u_char prefixlen)
+{
+ return prefix_bit((const u_char *) &prefix->s6_addr, prefixlen);
+}
+
/* Address Famiy Identifier to Address Family converter. */
int
afi2family (afi_t afi)