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