]> git.ipfire.org Git - thirdparty/bird.git/blob - proto/rip/rip.h
Better packet priority and traffic class handling.
[thirdparty/bird.git] / proto / rip / rip.h
1 /*
2 * Structures for RIP protocol
3 *
4 FIXME: in V6, they insert additional entry whenever next hop differs. Such entry is identified by 0xff in metric.
5 */
6
7 #include "nest/route.h"
8 #include "nest/password.h"
9 #include "nest/locks.h"
10
11 #define EA_RIP_TAG EA_CODE(EAP_RIP, 0)
12 #define EA_RIP_METRIC EA_CODE(EAP_RIP, 1)
13
14 #define PACKET_MAX 25
15 #define PACKET_MD5_MAX 18 /* FIXME */
16
17
18 #define RIP_V1 1
19 #define RIP_V2 2
20 #define RIP_NG 1 /* A new version numbering */
21
22 #ifndef IPV6
23 #define RIP_PORT 520 /* RIP for IPv4 */
24 #else
25 #define RIP_PORT 521 /* RIPng */
26 #endif
27
28 struct rip_connection {
29 node n;
30
31 int num;
32 struct proto *proto;
33 ip_addr addr;
34 sock *send;
35 struct rip_interface *rif;
36 struct fib_iterator iter;
37
38 ip_addr daddr;
39 int dport;
40 int done;
41 };
42
43 struct rip_packet_heading { /* 4 bytes */
44 u8 command;
45 #define RIPCMD_REQUEST 1 /* want info */
46 #define RIPCMD_RESPONSE 2 /* responding to request */
47 #define RIPCMD_TRACEON 3 /* turn tracing on */
48 #define RIPCMD_TRACEOFF 4 /* turn it off */
49 #define RIPCMD_MAX 5
50 u8 version;
51 #define RIP_V1 1
52 #define RIP_V2 2
53 #define RIP_NG 1 /* this is verion 1 of RIPng */
54 u16 unused;
55 };
56
57 #ifndef IPV6
58 struct rip_block { /* 20 bytes */
59 u16 family; /* 0xffff on first message means this is authentication */
60 u16 tag;
61 ip_addr network;
62 ip_addr netmask;
63 ip_addr nexthop;
64 u32 metric;
65 };
66 #else
67 struct rip_block { /* IPv6 version!, 20 bytes, too */
68 ip_addr network;
69 u16 tag;
70 u8 pxlen;
71 u8 metric;
72 };
73 #endif
74
75 struct rip_block_auth { /* 20 bytes */
76 u16 mustbeFFFF;
77 u16 authtype;
78 u16 packetlen;
79 u8 keyid;
80 u8 authlen;
81 u32 seq;
82 u32 zero0;
83 u32 zero1;
84 };
85
86 struct rip_md5_tail { /* 20 bytes */
87 u16 mustbeFFFF;
88 u16 mustbe0001;
89 char md5[16];
90 };
91
92 struct rip_entry {
93 struct fib_node n;
94
95 ip_addr whotoldme;
96 ip_addr nexthop;
97 int metric;
98 u16 tag;
99
100 bird_clock_t updated, changed;
101 int flags;
102 };
103
104 struct rip_packet {
105 struct rip_packet_heading heading;
106 struct rip_block block[PACKET_MAX];
107 };
108
109 struct rip_interface {
110 node n;
111 struct proto *proto;
112 struct iface *iface;
113 sock *sock;
114 struct rip_connection *busy;
115 int metric; /* You don't want to put struct rip_patt *patt here -- think about reconfigure */
116 int mode;
117 int triggered;
118 struct object_lock *lock;
119 int multicast;
120 };
121
122 struct rip_patt {
123 struct iface_patt i;
124
125 int metric; /* If you add entries here, don't forget to modify patt_compare! */
126 int mode;
127 #define IM_BROADCAST 2
128 #define IM_QUIET 4
129 #define IM_NOLISTEN 8
130 #define IM_VERSION1 16
131 int tx_tos;
132 int tx_priority;
133 };
134
135 struct rip_proto_config {
136 struct proto_config c;
137 list iface_list; /* Patterns configured -- keep it first; see rip_reconfigure why */
138 list *passwords; /* Passwords, keep second */
139
140 int infinity; /* User configurable data; must be comparable with memcmp */
141 int port;
142 int period;
143 int garbage_time;
144 int timeout_time;
145
146 int authtype;
147 #define AT_NONE 0
148 #define AT_PLAINTEXT 2
149 #define AT_MD5 3
150 int honor;
151 #define HO_NEVER 0
152 #define HO_NEIGHBOR 1
153 #define HO_ALWAYS 2
154 };
155
156 struct rip_proto {
157 struct proto inherited;
158 timer *timer;
159 list connections;
160 struct fib rtable;
161 list garbage;
162 list interfaces; /* Interfaces we really know about */
163 #ifdef LOCAL_DEBUG
164 int magic;
165 #endif
166 int tx_count; /* Do one regular update once in a while */
167 int rnd_count; /* Randomize sending time */
168 };
169
170 #ifdef LOCAL_DEBUG
171 #define RIP_MAGIC 81861253
172 #define CHK_MAGIC do { if (P->magic != RIP_MAGIC) bug( "Not enough magic" ); } while (0)
173 #else
174 #define CHK_MAGIC do { } while (0)
175 #endif
176
177
178 void rip_init_instance(struct proto *p);
179 void rip_init_config(struct rip_proto_config *c);
180
181 /* Authentication functions */
182
183 int rip_incoming_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num, ip_addr whotoldme );
184 int rip_outgoing_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );