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