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