2 * RIPng related value and structure.
3 * Copyright (C) 1998 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
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
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.
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
22 #ifndef _ZEBRA_RIPNG_RIPNGD_H
23 #define _ZEBRA_RIPNG_RIPNGD_H
27 #include <distribute.h>
30 #include "ripng_memory.h"
32 /* RIPng version and port number. */
34 #define RIPNG_PORT_DEFAULT 521
35 #define RIPNG_VTY_PORT 2603
36 #define RIPNG_MAX_PACKET_SIZE 1500
37 #define RIPNG_PRIORITY_DEFAULT 0
40 #define RIPNG_REQUEST 1
41 #define RIPNG_RESPONSE 2
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"
48 /* RIPng peer timeout value. */
49 #define RIPNG_PEER_TIMER_DEFAULT 180
51 /* Default config file name. */
52 #define RIPNG_DEFAULT_CONFIG "ripngd.conf"
54 /* RIPng route types. */
55 #define RIPNG_ROUTE_RTE 0
56 #define RIPNG_ROUTE_STATIC 1
57 #define RIPNG_ROUTE_DEFAULT 2
58 #define RIPNG_ROUTE_REDISTRIBUTE 3
59 #define RIPNG_ROUTE_INTERFACE 4
60 #define RIPNG_ROUTE_AGGREGATE 5
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
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
73 #define RIPNG_DEFAULT_ACCEPT_UNSPEC 0
74 #define RIPNG_DEFAULT_ACCEPT_NONE 1
75 #define RIPNG_DEFAULT_ACCEPT 2
77 /* For max RTE calculation. */
79 #define IPV6_HDRLEN 40
80 #endif /* IPV6_HDRLEN */
87 #define RIPNG_INSTANCE "/frr-ripngd:ripngd/instance"
88 #define RIPNG_IFACE "/frr-interface:lib/interface/frr-ripngd:ripng"
90 /* RIPng structure. */
98 /* RIPng Parameters.*/
101 uint16_t update_time
;
102 uint16_t timeout_time
;
103 uint16_t garbage_time
;
105 uint8_t default_metric
;
107 /* Input/output buffer of RIPng. */
111 /* RIPng routing information base. */
112 struct agg_table
*table
;
114 /* Linked list of RIPng peers. */
115 struct list
*peer_list
;
117 /* RIPng enabled interfaces. */
120 /* RIPng enabled networks. */
121 struct agg_table
*enable_network
;
123 /* Vector to store passive-interface name. */
124 vector passive_interface
;
126 /* RIPng offset-lists. */
127 struct list
*offset_list_master
;
130 struct thread
*t_read
;
131 struct thread
*t_write
;
132 struct thread
*t_update
;
133 struct thread
*t_garbage
;
134 struct thread
*t_zebra
;
136 /* Triggered update hack. */
138 struct thread
*t_triggered_update
;
139 struct thread
*t_triggered_interval
;
141 /* RIPng ECMP flag */
144 /* For redistribute route map. */
147 struct route_map
*map
;
150 } route_map
[ZEBRA_ROUTE_MAX
];
152 /* For distribute-list container */
153 struct distribute_ctx
*distribute_ctx
;
156 /* Routing table entry. */
158 struct in6_addr addr
; /* RIPng destination prefix */
159 uint16_t tag
; /* RIPng tag */
160 uint8_t prefixlen
; /* Length of the RIPng prefix */
161 uint8_t metric
; /* Metric of the RIPng route */
162 /* The nexthop is stored by the structure
163 * ripng_nexthop within ripngd.c */
166 /* RIPNG send packet. */
167 struct ripng_packet
{
174 /* Each route's information. */
176 /* This route's type. Static, ripng or aggregate. */
179 /* Sub type for static route. */
182 /* RIPng specific information */
183 struct in6_addr nexthop
;
184 struct in6_addr from
;
186 /* Which interface does this route come from. */
189 /* Metric of this route. */
192 /* Tag field of RIPng packet.*/
195 /* For aggregation. */
196 unsigned int suppress
;
198 /* Flags of RIPng route. */
199 #define RIPNG_RTF_FIB 1
200 #define RIPNG_RTF_CHANGED 2
203 /* Garbage collect timer. */
204 struct thread
*t_timeout
;
205 struct thread
*t_garbage_collect
;
207 /* Route-map features - this variables can be changed. */
208 struct in6_addr nexthop_out
;
218 /* RIPng tag structure. */
227 /* Multicast group. */
228 struct in6_addr maddr
;
237 uint8_t split_horizon
;
239 /* Poison reverse. */
240 uint8_t poison_reverse
;
246 RIPNG_NO_SPLIT_HORIZON
= 0,
248 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
249 } split_horizon_policy_t
;
251 /* RIPng specific interface configuration. */
252 struct ripng_interface
{
253 /* Parent routing instance. */
256 /* RIPng is enabled on this interface. */
258 int enable_interface
;
260 /* RIPng is running on this interface. */
263 /* Split horizon flag. */
264 split_horizon_policy_t split_horizon
;
266 /* For filter type slot. */
267 #define RIPNG_FILTER_IN 0
268 #define RIPNG_FILTER_OUT 1
269 #define RIPNG_FILTER_MAX 2
272 struct access_list
*list
[RIPNG_FILTER_MAX
];
275 struct prefix_list
*prefix
[RIPNG_FILTER_MAX
];
278 struct route_map
*routemap
[RIPNG_FILTER_MAX
];
282 /* RIPng tag configuration. */
283 struct ripng_tag
*rtag
;
287 /* Default information originate. */
288 uint8_t default_originate
;
290 /* Default information only. */
291 uint8_t default_only
;
293 /* Wake up thread. */
294 struct thread
*t_wakeup
;
296 /* Passive interface. */
300 /* RIPng peer information. */
302 /* Parent routing instance. */
306 struct in6_addr addr
;
308 /* Peer RIPng tag value. */
311 /* Last update time. */
314 /* Peer RIP version. */
321 /* Timeout thread. */
322 struct thread
*t_timeout
;
325 /* All RIPng events. */
331 RIPNG_TRIGGERED_UPDATE
,
334 /* RIPng timer on/off macro. */
335 #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
337 #define RIPNG_TIMER_OFF(T) \
345 #define RIPNG_OFFSET_LIST_IN 0
346 #define RIPNG_OFFSET_LIST_OUT 1
347 #define RIPNG_OFFSET_LIST_MAX 2
349 struct ripng_offset_list
{
350 /* Parent routing instance. */
357 /* struct access_list *alist; */
359 } direct
[RIPNG_OFFSET_LIST_MAX
];
362 /* Extern variables. */
363 extern struct zebra_privs_t ripngd_privs
;
364 extern struct thread_master
*master
;
367 extern void ripng_init(void);
368 extern void ripng_clean(struct ripng
*ripng
);
369 extern void ripng_clean_network(struct ripng
*ripng
);
370 extern void ripng_interface_clean(struct ripng
*ripng
);
371 extern int ripng_enable_network_add(struct ripng
*ripng
, struct prefix
*p
);
372 extern int ripng_enable_network_delete(struct ripng
*ripng
, struct prefix
*p
);
373 extern int ripng_enable_if_add(struct ripng
*ripng
, const char *ifname
);
374 extern int ripng_enable_if_delete(struct ripng
*ripng
, const char *ifname
);
375 extern int ripng_passive_interface_set(struct ripng
*ripng
, const char *ifname
);
376 extern int ripng_passive_interface_unset(struct ripng
*ripng
,
378 extern void ripng_passive_interface_clean(struct ripng
*ripng
);
379 extern void ripng_if_init(void);
380 extern void ripng_route_map_init(void);
381 extern void ripng_terminate(void);
382 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
383 extern void zebra_init(struct thread_master
*);
384 extern void ripng_zebra_stop(void);
385 extern void ripng_redistribute_conf_update(struct ripng
*ripng
, int type
);
386 extern void ripng_redistribute_conf_delete(struct ripng
*ripng
, int type
);
388 extern void ripng_peer_update(struct ripng
*ripng
, struct sockaddr_in6
*from
,
390 extern void ripng_peer_bad_route(struct ripng
*ripng
,
391 struct sockaddr_in6
*from
);
392 extern void ripng_peer_bad_packet(struct ripng
*ripng
,
393 struct sockaddr_in6
*from
);
394 extern void ripng_peer_display(struct vty
*vty
, struct ripng
*ripng
);
395 extern struct ripng_peer
*ripng_peer_lookup(struct ripng
*ripng
,
396 struct in6_addr
*addr
);
397 extern struct ripng_peer
*ripng_peer_lookup_next(struct ripng
*ripng
,
398 struct in6_addr
*addr
);
399 extern int ripng_peer_list_cmp(struct ripng_peer
*p1
, struct ripng_peer
*p2
);
400 extern void ripng_peer_list_del(void *arg
);
402 extern struct ripng_offset_list
*ripng_offset_list_new(struct ripng
*ripng
,
404 extern void ripng_offset_list_del(struct ripng_offset_list
*offset
);
405 extern struct ripng_offset_list
*ripng_offset_list_lookup(struct ripng
*ripng
,
407 extern int ripng_offset_list_apply_in(struct ripng
*ripng
,
408 struct prefix_ipv6
*p
,
409 struct interface
*ifp
, uint8_t *metric
);
410 extern int ripng_offset_list_apply_out(struct ripng
*ripng
,
411 struct prefix_ipv6
*p
,
412 struct interface
*ifp
, uint8_t *metric
);
413 extern int offset_list_cmp(struct ripng_offset_list
*o1
,
414 struct ripng_offset_list
*o2
);
416 extern int ripng_route_rte(struct ripng_info
*rinfo
);
417 extern struct ripng_info
*ripng_info_new(void);
418 extern void ripng_info_free(struct ripng_info
*rinfo
);
419 extern struct ripng
*ripng_info_get_instance(const struct ripng_info
*rinfo
);
420 extern void ripng_event(struct ripng
*ripng
, enum ripng_event event
, int sock
);
421 extern int ripng_request(struct interface
*ifp
);
422 extern void ripng_redistribute_add(struct ripng
*ripng
, int type
, int sub_type
,
423 struct prefix_ipv6
*p
, ifindex_t ifindex
,
424 struct in6_addr
*nexthop
, route_tag_t tag
);
425 extern void ripng_redistribute_delete(struct ripng
*ripng
, int type
,
426 int sub_type
, struct prefix_ipv6
*p
,
428 extern void ripng_redistribute_withdraw(struct ripng
*ripng
, int type
);
430 extern void ripng_ecmp_disable(struct ripng
*ripng
);
431 extern void ripng_distribute_update_interface(struct interface
*);
432 extern void ripng_if_rmap_update_interface(struct interface
*);
434 extern void ripng_zebra_ipv6_add(struct ripng
*ripng
, struct agg_node
*node
);
435 extern void ripng_zebra_ipv6_delete(struct ripng
*ripng
, struct agg_node
*node
);
437 extern void ripng_redistribute_clean(struct ripng
*ripng
);
438 extern int ripng_redistribute_check(struct ripng
*ripng
, int type
);
439 extern void ripng_redistribute_write(struct vty
*vty
, struct ripng
*ripng
);
441 extern int ripng_write_rte(int num
, struct stream
*s
, struct prefix_ipv6
*p
,
442 struct in6_addr
*nexthop
, uint16_t tag
,
444 extern int ripng_send_packet(caddr_t buf
, int bufsize
, struct sockaddr_in6
*to
,
445 struct interface
*ifp
);
447 extern void ripng_packet_dump(struct ripng_packet
*packet
, int size
,
450 extern int ripng_interface_up(int command
, struct zclient
*, zebra_size_t
,
452 extern int ripng_interface_down(int command
, struct zclient
*, zebra_size_t
,
454 extern int ripng_interface_add(int command
, struct zclient
*, zebra_size_t
,
456 extern int ripng_interface_delete(int command
, struct zclient
*, zebra_size_t
,
458 extern int ripng_interface_address_add(int command
, struct zclient
*,
459 zebra_size_t
, vrf_id_t
);
460 extern int ripng_interface_address_delete(int command
, struct zclient
*,
461 zebra_size_t
, vrf_id_t
);
463 extern struct ripng
*ripng_lookup_by_vrf_id(vrf_id_t vrf_id
);
464 extern struct ripng
*ripng_create(struct vrf
*vrf
, int socket
);
465 extern int ripng_make_socket(void);
466 extern int ripng_network_write(struct vty
*vty
, struct ripng
*ripng
);
468 extern struct ripng_info
*ripng_ecmp_add(struct ripng
*ripng
,
469 struct ripng_info
*rinfo
);
470 extern struct ripng_info
*ripng_ecmp_replace(struct ripng
*ripng
,
471 struct ripng_info
*rinfo
);
472 extern struct ripng_info
*ripng_ecmp_delete(struct ripng
*ripng
,
473 struct ripng_info
*rinfo
);
476 extern void ripng_cli_init(void);
477 extern const struct frr_yang_module_info frr_ripngd_info
;
479 #endif /* _ZEBRA_RIPNG_RIPNGD_H */