]> git.proxmox.com Git - mirror_frr.git/blame - ripngd/ripngd.h
* lib/prefix.[hc]: inet6_ntoa utility function copied from
[mirror_frr.git] / ripngd / ripngd.h
CommitLineData
718e3744 1/*
2 * RIPng related value and structure.
3 * Copyright (C) 1998 Kunihiro Ishiguro
4 *
5 * This file is part of GNU Zebra.
6 *
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.
11 *
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.
16 *
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.
21 */
22
23#ifndef _ZEBRA_RIPNG_RIPNGD_H
24#define _ZEBRA_RIPNG_RIPNGD_H
25
26/* RIPng version and port number. */
27#define RIPNG_V1 1
28#define RIPNG_PORT_DEFAULT 521
29#define RIPNG_VTY_PORT 2603
718e3744 30#define RIPNG_MAX_PACKET_SIZE 1500
31#define RIPNG_PRIORITY_DEFAULT 0
32
33/* RIPng commands. */
34#define RIPNG_REQUEST 1
35#define RIPNG_RESPONSE 2
36
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"
41
42/* RIPng timers. */
43#define RIPNG_UPDATE_TIMER_DEFAULT 30
44#define RIPNG_TIMEOUT_TIMER_DEFAULT 180
45#define RIPNG_GARBAGE_TIMER_DEFAULT 120
46
a94434b6 47/* RIPng peer timeout value. */
48#define RIPNG_PEER_TIMER_DEFAULT 180
49
718e3744 50/* Default config file name. */
51#define RIPNG_DEFAULT_CONFIG "ripngd.conf"
52
53/* RIPng route types. */
54#define RIPNG_ROUTE_RTE 0
55#define RIPNG_ROUTE_STATIC 1
a94434b6 56#define RIPNG_ROUTE_DEFAULT 2
57#define RIPNG_ROUTE_REDISTRIBUTE 3
58#define RIPNG_ROUTE_INTERFACE 4
59#define RIPNG_ROUTE_AGGREGATE 5
718e3744 60
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
66
718e3744 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
71
72#define RIPNG_DEFAULT_ACCEPT_UNSPEC 0
73#define RIPNG_DEFAULT_ACCEPT_NONE 1
74#define RIPNG_DEFAULT_ACCEPT 2
75
76/* Default value for "default-metric" command. */
77#define RIPNG_DEFAULT_METRIC_DEFAULT 1
78
79/* For max RTE calculation. */
80#ifndef IPV6_HDRLEN
81#define IPV6_HDRLEN 40
82#endif /* IPV6_HDRLEN */
83
84#ifndef IFMINMTU
85#define IFMINMTU 576
86#endif /* IFMINMTU */
87
88/* RIPng structure. */
89struct ripng
90{
91 /* RIPng socket. */
92 int sock;
93
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;
103
104 /* Input/output buffer of RIPng. */
105 struct stream *ibuf;
106 struct stream *obuf;
107
108 /* RIPng routing information base. */
109 struct route_table *table;
110
111 /* RIPng only static route information. */
112 struct route_table *route;
113
114 /* RIPng aggregate route information. */
115 struct route_table *aggregate;
116
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;
123
124 /* Triggered update hack. */
125 int trigger;
126 struct thread *t_triggered_update;
127 struct thread *t_triggered_interval;
128
129 /* For redistribute route map. */
130 struct
131 {
132 char *name;
133 struct route_map *map;
134 int metric_config;
135 u_int32_t metric;
136 } route_map[ZEBRA_ROUTE_MAX];
137};
138
139/* Routing table entry. */
140struct rte
141{
a94434b6 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 */
718e3744 148};
149
150/* RIPNG send packet. */
151struct ripng_packet
152{
153 u_char command;
154 u_char version;
155 u_int16_t zero;
156 struct rte rte[1];
157};
158
159/* Each route's information. */
160struct ripng_info
161{
162 /* This route's type. Static, ripng or aggregate. */
163 u_char type;
164
165 /* Sub type for static route. */
166 u_char sub_type;
167
168 /* RIPng specific information */
169 struct in6_addr nexthop;
170 struct in6_addr from;
171
172 /* Which interface does this route come from. */
173 unsigned int ifindex;
174
175 /* Metric of this route. */
176 u_char metric;
177
178 /* Tag field of RIPng packet.*/
179 u_int16_t tag;
180
181 /* For aggregation. */
182 unsigned int suppress;
183
184 /* Flags of RIPng route. */
185#define RIPNG_RTF_FIB 1
186#define RIPNG_RTF_CHANGED 2
187 u_char flags;
188
189 /* Garbage collect timer. */
190 struct thread *t_timeout;
191 struct thread *t_garbage_collect;
192
193 /* Route-map features - this variables can be changed. */
a94434b6 194 struct in6_addr nexthop_out;
718e3744 195 u_char metric_set;
a94434b6 196 u_char metric_out;
197 u_short tag_out;
718e3744 198
199 struct route_node *rp;
200};
201
a94434b6 202#ifdef notyet
203#if 0
718e3744 204/* RIPng tag structure. */
205struct ripng_tag
206{
207 /* Tag value. */
208 u_int16_t tag;
209
210 /* Port. */
211 u_int16_t port;
212
213 /* Multicast group. */
214 struct in6_addr maddr;
215
216 /* Table number. */
217 int table;
218
219 /* Distance. */
220 int distance;
221
222 /* Split horizon. */
223 u_char split_horizon;
224
225 /* Poison reverse. */
226 u_char poison_reverse;
227};
a94434b6 228#endif /* 0 */
229#endif /* not yet */
230
231typedef enum {
232 RIPNG_NO_SPLIT_HORIZON = 0,
233 RIPNG_SPLIT_HORIZON,
234 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
235} split_horizon_policy_t;
718e3744 236
237/* RIPng specific interface configuration. */
238struct ripng_interface
239{
240 /* RIPng is enabled on this interface. */
241 int enable_network;
242 int enable_interface;
243
244 /* RIPng is running on this interface. */
245 int running;
246
a94434b6 247 /* Split horizon flag. */
248 split_horizon_policy_t split_horizon;
249 split_horizon_policy_t split_horizon_default;
250
718e3744 251 /* For filter type slot. */
252#define RIPNG_FILTER_IN 0
253#define RIPNG_FILTER_OUT 1
254#define RIPNG_FILTER_MAX 2
255
256 /* Access-list. */
257 struct access_list *list[RIPNG_FILTER_MAX];
258
259 /* Prefix-list. */
260 struct prefix_list *prefix[RIPNG_FILTER_MAX];
261
262 /* Route-map. */
263 struct route_map *routemap[RIPNG_FILTER_MAX];
264
a94434b6 265#ifdef notyet
266#if 0
718e3744 267 /* RIPng tag configuration. */
268 struct ripng_tag *rtag;
a94434b6 269#endif /* 0 */
270#endif /* notyet */
718e3744 271
272 /* Default information originate. */
273 u_char default_originate;
274
275 /* Default information only. */
276 u_char default_only;
277
278 /* Wake up thread. */
279 struct thread *t_wakeup;
280
281 /* Passive interface. */
282 int passive;
283};
284
a94434b6 285/* RIPng peer information. */
286struct ripng_peer
287{
288 /* Peer address. */
289 struct in6_addr addr;
290
291 /* Peer RIPng tag value. */
292 int domain;
293
294 /* Last update time. */
295 time_t uptime;
296
297 /* Peer RIP version. */
298 u_char version;
299
300 /* Statistics. */
301 int recv_badpackets;
302 int recv_badroutes;
303
304 /* Timeout thread. */
305 struct thread *t_timeout;
306};
307
718e3744 308/* All RIPng events. */
309enum ripng_event
310{
311 RIPNG_READ,
312 RIPNG_ZEBRA,
313 RIPNG_REQUEST_EVENT,
314 RIPNG_UPDATE_EVENT,
315 RIPNG_TRIGGERED_UPDATE,
316};
317
318/* RIPng timer on/off macro. */
319#define RIPNG_TIMER_ON(T,F,V) \
320do { \
321 if (!(T)) \
322 (T) = thread_add_timer (master, (F), rinfo, (V)); \
323} while (0)
324
325#define RIPNG_TIMER_OFF(T) \
326do { \
327 if (T) \
328 { \
329 thread_cancel(T); \
330 (T) = NULL; \
331 } \
332} while (0)
333
334/* Count prefix size from mask length */
335#define PSIZE(a) (((a) + 7) / (8))
336
337/* Extern variables. */
338extern struct ripng *ripng;
339
340extern struct thread_master *master;
341
342/* Prototypes. */
343void ripng_init ();
a94434b6 344void ripng_reset ();
345void ripng_clean ();
346void ripng_clean_network ();
347void ripng_interface_clean ();
348void ripng_interface_reset ();
349void ripng_passive_interface_clean ();
718e3744 350void ripng_if_init ();
a94434b6 351void ripng_route_map_init ();
352void ripng_route_map_reset ();
718e3744 353void ripng_terminate ();
a94434b6 354 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
718e3744 355void zebra_init ();
a94434b6 356void ripng_zclient_start ();
357void ripng_zclient_reset ();
358void ripng_offset_init ();
359
360int config_write_ripng_offset_list (struct vty *);
361
362void ripng_peer_init ();
363void ripng_peer_update (struct sockaddr_in6 *, u_char);
364void ripng_peer_bad_route (struct sockaddr_in6 *);
365void ripng_peer_bad_packet (struct sockaddr_in6 *);
366void ripng_peer_display (struct vty *);
367struct ripng_peer *ripng_peer_lookup (struct in6_addr *);
368struct ripng_peer *ripng_peer_lookup_next (struct in6_addr *);
369
370int ripng_offset_list_apply_in (struct prefix_ipv6 *, struct interface *, u_char *);
371int ripng_offset_list_apply_out (struct prefix_ipv6 *, struct interface *, u_char *);
372void ripng_offset_clean ();
373
718e3744 374struct ripng_info * ripng_info_new ();
375void ripng_info_free (struct ripng_info *rinfo);
376void ripng_event (enum ripng_event, int);
377int ripng_request (struct interface *ifp);
a94434b6 378void ripng_redistribute_add (int, int, struct prefix_ipv6 *, unsigned int,
379 struct in6_addr *);
718e3744 380void ripng_redistribute_delete (int, int, struct prefix_ipv6 *, unsigned int);
381void ripng_redistribute_withdraw (int type);
382
383void ripng_distribute_update_interface (struct interface *);
384void ripng_if_rmap_update_interface (struct interface *);
385
386void ripng_zebra_ipv6_add (struct prefix_ipv6 *p, struct in6_addr *nexthop, unsigned int ifindex);
387void ripng_zebra_ipv6_delete (struct prefix_ipv6 *p, struct in6_addr *nexthop, unsigned int ifindex);
a94434b6 388
389void ripng_redistribute_clean ();
390
a94434b6 391int ripng_write_rte (int num, struct stream *s, struct prefix_ipv6 *p,
392 struct in6_addr *nexthop, u_int16_t tag, u_char metric);
393int ripng_send_packet (caddr_t buf, int bufsize, struct sockaddr_in6 *to,
394 struct interface *ifp);
395
7a1d583c 396void ripng_packet_dump (struct ripng_packet *packet, int size, const char *sndrcv);
a94434b6 397
718e3744 398
399#endif /* _ZEBRA_RIPNG_RIPNGD_H */