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
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
25 /* RIP version number. */
29 /* RIP command list. */
31 #define RIP_RESPONSE 2
32 #define RIP_TRACEON 3 /* Obsolete */
33 #define RIP_TRACEOFF 4 /* Obsolete */
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
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 */
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
95 /* Default version of rip instance. */
98 /* Output buffer of RIP. */
101 /* RIP routing information base. */
102 struct route_table
*table
;
104 /* RIP only static routing information. */
105 struct route_table
*route
;
108 struct route_table
*neighbor
;
111 struct thread
*t_read
;
113 /* Update and garbage timer. */
114 struct thread
*t_update
;
116 /* Triggered update hack. */
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. */
129 /* RIP default-information originate. */
130 u_char default_information
;
131 char *default_information_route_map
;
133 /* RIP default distance. */
135 struct route_table
*distance_table
;
137 /* For redistribute route map. */
141 struct route_map
*map
;
144 } route_map
[ZEBRA_ROUTE_MAX
];
147 /* RIP routing table entry which belong to rip_packet. */
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. */
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. */
171 struct rip_packet rip_packet
;
172 char buf
[RIP_PACKET_MAXSIZ
];
175 /* RIP route information. */
178 /* This route's type. */
185 struct in_addr nexthop
;
188 /* Which interface does this route come from. */
189 unsigned int ifindex
;
191 /* Metric of this route. */
194 /* Tag information of this route. */
197 /* Flags of RIP route. */
198 #define RIP_RTF_FIB 1
199 #define RIP_RTF_CHANGED 2
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
;
209 u_int32_t metric_out
;
210 unsigned int ifindex_out
;
212 struct route_node
*rp
;
217 struct rip_info
*next
;
218 struct rip_info
*prev
;
219 #endif /* NEW_RIP_TABLE */
222 /* RIP specific interface configuration. */
225 /* RIP is enabled on this interface. */
227 int enable_interface
;
229 /* RIP is running on this interface. */
232 /* Joined to multicast group for this interface. */
233 int joined_multicast
;
235 /* RIP version control. */
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
246 /* RIPv2 authentication string. */
249 /* RIPv2 authentication key chain. */
252 /* Split horizon flag. */
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
262 struct access_list
*list
[RIP_FILTER_MAX
];
265 struct prefix_list
*prefix
[RIP_FILTER_MAX
];
267 /* Wake up thread. */
268 struct thread
*t_wakeup
;
270 /* Interface statistics. */
275 /* Passive interface. */
279 /* RIP peer information. */
285 /* Peer RIP tag value. */
288 /* Last update time. */
291 /* Peer RIP version. */
298 /* Timeout thread. */
299 struct thread
*t_timeout
;
306 u_int16_t packet_len
;
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
335 RIP_TRIGGERED_UPDATE
,
338 /* Macro for timer turn on. */
339 #define RIP_TIMER_ON(T,F,V) \
342 (T) = thread_add_timer (master, (F), rinfo, (V)); \
345 /* Macro for timer turn off. */
346 #define RIP_TIMER_OFF(X) \
359 void rip_clean_network ();
360 void rip_interface_clean ();
361 void rip_interface_reset ();
362 void rip_passive_interface_clean ();
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,
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 */