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
28 #include "ripng_memory.h"
30 /* RIPng version and port number. */
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
38 #define RIPNG_REQUEST 1
39 #define RIPNG_RESPONSE 2
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"
46 /* RIPng peer timeout value. */
47 #define RIPNG_PEER_TIMER_DEFAULT 180
49 /* Default config file name. */
50 #define RIPNG_DEFAULT_CONFIG "ripngd.conf"
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
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
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
71 #define RIPNG_DEFAULT_ACCEPT_UNSPEC 0
72 #define RIPNG_DEFAULT_ACCEPT_NONE 1
73 #define RIPNG_DEFAULT_ACCEPT 2
75 /* For max RTE calculation. */
77 #define IPV6_HDRLEN 40
78 #endif /* IPV6_HDRLEN */
85 #define RIPNG_INSTANCE "/frr-ripngd:ripngd/instance"
86 #define RIPNG_IFACE "/frr-interface:lib/interface/frr-ripngd:ripng"
88 /* RIPng structure. */
93 /* RIPng Parameters.*/
97 uint16_t timeout_time
;
98 uint16_t garbage_time
;
100 uint8_t default_metric
;
102 /* Input/output buffer of RIPng. */
106 /* RIPng routing information base. */
107 struct agg_table
*table
;
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
;
116 /* Triggered update hack. */
118 struct thread
*t_triggered_update
;
119 struct thread
*t_triggered_interval
;
121 /* RIPng ECMP flag */
124 /* For redistribute route map. */
127 struct route_map
*map
;
130 } route_map
[ZEBRA_ROUTE_MAX
];
133 /* Routing table entry. */
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 */
143 /* RIPNG send packet. */
144 struct ripng_packet
{
151 /* Each route's information. */
153 /* This route's type. Static, ripng or aggregate. */
156 /* Sub type for static route. */
159 /* RIPng specific information */
160 struct in6_addr nexthop
;
161 struct in6_addr from
;
163 /* Which interface does this route come from. */
166 /* Metric of this route. */
169 /* Tag field of RIPng packet.*/
172 /* For aggregation. */
173 unsigned int suppress
;
175 /* Flags of RIPng route. */
176 #define RIPNG_RTF_FIB 1
177 #define RIPNG_RTF_CHANGED 2
180 /* Garbage collect timer. */
181 struct thread
*t_timeout
;
182 struct thread
*t_garbage_collect
;
184 /* Route-map features - this variables can be changed. */
185 struct in6_addr nexthop_out
;
195 /* RIPng tag structure. */
204 /* Multicast group. */
205 struct in6_addr maddr
;
214 uint8_t split_horizon
;
216 /* Poison reverse. */
217 uint8_t poison_reverse
;
223 RIPNG_NO_SPLIT_HORIZON
= 0,
225 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
226 } split_horizon_policy_t
;
228 /* RIPng specific interface configuration. */
229 struct ripng_interface
{
230 /* RIPng is enabled on this interface. */
232 int enable_interface
;
234 /* RIPng is running on this interface. */
237 /* Split horizon flag. */
238 split_horizon_policy_t split_horizon
;
240 /* For filter type slot. */
241 #define RIPNG_FILTER_IN 0
242 #define RIPNG_FILTER_OUT 1
243 #define RIPNG_FILTER_MAX 2
246 struct access_list
*list
[RIPNG_FILTER_MAX
];
249 struct prefix_list
*prefix
[RIPNG_FILTER_MAX
];
252 struct route_map
*routemap
[RIPNG_FILTER_MAX
];
256 /* RIPng tag configuration. */
257 struct ripng_tag
*rtag
;
261 /* Default information originate. */
262 uint8_t default_originate
;
264 /* Default information only. */
265 uint8_t default_only
;
267 /* Wake up thread. */
268 struct thread
*t_wakeup
;
270 /* Passive interface. */
274 /* RIPng peer information. */
277 struct in6_addr addr
;
279 /* Peer RIPng tag value. */
282 /* Last update time. */
285 /* Peer RIP version. */
292 /* Timeout thread. */
293 struct thread
*t_timeout
;
296 /* All RIPng events. */
302 RIPNG_TRIGGERED_UPDATE
,
305 /* RIPng timer on/off macro. */
306 #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
308 #define RIPNG_TIMER_OFF(T) \
316 #define RIPNG_OFFSET_LIST_IN 0
317 #define RIPNG_OFFSET_LIST_OUT 1
318 #define RIPNG_OFFSET_LIST_MAX 2
320 struct ripng_offset_list
{
325 /* struct access_list *alist; */
327 } direct
[RIPNG_OFFSET_LIST_MAX
];
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
;
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
);
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
*);
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
*,
371 extern int ripng_offset_list_apply_out(struct prefix_ipv6
*, struct interface
*,
373 extern void ripng_offset_init(void);
374 extern void ripng_offset_clean(void);
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
*,
385 extern void ripng_redistribute_withdraw(int type
);
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
*);
391 extern void ripng_zebra_ipv6_add(struct agg_node
*node
);
392 extern void ripng_zebra_ipv6_delete(struct agg_node
*node
);
394 extern void ripng_redistribute_clean(void);
395 extern int ripng_redistribute_check(int);
396 extern void ripng_redistribute_write(struct vty
*);
398 extern int ripng_write_rte(int num
, struct stream
*s
, struct prefix_ipv6
*p
,
399 struct in6_addr
*nexthop
, uint16_t tag
,
401 extern int ripng_send_packet(caddr_t buf
, int bufsize
, struct sockaddr_in6
*to
,
402 struct interface
*ifp
);
404 extern void ripng_packet_dump(struct ripng_packet
*packet
, int size
,
407 extern int ripng_interface_up(int command
, struct zclient
*, zebra_size_t
,
409 extern int ripng_interface_down(int command
, struct zclient
*, zebra_size_t
,
411 extern int ripng_interface_add(int command
, struct zclient
*, zebra_size_t
,
413 extern int ripng_interface_delete(int command
, struct zclient
*, zebra_size_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
);
420 extern int ripng_create(int socket
);
421 extern int ripng_make_socket(void);
422 extern int ripng_network_write(struct vty
*);
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
*);
429 extern void ripng_cli_init(void);
430 extern const struct frr_yang_module_info frr_ripngd_info
;
432 #endif /* _ZEBRA_RIPNG_RIPNGD_H */