]>
git.ipfire.org Git - thirdparty/bird.git/blob - lib/ip.h
2 * BIRD Internet Routing Daemon -- The Internet Protocol
4 * (c) 1998 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
18 #define ipa_zero(x) (!ipa_nonzero(x))
19 #define ip_is_prefix(a,l) (!ipa_nonzero(ipa_and(a, ipa_not(ipa_mkmask(l)))))
20 #define ipa_in_net(x,n,p) (ipa_zero(ipa_and(ipa_xor((n),(x)),ipa_mkmask(p))))
21 #define net_in_net(n1,l1,n2,l2) (((l1) >= (l2)) && (ipa_zero(ipa_and(ipa_xor((n1),(n2)),ipa_mkmask(l2)))))
24 * ip_classify() returns either a negative number for invalid addresses
25 * or scope OR'ed together with address type.
28 #define IADDR_INVALID -1
29 #define IADDR_SCOPE_MASK 0xfff
30 #define IADDR_HOST 0x1000
31 #define IADDR_BROADCAST 0x2000
32 #define IADDR_MULTICAST 0x4000
41 #define SCOPE_ORGANIZATION 3
42 #define SCOPE_UNIVERSE 4
43 #define SCOPE_UNDEFINED 5
45 char *ip_scope_text(unsigned);
56 static inline int ipa_classify_net(ip_addr a
)
57 { return ipa_zero(a
) ? (IADDR_HOST
| SCOPE_UNIVERSE
) : ipa_classify(a
); }
60 * Conversions between internal and string representation
63 char *ip_ntop(ip_addr a
, char *);
64 char *ip_ntox(ip_addr a
, char *);
65 int ip_pton(char *a
, ip_addr
*o
);