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