]> git.proxmox.com Git - mirror_frr.git/blame - ripngd/ripngd.h
lib: fix outdated candidate configuration issue
[mirror_frr.git] / ripngd / ripngd.h
CommitLineData
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 91struct ripng {
dde7b15b
RW
92 RB_ENTRY(ripng) entry;
93
94 /* VRF this routing instance is associated with. */
95 char *vrf_name;
96
97 /* VRF backpointer (might be NULL if the VRF doesn't exist). */
98 struct vrf *vrf;
99
100 /* Status of the routing instance. */
101 bool enabled;
5c84b9a5 102
d62a17ae 103 /* RIPng socket. */
104 int sock;
105
106 /* RIPng Parameters.*/
d7c0a89a
QY
107 uint8_t command;
108 uint8_t version;
f8981ec5
RW
109 uint16_t update_time;
110 uint16_t timeout_time;
111 uint16_t garbage_time;
d62a17ae 112 int max_mtu;
ad8778c0 113 uint8_t default_metric;
d62a17ae 114
115 /* Input/output buffer of RIPng. */
116 struct stream *ibuf;
117 struct stream *obuf;
118
119 /* RIPng routing information base. */
fe08ba7e 120 struct agg_table *table;
d62a17ae 121
ecece94c
RW
122 /* Linked list of RIPng peers. */
123 struct list *peer_list;
124
b0ba762f
RW
125 /* RIPng enabled interfaces. */
126 vector enable_if;
127
29b94d58
RW
128 /* RIPng enabled networks. */
129 struct agg_table *enable_network;
130
0c32404f
RW
131 /* Vector to store passive-interface name. */
132 vector passive_interface;
133
26c6be93
RW
134 /* RIPng offset-lists. */
135 struct list *offset_list_master;
136
d62a17ae 137 /* RIPng threads. */
138 struct thread *t_read;
139 struct thread *t_write;
140 struct thread *t_update;
141 struct thread *t_garbage;
142 struct thread *t_zebra;
143
144 /* Triggered update hack. */
145 int trigger;
146 struct thread *t_triggered_update;
147 struct thread *t_triggered_interval;
148
149 /* RIPng ECMP flag */
1e42a07c 150 bool ecmp;
d62a17ae 151
f9120f71 152 /* RIPng redistribute configuration. */
d62a17ae 153 struct {
f9120f71
RW
154 bool enabled;
155 struct {
156 char *name;
157 struct route_map *map;
158 } route_map;
db2038c7
RW
159 bool metric_config;
160 uint8_t metric;
f9120f71 161 } redist[ZEBRA_ROUTE_MAX];
03a38493
PG
162
163 /* For distribute-list container */
164 struct distribute_ctx *distribute_ctx;
4b23867c
PG
165
166 /* For if_rmap container */
167 struct if_rmap_ctx *if_rmap_ctx;
718e3744 168};
dde7b15b
RW
169RB_HEAD(ripng_instance_head, ripng);
170RB_PROTOTYPE(ripng_instance_head, ripng, entry, ripng_instance_compare)
718e3744 171
172/* Routing table entry. */
d62a17ae 173struct rte {
174 struct in6_addr addr; /* RIPng destination prefix */
d7c0a89a
QY
175 uint16_t tag; /* RIPng tag */
176 uint8_t prefixlen; /* Length of the RIPng prefix */
177 uint8_t metric; /* Metric of the RIPng route */
d62a17ae 178 /* The nexthop is stored by the structure
179 * ripng_nexthop within ripngd.c */
718e3744 180};
181
182/* RIPNG send packet. */
d62a17ae 183struct ripng_packet {
d7c0a89a
QY
184 uint8_t command;
185 uint8_t version;
186 uint16_t zero;
d62a17ae 187 struct rte rte[1];
718e3744 188};
189
190/* Each route's information. */
d62a17ae 191struct ripng_info {
192 /* This route's type. Static, ripng or aggregate. */
d7c0a89a 193 uint8_t type;
718e3744 194
d62a17ae 195 /* Sub type for static route. */
d7c0a89a 196 uint8_t sub_type;
718e3744 197
d62a17ae 198 /* RIPng specific information */
199 struct in6_addr nexthop;
200 struct in6_addr from;
718e3744 201
d62a17ae 202 /* Which interface does this route come from. */
203 ifindex_t ifindex;
718e3744 204
d62a17ae 205 /* Metric of this route. */
d7c0a89a 206 uint8_t metric;
718e3744 207
d62a17ae 208 /* Tag field of RIPng packet.*/
d7c0a89a 209 uint16_t tag;
718e3744 210
d62a17ae 211 /* For aggregation. */
212 unsigned int suppress;
718e3744 213
d62a17ae 214/* Flags of RIPng route. */
718e3744 215#define RIPNG_RTF_FIB 1
216#define RIPNG_RTF_CHANGED 2
d7c0a89a 217 uint8_t flags;
718e3744 218
d62a17ae 219 /* Garbage collect timer. */
220 struct thread *t_timeout;
221 struct thread *t_garbage_collect;
718e3744 222
d62a17ae 223 /* Route-map features - this variables can be changed. */
224 struct in6_addr nexthop_out;
d7c0a89a
QY
225 uint8_t metric_set;
226 uint8_t metric_out;
227 uint16_t tag_out;
718e3744 228
fe08ba7e 229 struct agg_node *rp;
718e3744 230};
231
a94434b6 232#ifdef notyet
233#if 0
718e3744 234/* RIPng tag structure. */
235struct ripng_tag
236{
237 /* Tag value. */
d7c0a89a 238 uint16_t tag;
718e3744 239
240 /* Port. */
d7c0a89a 241 uint16_t port;
718e3744 242
243 /* Multicast group. */
244 struct in6_addr maddr;
245
246 /* Table number. */
247 int table;
248
249 /* Distance. */
250 int distance;
251
252 /* Split horizon. */
d7c0a89a 253 uint8_t split_horizon;
718e3744 254
255 /* Poison reverse. */
d7c0a89a 256 uint8_t poison_reverse;
718e3744 257};
a94434b6 258#endif /* 0 */
259#endif /* not yet */
260
261typedef enum {
d62a17ae 262 RIPNG_NO_SPLIT_HORIZON = 0,
263 RIPNG_SPLIT_HORIZON,
264 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
a94434b6 265} split_horizon_policy_t;
718e3744 266
267/* RIPng specific interface configuration. */
d62a17ae 268struct ripng_interface {
5c84b9a5
RW
269 /* Parent routing instance. */
270 struct ripng *ripng;
271
d62a17ae 272 /* RIPng is enabled on this interface. */
273 int enable_network;
274 int enable_interface;
275
276 /* RIPng is running on this interface. */
277 int running;
278
279 /* Split horizon flag. */
280 split_horizon_policy_t split_horizon;
d62a17ae 281
282/* For filter type slot. */
718e3744 283#define RIPNG_FILTER_IN 0
284#define RIPNG_FILTER_OUT 1
285#define RIPNG_FILTER_MAX 2
286
d62a17ae 287 /* Access-list. */
288 struct access_list *list[RIPNG_FILTER_MAX];
718e3744 289
d62a17ae 290 /* Prefix-list. */
291 struct prefix_list *prefix[RIPNG_FILTER_MAX];
718e3744 292
d62a17ae 293 /* Route-map. */
294 struct route_map *routemap[RIPNG_FILTER_MAX];
718e3744 295
a94434b6 296#ifdef notyet
297#if 0
718e3744 298 /* RIPng tag configuration. */
299 struct ripng_tag *rtag;
a94434b6 300#endif /* 0 */
301#endif /* notyet */
718e3744 302
d62a17ae 303 /* Default information originate. */
d7c0a89a 304 uint8_t default_originate;
718e3744 305
d62a17ae 306 /* Default information only. */
d7c0a89a 307 uint8_t default_only;
718e3744 308
d62a17ae 309 /* Wake up thread. */
310 struct thread *t_wakeup;
718e3744 311
d62a17ae 312 /* Passive interface. */
313 int passive;
718e3744 314};
315
a94434b6 316/* RIPng peer information. */
d62a17ae 317struct ripng_peer {
5c84b9a5
RW
318 /* Parent routing instance. */
319 struct ripng *ripng;
320
d62a17ae 321 /* Peer address. */
322 struct in6_addr addr;
a94434b6 323
d62a17ae 324 /* Peer RIPng tag value. */
325 int domain;
a94434b6 326
d62a17ae 327 /* Last update time. */
328 time_t uptime;
a94434b6 329
d62a17ae 330 /* Peer RIP version. */
d7c0a89a 331 uint8_t version;
a94434b6 332
d62a17ae 333 /* Statistics. */
334 int recv_badpackets;
335 int recv_badroutes;
a94434b6 336
d62a17ae 337 /* Timeout thread. */
338 struct thread *t_timeout;
a94434b6 339};
340
718e3744 341/* All RIPng events. */
d62a17ae 342enum ripng_event {
343 RIPNG_READ,
344 RIPNG_ZEBRA,
345 RIPNG_REQUEST_EVENT,
346 RIPNG_UPDATE_EVENT,
347 RIPNG_TRIGGERED_UPDATE,
718e3744 348};
349
350/* RIPng timer on/off macro. */
ffa2c898 351#define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
718e3744 352
d62a17ae 353#define RIPNG_TIMER_OFF(T) \
354 do { \
355 if (T) { \
356 thread_cancel(T); \
357 (T) = NULL; \
358 } \
359 } while (0)
718e3744 360
b09956ca
RW
361#define RIPNG_OFFSET_LIST_IN 0
362#define RIPNG_OFFSET_LIST_OUT 1
363#define RIPNG_OFFSET_LIST_MAX 2
364
365struct ripng_offset_list {
5c84b9a5
RW
366 /* Parent routing instance. */
367 struct ripng *ripng;
368
b09956ca
RW
369 char *ifname;
370
371 struct {
372 char *alist_name;
373 /* struct access_list *alist; */
374 uint8_t metric;
375 } direct[RIPNG_OFFSET_LIST_MAX];
376};
377
718e3744 378/* Extern variables. */
5cb6ce9c 379extern struct zebra_privs_t ripngd_privs;
718e3744 380extern struct thread_master *master;
80cf4e45 381extern struct ripng_instance_head ripng_instances;
718e3744 382
383/* Prototypes. */
d62a17ae 384extern void ripng_init(void);
5c84b9a5
RW
385extern void ripng_clean(struct ripng *ripng);
386extern void ripng_clean_network(struct ripng *ripng);
387extern void ripng_interface_clean(struct ripng *ripng);
388extern int ripng_enable_network_add(struct ripng *ripng, struct prefix *p);
389extern int ripng_enable_network_delete(struct ripng *ripng, struct prefix *p);
390extern int ripng_enable_if_add(struct ripng *ripng, const char *ifname);
391extern int ripng_enable_if_delete(struct ripng *ripng, const char *ifname);
392extern int ripng_passive_interface_set(struct ripng *ripng, const char *ifname);
393extern int ripng_passive_interface_unset(struct ripng *ripng,
394 const char *ifname);
395extern void ripng_passive_interface_clean(struct ripng *ripng);
d62a17ae 396extern void ripng_if_init(void);
397extern void ripng_route_map_init(void);
dde7b15b
RW
398extern void ripng_zebra_vrf_register(struct vrf *vrf);
399extern void ripng_zebra_vrf_deregister(struct vrf *vrf);
d62a17ae 400extern void ripng_terminate(void);
401/* zclient_init() is done by ripng_zebra.c:zebra_init() */
4140ca4d 402extern void zebra_init(struct thread_master *);
d62a17ae 403extern void ripng_zebra_stop(void);
5c84b9a5
RW
404extern void ripng_redistribute_conf_update(struct ripng *ripng, int type);
405extern void ripng_redistribute_conf_delete(struct ripng *ripng, int type);
406
407extern void ripng_peer_update(struct ripng *ripng, struct sockaddr_in6 *from,
408 uint8_t version);
409extern void ripng_peer_bad_route(struct ripng *ripng,
410 struct sockaddr_in6 *from);
411extern void ripng_peer_bad_packet(struct ripng *ripng,
412 struct sockaddr_in6 *from);
413extern void ripng_peer_display(struct vty *vty, struct ripng *ripng);
414extern struct ripng_peer *ripng_peer_lookup(struct ripng *ripng,
415 struct in6_addr *addr);
416extern struct ripng_peer *ripng_peer_lookup_next(struct ripng *ripng,
417 struct in6_addr *addr);
ecece94c 418extern int ripng_peer_list_cmp(struct ripng_peer *p1, struct ripng_peer *p2);
56bf1cb2 419extern void ripng_peer_list_del(void *arg);
d62a17ae 420
5c84b9a5
RW
421extern struct ripng_offset_list *ripng_offset_list_new(struct ripng *ripng,
422 const char *ifname);
b09956ca 423extern void ripng_offset_list_del(struct ripng_offset_list *offset);
6c4c3561 424extern void ripng_offset_list_free(struct ripng_offset_list *offset);
5c84b9a5
RW
425extern struct ripng_offset_list *ripng_offset_list_lookup(struct ripng *ripng,
426 const char *ifname);
427extern int ripng_offset_list_apply_in(struct ripng *ripng,
428 struct prefix_ipv6 *p,
429 struct interface *ifp, uint8_t *metric);
430extern int ripng_offset_list_apply_out(struct ripng *ripng,
431 struct prefix_ipv6 *p,
432 struct interface *ifp, uint8_t *metric);
26c6be93
RW
433extern int offset_list_cmp(struct ripng_offset_list *o1,
434 struct ripng_offset_list *o2);
d62a17ae 435
49e06d25 436extern int ripng_route_rte(struct ripng_info *rinfo);
d62a17ae 437extern struct ripng_info *ripng_info_new(void);
438extern void ripng_info_free(struct ripng_info *rinfo);
5c84b9a5
RW
439extern struct ripng *ripng_info_get_instance(const struct ripng_info *rinfo);
440extern void ripng_event(struct ripng *ripng, enum ripng_event event, int sock);
d62a17ae 441extern int ripng_request(struct interface *ifp);
5c84b9a5
RW
442extern void ripng_redistribute_add(struct ripng *ripng, int type, int sub_type,
443 struct prefix_ipv6 *p, ifindex_t ifindex,
444 struct in6_addr *nexthop, route_tag_t tag);
445extern void ripng_redistribute_delete(struct ripng *ripng, int type,
446 int sub_type, struct prefix_ipv6 *p,
447 ifindex_t ifindex);
448extern void ripng_redistribute_withdraw(struct ripng *ripng, int type);
449
450extern void ripng_ecmp_disable(struct ripng *ripng);
d62a17ae 451extern void ripng_distribute_update_interface(struct interface *);
452extern void ripng_if_rmap_update_interface(struct interface *);
453
5c84b9a5
RW
454extern void ripng_zebra_ipv6_add(struct ripng *ripng, struct agg_node *node);
455extern void ripng_zebra_ipv6_delete(struct ripng *ripng, struct agg_node *node);
d62a17ae 456
f9120f71
RW
457extern void ripng_redistribute_enable(struct ripng *ripng);
458extern void ripng_redistribute_disable(struct ripng *ripng);
5c84b9a5
RW
459extern int ripng_redistribute_check(struct ripng *ripng, int type);
460extern void ripng_redistribute_write(struct vty *vty, struct ripng *ripng);
d62a17ae 461
462extern int ripng_write_rte(int num, struct stream *s, struct prefix_ipv6 *p,
d7c0a89a
QY
463 struct in6_addr *nexthop, uint16_t tag,
464 uint8_t metric);
d62a17ae 465extern int ripng_send_packet(caddr_t buf, int bufsize, struct sockaddr_in6 *to,
466 struct interface *ifp);
467
468extern void ripng_packet_dump(struct ripng_packet *packet, int size,
469 const char *sndrcv);
470
121f9dee
QY
471extern int ripng_interface_up(ZAPI_CALLBACK_ARGS);
472extern int ripng_interface_down(ZAPI_CALLBACK_ARGS);
473extern int ripng_interface_add(ZAPI_CALLBACK_ARGS);
474extern int ripng_interface_delete(ZAPI_CALLBACK_ARGS);
475extern int ripng_interface_address_add(ZAPI_CALLBACK_ARGS);
476extern int ripng_interface_address_delete(ZAPI_CALLBACK_ARGS);
477extern int ripng_interface_vrf_update(ZAPI_CALLBACK_ARGS);
dde7b15b 478extern void ripng_interface_sync(struct interface *ifp);
d62a17ae 479
5c84b9a5 480extern struct ripng *ripng_lookup_by_vrf_id(vrf_id_t vrf_id);
dde7b15b
RW
481extern struct ripng *ripng_lookup_by_vrf_name(const char *vrf_name);
482extern struct ripng *ripng_create(const char *vrf_name, struct vrf *vrf,
483 int socket);
484extern int ripng_make_socket(struct vrf *vrf);
5c84b9a5
RW
485extern int ripng_network_write(struct vty *vty, struct ripng *ripng);
486
487extern struct ripng_info *ripng_ecmp_add(struct ripng *ripng,
488 struct ripng_info *rinfo);
489extern struct ripng_info *ripng_ecmp_replace(struct ripng *ripng,
490 struct ripng_info *rinfo);
491extern struct ripng_info *ripng_ecmp_delete(struct ripng *ripng,
492 struct ripng_info *rinfo);
c880b636 493
dde7b15b
RW
494extern void ripng_vrf_init(void);
495extern void ripng_vrf_terminate(void);
496
e9ce224b
RW
497/* Northbound. */
498extern void ripng_cli_init(void);
499extern const struct frr_yang_module_info frr_ripngd_info;
500
718e3744 501#endif /* _ZEBRA_RIPNG_RIPNGD_H */