[lib] add mising UL qualifier to numerical constant
[jleu-quagga.git] / ripngd / ripngd.h
blobb478e9bc3604e9665c596cdcb0af69753024313c
1 /*
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
10 * later version.
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
20 * 02111-1307, USA.
23 #ifndef _ZEBRA_RIPNG_RIPNGD_H
24 #define _ZEBRA_RIPNG_RIPNGD_H
26 /* RIPng version and port number. */
27 #define RIPNG_V1 1
28 #define RIPNG_PORT_DEFAULT 521
29 #define RIPNG_VTY_PORT 2603
30 #define RIPNG_MAX_PACKET_SIZE 1500
31 #define RIPNG_PRIORITY_DEFAULT 0
33 /* RIPng commands. */
34 #define RIPNG_REQUEST 1
35 #define RIPNG_RESPONSE 2
37 /* RIPng metric and multicast group address. */
38 #define RIPNG_METRIC_INFINITY 16
39 #define RIPNG_METRIC_NEXTHOP 0xff
40 #define RIPNG_GROUP "ff02::9"
42 /* RIPng timers. */
43 #define RIPNG_UPDATE_TIMER_DEFAULT 30
44 #define RIPNG_TIMEOUT_TIMER_DEFAULT 180
45 #define RIPNG_GARBAGE_TIMER_DEFAULT 120
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 /* Default value for "default-metric" command. */
77 #define RIPNG_DEFAULT_METRIC_DEFAULT 1
79 /* For max RTE calculation. */
80 #ifndef IPV6_HDRLEN
81 #define IPV6_HDRLEN 40
82 #endif /* IPV6_HDRLEN */
84 #ifndef IFMINMTU
85 #define IFMINMTU 576
86 #endif /* IFMINMTU */
88 /* RIPng structure. */
89 struct ripng
91 /* RIPng socket. */
92 int sock;
94 /* RIPng Parameters.*/
95 u_char command;
96 u_char version;
97 unsigned long update_time;
98 unsigned long timeout_time;
99 unsigned long garbage_time;
100 int max_mtu;
101 int default_metric;
102 int default_information;
104 /* Input/output buffer of RIPng. */
105 struct stream *ibuf;
106 struct stream *obuf;
108 /* RIPng routing information base. */
109 struct route_table *table;
111 /* RIPng only static route information. */
112 struct route_table *route;
114 /* RIPng aggregate route information. */
115 struct route_table *aggregate;
117 /* RIPng threads. */
118 struct thread *t_read;
119 struct thread *t_write;
120 struct thread *t_update;
121 struct thread *t_garbage;
122 struct thread *t_zebra;
124 /* Triggered update hack. */
125 int trigger;
126 struct thread *t_triggered_update;
127 struct thread *t_triggered_interval;
129 /* For redistribute route map. */
130 struct
132 char *name;
133 struct route_map *map;
134 int metric_config;
135 u_int32_t metric;
136 } route_map[ZEBRA_ROUTE_MAX];
139 /* Routing table entry. */
140 struct rte
142 struct in6_addr addr; /* RIPng destination prefix */
143 u_short tag; /* RIPng tag */
144 u_char prefixlen; /* Length of the RIPng prefix */
145 u_char metric; /* Metric of the RIPng route */
146 /* The nexthop is stored by the structure
147 * ripng_nexthop within ripngd.c */
150 /* RIPNG send packet. */
151 struct ripng_packet
153 u_char command;
154 u_char version;
155 u_int16_t zero;
156 struct rte rte[1];
159 /* Each route's information. */
160 struct ripng_info
162 /* This route's type. Static, ripng or aggregate. */
163 u_char type;
165 /* Sub type for static route. */
166 u_char sub_type;
168 /* RIPng specific information */
169 struct in6_addr nexthop;
170 struct in6_addr from;
172 /* Which interface does this route come from. */
173 unsigned int ifindex;
175 /* Metric of this route. */
176 u_char metric;
178 /* Tag field of RIPng packet.*/
179 u_int16_t tag;
181 /* For aggregation. */
182 unsigned int suppress;
184 /* Flags of RIPng route. */
185 #define RIPNG_RTF_FIB 1
186 #define RIPNG_RTF_CHANGED 2
187 u_char flags;
189 /* Garbage collect timer. */
190 struct thread *t_timeout;
191 struct thread *t_garbage_collect;
193 /* Route-map features - this variables can be changed. */
194 struct in6_addr nexthop_out;
195 u_char metric_set;
196 u_char metric_out;
197 u_short tag_out;
199 struct route_node *rp;
202 #ifdef notyet
203 #if 0
204 /* RIPng tag structure. */
205 struct ripng_tag
207 /* Tag value. */
208 u_int16_t tag;
210 /* Port. */
211 u_int16_t port;
213 /* Multicast group. */
214 struct in6_addr maddr;
216 /* Table number. */
217 int table;
219 /* Distance. */
220 int distance;
222 /* Split horizon. */
223 u_char split_horizon;
225 /* Poison reverse. */
226 u_char poison_reverse;
228 #endif /* 0 */
229 #endif /* not yet */
231 typedef enum {
232 RIPNG_NO_SPLIT_HORIZON = 0,
233 RIPNG_SPLIT_HORIZON,
234 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
235 } split_horizon_policy_t;
237 /* RIPng specific interface configuration. */
238 struct ripng_interface
240 /* RIPng is enabled on this interface. */
241 int enable_network;
242 int enable_interface;
244 /* RIPng is running on this interface. */
245 int running;
247 /* Split horizon flag. */
248 split_horizon_policy_t split_horizon;
249 split_horizon_policy_t split_horizon_default;
251 /* For filter type slot. */
252 #define RIPNG_FILTER_IN 0
253 #define RIPNG_FILTER_OUT 1
254 #define RIPNG_FILTER_MAX 2
256 /* Access-list. */
257 struct access_list *list[RIPNG_FILTER_MAX];
259 /* Prefix-list. */
260 struct prefix_list *prefix[RIPNG_FILTER_MAX];
262 /* Route-map. */
263 struct route_map *routemap[RIPNG_FILTER_MAX];
265 #ifdef notyet
266 #if 0
267 /* RIPng tag configuration. */
268 struct ripng_tag *rtag;
269 #endif /* 0 */
270 #endif /* notyet */
272 /* Default information originate. */
273 u_char default_originate;
275 /* Default information only. */
276 u_char default_only;
278 /* Wake up thread. */
279 struct thread *t_wakeup;
281 /* Passive interface. */
282 int passive;
285 /* RIPng peer information. */
286 struct ripng_peer
288 /* Peer address. */
289 struct in6_addr addr;
291 /* Peer RIPng tag value. */
292 int domain;
294 /* Last update time. */
295 time_t uptime;
297 /* Peer RIP version. */
298 u_char version;
300 /* Statistics. */
301 int recv_badpackets;
302 int recv_badroutes;
304 /* Timeout thread. */
305 struct thread *t_timeout;
308 /* All RIPng events. */
309 enum ripng_event
311 RIPNG_READ,
312 RIPNG_ZEBRA,
313 RIPNG_REQUEST_EVENT,
314 RIPNG_UPDATE_EVENT,
315 RIPNG_TRIGGERED_UPDATE,
318 /* RIPng timer on/off macro. */
319 #define RIPNG_TIMER_ON(T,F,V) \
320 do { \
321 if (!(T)) \
322 (T) = thread_add_timer (master, (F), rinfo, (V)); \
323 } while (0)
325 #define RIPNG_TIMER_OFF(T) \
326 do { \
327 if (T) \
329 thread_cancel(T); \
330 (T) = NULL; \
332 } while (0)
334 /* Count prefix size from mask length */
335 #define PSIZE(a) (((a) + 7) / (8))
337 /* Extern variables. */
338 extern struct ripng *ripng;
340 extern struct thread_master *master;
342 /* Prototypes. */
343 void ripng_init ();
344 void ripng_reset ();
345 void ripng_clean ();
346 void ripng_clean_network ();
347 void ripng_interface_clean ();
348 void ripng_interface_reset ();
349 void ripng_passive_interface_clean ();
350 void ripng_if_init ();
351 void ripng_route_map_init ();
352 void ripng_route_map_reset ();
353 void ripng_terminate ();
354 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
355 void zebra_init ();
356 void ripng_zclient_start ();
357 void ripng_zclient_reset ();
358 void ripng_offset_init ();
360 int config_write_ripng_offset_list (struct vty *);
362 void ripng_peer_init ();
363 void ripng_peer_update (struct sockaddr_in6 *, u_char);
364 void ripng_peer_bad_route (struct sockaddr_in6 *);
365 void ripng_peer_bad_packet (struct sockaddr_in6 *);
366 void ripng_peer_display (struct vty *);
367 struct ripng_peer *ripng_peer_lookup (struct in6_addr *);
368 struct ripng_peer *ripng_peer_lookup_next (struct in6_addr *);
370 int ripng_offset_list_apply_in (struct prefix_ipv6 *, struct interface *, u_char *);
371 int ripng_offset_list_apply_out (struct prefix_ipv6 *, struct interface *, u_char *);
372 void ripng_offset_clean ();
374 struct ripng_info * ripng_info_new ();
375 void ripng_info_free (struct ripng_info *rinfo);
376 void ripng_event (enum ripng_event, int);
377 int ripng_request (struct interface *ifp);
378 void ripng_redistribute_add (int, int, struct prefix_ipv6 *, unsigned int,
379 struct in6_addr *);
380 void ripng_redistribute_delete (int, int, struct prefix_ipv6 *, unsigned int);
381 void ripng_redistribute_withdraw (int type);
383 void ripng_distribute_update_interface (struct interface *);
384 void ripng_if_rmap_update_interface (struct interface *);
386 void ripng_zebra_ipv6_add (struct prefix_ipv6 *p, struct in6_addr *nexthop, unsigned int ifindex, u_char metric);
387 void ripng_zebra_ipv6_delete (struct prefix_ipv6 *p, struct in6_addr *nexthop, unsigned int ifindex);
389 void ripng_redistribute_clean ();
391 int ripng_write_rte (int num, struct stream *s, struct prefix_ipv6 *p,
392 struct in6_addr *nexthop, u_int16_t tag, u_char metric);
393 int ripng_send_packet (caddr_t buf, int bufsize, struct sockaddr_in6 *to,
394 struct interface *ifp);
396 void ripng_packet_dump (struct ripng_packet *packet, int size, const char *sndrcv);
399 #endif /* _ZEBRA_RIPNG_RIPNGD_H */