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
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 #ifndef _ZEBRA_RIPNG_RIPNGD_H
24 #define _ZEBRA_RIPNG_RIPNGD_H
29 #include "ripng_memory.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"
48 #define RIPNG_UPDATE_TIMER_DEFAULT 30
49 #define RIPNG_TIMEOUT_TIMER_DEFAULT 180
50 #define RIPNG_GARBAGE_TIMER_DEFAULT 120
52 /* RIPng peer timeout value. */
53 #define RIPNG_PEER_TIMER_DEFAULT 180
55 /* Default config file name. */
56 #define RIPNG_DEFAULT_CONFIG "ripngd.conf"
58 /* RIPng route types. */
59 #define RIPNG_ROUTE_RTE 0
60 #define RIPNG_ROUTE_STATIC 1
61 #define RIPNG_ROUTE_DEFAULT 2
62 #define RIPNG_ROUTE_REDISTRIBUTE 3
63 #define RIPNG_ROUTE_INTERFACE 4
64 #define RIPNG_ROUTE_AGGREGATE 5
66 /* Interface send/receive configuration. */
67 #define RIPNG_SEND_UNSPEC 0
68 #define RIPNG_SEND_OFF 1
69 #define RIPNG_RECEIVE_UNSPEC 0
70 #define RIPNG_RECEIVE_OFF 1
72 /* RIP default route's accept/announce methods. */
73 #define RIPNG_DEFAULT_ADVERTISE_UNSPEC 0
74 #define RIPNG_DEFAULT_ADVERTISE_NONE 1
75 #define RIPNG_DEFAULT_ADVERTISE 2
77 #define RIPNG_DEFAULT_ACCEPT_UNSPEC 0
78 #define RIPNG_DEFAULT_ACCEPT_NONE 1
79 #define RIPNG_DEFAULT_ACCEPT 2
81 /* Default value for "default-metric" command. */
82 #define RIPNG_DEFAULT_METRIC_DEFAULT 1
84 /* For max RTE calculation. */
86 #define IPV6_HDRLEN 40
87 #endif /* IPV6_HDRLEN */
93 /* RIPng structure. */
99 /* RIPng Parameters.*/
102 unsigned long update_time
;
103 unsigned long timeout_time
;
104 unsigned long garbage_time
;
107 int default_information
;
109 /* Input/output buffer of RIPng. */
113 /* RIPng routing information base. */
114 struct route_table
*table
;
116 /* RIPng only static route information. */
117 struct route_table
*route
;
119 /* RIPng aggregate route information. */
120 struct route_table
*aggregate
;
123 struct thread
*t_read
;
124 struct thread
*t_write
;
125 struct thread
*t_update
;
126 struct thread
*t_garbage
;
127 struct thread
*t_zebra
;
129 /* Triggered update hack. */
131 struct thread
*t_triggered_update
;
132 struct thread
*t_triggered_interval
;
134 /* RIPng ECMP flag */
137 /* For redistribute route map. */
141 struct route_map
*map
;
144 } route_map
[ZEBRA_ROUTE_MAX
];
147 /* Routing table entry. */
150 struct in6_addr addr
; /* RIPng destination prefix */
151 u_int16_t tag
; /* RIPng tag */
152 u_char prefixlen
; /* Length of the RIPng prefix */
153 u_char metric
; /* Metric of the RIPng route */
154 /* The nexthop is stored by the structure
155 * ripng_nexthop within ripngd.c */
158 /* RIPNG send packet. */
167 /* 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
;
207 struct route_node
*rp
;
212 /* RIPng tag structure. */
221 /* Multicast group. */
222 struct in6_addr maddr
;
231 u_char split_horizon
;
233 /* Poison reverse. */
234 u_char 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
248 /* RIPng is enabled on this interface. */
250 int enable_interface
;
252 /* RIPng is running on this interface. */
255 /* Split horizon flag. */
256 split_horizon_policy_t split_horizon
;
257 split_horizon_policy_t split_horizon_default
;
259 /* For filter type slot. */
260 #define RIPNG_FILTER_IN 0
261 #define RIPNG_FILTER_OUT 1
262 #define RIPNG_FILTER_MAX 2
265 struct access_list
*list
[RIPNG_FILTER_MAX
];
268 struct prefix_list
*prefix
[RIPNG_FILTER_MAX
];
271 struct route_map
*routemap
[RIPNG_FILTER_MAX
];
275 /* RIPng tag configuration. */
276 struct ripng_tag
*rtag
;
280 /* Default information originate. */
281 u_char default_originate
;
283 /* Default information only. */
286 /* Wake up thread. */
287 struct thread
*t_wakeup
;
289 /* Passive interface. */
293 /* RIPng peer information. */
297 struct in6_addr addr
;
299 /* Peer RIPng tag value. */
302 /* Last update time. */
305 /* Peer RIP version. */
312 /* Timeout thread. */
313 struct thread
*t_timeout
;
316 /* All RIPng events. */
323 RIPNG_TRIGGERED_UPDATE
,
326 /* RIPng timer on/off macro. */
327 #define RIPNG_TIMER_ON(T,F,V) \
330 (T) = thread_add_timer (master, (F), rinfo, (V)); \
333 #define RIPNG_TIMER_OFF(T) \
342 /* Extern variables. */
343 extern struct ripng
*ripng
;
345 extern struct thread_master
*master
;
348 extern void ripng_init (void);
349 extern void ripng_reset (void);
350 extern void ripng_clean (void);
351 extern void ripng_clean_network (void);
352 extern void ripng_interface_clean (void);
353 extern void ripng_interface_reset (void);
354 extern void ripng_passive_interface_clean (void);
355 extern void ripng_if_init (void);
356 extern void ripng_route_map_init (void);
357 extern void ripng_route_map_reset (void);
358 extern void ripng_terminate (void);
359 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
360 extern void zebra_init(struct thread_master
*);
361 extern void ripng_zclient_reset (void);
362 extern void ripng_offset_init (void);
364 extern int config_write_ripng_offset_list (struct vty
*);
366 extern void ripng_peer_init (void);
367 extern void ripng_peer_update (struct sockaddr_in6
*, u_char
);
368 extern void ripng_peer_bad_route (struct sockaddr_in6
*);
369 extern void ripng_peer_bad_packet (struct sockaddr_in6
*);
370 extern void ripng_peer_display (struct vty
*);
371 extern struct ripng_peer
*ripng_peer_lookup (struct in6_addr
*);
372 extern struct ripng_peer
*ripng_peer_lookup_next (struct in6_addr
*);
374 extern int ripng_offset_list_apply_in (struct prefix_ipv6
*,
375 struct interface
*, u_char
*);
376 extern int ripng_offset_list_apply_out (struct prefix_ipv6
*,
377 struct interface
*, u_char
*);
378 extern void ripng_offset_clean (void);
380 extern struct ripng_info
* ripng_info_new (void);
381 extern void ripng_info_free (struct ripng_info
*rinfo
);
382 extern void ripng_event (enum ripng_event
, int);
383 extern int ripng_request (struct interface
*ifp
);
384 extern void ripng_redistribute_add (int, int, struct prefix_ipv6
*,
385 ifindex_t
, struct in6_addr
*, route_tag_t
);
386 extern void ripng_redistribute_delete (int, int, struct prefix_ipv6
*,
388 extern void ripng_redistribute_withdraw (int type
);
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 route_node
*);
394 extern void ripng_zebra_ipv6_delete (struct route_node
*);
396 extern void ripng_redistribute_clean (void);
397 extern int ripng_redistribute_check (int);
398 extern void ripng_redistribute_write (struct vty
*, int);
400 extern int ripng_write_rte (int num
, struct stream
*s
, struct prefix_ipv6
*p
,
401 struct in6_addr
*nexthop
,
402 u_int16_t tag
, u_char metric
);
403 extern int ripng_send_packet (caddr_t buf
, int bufsize
,
404 struct sockaddr_in6
*to
, struct interface
*ifp
);
406 extern void ripng_packet_dump (struct ripng_packet
*packet
, int size
,
409 extern int ripng_interface_up (int command
, struct zclient
*, zebra_size_t
,
411 extern int ripng_interface_down (int command
, struct zclient
*, zebra_size_t
,
413 extern int ripng_interface_add (int command
, struct zclient
*, zebra_size_t
,
415 extern int ripng_interface_delete (int command
, struct zclient
*, zebra_size_t
,
417 extern int ripng_interface_address_add (int command
, struct zclient
*, zebra_size_t
,
419 extern int ripng_interface_address_delete (int command
, struct zclient
*, zebra_size_t
,
422 extern int ripng_network_write (struct vty
*, int);
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
*);
428 #endif /* _ZEBRA_RIPNG_RIPNGD_H */