]> git.ipfire.org Git - thirdparty/bird.git/blob - lib/ip.h
Adds %R printf directive for Router ID.
[thirdparty/bird.git] / lib / ip.h
1 /*
2 * BIRD Internet Routing Daemon -- The Internet Protocol
3 *
4 * (c) 1998 Martin Mares <mj@ucw.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9 #ifndef _BIRD_IP_H_
10 #define _BIRD_IP_H_
11
12 #ifndef IPV6
13 #include "ipv4.h"
14 #else
15 #include "ipv6.h"
16 #endif
17
18 #define ipa_in_net(x,n,p) (!ipa_nonzero(ipa_and(ipa_xor((n),(x)),ipa_mkmask(p))))
19
20 /*
21 * ip_classify() returns either a negative number for invalid addresses
22 * or scope OR'ed together with address type.
23 */
24
25 #define IADDR_INVALID -1
26 #define IADDR_SCOPE_MASK 0xfff
27 #define IADDR_HOST 0x1000
28 #define IADDR_BROADCAST 0x2000
29 #define IADDR_MULTICAST 0x4000
30
31 /*
32 * Address scope
33 */
34
35 #define SCOPE_HOST 0
36 #define SCOPE_LINK 1
37 #define SCOPE_SITE 2
38 #define SCOPE_ORGANIZATION 3
39 #define SCOPE_UNIVERSE 4
40
41 char *ip_scope_text(unsigned);
42
43 /*
44 * Network prefixes
45 */
46
47 struct prefix {
48 ip_addr addr;
49 int len;
50 };
51
52 #define ip_is_prefix(a,l) (!ipa_nonzero(ipa_and(a, ipa_not(ipa_mkmask(l)))))
53
54 /*
55 * Conversions between internal and string representation
56 */
57
58 char *ip_ntop(ip_addr a, char *);
59 char *ip_ntox(ip_addr a, char *);
60 int ip_pton(char *a, ip_addr *o);
61
62 #endif