iof-bird-daemon / nest / iface.h @ 9a158361
History | View | Annotate | Download (4.06 KB)
1 |
/*
|
---|---|
2 |
* BIRD Internet Routing Daemon -- Network Interfaces
|
3 |
*
|
4 |
* (c) 1998--1999 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_IFACE_H_
|
10 |
#define _BIRD_IFACE_H_
|
11 |
|
12 |
#include "lib/lists.h" |
13 |
|
14 |
extern list iface_list;
|
15 |
|
16 |
struct proto;
|
17 |
|
18 |
struct ifa { /* Interface address */ |
19 |
node n; |
20 |
struct iface *iface; /* Interface this address belongs to */ |
21 |
ip_addr ip; /* IP address of this host */
|
22 |
ip_addr prefix; /* Network prefix */
|
23 |
unsigned pxlen; /* Prefix length */ |
24 |
ip_addr brd; /* Broadcast address */
|
25 |
ip_addr opposite; /* Opposite end of a point-to-point link */
|
26 |
unsigned scope; /* Interface address scope */ |
27 |
unsigned flags; /* Analogous to iface->flags */ |
28 |
}; |
29 |
|
30 |
struct iface {
|
31 |
node n; |
32 |
char name[16]; |
33 |
unsigned flags;
|
34 |
unsigned mtu;
|
35 |
unsigned index; /* OS-dependent interface index */ |
36 |
list addrs; /* Addresses assigned to this interface */
|
37 |
struct ifa *addr; /* Primary address */ |
38 |
struct neighbor *neigh; /* List of neighbors on this interface */ |
39 |
}; |
40 |
|
41 |
#define IF_UP 1 /* IF_LINK_UP and IP address known */ |
42 |
#define IF_MULTIACCESS 2 |
43 |
#define IF_UNNUMBERED 4 |
44 |
#define IF_BROADCAST 8 |
45 |
#define IF_MULTICAST 0x10 |
46 |
#define IF_TUNNEL 0x20 |
47 |
#define IF_ADMIN_DOWN 0x40 |
48 |
#define IF_LOOPBACK 0x80 |
49 |
#define IF_IGNORE 0x100 /* Not to be used by routing protocols (loopbacks etc.) */ |
50 |
#define IF_LINK_UP 0x200 |
51 |
|
52 |
#define IA_PRIMARY 0x10000 /* This address is primary */ |
53 |
#define IA_SECONDARY 0x20000 /* This address has been reported as secondary by the kernel */ |
54 |
#define IA_FLAGS 0xff0000 |
55 |
|
56 |
#define IF_JUST_CREATED 0x10000000 /* Send creation event as soon as possible */ |
57 |
#define IF_TMP_DOWN 0x20000000 /* Temporary shutdown due to interface reconfiguration */ |
58 |
#define IF_UPDATED 0x40000000 /* Touched in last scan */ |
59 |
|
60 |
/* Interface change events */
|
61 |
|
62 |
#define IF_CHANGE_UP 1 |
63 |
#define IF_CHANGE_DOWN 2 |
64 |
#define IF_CHANGE_MTU 4 |
65 |
#define IF_CHANGE_CREATE 8 /* Seen this interface for the first time */ |
66 |
#define IF_CHANGE_TOO_MUCH 0x40000000 /* Used internally */ |
67 |
|
68 |
void if_init(void); |
69 |
void if_dump(struct iface *); |
70 |
void if_dump_all(void); |
71 |
void ifa_dump(struct ifa *); |
72 |
struct iface *if_update(struct iface *); |
73 |
struct ifa *ifa_update(struct ifa *); |
74 |
void ifa_delete(struct ifa *); |
75 |
void if_start_update(void); |
76 |
void if_end_update(void); |
77 |
void if_end_partial_update(struct iface *); |
78 |
void if_feed_baby(struct proto *); |
79 |
struct iface *if_find_by_index(unsigned); |
80 |
struct iface *if_find_by_name(char *); |
81 |
|
82 |
/*
|
83 |
* Neighbor Cache. We hold (direct neighbor, protocol) pairs we've seen
|
84 |
* along with pointer to protocol-specific data.
|
85 |
*
|
86 |
* The primary goal of this cache is to quickly validate all incoming
|
87 |
* packets if their have been sent by our neighbors and to notify
|
88 |
* protocols about lost neighbors when an interface goes down.
|
89 |
*
|
90 |
* Anyway, it can also contain `sticky' entries for currently unreachable
|
91 |
* addresses which cause notification when the address becomes a neighbor.
|
92 |
*/
|
93 |
|
94 |
typedef struct neighbor { |
95 |
node n; /* Node in global neighbor list */
|
96 |
ip_addr addr; /* Address of the neighbor */
|
97 |
struct iface *iface; /* Interface it's connected to */ |
98 |
struct neighbor *sibling; /* Next in per-device chain */ |
99 |
struct proto *proto; /* Protocol this belongs to */ |
100 |
void *data; /* Protocol-specific data */ |
101 |
unsigned flags;
|
102 |
} neighbor; |
103 |
|
104 |
#define NEF_STICKY 1 |
105 |
|
106 |
/*
|
107 |
* Find neighbor or return NULL if it doesn't exist.
|
108 |
* If you specify flags == NEF_STICKY, a sticky entry is created if the
|
109 |
* address is not a neighbor, but NULL can still be returned if the address
|
110 |
* given is invalid.
|
111 |
*/
|
112 |
neighbor *neigh_find(struct proto *, ip_addr *, unsigned flags); |
113 |
|
114 |
void neigh_dump(neighbor *);
|
115 |
void neigh_dump_all(void); |
116 |
void neigh_prune(void); |
117 |
|
118 |
/*
|
119 |
* Interface Pattern Lists
|
120 |
*/
|
121 |
|
122 |
struct iface_patt {
|
123 |
node n; |
124 |
byte *pattern; /* Interface name pattern */
|
125 |
|
126 |
/* Protocol-specific data follow, but keep them like this:
|
127 |
struct rip_iface_patt {
|
128 |
struct iface_patt i;
|
129 |
whatever you (need);
|
130 |
}
|
131 |
*/
|
132 |
}; |
133 |
|
134 |
struct iface_patt *iface_patt_match(list *, struct iface *); |
135 |
int iface_patts_equal(list *, list *, int (*)(struct iface_patt *, struct iface_patt *)); |
136 |
|
137 |
#endif
|