]> git.proxmox.com Git - mirror_frr.git/blame - ripd/ripd.h
Just "write" command without any parameters writes conf to file.
[mirror_frr.git] / ripd / ripd.h
CommitLineData
718e3744 1/* RIP related values and structures.
2 * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22#ifndef _ZEBRA_RIP_H
23#define _ZEBRA_RIP_H
24
25/* RIP version number. */
26#define RIPv1 1
27#define RIPv2 2
28
29/* RIP command list. */
30#define RIP_REQUEST 1
31#define RIP_RESPONSE 2
32#define RIP_TRACEON 3 /* Obsolete */
33#define RIP_TRACEOFF 4 /* Obsolete */
34#define RIP_POLL 5
35#define RIP_POLL_ENTRY 6
36#define RIP_COMMAND_MAX 7
37
38/* RIP metric infinity value.*/
39#define RIP_METRIC_INFINITY 16
40
41/* Normal RIP packet min and max size. */
42#define RIP_PACKET_MINSIZ 4
43#define RIP_PACKET_MAXSIZ 512
44
45#define RIP_HEADER_SIZE 4
46#define RIP_RTE_SIZE 20
47
48/* Max count of routing table entry in one rip packet. */
49#define RIP_MAX_RTE 25
50
51/* RIP version 2 multicast address. */
52#ifndef INADDR_RIP_GROUP
53#define INADDR_RIP_GROUP 0xe0000009 /* 224.0.0.9 */
54#endif
55
56/* RIP timers */
57#define RIP_UPDATE_TIMER_DEFAULT 30
58#define RIP_TIMEOUT_TIMER_DEFAULT 180
59#define RIP_GARBAGE_TIMER_DEFAULT 120
60
61/* RIP peer timeout value. */
62#define RIP_PEER_TIMER_DEFAULT 180
63
64/* RIP port number. */
65#define RIP_PORT_DEFAULT 520
66#define RIP_VTY_PORT 2602
718e3744 67
68/* Default configuration file name. */
69#define RIPD_DEFAULT_CONFIG "ripd.conf"
70
71/* RIP route types. */
72#define RIP_ROUTE_RTE 0
73#define RIP_ROUTE_STATIC 1
74#define RIP_ROUTE_DEFAULT 2
75#define RIP_ROUTE_REDISTRIBUTE 3
76#define RIP_ROUTE_INTERFACE 4
77
78/* RIP MD5 authentication. */
79#define RIP_AUTH_MD5_SIZE 16
80
81/* RIP structure. */
82struct rip
83{
84 /* RIP socket. */
85 int sock;
86
87 /* Default version of rip instance. */
88 u_char version;
89
90 /* Output buffer of RIP. */
91 struct stream *obuf;
92
93 /* RIP routing information base. */
94 struct route_table *table;
95
96 /* RIP only static routing information. */
97 struct route_table *route;
98
99 /* RIP neighbor. */
100 struct route_table *neighbor;
101
102 /* RIP threads. */
103 struct thread *t_read;
104
105 /* Update and garbage timer. */
106 struct thread *t_update;
107
108 /* Triggered update hack. */
109 int trigger;
110 struct thread *t_triggered_update;
111 struct thread *t_triggered_interval;
112
113 /* RIP timer values. */
114 unsigned long update_time;
115 unsigned long timeout_time;
116 unsigned long garbage_time;
117
118 /* RIP default metric. */
119 int default_metric;
120
121 /* RIP default-information originate. */
122 u_char default_information;
123 char *default_information_route_map;
124
125 /* RIP default distance. */
126 u_char distance;
127 struct route_table *distance_table;
128
129 /* For redistribute route map. */
130 struct
131 {
132 char *name;
133 struct route_map *map;
134 int metric_config;
135 u_int32_t metric;
136 } route_map[ZEBRA_ROUTE_MAX];
137};
138
139/* RIP routing table entry which belong to rip_packet. */
140struct rte
141{
142 u_int16_t family; /* Address family of this route. */
143 u_int16_t tag; /* Route Tag which included in RIP2 packet. */
144 struct in_addr prefix; /* Prefix of rip route. */
145 struct in_addr mask; /* Netmask of rip route. */
146 struct in_addr nexthop; /* Next hop of rip route. */
147 u_int32_t metric; /* Metric value of rip route. */
148};
149
150/* RIP packet structure. */
151struct rip_packet
152{
153 unsigned char command; /* Command type of RIP packet. */
154 unsigned char version; /* RIP version which coming from peer. */
155 unsigned char pad1; /* Padding of RIP packet header. */
156 unsigned char pad2; /* Same as above. */
157 struct rte rte[1]; /* Address structure. */
158};
159
160/* Buffer to read RIP packet. */
161union rip_buf
162{
163 struct rip_packet rip_packet;
164 char buf[RIP_PACKET_MAXSIZ];
165};
166
167/* RIP route information. */
168struct rip_info
169{
170 /* This route's type. */
171 int type;
172
173 /* Sub type. */
174 int sub_type;
175
176 /* RIP nexthop. */
177 struct in_addr nexthop;
178 struct in_addr from;
179
180 /* Which interface does this route come from. */
181 unsigned int ifindex;
182
183 /* Metric of this route. */
184 u_int32_t metric;
185
186 /* Tag information of this route. */
187 u_int16_t tag;
188
189 /* Flags of RIP route. */
190#define RIP_RTF_FIB 1
191#define RIP_RTF_CHANGED 2
192 u_char flags;
193
194 /* Garbage collect timer. */
195 struct thread *t_timeout;
196 struct thread *t_garbage_collect;
197
198 /* Route-map futures - this variables can be changed. */
199 struct in_addr nexthop_out;
200 u_char metric_set;
201 u_int32_t metric_out;
202 unsigned int ifindex_out;
203
204 struct route_node *rp;
205
206 u_char distance;
207
208#ifdef NEW_RIP_TABLE
209 struct rip_info *next;
210 struct rip_info *prev;
211#endif /* NEW_RIP_TABLE */
212};
213
214/* RIP specific interface configuration. */
215struct rip_interface
216{
217 /* RIP is enabled on this interface. */
218 int enable_network;
219 int enable_interface;
220
221 /* RIP is running on this interface. */
222 int running;
223
224 /* RIP version control. */
225 int ri_send;
226 int ri_receive;
227
228 /* RIPv2 authentication type. */
229#define RIP_NO_AUTH 0
230#define RIP_AUTH_DATA 1
231#define RIP_AUTH_SIMPLE_PASSWORD 2
232#define RIP_AUTH_MD5 3
233 int auth_type;
234
235 /* RIPv2 authentication string. */
236 char *auth_str;
237
238 /* RIPv2 authentication key chain. */
239 char *key_chain;
240
241 /* Split horizon flag. */
242 int split_horizon;
243 int split_horizon_default;
244
245 /* For filter type slot. */
246#define RIP_FILTER_IN 0
247#define RIP_FILTER_OUT 1
248#define RIP_FILTER_MAX 2
249
250 /* Access-list. */
251 struct access_list *list[RIP_FILTER_MAX];
252
253 /* Prefix-list. */
254 struct prefix_list *prefix[RIP_FILTER_MAX];
255
256 /* Wake up thread. */
257 struct thread *t_wakeup;
258
259 /* Interface statistics. */
260 int recv_badpackets;
261 int recv_badroutes;
262 int sent_updates;
263
264 /* Passive interface. */
265 int passive;
266};
267
268/* RIP peer information. */
269struct rip_peer
270{
271 /* Peer address. */
272 struct in_addr addr;
273
274 /* Peer RIP tag value. */
275 int domain;
276
277 /* Last update time. */
278 time_t uptime;
279
280 /* Peer RIP version. */
281 u_char version;
282
283 /* Statistics. */
284 int recv_badpackets;
285 int recv_badroutes;
286
287 /* Timeout thread. */
288 struct thread *t_timeout;
289};
290
291struct rip_md5_info
292{
293 u_int16_t family;
294 u_int16_t type;
295 u_int16_t packet_len;
296 u_char keyid;
297 u_char auth_len;
298 u_int32_t sequence;
299 u_int32_t reserv1;
300 u_int32_t reserv2;
301};
302
303struct rip_md5_data
304{
305 u_int16_t family;
306 u_int16_t type;
307 u_char digest[16];
308};
309
310/* RIP accepet/announce methods. */
311#define RI_RIP_UNSPEC 0
312#define RI_RIP_VERSION_1 1
313#define RI_RIP_VERSION_2 2
314#define RI_RIP_VERSION_1_AND_2 3
315
316/* Default value for "default-metric" command. */
317#define RIP_DEFAULT_METRIC_DEFAULT 1
318
319/* RIP event. */
320enum rip_event
321{
322 RIP_READ,
323 RIP_UPDATE_EVENT,
324 RIP_TRIGGERED_UPDATE,
325};
326
327/* Macro for timer turn on. */
328#define RIP_TIMER_ON(T,F,V) \
329 do { \
330 if (!(T)) \
331 (T) = thread_add_timer (master, (F), rinfo, (V)); \
332 } while (0)
333
334/* Macro for timer turn off. */
335#define RIP_TIMER_OFF(X) \
336 do { \
337 if (X) \
338 { \
339 thread_cancel (X); \
340 (X) = NULL; \
341 } \
342 } while (0)
343
344/* Prototypes. */
345void rip_init ();
346void rip_reset ();
347void rip_clean ();
348void rip_clean_network ();
349void rip_interface_clean ();
350void rip_interface_reset ();
351void rip_passive_interface_clean ();
352void rip_if_init ();
353void rip_if_down_all ();
354void rip_route_map_init ();
355void rip_route_map_reset ();
356void rip_snmp_init ();
357void rip_zclient_init ();
358void rip_zclient_start ();
359void rip_zclient_reset ();
360void rip_offset_init ();
718e3744 361
362int rip_request_send (struct sockaddr_in *, struct interface *, u_char);
363int rip_neighbor_lookup (struct sockaddr_in *);
364void rip_redistribute_add (int, int, struct prefix_ipv4 *, unsigned int,
365 struct in_addr *);
366void rip_redistribute_delete (int, int, struct prefix_ipv4 *, unsigned int);
367void rip_redistribute_withdraw (int);
368void rip_zebra_ipv4_add (struct prefix_ipv4 *, struct in_addr *, u_int32_t, u_char);
369void rip_zebra_ipv4_delete (struct prefix_ipv4 *, struct in_addr *, u_int32_t);
370void rip_interface_multicast_set (int, struct interface *);
371void rip_distribute_update_interface (struct interface *);
372
373int config_write_rip_network (struct vty *, int);
374int config_write_rip_offset_list (struct vty *);
375int config_write_rip_redistribute (struct vty *, int);
376
377void rip_peer_init ();
378void rip_peer_update (struct sockaddr_in *, u_char);
379void rip_peer_bad_route (struct sockaddr_in *);
380void rip_peer_bad_packet (struct sockaddr_in *);
381void rip_peer_display (struct vty *);
382struct rip_peer *rip_peer_lookup (struct in_addr *);
383struct rip_peer *rip_peer_lookup_next (struct in_addr *);
384
385int rip_offset_list_apply_in (struct prefix_ipv4 *, struct interface *, u_int32_t *);
386int rip_offset_list_apply_out (struct prefix_ipv4 *, struct interface *, u_int32_t *);
387void rip_offset_clean ();
388
389void rip_info_free (struct rip_info *);
390u_char rip_distance_apply (struct rip_info *);
391void rip_redistribute_clean ();
392void rip_ifaddr_add (struct interface *, struct connected *);
393void rip_ifaddr_delete (struct interface *, struct connected *);
394
395/* There is only one rip strucutre. */
396extern struct rip *rip;
397
398/* Master thread strucutre. */
399extern struct thread_master *master;
400
401/* RIP statistics for SNMP. */
402extern long rip_global_route_changes;
403extern long rip_global_queries;
404
405#endif /* _ZEBRA_RIP_H */