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. */
95 /* RIPng Parameters.*/
99 uint16_t timeout_time
;
100 uint16_t garbage_time
;
102 uint8_t default_metric
;
104 /* Input/output buffer of RIPng. */
108 /* RIPng routing information base. */
109 struct agg_table
*table
;
111 /* Linked list of RIPng peers. */
112 struct list
*peer_list
;
114 /* RIPng enabled interfaces. */
117 /* RIPng enabled networks. */
118 struct agg_table
*enable_network
;
120 /* Vector to store passive-interface name. */
121 vector passive_interface
;
124 struct thread
*t_read
;
125 struct thread
*t_write
;
126 struct thread
*t_update
;
127 struct thread
*t_garbage
;
128 struct thread
*t_zebra
;
130 /* Triggered update hack. */
132 struct thread
*t_triggered_update
;
133 struct thread
*t_triggered_interval
;
135 /* RIPng ECMP flag */
138 /* For redistribute route map. */
141 struct route_map
*map
;
144 } route_map
[ZEBRA_ROUTE_MAX
];
146 /* For distribute-list container */
147 struct distribute_ctx
*distribute_ctx
;
150 /* Routing table entry. */
152 struct in6_addr addr
; /* RIPng destination prefix */
153 uint16_t tag
; /* RIPng tag */
154 uint8_t prefixlen
; /* Length of the RIPng prefix */
155 uint8_t metric
; /* Metric of the RIPng route */
156 /* The nexthop is stored by the structure
157 * ripng_nexthop within ripngd.c */
160 /* RIPNG send packet. */
161 struct ripng_packet
{
168 /* Each route's information. */
170 /* This route's type. Static, ripng or aggregate. */
173 /* Sub type for static route. */
176 /* RIPng specific information */
177 struct in6_addr nexthop
;
178 struct in6_addr from
;
180 /* Which interface does this route come from. */
183 /* Metric of this route. */
186 /* Tag field of RIPng packet.*/
189 /* For aggregation. */
190 unsigned int suppress
;
192 /* Flags of RIPng route. */
193 #define RIPNG_RTF_FIB 1
194 #define RIPNG_RTF_CHANGED 2
197 /* Garbage collect timer. */
198 struct thread
*t_timeout
;
199 struct thread
*t_garbage_collect
;
201 /* Route-map features - this variables can be changed. */
202 struct in6_addr nexthop_out
;
212 /* RIPng tag structure. */
221 /* Multicast group. */
222 struct in6_addr maddr
;
231 uint8_t split_horizon
;
233 /* Poison reverse. */
234 uint8_t poison_reverse
;
240 RIPNG_NO_SPLIT_HORIZON
= 0,
242 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
243 } split_horizon_policy_t
;
245 /* RIPng specific interface configuration. */
246 struct ripng_interface
{
247 /* RIPng is enabled on this interface. */
249 int enable_interface
;
251 /* RIPng is running on this interface. */
254 /* Split horizon flag. */
255 split_horizon_policy_t split_horizon
;
257 /* For filter type slot. */
258 #define RIPNG_FILTER_IN 0
259 #define RIPNG_FILTER_OUT 1
260 #define RIPNG_FILTER_MAX 2
263 struct access_list
*list
[RIPNG_FILTER_MAX
];
266 struct prefix_list
*prefix
[RIPNG_FILTER_MAX
];
269 struct route_map
*routemap
[RIPNG_FILTER_MAX
];
273 /* RIPng tag configuration. */
274 struct ripng_tag
*rtag
;
278 /* Default information originate. */
279 uint8_t default_originate
;
281 /* Default information only. */
282 uint8_t default_only
;
284 /* Wake up thread. */
285 struct thread
*t_wakeup
;
287 /* Passive interface. */
291 /* RIPng peer information. */
294 struct in6_addr addr
;
296 /* Peer RIPng tag value. */
299 /* Last update time. */
302 /* Peer RIP version. */
309 /* Timeout thread. */
310 struct thread
*t_timeout
;
313 /* All RIPng events. */
319 RIPNG_TRIGGERED_UPDATE
,
322 /* RIPng timer on/off macro. */
323 #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
325 #define RIPNG_TIMER_OFF(T) \
333 #define RIPNG_OFFSET_LIST_IN 0
334 #define RIPNG_OFFSET_LIST_OUT 1
335 #define RIPNG_OFFSET_LIST_MAX 2
337 struct ripng_offset_list
{
342 /* struct access_list *alist; */
344 } direct
[RIPNG_OFFSET_LIST_MAX
];
347 /* Extern variables. */
348 extern struct ripng
*ripng
;
349 extern struct zebra_privs_t ripngd_privs
;
350 extern struct thread_master
*master
;
353 extern void ripng_init(void);
354 extern void ripng_clean(void);
355 extern void ripng_clean_network(void);
356 extern void ripng_interface_clean(void);
357 extern int ripng_enable_network_add(struct prefix
*p
);
358 extern int ripng_enable_network_delete(struct prefix
*p
);
359 extern int ripng_enable_if_add(const char *ifname
);
360 extern int ripng_enable_if_delete(const char *ifname
);
361 extern int ripng_passive_interface_set(const char *ifname
);
362 extern int ripng_passive_interface_unset(const char *ifname
);
363 extern void ripng_passive_interface_clean(void);
364 extern void ripng_if_init(void);
365 extern void ripng_route_map_init(void);
366 extern void ripng_terminate(void);
367 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
368 extern void zebra_init(struct thread_master
*);
369 extern void ripng_zebra_stop(void);
370 extern void ripng_redistribute_conf_update(int type
);
371 extern void ripng_redistribute_conf_delete(int type
);
373 extern void ripng_peer_update(struct sockaddr_in6
*, uint8_t);
374 extern void ripng_peer_bad_route(struct sockaddr_in6
*);
375 extern void ripng_peer_bad_packet(struct sockaddr_in6
*);
376 extern void ripng_peer_display(struct vty
*);
377 extern struct ripng_peer
*ripng_peer_lookup(struct in6_addr
*);
378 extern struct ripng_peer
*ripng_peer_lookup_next(struct in6_addr
*);
379 extern int ripng_peer_list_cmp(struct ripng_peer
*p1
, struct ripng_peer
*p2
);
381 extern struct ripng_offset_list
*ripng_offset_list_new(const char *ifname
);
382 extern void ripng_offset_list_del(struct ripng_offset_list
*offset
);
383 extern struct ripng_offset_list
*ripng_offset_list_lookup(const char *ifname
);
384 extern struct ripng_offset_list
*ripng_offset_list_lookup(const char *ifname
);
385 extern int ripng_offset_list_apply_in(struct prefix_ipv6
*, struct interface
*,
387 extern int ripng_offset_list_apply_out(struct prefix_ipv6
*, struct interface
*,
389 extern void ripng_offset_init(void);
390 extern void ripng_offset_clean(void);
392 extern int ripng_route_rte(struct ripng_info
*rinfo
);
393 extern struct ripng_info
*ripng_info_new(void);
394 extern void ripng_info_free(struct ripng_info
*rinfo
);
395 extern void ripng_event(enum ripng_event
, int);
396 extern int ripng_request(struct interface
*ifp
);
397 extern void ripng_redistribute_add(int, int, struct prefix_ipv6
*, ifindex_t
,
398 struct in6_addr
*, route_tag_t
);
399 extern void ripng_redistribute_delete(int, int, struct prefix_ipv6
*,
401 extern void ripng_redistribute_withdraw(int type
);
403 extern void ripng_ecmp_disable(void);
404 extern void ripng_distribute_update_interface(struct interface
*);
405 extern void ripng_if_rmap_update_interface(struct interface
*);
407 extern void ripng_zebra_ipv6_add(struct agg_node
*node
);
408 extern void ripng_zebra_ipv6_delete(struct agg_node
*node
);
410 extern void ripng_redistribute_clean(void);
411 extern int ripng_redistribute_check(int);
412 extern void ripng_redistribute_write(struct vty
*);
414 extern int ripng_write_rte(int num
, struct stream
*s
, struct prefix_ipv6
*p
,
415 struct in6_addr
*nexthop
, uint16_t tag
,
417 extern int ripng_send_packet(caddr_t buf
, int bufsize
, struct sockaddr_in6
*to
,
418 struct interface
*ifp
);
420 extern void ripng_packet_dump(struct ripng_packet
*packet
, int size
,
423 extern int ripng_interface_up(int command
, struct zclient
*, zebra_size_t
,
425 extern int ripng_interface_down(int command
, struct zclient
*, zebra_size_t
,
427 extern int ripng_interface_add(int command
, struct zclient
*, zebra_size_t
,
429 extern int ripng_interface_delete(int command
, struct zclient
*, zebra_size_t
,
431 extern int ripng_interface_address_add(int command
, struct zclient
*,
432 zebra_size_t
, vrf_id_t
);
433 extern int ripng_interface_address_delete(int command
, struct zclient
*,
434 zebra_size_t
, vrf_id_t
);
436 extern int ripng_create(int socket
);
437 extern int ripng_make_socket(void);
438 extern int ripng_network_write(struct vty
*);
440 extern struct ripng_info
*ripng_ecmp_add(struct ripng_info
*);
441 extern struct ripng_info
*ripng_ecmp_replace(struct ripng_info
*);
442 extern struct ripng_info
*ripng_ecmp_delete(struct ripng_info
*);
445 extern void ripng_cli_init(void);
446 extern const struct frr_yang_module_info frr_ripngd_info
;
448 #endif /* _ZEBRA_RIPNG_RIPNGD_H */