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>
29 #include "ripng_memory.h"
31 /* RIPng version and port number. */
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
39 #define RIPNG_REQUEST 1
40 #define RIPNG_RESPONSE 2
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"
47 /* RIPng peer timeout value. */
48 #define RIPNG_PEER_TIMER_DEFAULT 180
50 /* Default config file name. */
51 #define RIPNG_DEFAULT_CONFIG "ripngd.conf"
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
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
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
72 #define RIPNG_DEFAULT_ACCEPT_UNSPEC 0
73 #define RIPNG_DEFAULT_ACCEPT_NONE 1
74 #define RIPNG_DEFAULT_ACCEPT 2
76 /* For max RTE calculation. */
78 #define IPV6_HDRLEN 40
79 #endif /* IPV6_HDRLEN */
86 #define RIPNG_INSTANCE "/frr-ripngd:ripngd/instance"
87 #define RIPNG_IFACE "/frr-interface:lib/interface/frr-ripngd:ripng"
89 /* RIPng structure. */
94 /* RIPng Parameters.*/
98 uint16_t timeout_time
;
99 uint16_t garbage_time
;
101 uint8_t default_metric
;
103 /* Input/output buffer of RIPng. */
107 /* RIPng routing information base. */
108 struct agg_table
*table
;
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
;
117 /* Triggered update hack. */
119 struct thread
*t_triggered_update
;
120 struct thread
*t_triggered_interval
;
122 /* RIPng ECMP flag */
125 /* For redistribute route map. */
128 struct route_map
*map
;
131 } route_map
[ZEBRA_ROUTE_MAX
];
133 /* For distribute-list container */
134 struct distribute_ctx
*distribute_ctx
;
137 /* Routing table entry. */
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 */
147 /* RIPNG send packet. */
148 struct ripng_packet
{
155 /* Each route's information. */
157 /* This route's type. Static, ripng or aggregate. */
160 /* Sub type for static route. */
163 /* RIPng specific information */
164 struct in6_addr nexthop
;
165 struct in6_addr from
;
167 /* Which interface does this route come from. */
170 /* Metric of this route. */
173 /* Tag field of RIPng packet.*/
176 /* For aggregation. */
177 unsigned int suppress
;
179 /* Flags of RIPng route. */
180 #define RIPNG_RTF_FIB 1
181 #define RIPNG_RTF_CHANGED 2
184 /* Garbage collect timer. */
185 struct thread
*t_timeout
;
186 struct thread
*t_garbage_collect
;
188 /* Route-map features - this variables can be changed. */
189 struct in6_addr nexthop_out
;
199 /* RIPng tag structure. */
208 /* Multicast group. */
209 struct in6_addr maddr
;
218 uint8_t split_horizon
;
220 /* Poison reverse. */
221 uint8_t poison_reverse
;
227 RIPNG_NO_SPLIT_HORIZON
= 0,
229 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
230 } split_horizon_policy_t
;
232 /* RIPng specific interface configuration. */
233 struct ripng_interface
{
234 /* RIPng is enabled on this interface. */
236 int enable_interface
;
238 /* RIPng is running on this interface. */
241 /* Split horizon flag. */
242 split_horizon_policy_t split_horizon
;
244 /* For filter type slot. */
245 #define RIPNG_FILTER_IN 0
246 #define RIPNG_FILTER_OUT 1
247 #define RIPNG_FILTER_MAX 2
250 struct access_list
*list
[RIPNG_FILTER_MAX
];
253 struct prefix_list
*prefix
[RIPNG_FILTER_MAX
];
256 struct route_map
*routemap
[RIPNG_FILTER_MAX
];
260 /* RIPng tag configuration. */
261 struct ripng_tag
*rtag
;
265 /* Default information originate. */
266 uint8_t default_originate
;
268 /* Default information only. */
269 uint8_t default_only
;
271 /* Wake up thread. */
272 struct thread
*t_wakeup
;
274 /* Passive interface. */
278 /* RIPng peer information. */
281 struct in6_addr addr
;
283 /* Peer RIPng tag value. */
286 /* Last update time. */
289 /* Peer RIP version. */
296 /* Timeout thread. */
297 struct thread
*t_timeout
;
300 /* All RIPng events. */
306 RIPNG_TRIGGERED_UPDATE
,
309 /* RIPng timer on/off macro. */
310 #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
312 #define RIPNG_TIMER_OFF(T) \
320 #define RIPNG_OFFSET_LIST_IN 0
321 #define RIPNG_OFFSET_LIST_OUT 1
322 #define RIPNG_OFFSET_LIST_MAX 2
324 struct ripng_offset_list
{
329 /* struct access_list *alist; */
331 } direct
[RIPNG_OFFSET_LIST_MAX
];
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
;
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
);
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
*);
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
*,
375 extern int ripng_offset_list_apply_out(struct prefix_ipv6
*, struct interface
*,
377 extern void ripng_offset_init(void);
378 extern void ripng_offset_clean(void);
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
*,
389 extern void ripng_redistribute_withdraw(int type
);
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
*);
395 extern void ripng_zebra_ipv6_add(struct agg_node
*node
);
396 extern void ripng_zebra_ipv6_delete(struct agg_node
*node
);
398 extern void ripng_redistribute_clean(void);
399 extern int ripng_redistribute_check(int);
400 extern void ripng_redistribute_write(struct vty
*);
402 extern int ripng_write_rte(int num
, struct stream
*s
, struct prefix_ipv6
*p
,
403 struct in6_addr
*nexthop
, uint16_t tag
,
405 extern int ripng_send_packet(caddr_t buf
, int bufsize
, struct sockaddr_in6
*to
,
406 struct interface
*ifp
);
408 extern void ripng_packet_dump(struct ripng_packet
*packet
, int size
,
411 extern int ripng_interface_up(int command
, struct zclient
*, zebra_size_t
,
413 extern int ripng_interface_down(int command
, struct zclient
*, zebra_size_t
,
415 extern int ripng_interface_add(int command
, struct zclient
*, zebra_size_t
,
417 extern int ripng_interface_delete(int command
, struct zclient
*, zebra_size_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
);
424 extern int ripng_create(int socket
);
425 extern int ripng_make_socket(void);
426 extern int ripng_network_write(struct vty
*);
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
*);
433 extern void ripng_cli_init(void);
434 extern const struct frr_yang_module_info frr_ripngd_info
;
436 #endif /* _ZEBRA_RIPNG_RIPNGD_H */