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>
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 DECLARE_MGROUP(RIPNGD
)
91 /* RIPng structure. */
93 RB_ENTRY(ripng
) entry
;
95 /* VRF this routing instance is associated with. */
98 /* VRF backpointer (might be NULL if the VRF doesn't exist). */
101 /* Status of the routing instance. */
107 /* RIPng Parameters.*/
110 uint16_t update_time
;
111 uint16_t timeout_time
;
112 uint16_t garbage_time
;
114 uint8_t default_metric
;
116 /* Input/output buffer of RIPng. */
120 /* RIPng routing information base. */
121 struct agg_table
*table
;
123 /* Linked list of RIPng peers. */
124 struct list
*peer_list
;
126 /* RIPng enabled interfaces. */
129 /* RIPng enabled networks. */
130 struct agg_table
*enable_network
;
132 /* Vector to store passive-interface name. */
133 vector passive_interface
;
135 /* RIPng offset-lists. */
136 struct list
*offset_list_master
;
139 struct thread
*t_read
;
140 struct thread
*t_write
;
141 struct thread
*t_update
;
142 struct thread
*t_garbage
;
143 struct thread
*t_zebra
;
145 /* Triggered update hack. */
147 struct thread
*t_triggered_update
;
148 struct thread
*t_triggered_interval
;
150 /* RIPng ECMP flag */
153 /* RIPng redistribute configuration. */
158 struct route_map
*map
;
162 } redist
[ZEBRA_ROUTE_MAX
];
164 /* For distribute-list container */
165 struct distribute_ctx
*distribute_ctx
;
167 /* For if_rmap container */
168 struct if_rmap_ctx
*if_rmap_ctx
;
170 RB_HEAD(ripng_instance_head
, ripng
);
171 RB_PROTOTYPE(ripng_instance_head
, ripng
, entry
, ripng_instance_compare
)
173 /* Routing table entry. */
175 struct in6_addr addr
; /* RIPng destination prefix */
176 uint16_t tag
; /* RIPng tag */
177 uint8_t prefixlen
; /* Length of the RIPng prefix */
178 uint8_t metric
; /* Metric of the RIPng route */
179 /* The nexthop is stored by the structure
180 * ripng_nexthop within ripngd.c */
183 /* RIPNG send packet. */
184 struct ripng_packet
{
191 /* Each route's information. */
193 /* This route's type. Static, ripng or aggregate. */
196 /* Sub type for static route. */
199 /* RIPng specific information */
200 struct in6_addr nexthop
;
201 struct in6_addr from
;
203 /* Which interface does this route come from. */
206 /* Metric of this route. */
209 /* Tag field of RIPng packet.*/
212 /* For aggregation. */
213 unsigned int suppress
;
215 /* Flags of RIPng route. */
216 #define RIPNG_RTF_FIB 1
217 #define RIPNG_RTF_CHANGED 2
220 /* Garbage collect timer. */
221 struct thread
*t_timeout
;
222 struct thread
*t_garbage_collect
;
224 /* Route-map features - this variables can be changed. */
225 struct in6_addr nexthop_out
;
234 RIPNG_NO_SPLIT_HORIZON
= 0,
236 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
237 } split_horizon_policy_t
;
239 /* RIPng specific interface configuration. */
240 struct ripng_interface
{
241 /* Parent routing instance. */
244 /* RIPng is enabled on this interface. */
246 int enable_interface
;
248 /* RIPng is running on this interface. */
251 /* Split horizon flag. */
252 split_horizon_policy_t split_horizon
;
254 /* For filter type slot. */
255 #define RIPNG_FILTER_IN 0
256 #define RIPNG_FILTER_OUT 1
257 #define RIPNG_FILTER_MAX 2
260 struct access_list
*list
[RIPNG_FILTER_MAX
];
263 struct prefix_list
*prefix
[RIPNG_FILTER_MAX
];
266 struct route_map
*routemap
[RIPNG_FILTER_MAX
];
268 /* Default information originate. */
269 uint8_t default_originate
;
271 /* Default information only. */
272 uint8_t default_only
;
274 /* Wake up thread. */
275 struct thread
*t_wakeup
;
277 /* Passive interface. */
281 /* RIPng peer information. */
283 /* Parent routing instance. */
287 struct in6_addr addr
;
289 /* Peer RIPng tag value. */
292 /* Last update time. */
295 /* Peer RIP version. */
302 /* Timeout thread. */
303 struct thread
*t_timeout
;
306 /* All RIPng events. */
312 RIPNG_TRIGGERED_UPDATE
,
315 /* RIPng timer on/off macro. */
316 #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
318 #define RIPNG_TIMER_OFF(T) thread_cancel(&(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
{
325 /* Parent routing instance. */
332 /* struct access_list *alist; */
334 } direct
[RIPNG_OFFSET_LIST_MAX
];
337 /* Extern variables. */
338 extern struct zebra_privs_t ripngd_privs
;
339 extern struct thread_master
*master
;
340 extern struct ripng_instance_head ripng_instances
;
343 extern void ripng_init(void);
344 extern void ripng_clean(struct ripng
*ripng
);
345 extern void ripng_clean_network(struct ripng
*ripng
);
346 extern void ripng_interface_clean(struct ripng
*ripng
);
347 extern int ripng_enable_network_add(struct ripng
*ripng
, struct prefix
*p
);
348 extern int ripng_enable_network_delete(struct ripng
*ripng
, struct prefix
*p
);
349 extern int ripng_enable_if_add(struct ripng
*ripng
, const char *ifname
);
350 extern int ripng_enable_if_delete(struct ripng
*ripng
, const char *ifname
);
351 extern int ripng_passive_interface_set(struct ripng
*ripng
, const char *ifname
);
352 extern int ripng_passive_interface_unset(struct ripng
*ripng
,
354 extern void ripng_passive_interface_clean(struct ripng
*ripng
);
355 extern void ripng_if_init(void);
356 extern void ripng_route_map_init(void);
357 extern void ripng_zebra_vrf_register(struct vrf
*vrf
);
358 extern void ripng_zebra_vrf_deregister(struct vrf
*vrf
);
359 extern void ripng_terminate(void);
360 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
361 extern void zebra_init(struct thread_master
*);
362 extern void ripng_zebra_stop(void);
363 extern void ripng_redistribute_conf_update(struct ripng
*ripng
, int type
);
364 extern void ripng_redistribute_conf_delete(struct ripng
*ripng
, int type
);
366 extern void ripng_peer_update(struct ripng
*ripng
, struct sockaddr_in6
*from
,
368 extern void ripng_peer_bad_route(struct ripng
*ripng
,
369 struct sockaddr_in6
*from
);
370 extern void ripng_peer_bad_packet(struct ripng
*ripng
,
371 struct sockaddr_in6
*from
);
372 extern void ripng_peer_display(struct vty
*vty
, struct ripng
*ripng
);
373 extern struct ripng_peer
*ripng_peer_lookup(struct ripng
*ripng
,
374 struct in6_addr
*addr
);
375 extern struct ripng_peer
*ripng_peer_lookup_next(struct ripng
*ripng
,
376 struct in6_addr
*addr
);
377 extern int ripng_peer_list_cmp(struct ripng_peer
*p1
, struct ripng_peer
*p2
);
378 extern void ripng_peer_list_del(void *arg
);
380 extern struct ripng_offset_list
*ripng_offset_list_new(struct ripng
*ripng
,
382 extern void ripng_offset_list_del(struct ripng_offset_list
*offset
);
383 extern void ripng_offset_list_free(struct ripng_offset_list
*offset
);
384 extern struct ripng_offset_list
*ripng_offset_list_lookup(struct ripng
*ripng
,
386 extern int ripng_offset_list_apply_in(struct ripng
*ripng
,
387 struct prefix_ipv6
*p
,
388 struct interface
*ifp
, uint8_t *metric
);
389 extern int ripng_offset_list_apply_out(struct ripng
*ripng
,
390 struct prefix_ipv6
*p
,
391 struct interface
*ifp
, uint8_t *metric
);
392 extern int offset_list_cmp(struct ripng_offset_list
*o1
,
393 struct ripng_offset_list
*o2
);
395 extern int ripng_route_rte(struct ripng_info
*rinfo
);
396 extern struct ripng_info
*ripng_info_new(void);
397 extern void ripng_info_free(struct ripng_info
*rinfo
);
398 extern struct ripng
*ripng_info_get_instance(const struct ripng_info
*rinfo
);
399 extern void ripng_event(struct ripng
*ripng
, enum ripng_event event
, int sock
);
400 extern int ripng_request(struct interface
*ifp
);
401 extern void ripng_redistribute_add(struct ripng
*ripng
, int type
, int sub_type
,
402 struct prefix_ipv6
*p
, ifindex_t ifindex
,
403 struct in6_addr
*nexthop
, route_tag_t tag
);
404 extern void ripng_redistribute_delete(struct ripng
*ripng
, int type
,
405 int sub_type
, struct prefix_ipv6
*p
,
407 extern void ripng_redistribute_withdraw(struct ripng
*ripng
, int type
);
409 extern void ripng_ecmp_disable(struct ripng
*ripng
);
410 extern void ripng_distribute_update_interface(struct interface
*);
411 extern void ripng_if_rmap_update_interface(struct interface
*);
413 extern void ripng_zebra_ipv6_add(struct ripng
*ripng
, struct agg_node
*node
);
414 extern void ripng_zebra_ipv6_delete(struct ripng
*ripng
, struct agg_node
*node
);
416 extern void ripng_redistribute_enable(struct ripng
*ripng
);
417 extern void ripng_redistribute_disable(struct ripng
*ripng
);
418 extern int ripng_redistribute_check(struct ripng
*ripng
, int type
);
419 extern void ripng_redistribute_write(struct vty
*vty
, struct ripng
*ripng
);
421 extern int ripng_write_rte(int num
, struct stream
*s
, struct prefix_ipv6
*p
,
422 struct in6_addr
*nexthop
, uint16_t tag
,
424 extern int ripng_send_packet(caddr_t buf
, int bufsize
, struct sockaddr_in6
*to
,
425 struct interface
*ifp
);
427 extern void ripng_packet_dump(struct ripng_packet
*packet
, int size
,
430 extern int ripng_interface_up(ZAPI_CALLBACK_ARGS
);
431 extern int ripng_interface_down(ZAPI_CALLBACK_ARGS
);
432 extern int ripng_interface_add(ZAPI_CALLBACK_ARGS
);
433 extern int ripng_interface_delete(ZAPI_CALLBACK_ARGS
);
434 extern int ripng_interface_address_add(ZAPI_CALLBACK_ARGS
);
435 extern int ripng_interface_address_delete(ZAPI_CALLBACK_ARGS
);
436 extern int ripng_interface_vrf_update(ZAPI_CALLBACK_ARGS
);
437 extern void ripng_interface_sync(struct interface
*ifp
);
439 extern struct ripng
*ripng_lookup_by_vrf_id(vrf_id_t vrf_id
);
440 extern struct ripng
*ripng_lookup_by_vrf_name(const char *vrf_name
);
441 extern struct ripng
*ripng_create(const char *vrf_name
, struct vrf
*vrf
,
443 extern int ripng_make_socket(struct vrf
*vrf
);
444 extern int ripng_network_write(struct vty
*vty
, struct ripng
*ripng
);
446 extern struct ripng_info
*ripng_ecmp_add(struct ripng
*ripng
,
447 struct ripng_info
*rinfo
);
448 extern struct ripng_info
*ripng_ecmp_replace(struct ripng
*ripng
,
449 struct ripng_info
*rinfo
);
450 extern struct ripng_info
*ripng_ecmp_delete(struct ripng
*ripng
,
451 struct ripng_info
*rinfo
);
453 extern void ripng_vrf_init(void);
454 extern void ripng_vrf_terminate(void);
455 extern void ripng_cli_init(void);
457 #endif /* _ZEBRA_RIPNG_RIPNGD_H */