MiniDLNA update: 1.0.19.1 to 1.0.20
[tomato.git] / release / src / router / zebra / ripd / ripd.h
blob9b25fce02796c85256b6f5f6124c8d0af4d4720c
1 /* RIP related values and structures.
2 * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
4 * This file is part of GNU Zebra.
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.
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.
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.
22 #ifndef _ZEBRA_RIP_H
23 #define _ZEBRA_RIP_H
25 /* RIP version number. */
26 #define RIPv1 1
27 #define RIPv2 2
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
38 /* RIP metric infinity value.*/
39 #define RIP_METRIC_INFINITY 16
41 /* Normal RIP packet min size. */
42 #define RIP_PACKET_MINSIZ 4
44 /* Normal RIP packet max size is 512 but some implementation has a bug
45 in authentication handling. In that case 524 length RIP packet may
46 come. */
47 #define RIP_PACKET_MAXSIZ 512
49 #define RIP_HEADER_SIZE 4
50 #define RIP_RTE_SIZE 20
52 /* Max count of routing table entry in one rip packet. */
53 #define RIP_MAX_RTE 25
55 /* RIP version 2 multicast address. */
56 #ifndef INADDR_RIP_GROUP
57 #define INADDR_RIP_GROUP 0xe0000009 /* 224.0.0.9 */
58 #endif
60 /* RIP timers */
61 #define RIP_UPDATE_TIMER_DEFAULT 30
62 #define RIP_TIMEOUT_TIMER_DEFAULT 180
63 #define RIP_GARBAGE_TIMER_DEFAULT 120
65 /* RIP peer timeout value. */
66 #define RIP_PEER_TIMER_DEFAULT 180
68 /* RIP port number. */
69 #define RIP_PORT_DEFAULT 520
70 #define RIP_VTY_PORT 2602
71 #define RIP_VTYSH_PATH "/tmp/.ripd"
73 /* Default configuration file name. */
74 #define RIPD_DEFAULT_CONFIG "ripd.conf"
76 /* RIP route types. */
77 #define RIP_ROUTE_RTE 0
78 #define RIP_ROUTE_STATIC 1
79 #define RIP_ROUTE_DEFAULT 2
80 #define RIP_ROUTE_REDISTRIBUTE 3
81 #define RIP_ROUTE_INTERFACE 4
83 /* RIP MD5 authentication. */
84 #define RIP_AUTH_MD5_SIZE 16
86 /* UDP socket receive buffer size. */
87 #define RIP_UDP_RCV_BUF 41600
89 /* RIP structure. */
90 struct rip
92 /* RIP socket. */
93 int sock;
95 /* Default version of rip instance. */
96 u_char version;
98 /* Output buffer of RIP. */
99 struct stream *obuf;
101 /* RIP routing information base. */
102 struct route_table *table;
104 /* RIP only static routing information. */
105 struct route_table *route;
107 /* RIP neighbor. */
108 struct route_table *neighbor;
110 /* RIP threads. */
111 struct thread *t_read;
113 /* Update and garbage timer. */
114 struct thread *t_update;
116 /* Triggered update hack. */
117 int trigger;
118 struct thread *t_triggered_update;
119 struct thread *t_triggered_interval;
121 /* RIP timer values. */
122 unsigned long update_time;
123 unsigned long timeout_time;
124 unsigned long garbage_time;
126 /* RIP default metric. */
127 int default_metric;
129 /* RIP default-information originate. */
130 u_char default_information;
131 char *default_information_route_map;
133 /* RIP default distance. */
134 u_char distance;
135 struct route_table *distance_table;
137 /* For redistribute route map. */
138 struct
140 char *name;
141 struct route_map *map;
142 int metric_config;
143 u_int32_t metric;
144 } route_map[ZEBRA_ROUTE_MAX];
147 /* RIP routing table entry which belong to rip_packet. */
148 struct rte
150 u_int16_t family; /* Address family of this route. */
151 u_int16_t tag; /* Route Tag which included in RIP2 packet. */
152 struct in_addr prefix; /* Prefix of rip route. */
153 struct in_addr mask; /* Netmask of rip route. */
154 struct in_addr nexthop; /* Next hop of rip route. */
155 u_int32_t metric; /* Metric value of rip route. */
158 /* RIP packet structure. */
159 struct rip_packet
161 unsigned char command; /* Command type of RIP packet. */
162 unsigned char version; /* RIP version which coming from peer. */
163 unsigned char pad1; /* Padding of RIP packet header. */
164 unsigned char pad2; /* Same as above. */
165 struct rte rte[1]; /* Address structure. */
168 /* Buffer to read RIP packet. */
169 union rip_buf
171 struct rip_packet rip_packet;
172 char buf[RIP_PACKET_MAXSIZ];
175 /* RIP route information. */
176 struct rip_info
178 /* This route's type. */
179 int type;
181 /* Sub type. */
182 int sub_type;
184 /* RIP nexthop. */
185 struct in_addr nexthop;
186 struct in_addr from;
188 /* Which interface does this route come from. */
189 unsigned int ifindex;
191 /* Metric of this route. */
192 u_int32_t metric;
194 /* Tag information of this route. */
195 u_int16_t tag;
197 /* Flags of RIP route. */
198 #define RIP_RTF_FIB 1
199 #define RIP_RTF_CHANGED 2
200 u_char flags;
202 /* Garbage collect timer. */
203 struct thread *t_timeout;
204 struct thread *t_garbage_collect;
206 /* Route-map futures - this variables can be changed. */
207 struct in_addr nexthop_out;
208 u_char metric_set;
209 u_int32_t metric_out;
210 unsigned int ifindex_out;
212 struct route_node *rp;
214 u_char distance;
216 #ifdef NEW_RIP_TABLE
217 struct rip_info *next;
218 struct rip_info *prev;
219 #endif /* NEW_RIP_TABLE */
222 /* RIP specific interface configuration. */
223 struct rip_interface
225 /* RIP is enabled on this interface. */
226 int enable_network;
227 int enable_interface;
229 /* RIP is running on this interface. */
230 int running;
232 /* Joined to multicast group for this interface. */
233 int joined_multicast;
235 /* RIP version control. */
236 int ri_send;
237 int ri_receive;
239 /* RIPv2 authentication type. */
240 #define RIP_NO_AUTH 0
241 #define RIP_AUTH_DATA 1
242 #define RIP_AUTH_SIMPLE_PASSWORD 2
243 #define RIP_AUTH_MD5 3
244 int auth_type;
246 /* RIPv2 authentication string. */
247 char *auth_str;
249 /* RIPv2 authentication key chain. */
250 char *key_chain;
252 /* Split horizon flag. */
253 int split_horizon;
254 int split_horizon_default;
256 /* For filter type slot. */
257 #define RIP_FILTER_IN 0
258 #define RIP_FILTER_OUT 1
259 #define RIP_FILTER_MAX 2
261 /* Access-list. */
262 struct access_list *list[RIP_FILTER_MAX];
264 /* Prefix-list. */
265 struct prefix_list *prefix[RIP_FILTER_MAX];
267 /* Wake up thread. */
268 struct thread *t_wakeup;
270 /* Interface statistics. */
271 int recv_badpackets;
272 int recv_badroutes;
273 int sent_updates;
275 /* Passive interface. */
276 int passive;
279 /* RIP peer information. */
280 struct rip_peer
282 /* Peer address. */
283 struct in_addr addr;
285 /* Peer RIP tag value. */
286 int domain;
288 /* Last update time. */
289 time_t uptime;
291 /* Peer RIP version. */
292 u_char version;
294 /* Statistics. */
295 int recv_badpackets;
296 int recv_badroutes;
298 /* Timeout thread. */
299 struct thread *t_timeout;
302 struct rip_md5_info
304 u_int16_t family;
305 u_int16_t type;
306 u_int16_t packet_len;
307 u_char keyid;
308 u_char auth_len;
309 u_int32_t sequence;
310 u_int32_t reserv1;
311 u_int32_t reserv2;
314 struct rip_md5_data
316 u_int16_t family;
317 u_int16_t type;
318 u_char digest[16];
321 /* RIP accepet/announce methods. */
322 #define RI_RIP_UNSPEC 0
323 #define RI_RIP_VERSION_1 1
324 #define RI_RIP_VERSION_2 2
325 #define RI_RIP_VERSION_1_AND_2 3
327 /* Default value for "default-metric" command. */
328 #define RIP_DEFAULT_METRIC_DEFAULT 1
330 /* RIP event. */
331 enum rip_event
333 RIP_READ,
334 RIP_UPDATE_EVENT,
335 RIP_TRIGGERED_UPDATE,
338 /* Macro for timer turn on. */
339 #define RIP_TIMER_ON(T,F,V) \
340 do { \
341 if (!(T)) \
342 (T) = thread_add_timer (master, (F), rinfo, (V)); \
343 } while (0)
345 /* Macro for timer turn off. */
346 #define RIP_TIMER_OFF(X) \
347 do { \
348 if (X) \
350 thread_cancel (X); \
351 (X) = NULL; \
353 } while (0)
355 /* Prototypes. */
356 void rip_init ();
357 void rip_reset ();
358 void rip_clean ();
359 void rip_clean_network ();
360 void rip_interface_clean ();
361 void rip_interface_reset ();
362 void rip_passive_interface_clean ();
363 void rip_if_init ();
364 void rip_if_down_all ();
365 void rip_route_map_init ();
366 void rip_route_map_reset ();
367 void rip_snmp_init ();
368 void rip_zclient_init ();
369 void rip_zclient_start ();
370 void rip_zclient_reset ();
371 void rip_offset_init ();
372 int if_check_address (struct in_addr addr);
373 int if_valid_neighbor (struct in_addr addr);
375 int rip_request_send (struct sockaddr_in *, struct interface *, u_char);
376 int rip_neighbor_lookup (struct sockaddr_in *);
377 void rip_redistribute_add (int, int, struct prefix_ipv4 *, unsigned int,
378 struct in_addr *);
379 void rip_redistribute_delete (int, int, struct prefix_ipv4 *, unsigned int);
380 void rip_redistribute_withdraw (int);
381 void rip_zebra_ipv4_add (struct prefix_ipv4 *, struct in_addr *, u_int32_t, u_char);
382 void rip_zebra_ipv4_delete (struct prefix_ipv4 *, struct in_addr *, u_int32_t);
383 void rip_interface_multicast_set (int, struct interface *);
384 void rip_distribute_update_interface (struct interface *);
386 int config_write_rip_network (struct vty *, int);
387 int config_write_rip_offset_list (struct vty *);
388 int config_write_rip_redistribute (struct vty *, int);
390 void rip_peer_init ();
391 void rip_peer_update (struct sockaddr_in *, u_char);
392 void rip_peer_bad_route (struct sockaddr_in *);
393 void rip_peer_bad_packet (struct sockaddr_in *);
394 void rip_peer_display (struct vty *);
395 struct rip_peer *rip_peer_lookup (struct in_addr *);
396 struct rip_peer *rip_peer_lookup_next (struct in_addr *);
398 int rip_offset_list_apply_in (struct prefix_ipv4 *, struct interface *, u_int32_t *);
399 int rip_offset_list_apply_out (struct prefix_ipv4 *, struct interface *, u_int32_t *);
400 void rip_offset_clean ();
402 void rip_info_free (struct rip_info *);
403 u_char rip_distance_apply (struct rip_info *);
404 void rip_redistribute_clean ();
405 void rip_ifaddr_add (struct interface *, struct connected *);
406 void rip_ifaddr_delete (struct interface *, struct connected *);
408 /* There is only one rip strucutre. */
409 extern struct rip *rip;
411 /* Master thread strucutre. */
412 extern struct thread_master *master;
414 /* RIP statistics for SNMP. */
415 extern long rip_global_route_changes;
416 extern long rip_global_queries;
418 #endif /* _ZEBRA_RIP_H */