]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripngd.h
ripngd: retrofit the 'timer basic' command to the new northbound model
[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 split_horizon_policy_t split_horizon_default;
240
241 /* For filter type slot. */
242 #define RIPNG_FILTER_IN 0
243 #define RIPNG_FILTER_OUT 1
244 #define RIPNG_FILTER_MAX 2
245
246 /* Access-list. */
247 struct access_list *list[RIPNG_FILTER_MAX];
248
249 /* Prefix-list. */
250 struct prefix_list *prefix[RIPNG_FILTER_MAX];
251
252 /* Route-map. */
253 struct route_map *routemap[RIPNG_FILTER_MAX];
254
255 #ifdef notyet
256 #if 0
257 /* RIPng tag configuration. */
258 struct ripng_tag *rtag;
259 #endif /* 0 */
260 #endif /* notyet */
261
262 /* Default information originate. */
263 uint8_t default_originate;
264
265 /* Default information only. */
266 uint8_t default_only;
267
268 /* Wake up thread. */
269 struct thread *t_wakeup;
270
271 /* Passive interface. */
272 int passive;
273 };
274
275 /* RIPng peer information. */
276 struct ripng_peer {
277 /* Peer address. */
278 struct in6_addr addr;
279
280 /* Peer RIPng tag value. */
281 int domain;
282
283 /* Last update time. */
284 time_t uptime;
285
286 /* Peer RIP version. */
287 uint8_t version;
288
289 /* Statistics. */
290 int recv_badpackets;
291 int recv_badroutes;
292
293 /* Timeout thread. */
294 struct thread *t_timeout;
295 };
296
297 /* All RIPng events. */
298 enum ripng_event {
299 RIPNG_READ,
300 RIPNG_ZEBRA,
301 RIPNG_REQUEST_EVENT,
302 RIPNG_UPDATE_EVENT,
303 RIPNG_TRIGGERED_UPDATE,
304 };
305
306 /* RIPng timer on/off macro. */
307 #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
308
309 #define RIPNG_TIMER_OFF(T) \
310 do { \
311 if (T) { \
312 thread_cancel(T); \
313 (T) = NULL; \
314 } \
315 } while (0)
316
317 #define RIPNG_OFFSET_LIST_IN 0
318 #define RIPNG_OFFSET_LIST_OUT 1
319 #define RIPNG_OFFSET_LIST_MAX 2
320
321 struct ripng_offset_list {
322 char *ifname;
323
324 struct {
325 char *alist_name;
326 /* struct access_list *alist; */
327 uint8_t metric;
328 } direct[RIPNG_OFFSET_LIST_MAX];
329 };
330
331 /* Extern variables. */
332 extern struct ripng *ripng;
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_reset(void);
339 extern void ripng_clean(void);
340 extern void ripng_clean_network(void);
341 extern void ripng_interface_clean(void);
342 extern void ripng_interface_reset(void);
343 extern int ripng_enable_network_add(struct prefix *p);
344 extern int ripng_enable_network_delete(struct prefix *p);
345 extern int ripng_enable_if_add(const char *ifname);
346 extern int ripng_enable_if_delete(const char *ifname);
347 extern int ripng_passive_interface_set(const char *ifname);
348 extern int ripng_passive_interface_unset(const char *ifname);
349 extern void ripng_passive_interface_clean(void);
350 extern void ripng_if_init(void);
351 extern void ripng_route_map_init(void);
352 extern void ripng_route_map_reset(void);
353 extern void ripng_terminate(void);
354 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
355 extern void zebra_init(struct thread_master *);
356 extern void ripng_zebra_stop(void);
357 extern void ripng_zclient_reset(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 struct ripng_info *ripng_info_new(void);
381 extern void ripng_info_free(struct ripng_info *rinfo);
382 extern void ripng_event(enum ripng_event, int);
383 extern int ripng_request(struct interface *ifp);
384 extern void ripng_redistribute_add(int, int, struct prefix_ipv6 *, ifindex_t,
385 struct in6_addr *, route_tag_t);
386 extern void ripng_redistribute_delete(int, int, struct prefix_ipv6 *,
387 ifindex_t);
388 extern void ripng_redistribute_withdraw(int type);
389
390 extern void ripng_ecmp_disable(void);
391 extern void ripng_distribute_update_interface(struct interface *);
392 extern void ripng_if_rmap_update_interface(struct interface *);
393
394 extern void ripng_zebra_ipv6_add(struct agg_node *node);
395 extern void ripng_zebra_ipv6_delete(struct agg_node *node);
396
397 extern void ripng_redistribute_clean(void);
398 extern int ripng_redistribute_check(int);
399 extern void ripng_redistribute_write(struct vty *);
400
401 extern int ripng_write_rte(int num, struct stream *s, struct prefix_ipv6 *p,
402 struct in6_addr *nexthop, uint16_t tag,
403 uint8_t metric);
404 extern int ripng_send_packet(caddr_t buf, int bufsize, struct sockaddr_in6 *to,
405 struct interface *ifp);
406
407 extern void ripng_packet_dump(struct ripng_packet *packet, int size,
408 const char *sndrcv);
409
410 extern int ripng_interface_up(int command, struct zclient *, zebra_size_t,
411 vrf_id_t);
412 extern int ripng_interface_down(int command, struct zclient *, zebra_size_t,
413 vrf_id_t);
414 extern int ripng_interface_add(int command, struct zclient *, zebra_size_t,
415 vrf_id_t);
416 extern int ripng_interface_delete(int command, struct zclient *, zebra_size_t,
417 vrf_id_t);
418 extern int ripng_interface_address_add(int command, struct zclient *,
419 zebra_size_t, vrf_id_t);
420 extern int ripng_interface_address_delete(int command, struct zclient *,
421 zebra_size_t, vrf_id_t);
422
423 extern int ripng_create(int socket);
424 extern int ripng_make_socket(void);
425 extern int ripng_network_write(struct vty *);
426
427 extern struct ripng_info *ripng_ecmp_add(struct ripng_info *);
428 extern struct ripng_info *ripng_ecmp_replace(struct ripng_info *);
429 extern struct ripng_info *ripng_ecmp_delete(struct ripng_info *);
430
431 /* Northbound. */
432 extern void ripng_cli_init(void);
433 extern const struct frr_yang_module_info frr_ripngd_info;
434
435 #endif /* _ZEBRA_RIPNG_RIPNGD_H */