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