1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * RIPng related value and structure.
4 * Copyright (C) 1998 Kunihiro Ishiguro
7 #ifndef _ZEBRA_RIPNG_RIPNGD_H
8 #define _ZEBRA_RIPNG_RIPNGD_H
12 #include <distribute.h>
16 /* RIPng version and port number. */
18 #define RIPNG_PORT_DEFAULT 521
19 #define RIPNG_VTY_PORT 2603
20 #define RIPNG_MAX_PACKET_SIZE 1500
21 #define RIPNG_PRIORITY_DEFAULT 0
24 #define RIPNG_REQUEST 1
25 #define RIPNG_RESPONSE 2
27 /* RIPng metric and multicast group address. */
28 #define RIPNG_METRIC_INFINITY 16
29 #define RIPNG_METRIC_NEXTHOP 0xff
30 #define RIPNG_GROUP "ff02::9"
32 /* RIPng peer timeout value. */
33 #define RIPNG_PEER_TIMER_DEFAULT 180
35 /* Default config file name. */
36 #define RIPNG_DEFAULT_CONFIG "ripngd.conf"
38 /* RIPng route types. */
39 #define RIPNG_ROUTE_RTE 0
40 #define RIPNG_ROUTE_STATIC 1
41 #define RIPNG_ROUTE_DEFAULT 2
42 #define RIPNG_ROUTE_REDISTRIBUTE 3
43 #define RIPNG_ROUTE_INTERFACE 4
44 #define RIPNG_ROUTE_AGGREGATE 5
46 /* Interface send/receive configuration. */
47 #define RIPNG_SEND_UNSPEC 0
48 #define RIPNG_SEND_OFF 1
49 #define RIPNG_RECEIVE_UNSPEC 0
50 #define RIPNG_RECEIVE_OFF 1
52 /* RIP default route's accept/announce methods. */
53 #define RIPNG_DEFAULT_ADVERTISE_UNSPEC 0
54 #define RIPNG_DEFAULT_ADVERTISE_NONE 1
55 #define RIPNG_DEFAULT_ADVERTISE 2
57 #define RIPNG_DEFAULT_ACCEPT_UNSPEC 0
58 #define RIPNG_DEFAULT_ACCEPT_NONE 1
59 #define RIPNG_DEFAULT_ACCEPT 2
61 /* For max RTE calculation. */
63 #define IPV6_HDRLEN 40
64 #endif /* IPV6_HDRLEN */
71 #define RIPNG_INSTANCE "/frr-ripngd:ripngd/instance"
72 #define RIPNG_IFACE "/frr-interface:lib/interface/frr-ripngd:ripng"
74 DECLARE_MGROUP(RIPNGD
);
76 /* RIPng structure. */
78 RB_ENTRY(ripng
) entry
;
80 /* VRF this routing instance is associated with. */
83 /* VRF backpointer (might be NULL if the VRF doesn't exist). */
86 /* Status of the routing instance. */
92 /* RIPng Parameters.*/
96 uint16_t timeout_time
;
97 uint16_t garbage_time
;
99 uint8_t default_metric
;
101 /* Input/output buffer of RIPng. */
105 /* RIPng routing information base. */
106 struct agg_table
*table
;
108 /* Linked list of RIPng peers. */
109 struct list
*peer_list
;
111 /* RIPng enabled interfaces. */
114 /* RIPng enabled networks. */
115 struct agg_table
*enable_network
;
117 /* Vector to store passive-interface name. */
118 vector passive_interface
;
120 /* RIPng offset-lists. */
121 struct list
*offset_list_master
;
124 struct thread
*t_read
;
125 struct thread
*t_update
;
127 /* Triggered update hack. */
129 struct thread
*t_triggered_update
;
130 struct thread
*t_triggered_interval
;
132 /* RIPng ECMP flag */
135 /* RIPng redistribute configuration. */
140 struct route_map
*map
;
144 } redist
[ZEBRA_ROUTE_MAX
];
146 /* For distribute-list container */
147 struct distribute_ctx
*distribute_ctx
;
149 /* For if_rmap container */
150 struct if_rmap_ctx
*if_rmap_ctx
;
152 RB_HEAD(ripng_instance_head
, ripng
);
153 RB_PROTOTYPE(ripng_instance_head
, ripng
, entry
, ripng_instance_compare
)
155 /* Routing table entry. */
157 struct in6_addr addr
; /* RIPng destination prefix */
158 uint16_t tag
; /* RIPng tag */
159 uint8_t prefixlen
; /* Length of the RIPng prefix */
160 uint8_t metric
; /* Metric of the RIPng route */
161 /* The nexthop is stored by the structure
162 * ripng_nexthop within ripngd.c */
165 /* RIPNG send packet. */
166 struct ripng_packet
{
173 /* Each route's information. */
175 /* This route's type. Static, ripng or aggregate. */
178 /* Sub type for static route. */
181 /* RIPng specific information */
182 struct in6_addr nexthop
;
183 struct in6_addr from
;
185 /* Which interface does this route come from. */
188 /* Metric of this route. */
191 /* Tag field of RIPng packet.*/
194 /* For aggregation. */
195 unsigned int suppress
;
197 /* Flags of RIPng route. */
198 #define RIPNG_RTF_FIB 1
199 #define RIPNG_RTF_CHANGED 2
202 /* Garbage collect timer. */
203 struct thread
*t_timeout
;
204 struct thread
*t_garbage_collect
;
206 /* Route-map features - this variables can be changed. */
207 struct in6_addr nexthop_out
;
216 RIPNG_NO_SPLIT_HORIZON
= 0,
218 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
219 } split_horizon_policy_t
;
221 /* RIPng specific interface configuration. */
222 struct ripng_interface
{
223 /* Parent routing instance. */
226 /* RIPng is enabled on this interface. */
228 int enable_interface
;
230 /* RIPng is running on this interface. */
233 /* Split horizon flag. */
234 split_horizon_policy_t split_horizon
;
236 /* For filter type slot. */
237 #define RIPNG_FILTER_IN 0
238 #define RIPNG_FILTER_OUT 1
239 #define RIPNG_FILTER_MAX 2
242 struct access_list
*list
[RIPNG_FILTER_MAX
];
245 struct prefix_list
*prefix
[RIPNG_FILTER_MAX
];
248 struct route_map
*routemap
[RIPNG_FILTER_MAX
];
250 /* Default information originate. */
251 uint8_t default_originate
;
253 /* Default information only. */
254 uint8_t default_only
;
256 /* Wake up thread. */
257 struct thread
*t_wakeup
;
259 /* Passive interface. */
263 /* RIPng peer information. */
265 /* Parent routing instance. */
269 struct in6_addr addr
;
271 /* Peer RIPng tag value. */
274 /* Last update time. */
277 /* Peer RIP version. */
284 /* Timeout thread. */
285 struct thread
*t_timeout
;
288 /* All RIPng events. */
294 RIPNG_TRIGGERED_UPDATE
,
297 /* RIPng timer on/off macro. */
298 #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
300 #define RIPNG_OFFSET_LIST_IN 0
301 #define RIPNG_OFFSET_LIST_OUT 1
302 #define RIPNG_OFFSET_LIST_MAX 2
304 struct ripng_offset_list
{
305 /* Parent routing instance. */
312 /* struct access_list *alist; */
314 } direct
[RIPNG_OFFSET_LIST_MAX
];
317 /* Extern variables. */
318 extern struct zebra_privs_t ripngd_privs
;
319 extern struct thread_master
*master
;
320 extern struct ripng_instance_head ripng_instances
;
323 extern void ripng_init(void);
324 extern void ripng_clean(struct ripng
*ripng
);
325 extern void ripng_clean_network(struct ripng
*ripng
);
326 extern void ripng_interface_clean(struct ripng
*ripng
);
327 extern int ripng_enable_network_add(struct ripng
*ripng
, struct prefix
*p
);
328 extern int ripng_enable_network_delete(struct ripng
*ripng
, struct prefix
*p
);
329 extern int ripng_enable_if_add(struct ripng
*ripng
, const char *ifname
);
330 extern int ripng_enable_if_delete(struct ripng
*ripng
, const char *ifname
);
331 extern int ripng_passive_interface_set(struct ripng
*ripng
, const char *ifname
);
332 extern int ripng_passive_interface_unset(struct ripng
*ripng
,
334 extern void ripng_passive_interface_clean(struct ripng
*ripng
);
335 extern void ripng_if_init(void);
336 extern void ripng_route_map_init(void);
337 extern void ripng_zebra_vrf_register(struct vrf
*vrf
);
338 extern void ripng_zebra_vrf_deregister(struct vrf
*vrf
);
339 extern void ripng_terminate(void);
340 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
341 extern void zebra_init(struct thread_master
*);
342 extern void ripng_zebra_stop(void);
343 extern void ripng_redistribute_conf_update(struct ripng
*ripng
, int type
);
344 extern void ripng_redistribute_conf_delete(struct ripng
*ripng
, int type
);
346 extern void ripng_peer_update(struct ripng
*ripng
, struct sockaddr_in6
*from
,
348 extern void ripng_peer_bad_route(struct ripng
*ripng
,
349 struct sockaddr_in6
*from
);
350 extern void ripng_peer_bad_packet(struct ripng
*ripng
,
351 struct sockaddr_in6
*from
);
352 extern void ripng_peer_display(struct vty
*vty
, struct ripng
*ripng
);
353 extern struct ripng_peer
*ripng_peer_lookup(struct ripng
*ripng
,
354 struct in6_addr
*addr
);
355 extern struct ripng_peer
*ripng_peer_lookup_next(struct ripng
*ripng
,
356 struct in6_addr
*addr
);
357 extern int ripng_peer_list_cmp(struct ripng_peer
*p1
, struct ripng_peer
*p2
);
358 extern void ripng_peer_list_del(void *arg
);
360 extern struct ripng_offset_list
*ripng_offset_list_new(struct ripng
*ripng
,
362 extern void ripng_offset_list_del(struct ripng_offset_list
*offset
);
363 extern void ripng_offset_list_free(struct ripng_offset_list
*offset
);
364 extern struct ripng_offset_list
*ripng_offset_list_lookup(struct ripng
*ripng
,
366 extern int ripng_offset_list_apply_in(struct ripng
*ripng
,
367 struct prefix_ipv6
*p
,
368 struct interface
*ifp
, uint8_t *metric
);
369 extern int ripng_offset_list_apply_out(struct ripng
*ripng
,
370 struct prefix_ipv6
*p
,
371 struct interface
*ifp
, uint8_t *metric
);
372 extern int offset_list_cmp(struct ripng_offset_list
*o1
,
373 struct ripng_offset_list
*o2
);
375 extern int ripng_route_rte(struct ripng_info
*rinfo
);
376 extern struct ripng_info
*ripng_info_new(void);
377 extern void ripng_info_free(struct ripng_info
*rinfo
);
378 extern struct ripng
*ripng_info_get_instance(const struct ripng_info
*rinfo
);
379 extern void ripng_event(struct ripng
*ripng
, enum ripng_event event
, int sock
);
380 extern int ripng_request(struct interface
*ifp
);
381 extern void ripng_redistribute_add(struct ripng
*ripng
, int type
, int sub_type
,
382 struct prefix_ipv6
*p
, ifindex_t ifindex
,
383 struct in6_addr
*nexthop
, route_tag_t tag
);
384 extern void ripng_redistribute_delete(struct ripng
*ripng
, int type
,
385 int sub_type
, struct prefix_ipv6
*p
,
387 extern void ripng_redistribute_withdraw(struct ripng
*ripng
, int type
);
389 extern void ripng_ecmp_disable(struct ripng
*ripng
);
390 extern void ripng_distribute_update_interface(struct interface
*);
391 extern void ripng_if_rmap_update_interface(struct interface
*);
393 extern void ripng_zebra_ipv6_add(struct ripng
*ripng
, struct agg_node
*node
);
394 extern void ripng_zebra_ipv6_delete(struct ripng
*ripng
, struct agg_node
*node
);
396 extern void ripng_redistribute_enable(struct ripng
*ripng
);
397 extern void ripng_redistribute_disable(struct ripng
*ripng
);
398 extern int ripng_redistribute_check(struct ripng
*ripng
, int type
);
399 extern void ripng_redistribute_write(struct vty
*vty
, struct ripng
*ripng
);
401 extern int ripng_write_rte(int num
, struct stream
*s
, struct prefix_ipv6
*p
,
402 struct in6_addr
*nexthop
, uint16_t tag
,
404 extern int ripng_send_packet(caddr_t buf
, int bufsize
, struct sockaddr_in6
*to
,
405 struct interface
*ifp
);
407 extern void ripng_packet_dump(struct ripng_packet
*packet
, int size
,
410 extern int ripng_interface_up(ZAPI_CALLBACK_ARGS
);
411 extern int ripng_interface_down(ZAPI_CALLBACK_ARGS
);
412 extern int ripng_interface_add(ZAPI_CALLBACK_ARGS
);
413 extern int ripng_interface_delete(ZAPI_CALLBACK_ARGS
);
414 extern int ripng_interface_address_add(ZAPI_CALLBACK_ARGS
);
415 extern int ripng_interface_address_delete(ZAPI_CALLBACK_ARGS
);
416 extern int ripng_interface_vrf_update(ZAPI_CALLBACK_ARGS
);
417 extern void ripng_interface_sync(struct interface
*ifp
);
419 extern struct ripng
*ripng_lookup_by_vrf_id(vrf_id_t vrf_id
);
420 extern struct ripng
*ripng_lookup_by_vrf_name(const char *vrf_name
);
421 extern struct ripng
*ripng_create(const char *vrf_name
, struct vrf
*vrf
,
423 extern int ripng_make_socket(struct vrf
*vrf
);
424 extern int ripng_network_write(struct vty
*vty
, struct ripng
*ripng
);
426 extern struct ripng_info
*ripng_ecmp_add(struct ripng
*ripng
,
427 struct ripng_info
*rinfo
);
428 extern struct ripng_info
*ripng_ecmp_replace(struct ripng
*ripng
,
429 struct ripng_info
*rinfo
);
430 extern struct ripng_info
*ripng_ecmp_delete(struct ripng
*ripng
,
431 struct ripng_info
*rinfo
);
433 extern void ripng_vrf_init(void);
434 extern void ripng_vrf_terminate(void);
435 extern void ripng_cli_init(void);
437 #endif /* _ZEBRA_RIPNG_RIPNGD_H */