]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripngd.h
zebra: Allow ns delete to happen after under/over flow checks
[mirror_frr.git] / ripngd / ripngd.h
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 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
20 */
21
22 #ifndef _ZEBRA_RIPNG_RIPNGD_H
23 #define _ZEBRA_RIPNG_RIPNGD_H
24
25 #include <zclient.h>
26 #include <vty.h>
27
28 #include "ripng_memory.h"
29
30 /* RIPng version and port number. */
31 #define RIPNG_V1 1
32 #define RIPNG_PORT_DEFAULT 521
33 #define RIPNG_VTY_PORT 2603
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 peer timeout value. */
47 #define RIPNG_PEER_TIMER_DEFAULT 180
48
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
55 #define RIPNG_ROUTE_DEFAULT 2
56 #define RIPNG_ROUTE_REDISTRIBUTE 3
57 #define RIPNG_ROUTE_INTERFACE 4
58 #define RIPNG_ROUTE_AGGREGATE 5
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
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
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
84 /* YANG paths */
85 #define RIPNG_INSTANCE "/frr-ripngd:ripngd/instance"
86 #define RIPNG_IFACE "/frr-interface:lib/interface/frr-ripngd:ripng"
87
88 /* RIPng structure. */
89 struct ripng {
90 /* RIPng socket. */
91 int sock;
92
93 /* RIPng Parameters.*/
94 uint8_t command;
95 uint8_t version;
96 uint16_t update_time;
97 uint16_t timeout_time;
98 uint16_t garbage_time;
99 int max_mtu;
100 uint8_t default_metric;
101
102 /* Input/output buffer of RIPng. */
103 struct stream *ibuf;
104 struct stream *obuf;
105
106 /* RIPng routing information base. */
107 struct agg_table *table;
108
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 */
122 bool ecmp;
123
124 /* For redistribute route map. */
125 struct {
126 char *name;
127 struct route_map *map;
128 bool metric_config;
129 uint8_t metric;
130 } route_map[ZEBRA_ROUTE_MAX];
131 };
132
133 /* Routing table entry. */
134 struct rte {
135 struct in6_addr addr; /* RIPng destination prefix */
136 uint16_t tag; /* RIPng tag */
137 uint8_t prefixlen; /* Length of the RIPng prefix */
138 uint8_t metric; /* Metric of the RIPng route */
139 /* The nexthop is stored by the structure
140 * ripng_nexthop within ripngd.c */
141 };
142
143 /* RIPNG send packet. */
144 struct ripng_packet {
145 uint8_t command;
146 uint8_t version;
147 uint16_t zero;
148 struct rte rte[1];
149 };
150
151 /* Each route's information. */
152 struct ripng_info {
153 /* This route's type. Static, ripng or aggregate. */
154 uint8_t type;
155
156 /* Sub type for static route. */
157 uint8_t sub_type;
158
159 /* RIPng specific information */
160 struct in6_addr nexthop;
161 struct in6_addr from;
162
163 /* Which interface does this route come from. */
164 ifindex_t ifindex;
165
166 /* Metric of this route. */
167 uint8_t metric;
168
169 /* Tag field of RIPng packet.*/
170 uint16_t tag;
171
172 /* For aggregation. */
173 unsigned int suppress;
174
175 /* Flags of RIPng route. */
176 #define RIPNG_RTF_FIB 1
177 #define RIPNG_RTF_CHANGED 2
178 uint8_t flags;
179
180 /* Garbage collect timer. */
181 struct thread *t_timeout;
182 struct thread *t_garbage_collect;
183
184 /* Route-map features - this variables can be changed. */
185 struct in6_addr nexthop_out;
186 uint8_t metric_set;
187 uint8_t metric_out;
188 uint16_t tag_out;
189
190 struct agg_node *rp;
191 };
192
193 #ifdef notyet
194 #if 0
195 /* RIPng tag structure. */
196 struct ripng_tag
197 {
198 /* Tag value. */
199 uint16_t tag;
200
201 /* Port. */
202 uint16_t port;
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. */
214 uint8_t split_horizon;
215
216 /* Poison reverse. */
217 uint8_t poison_reverse;
218 };
219 #endif /* 0 */
220 #endif /* not yet */
221
222 typedef enum {
223 RIPNG_NO_SPLIT_HORIZON = 0,
224 RIPNG_SPLIT_HORIZON,
225 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
226 } split_horizon_policy_t;
227
228 /* RIPng specific interface configuration. */
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;
239
240 /* For filter type slot. */
241 #define RIPNG_FILTER_IN 0
242 #define RIPNG_FILTER_OUT 1
243 #define RIPNG_FILTER_MAX 2
244
245 /* Access-list. */
246 struct access_list *list[RIPNG_FILTER_MAX];
247
248 /* Prefix-list. */
249 struct prefix_list *prefix[RIPNG_FILTER_MAX];
250
251 /* Route-map. */
252 struct route_map *routemap[RIPNG_FILTER_MAX];
253
254 #ifdef notyet
255 #if 0
256 /* RIPng tag configuration. */
257 struct ripng_tag *rtag;
258 #endif /* 0 */
259 #endif /* notyet */
260
261 /* Default information originate. */
262 uint8_t default_originate;
263
264 /* Default information only. */
265 uint8_t default_only;
266
267 /* Wake up thread. */
268 struct thread *t_wakeup;
269
270 /* Passive interface. */
271 int passive;
272 };
273
274 /* RIPng peer information. */
275 struct ripng_peer {
276 /* Peer address. */
277 struct in6_addr addr;
278
279 /* Peer RIPng tag value. */
280 int domain;
281
282 /* Last update time. */
283 time_t uptime;
284
285 /* Peer RIP version. */
286 uint8_t version;
287
288 /* Statistics. */
289 int recv_badpackets;
290 int recv_badroutes;
291
292 /* Timeout thread. */
293 struct thread *t_timeout;
294 };
295
296 /* All RIPng events. */
297 enum ripng_event {
298 RIPNG_READ,
299 RIPNG_ZEBRA,
300 RIPNG_REQUEST_EVENT,
301 RIPNG_UPDATE_EVENT,
302 RIPNG_TRIGGERED_UPDATE,
303 };
304
305 /* RIPng timer on/off macro. */
306 #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
307
308 #define RIPNG_TIMER_OFF(T) \
309 do { \
310 if (T) { \
311 thread_cancel(T); \
312 (T) = NULL; \
313 } \
314 } while (0)
315
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
330 /* Extern variables. */
331 extern struct ripng *ripng;
332 extern struct list *peer_list;
333 extern struct zebra_privs_t ripngd_privs;
334 extern struct thread_master *master;
335
336 /* Prototypes. */
337 extern void ripng_init(void);
338 extern void ripng_clean(void);
339 extern void ripng_clean_network(void);
340 extern void ripng_interface_clean(void);
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);
345 extern int ripng_passive_interface_set(const char *ifname);
346 extern int ripng_passive_interface_unset(const char *ifname);
347 extern void ripng_passive_interface_clean(void);
348 extern void ripng_if_init(void);
349 extern void ripng_route_map_init(void);
350 extern void ripng_terminate(void);
351 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
352 extern void zebra_init(struct thread_master *);
353 extern void ripng_zebra_stop(void);
354 extern void ripng_redistribute_conf_update(int type);
355 extern void ripng_redistribute_conf_delete(int type);
356
357 extern void ripng_peer_init(void);
358 extern void ripng_peer_update(struct sockaddr_in6 *, uint8_t);
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
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);
369 extern int ripng_offset_list_apply_in(struct prefix_ipv6 *, struct interface *,
370 uint8_t *);
371 extern int ripng_offset_list_apply_out(struct prefix_ipv6 *, struct interface *,
372 uint8_t *);
373 extern void ripng_offset_init(void);
374 extern void ripng_offset_clean(void);
375
376 extern int ripng_route_rte(struct ripng_info *rinfo);
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
387 extern void ripng_ecmp_disable(void);
388 extern void ripng_distribute_update_interface(struct interface *);
389 extern void ripng_if_rmap_update_interface(struct interface *);
390
391 extern void ripng_zebra_ipv6_add(struct agg_node *node);
392 extern void ripng_zebra_ipv6_delete(struct agg_node *node);
393
394 extern void ripng_redistribute_clean(void);
395 extern int ripng_redistribute_check(int);
396 extern void ripng_redistribute_write(struct vty *);
397
398 extern int ripng_write_rte(int num, struct stream *s, struct prefix_ipv6 *p,
399 struct in6_addr *nexthop, uint16_t tag,
400 uint8_t metric);
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
420 extern int ripng_create(int socket);
421 extern int ripng_make_socket(void);
422 extern int ripng_network_write(struct vty *);
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 *);
427
428 /* Northbound. */
429 extern void ripng_cli_init(void);
430 extern const struct frr_yang_module_info frr_ripngd_info;
431
432 #endif /* _ZEBRA_RIPNG_RIPNGD_H */