]> git.ipfire.org Git - thirdparty/bird.git/blob - nest/iface.h
Now sending IF_CHANGE_CREATE when a new interface appears and IF_CHANGE_UP
[thirdparty/bird.git] / nest / iface.h
1 /*
2 * BIRD Internet Routing Daemon -- Network Interfaces
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_IFACE_H_
10 #define _BIRD_IFACE_H_
11
12 #include "lib/lists.h"
13
14 extern list iface_list;
15
16 struct iface {
17 node n;
18 char name[16];
19 unsigned flags;
20 unsigned mtu;
21 unsigned index; /* OS-dependent interface index */
22 ip_addr ip; /* IP address of this host */
23 ip_addr prefix; /* Network prefix */
24 unsigned pxlen; /* Prefix length */
25 ip_addr brd; /* Broadcast address */
26 ip_addr opposite; /* Opposite end of a point-to-point link */
27 struct neighbor *neigh; /* List of neighbors on this interface */
28 };
29
30 #define IF_UP 1
31 #define IF_MULTIACCESS 2
32 #define IF_UNNUMBERED 4
33 #define IF_BROADCAST 8
34 #define IF_MULTICAST 16
35 #define IF_TUNNEL 32
36 #define IF_ADMIN_DOWN 64
37 #define IF_LOOPBACK 128
38 #define IF_IGNORE 256
39 #define IF_UPDATED 0x1000 /* Touched in last scan */
40
41 /* Interface change events */
42
43 #define IF_CHANGE_UP 1
44 #define IF_CHANGE_DOWN 2
45 #define IF_CHANGE_FLAGS 4 /* Can be converted to down/up internally */
46 #define IF_CHANGE_MTU 8
47 #define IF_CHANGE_CREATE 16 /* Seen this interface for the first time */
48
49 void if_init(void);
50 void if_dump(struct iface *);
51 void if_dump_all(void);
52 void if_update(struct iface *);
53 void if_end_update(void);
54
55 /*
56 * Neighbor Cache. We hold (direct neighbor, protocol) pairs we've seen
57 * along with pointer to protocol-specific data.
58 *
59 * The primary goal of this cache is to quickly validate all incoming
60 * packets if their have been sent by our neighbors and to notify
61 * protocols about lost neighbors when an interface goes down.
62 *
63 * Anyway, it can also contain `sticky' entries for currently unreachable
64 * addresses which cause notification when the address becomes a neighbor.
65 */
66
67 typedef struct neighbor {
68 node n; /* Node in global neighbor list */
69 ip_addr addr; /* Address of the neighbor */
70 struct iface *iface; /* Interface address it's connected to */
71 struct neighbor *sibling; /* Next in per-device chain */
72 struct proto *proto; /* Protocol this belongs to */
73 void *data; /* Protocol-specific data */
74 unsigned flags;
75 } neighbor;
76
77 #define NEF_STICKY 1
78
79 /*
80 * Find neighbor or return NULL if it doesn't exist.
81 * If you specify flags == NEF_STICKY, a sticky entry is created if the
82 * address is not a neighbor, but NULL can still be returned if the address
83 * given is invalid.
84 */
85 neighbor *neigh_find(struct proto *, ip_addr *, unsigned flags);
86
87 void neigh_dump(neighbor *);
88 void neigh_dump_all(void);
89
90 #endif