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"
47 #define RIPNG_UPDATE_TIMER_DEFAULT 30
48 #define RIPNG_TIMEOUT_TIMER_DEFAULT 180
49 #define RIPNG_GARBAGE_TIMER_DEFAULT 120
51 /* RIPng peer timeout value. */
52 #define RIPNG_PEER_TIMER_DEFAULT 180
54 /* Default config file name. */
55 #define RIPNG_DEFAULT_CONFIG "ripngd.conf"
57 /* RIPng route types. */
58 #define RIPNG_ROUTE_RTE 0
59 #define RIPNG_ROUTE_STATIC 1
60 #define RIPNG_ROUTE_DEFAULT 2
61 #define RIPNG_ROUTE_REDISTRIBUTE 3
62 #define RIPNG_ROUTE_INTERFACE 4
63 #define RIPNG_ROUTE_AGGREGATE 5
65 /* Interface send/receive configuration. */
66 #define RIPNG_SEND_UNSPEC 0
67 #define RIPNG_SEND_OFF 1
68 #define RIPNG_RECEIVE_UNSPEC 0
69 #define RIPNG_RECEIVE_OFF 1
71 /* RIP default route's accept/announce methods. */
72 #define RIPNG_DEFAULT_ADVERTISE_UNSPEC 0
73 #define RIPNG_DEFAULT_ADVERTISE_NONE 1
74 #define RIPNG_DEFAULT_ADVERTISE 2
76 #define RIPNG_DEFAULT_ACCEPT_UNSPEC 0
77 #define RIPNG_DEFAULT_ACCEPT_NONE 1
78 #define RIPNG_DEFAULT_ACCEPT 2
80 /* Default value for "default-metric" command. */
81 #define RIPNG_DEFAULT_METRIC_DEFAULT 1
83 /* For max RTE calculation. */
85 #define IPV6_HDRLEN 40
86 #endif /* IPV6_HDRLEN */
92 /* RIPng structure. */
97 /* RIPng Parameters.*/
100 unsigned long update_time
;
101 unsigned long timeout_time
;
102 unsigned long garbage_time
;
105 int default_information
;
107 /* Input/output buffer of RIPng. */
111 /* RIPng routing information base. */
112 struct route_table
*table
;
114 /* RIPng only static route information. */
115 struct route_table
*route
;
117 /* RIPng aggregate route information. */
118 struct route_table
*aggregate
;
121 struct thread
*t_read
;
122 struct thread
*t_write
;
123 struct thread
*t_update
;
124 struct thread
*t_garbage
;
125 struct thread
*t_zebra
;
127 /* Triggered update hack. */
129 struct thread
*t_triggered_update
;
130 struct thread
*t_triggered_interval
;
132 /* RIPng ECMP flag */
135 /* For redistribute route map. */
138 struct route_map
*map
;
141 } route_map
[ZEBRA_ROUTE_MAX
];
144 /* Routing table entry. */
146 struct in6_addr addr
; /* RIPng destination prefix */
147 uint16_t tag
; /* RIPng tag */
148 uint8_t prefixlen
; /* Length of the RIPng prefix */
149 uint8_t metric
; /* Metric of the RIPng route */
150 /* The nexthop is stored by the structure
151 * ripng_nexthop within ripngd.c */
154 /* RIPNG send packet. */
155 struct ripng_packet
{
162 /* Each route's information. */
164 /* This route's type. Static, ripng or aggregate. */
167 /* Sub type for static route. */
170 /* RIPng specific information */
171 struct in6_addr nexthop
;
172 struct in6_addr from
;
174 /* Which interface does this route come from. */
177 /* Metric of this route. */
180 /* Tag field of RIPng packet.*/
183 /* For aggregation. */
184 unsigned int suppress
;
186 /* Flags of RIPng route. */
187 #define RIPNG_RTF_FIB 1
188 #define RIPNG_RTF_CHANGED 2
191 /* Garbage collect timer. */
192 struct thread
*t_timeout
;
193 struct thread
*t_garbage_collect
;
195 /* Route-map features - this variables can be changed. */
196 struct in6_addr nexthop_out
;
201 struct route_node
*rp
;
206 /* RIPng tag structure. */
215 /* Multicast group. */
216 struct in6_addr maddr
;
225 uint8_t split_horizon
;
227 /* Poison reverse. */
228 uint8_t poison_reverse
;
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 /* RIPng is enabled on this interface. */
243 int enable_interface
;
245 /* RIPng is running on this interface. */
248 /* Split horizon flag. */
249 split_horizon_policy_t split_horizon
;
250 split_horizon_policy_t split_horizon_default
;
252 /* For filter type slot. */
253 #define RIPNG_FILTER_IN 0
254 #define RIPNG_FILTER_OUT 1
255 #define RIPNG_FILTER_MAX 2
258 struct access_list
*list
[RIPNG_FILTER_MAX
];
261 struct prefix_list
*prefix
[RIPNG_FILTER_MAX
];
264 struct route_map
*routemap
[RIPNG_FILTER_MAX
];
268 /* RIPng tag configuration. */
269 struct ripng_tag
*rtag
;
273 /* Default information originate. */
274 uint8_t default_originate
;
276 /* Default information only. */
277 uint8_t default_only
;
279 /* Wake up thread. */
280 struct thread
*t_wakeup
;
282 /* Passive interface. */
286 /* RIPng peer information. */
289 struct in6_addr addr
;
291 /* Peer RIPng tag value. */
294 /* Last update time. */
297 /* Peer RIP version. */
304 /* Timeout thread. */
305 struct thread
*t_timeout
;
308 /* All RIPng events. */
314 RIPNG_TRIGGERED_UPDATE
,
317 /* RIPng timer on/off macro. */
318 #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
320 #define RIPNG_TIMER_OFF(T) \
328 /* Extern variables. */
329 extern struct ripng
*ripng
;
330 extern struct zebra_privs_t ripngd_privs
;
331 extern struct thread_master
*master
;
334 extern void ripng_init(void);
335 extern void ripng_reset(void);
336 extern void ripng_clean(void);
337 extern void ripng_clean_network(void);
338 extern void ripng_interface_clean(void);
339 extern void ripng_interface_reset(void);
340 extern void ripng_passive_interface_clean(void);
341 extern void ripng_if_init(void);
342 extern void ripng_route_map_init(void);
343 extern void ripng_route_map_reset(void);
344 extern void ripng_terminate(void);
345 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
346 extern void zebra_init(struct thread_master
*);
347 extern void ripng_zebra_stop(void);
348 extern void ripng_zclient_reset(void);
349 extern void ripng_offset_init(void);
351 extern int config_write_ripng_offset_list(struct vty
*);
353 extern void ripng_peer_init(void);
354 extern void ripng_peer_update(struct sockaddr_in6
*, uint8_t);
355 extern void ripng_peer_bad_route(struct sockaddr_in6
*);
356 extern void ripng_peer_bad_packet(struct sockaddr_in6
*);
357 extern void ripng_peer_display(struct vty
*);
358 extern struct ripng_peer
*ripng_peer_lookup(struct in6_addr
*);
359 extern struct ripng_peer
*ripng_peer_lookup_next(struct in6_addr
*);
361 extern int ripng_offset_list_apply_in(struct prefix_ipv6
*, struct interface
*,
363 extern int ripng_offset_list_apply_out(struct prefix_ipv6
*, struct interface
*,
365 extern void ripng_offset_clean(void);
367 extern struct ripng_info
*ripng_info_new(void);
368 extern void ripng_info_free(struct ripng_info
*rinfo
);
369 extern void ripng_event(enum ripng_event
, int);
370 extern int ripng_request(struct interface
*ifp
);
371 extern void ripng_redistribute_add(int, int, struct prefix_ipv6
*, ifindex_t
,
372 struct in6_addr
*, route_tag_t
);
373 extern void ripng_redistribute_delete(int, int, struct prefix_ipv6
*,
375 extern void ripng_redistribute_withdraw(int type
);
377 extern void ripng_distribute_update_interface(struct interface
*);
378 extern void ripng_if_rmap_update_interface(struct interface
*);
380 extern void ripng_zebra_ipv6_add(struct route_node
*);
381 extern void ripng_zebra_ipv6_delete(struct route_node
*);
383 extern void ripng_redistribute_clean(void);
384 extern int ripng_redistribute_check(int);
385 extern void ripng_redistribute_write(struct vty
*, int);
387 extern int ripng_write_rte(int num
, struct stream
*s
, struct prefix_ipv6
*p
,
388 struct in6_addr
*nexthop
, uint16_t tag
,
390 extern int ripng_send_packet(caddr_t buf
, int bufsize
, struct sockaddr_in6
*to
,
391 struct interface
*ifp
);
393 extern void ripng_packet_dump(struct ripng_packet
*packet
, int size
,
396 extern int ripng_interface_up(int command
, struct zclient
*, zebra_size_t
,
398 extern int ripng_interface_down(int command
, struct zclient
*, zebra_size_t
,
400 extern int ripng_interface_add(int command
, struct zclient
*, zebra_size_t
,
402 extern int ripng_interface_delete(int command
, struct zclient
*, zebra_size_t
,
404 extern int ripng_interface_address_add(int command
, struct zclient
*,
405 zebra_size_t
, vrf_id_t
);
406 extern int ripng_interface_address_delete(int command
, struct zclient
*,
407 zebra_size_t
, vrf_id_t
);
409 extern int ripng_network_write(struct vty
*, int);
411 extern struct ripng_info
*ripng_ecmp_add(struct ripng_info
*);
412 extern struct ripng_info
*ripng_ecmp_replace(struct ripng_info
*);
413 extern struct ripng_info
*ripng_ecmp_delete(struct ripng_info
*);
415 #endif /* _ZEBRA_RIPNG_RIPNGD_H */