]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * RIPng related value and structure. | |
3 | * Copyright (C) 1998 Kunihiro Ishiguro | |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free | |
19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | * 02111-1307, USA. | |
21 | */ | |
22 | ||
23 | #ifndef _ZEBRA_RIPNG_RIPNGD_H | |
24 | #define _ZEBRA_RIPNG_RIPNGD_H | |
25 | ||
6ac29a51 PJ |
26 | #include <zclient.h> |
27 | #include <vty.h> | |
28 | ||
4a1ab8e4 DL |
29 | #include "ripng_memory.h" |
30 | ||
718e3744 | 31 | /* RIPng version and port number. */ |
32 | #define RIPNG_V1 1 | |
33 | #define RIPNG_PORT_DEFAULT 521 | |
34 | #define RIPNG_VTY_PORT 2603 | |
718e3744 | 35 | #define RIPNG_MAX_PACKET_SIZE 1500 |
36 | #define RIPNG_PRIORITY_DEFAULT 0 | |
37 | ||
38 | /* RIPng commands. */ | |
39 | #define RIPNG_REQUEST 1 | |
40 | #define RIPNG_RESPONSE 2 | |
41 | ||
42 | /* RIPng metric and multicast group address. */ | |
43 | #define RIPNG_METRIC_INFINITY 16 | |
44 | #define RIPNG_METRIC_NEXTHOP 0xff | |
45 | #define RIPNG_GROUP "ff02::9" | |
46 | ||
47 | /* RIPng timers. */ | |
48 | #define RIPNG_UPDATE_TIMER_DEFAULT 30 | |
49 | #define RIPNG_TIMEOUT_TIMER_DEFAULT 180 | |
50 | #define RIPNG_GARBAGE_TIMER_DEFAULT 120 | |
51 | ||
a94434b6 | 52 | /* RIPng peer timeout value. */ |
53 | #define RIPNG_PEER_TIMER_DEFAULT 180 | |
54 | ||
718e3744 | 55 | /* Default config file name. */ |
56 | #define RIPNG_DEFAULT_CONFIG "ripngd.conf" | |
57 | ||
58 | /* RIPng route types. */ | |
59 | #define RIPNG_ROUTE_RTE 0 | |
60 | #define RIPNG_ROUTE_STATIC 1 | |
a94434b6 | 61 | #define RIPNG_ROUTE_DEFAULT 2 |
62 | #define RIPNG_ROUTE_REDISTRIBUTE 3 | |
63 | #define RIPNG_ROUTE_INTERFACE 4 | |
64 | #define RIPNG_ROUTE_AGGREGATE 5 | |
718e3744 | 65 | |
66 | /* Interface send/receive configuration. */ | |
67 | #define RIPNG_SEND_UNSPEC 0 | |
68 | #define RIPNG_SEND_OFF 1 | |
69 | #define RIPNG_RECEIVE_UNSPEC 0 | |
70 | #define RIPNG_RECEIVE_OFF 1 | |
71 | ||
718e3744 | 72 | /* RIP default route's accept/announce methods. */ |
73 | #define RIPNG_DEFAULT_ADVERTISE_UNSPEC 0 | |
74 | #define RIPNG_DEFAULT_ADVERTISE_NONE 1 | |
75 | #define RIPNG_DEFAULT_ADVERTISE 2 | |
76 | ||
77 | #define RIPNG_DEFAULT_ACCEPT_UNSPEC 0 | |
78 | #define RIPNG_DEFAULT_ACCEPT_NONE 1 | |
79 | #define RIPNG_DEFAULT_ACCEPT 2 | |
80 | ||
81 | /* Default value for "default-metric" command. */ | |
82 | #define RIPNG_DEFAULT_METRIC_DEFAULT 1 | |
83 | ||
84 | /* For max RTE calculation. */ | |
85 | #ifndef IPV6_HDRLEN | |
86 | #define IPV6_HDRLEN 40 | |
87 | #endif /* IPV6_HDRLEN */ | |
88 | ||
89 | #ifndef IFMINMTU | |
90 | #define IFMINMTU 576 | |
91 | #endif /* IFMINMTU */ | |
92 | ||
93 | /* RIPng structure. */ | |
94 | struct ripng | |
95 | { | |
96 | /* RIPng socket. */ | |
97 | int sock; | |
98 | ||
99 | /* RIPng Parameters.*/ | |
100 | u_char command; | |
101 | u_char version; | |
102 | unsigned long update_time; | |
103 | unsigned long timeout_time; | |
104 | unsigned long garbage_time; | |
105 | int max_mtu; | |
106 | int default_metric; | |
107 | int default_information; | |
108 | ||
109 | /* Input/output buffer of RIPng. */ | |
110 | struct stream *ibuf; | |
111 | struct stream *obuf; | |
112 | ||
113 | /* RIPng routing information base. */ | |
114 | struct route_table *table; | |
115 | ||
116 | /* RIPng only static route information. */ | |
117 | struct route_table *route; | |
118 | ||
119 | /* RIPng aggregate route information. */ | |
120 | struct route_table *aggregate; | |
121 | ||
122 | /* RIPng threads. */ | |
123 | struct thread *t_read; | |
124 | struct thread *t_write; | |
125 | struct thread *t_update; | |
126 | struct thread *t_garbage; | |
127 | struct thread *t_zebra; | |
128 | ||
129 | /* Triggered update hack. */ | |
130 | int trigger; | |
131 | struct thread *t_triggered_update; | |
132 | struct thread *t_triggered_interval; | |
133 | ||
fac76f9c FL |
134 | /* RIPng ECMP flag */ |
135 | unsigned int ecmp; | |
136 | ||
718e3744 | 137 | /* For redistribute route map. */ |
138 | struct | |
139 | { | |
140 | char *name; | |
141 | struct route_map *map; | |
142 | int metric_config; | |
143 | u_int32_t metric; | |
144 | } route_map[ZEBRA_ROUTE_MAX]; | |
145 | }; | |
146 | ||
147 | /* Routing table entry. */ | |
148 | struct rte | |
149 | { | |
a94434b6 | 150 | struct in6_addr addr; /* RIPng destination prefix */ |
151 | u_short tag; /* RIPng tag */ | |
152 | u_char prefixlen; /* Length of the RIPng prefix */ | |
153 | u_char metric; /* Metric of the RIPng route */ | |
154 | /* The nexthop is stored by the structure | |
155 | * ripng_nexthop within ripngd.c */ | |
718e3744 | 156 | }; |
157 | ||
158 | /* RIPNG send packet. */ | |
159 | struct ripng_packet | |
160 | { | |
161 | u_char command; | |
162 | u_char version; | |
163 | u_int16_t zero; | |
164 | struct rte rte[1]; | |
165 | }; | |
166 | ||
167 | /* Each route's information. */ | |
168 | struct ripng_info | |
169 | { | |
170 | /* This route's type. Static, ripng or aggregate. */ | |
171 | u_char type; | |
172 | ||
173 | /* Sub type for static route. */ | |
174 | u_char sub_type; | |
175 | ||
176 | /* RIPng specific information */ | |
177 | struct in6_addr nexthop; | |
178 | struct in6_addr from; | |
179 | ||
180 | /* Which interface does this route come from. */ | |
b892f1dd | 181 | ifindex_t ifindex; |
718e3744 | 182 | |
183 | /* Metric of this route. */ | |
184 | u_char metric; | |
185 | ||
186 | /* Tag field of RIPng packet.*/ | |
187 | u_int16_t tag; | |
188 | ||
189 | /* For aggregation. */ | |
190 | unsigned int suppress; | |
191 | ||
192 | /* Flags of RIPng route. */ | |
193 | #define RIPNG_RTF_FIB 1 | |
194 | #define RIPNG_RTF_CHANGED 2 | |
195 | u_char flags; | |
196 | ||
197 | /* Garbage collect timer. */ | |
198 | struct thread *t_timeout; | |
199 | struct thread *t_garbage_collect; | |
200 | ||
201 | /* Route-map features - this variables can be changed. */ | |
a94434b6 | 202 | struct in6_addr nexthop_out; |
718e3744 | 203 | u_char metric_set; |
a94434b6 | 204 | u_char metric_out; |
205 | u_short tag_out; | |
718e3744 | 206 | |
207 | struct route_node *rp; | |
208 | }; | |
209 | ||
a94434b6 | 210 | #ifdef notyet |
211 | #if 0 | |
718e3744 | 212 | /* RIPng tag structure. */ |
213 | struct ripng_tag | |
214 | { | |
215 | /* Tag value. */ | |
216 | u_int16_t tag; | |
217 | ||
218 | /* Port. */ | |
219 | u_int16_t port; | |
220 | ||
221 | /* Multicast group. */ | |
222 | struct in6_addr maddr; | |
223 | ||
224 | /* Table number. */ | |
225 | int table; | |
226 | ||
227 | /* Distance. */ | |
228 | int distance; | |
229 | ||
230 | /* Split horizon. */ | |
231 | u_char split_horizon; | |
232 | ||
233 | /* Poison reverse. */ | |
234 | u_char poison_reverse; | |
235 | }; | |
a94434b6 | 236 | #endif /* 0 */ |
237 | #endif /* not yet */ | |
238 | ||
239 | typedef enum { | |
240 | RIPNG_NO_SPLIT_HORIZON = 0, | |
241 | RIPNG_SPLIT_HORIZON, | |
242 | RIPNG_SPLIT_HORIZON_POISONED_REVERSE | |
243 | } split_horizon_policy_t; | |
718e3744 | 244 | |
245 | /* RIPng specific interface configuration. */ | |
246 | struct ripng_interface | |
247 | { | |
248 | /* RIPng is enabled on this interface. */ | |
249 | int enable_network; | |
250 | int enable_interface; | |
251 | ||
252 | /* RIPng is running on this interface. */ | |
253 | int running; | |
254 | ||
a94434b6 | 255 | /* Split horizon flag. */ |
256 | split_horizon_policy_t split_horizon; | |
257 | split_horizon_policy_t split_horizon_default; | |
258 | ||
718e3744 | 259 | /* For filter type slot. */ |
260 | #define RIPNG_FILTER_IN 0 | |
261 | #define RIPNG_FILTER_OUT 1 | |
262 | #define RIPNG_FILTER_MAX 2 | |
263 | ||
264 | /* Access-list. */ | |
265 | struct access_list *list[RIPNG_FILTER_MAX]; | |
266 | ||
267 | /* Prefix-list. */ | |
268 | struct prefix_list *prefix[RIPNG_FILTER_MAX]; | |
269 | ||
270 | /* Route-map. */ | |
271 | struct route_map *routemap[RIPNG_FILTER_MAX]; | |
272 | ||
a94434b6 | 273 | #ifdef notyet |
274 | #if 0 | |
718e3744 | 275 | /* RIPng tag configuration. */ |
276 | struct ripng_tag *rtag; | |
a94434b6 | 277 | #endif /* 0 */ |
278 | #endif /* notyet */ | |
718e3744 | 279 | |
280 | /* Default information originate. */ | |
281 | u_char default_originate; | |
282 | ||
283 | /* Default information only. */ | |
284 | u_char default_only; | |
285 | ||
286 | /* Wake up thread. */ | |
287 | struct thread *t_wakeup; | |
288 | ||
289 | /* Passive interface. */ | |
290 | int passive; | |
291 | }; | |
292 | ||
a94434b6 | 293 | /* RIPng peer information. */ |
294 | struct ripng_peer | |
295 | { | |
296 | /* Peer address. */ | |
297 | struct in6_addr addr; | |
298 | ||
299 | /* Peer RIPng tag value. */ | |
300 | int domain; | |
301 | ||
302 | /* Last update time. */ | |
303 | time_t uptime; | |
304 | ||
305 | /* Peer RIP version. */ | |
306 | u_char version; | |
307 | ||
308 | /* Statistics. */ | |
309 | int recv_badpackets; | |
310 | int recv_badroutes; | |
311 | ||
312 | /* Timeout thread. */ | |
313 | struct thread *t_timeout; | |
314 | }; | |
315 | ||
718e3744 | 316 | /* All RIPng events. */ |
317 | enum ripng_event | |
318 | { | |
319 | RIPNG_READ, | |
320 | RIPNG_ZEBRA, | |
321 | RIPNG_REQUEST_EVENT, | |
322 | RIPNG_UPDATE_EVENT, | |
323 | RIPNG_TRIGGERED_UPDATE, | |
324 | }; | |
325 | ||
326 | /* RIPng timer on/off macro. */ | |
327 | #define RIPNG_TIMER_ON(T,F,V) \ | |
328 | do { \ | |
329 | if (!(T)) \ | |
330 | (T) = thread_add_timer (master, (F), rinfo, (V)); \ | |
331 | } while (0) | |
332 | ||
333 | #define RIPNG_TIMER_OFF(T) \ | |
334 | do { \ | |
335 | if (T) \ | |
336 | { \ | |
337 | thread_cancel(T); \ | |
338 | (T) = NULL; \ | |
339 | } \ | |
340 | } while (0) | |
341 | ||
718e3744 | 342 | /* Extern variables. */ |
343 | extern struct ripng *ripng; | |
344 | ||
345 | extern struct thread_master *master; | |
346 | ||
347 | /* Prototypes. */ | |
6ac29a51 PJ |
348 | extern void ripng_init (void); |
349 | extern void ripng_reset (void); | |
350 | extern void ripng_clean (void); | |
351 | extern void ripng_clean_network (void); | |
352 | extern void ripng_interface_clean (void); | |
353 | extern void ripng_interface_reset (void); | |
354 | extern void ripng_passive_interface_clean (void); | |
355 | extern void ripng_if_init (void); | |
356 | extern void ripng_route_map_init (void); | |
357 | extern void ripng_route_map_reset (void); | |
358 | extern void ripng_terminate (void); | |
a94434b6 | 359 | /* zclient_init() is done by ripng_zebra.c:zebra_init() */ |
4140ca4d | 360 | extern void zebra_init(struct thread_master *); |
6ac29a51 PJ |
361 | extern void ripng_zclient_reset (void); |
362 | extern void ripng_offset_init (void); | |
363 | ||
364 | extern int config_write_ripng_offset_list (struct vty *); | |
365 | ||
366 | extern void ripng_peer_init (void); | |
367 | extern void ripng_peer_update (struct sockaddr_in6 *, u_char); | |
368 | extern void ripng_peer_bad_route (struct sockaddr_in6 *); | |
369 | extern void ripng_peer_bad_packet (struct sockaddr_in6 *); | |
370 | extern void ripng_peer_display (struct vty *); | |
371 | extern struct ripng_peer *ripng_peer_lookup (struct in6_addr *); | |
372 | extern struct ripng_peer *ripng_peer_lookup_next (struct in6_addr *); | |
373 | ||
374 | extern int ripng_offset_list_apply_in (struct prefix_ipv6 *, | |
375 | struct interface *, u_char *); | |
376 | extern int ripng_offset_list_apply_out (struct prefix_ipv6 *, | |
377 | struct interface *, u_char *); | |
378 | extern void ripng_offset_clean (void); | |
379 | ||
380 | extern struct ripng_info * ripng_info_new (void); | |
381 | extern void ripng_info_free (struct ripng_info *rinfo); | |
382 | extern void ripng_event (enum ripng_event, int); | |
383 | extern int ripng_request (struct interface *ifp); | |
384 | extern void ripng_redistribute_add (int, int, struct prefix_ipv6 *, | |
b892f1dd | 385 | ifindex_t, struct in6_addr *); |
6ac29a51 | 386 | extern void ripng_redistribute_delete (int, int, struct prefix_ipv6 *, |
b892f1dd | 387 | ifindex_t); |
6ac29a51 PJ |
388 | extern void ripng_redistribute_withdraw (int type); |
389 | ||
390 | extern void ripng_distribute_update_interface (struct interface *); | |
391 | extern void ripng_if_rmap_update_interface (struct interface *); | |
392 | ||
c880b636 FL |
393 | extern void ripng_zebra_ipv6_add (struct route_node *); |
394 | extern void ripng_zebra_ipv6_delete (struct route_node *); | |
6ac29a51 PJ |
395 | |
396 | extern void ripng_redistribute_clean (void); | |
397 | extern int ripng_redistribute_check (int); | |
398 | extern void ripng_redistribute_write (struct vty *, int); | |
399 | ||
400 | extern int ripng_write_rte (int num, struct stream *s, struct prefix_ipv6 *p, | |
401 | struct in6_addr *nexthop, | |
402 | u_int16_t tag, u_char metric); | |
403 | extern int ripng_send_packet (caddr_t buf, int bufsize, | |
404 | struct sockaddr_in6 *to, struct interface *ifp); | |
405 | ||
406 | extern void ripng_packet_dump (struct ripng_packet *packet, int size, | |
407 | const char *sndrcv); | |
408 | ||
7076bb2f FL |
409 | extern int ripng_interface_up (int command, struct zclient *, zebra_size_t, |
410 | vrf_id_t); | |
411 | extern int ripng_interface_down (int command, struct zclient *, zebra_size_t, | |
412 | vrf_id_t); | |
413 | extern int ripng_interface_add (int command, struct zclient *, zebra_size_t, | |
414 | vrf_id_t); | |
415 | extern int ripng_interface_delete (int command, struct zclient *, zebra_size_t, | |
416 | vrf_id_t); | |
417 | extern int ripng_interface_address_add (int command, struct zclient *, zebra_size_t, | |
418 | vrf_id_t); | |
419 | extern int ripng_interface_address_delete (int command, struct zclient *, zebra_size_t, | |
420 | vrf_id_t); | |
6ac29a51 PJ |
421 | |
422 | extern int ripng_network_write (struct vty *, int); | |
718e3744 | 423 | |
c880b636 FL |
424 | extern struct ripng_info *ripng_ecmp_add (struct ripng_info *); |
425 | extern struct ripng_info *ripng_ecmp_replace (struct ripng_info *); | |
426 | extern struct ripng_info *ripng_ecmp_delete (struct ripng_info *); | |
427 | ||
718e3744 | 428 | #endif /* _ZEBRA_RIPNG_RIPNGD_H */ |