blob: 816deb647a177f52640da57900e97293fa844eba [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
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
paul718e3742002-12-13 20:15:29 +000030#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
47/* Default config file name. */
48#define RIPNG_DEFAULT_CONFIG "ripngd.conf"
49
50/* RIPng route types. */
51#define RIPNG_ROUTE_RTE 0
52#define RIPNG_ROUTE_STATIC 1
53#define RIPNG_ROUTE_AGGREGATE 2
54
55/* Interface send/receive configuration. */
56#define RIPNG_SEND_UNSPEC 0
57#define RIPNG_SEND_OFF 1
58#define RIPNG_RECEIVE_UNSPEC 0
59#define RIPNG_RECEIVE_OFF 1
60
61/* Split horizon definitions. */
62#define RIPNG_SPLIT_HORIZON_UNSPEC 0
63#define RIPNG_SPLIT_HORIZON_NONE 1
64#define RIPNG_SPLIT_HORIZON 2
65#define RIPNG_SPLIT_HORIZON_POISONED 3
66
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{
142 struct in6_addr addr;
143 u_short tag;
144 u_char prefixlen;
145 u_char metric;
146};
147
148/* RIPNG send packet. */
149struct ripng_packet
150{
151 u_char command;
152 u_char version;
153 u_int16_t zero;
154 struct rte rte[1];
155};
156
157/* Each route's information. */
158struct ripng_info
159{
160 /* This route's type. Static, ripng or aggregate. */
161 u_char type;
162
163 /* Sub type for static route. */
164 u_char sub_type;
165
166 /* RIPng specific information */
167 struct in6_addr nexthop;
168 struct in6_addr from;
169
170 /* Which interface does this route come from. */
171 unsigned int ifindex;
172
173 /* Metric of this route. */
174 u_char metric;
175
176 /* Tag field of RIPng packet.*/
177 u_int16_t tag;
178
179 /* For aggregation. */
180 unsigned int suppress;
181
182 /* Flags of RIPng route. */
183#define RIPNG_RTF_FIB 1
184#define RIPNG_RTF_CHANGED 2
185 u_char flags;
186
187 /* Garbage collect timer. */
188 struct thread *t_timeout;
189 struct thread *t_garbage_collect;
190
191 /* Route-map features - this variables can be changed. */
192 u_char metric_set;
193
194 struct route_node *rp;
195};
196
197/* RIPng tag structure. */
198struct ripng_tag
199{
200 /* Tag value. */
201 u_int16_t tag;
202
203 /* Port. */
204 u_int16_t port;
205
206 /* Multicast group. */
207 struct in6_addr maddr;
208
209 /* Table number. */
210 int table;
211
212 /* Distance. */
213 int distance;
214
215 /* Split horizon. */
216 u_char split_horizon;
217
218 /* Poison reverse. */
219 u_char poison_reverse;
220};
221
222/* RIPng specific interface configuration. */
223struct ripng_interface
224{
225 /* RIPng is enabled on this interface. */
226 int enable_network;
227 int enable_interface;
228
229 /* RIPng is running on this interface. */
230 int running;
231
232 /* For filter type slot. */
233#define RIPNG_FILTER_IN 0
234#define RIPNG_FILTER_OUT 1
235#define RIPNG_FILTER_MAX 2
236
237 /* Access-list. */
238 struct access_list *list[RIPNG_FILTER_MAX];
239
240 /* Prefix-list. */
241 struct prefix_list *prefix[RIPNG_FILTER_MAX];
242
243 /* Route-map. */
244 struct route_map *routemap[RIPNG_FILTER_MAX];
245
246 /* RIPng tag configuration. */
247 struct ripng_tag *rtag;
248
249 /* Default information originate. */
250 u_char default_originate;
251
252 /* Default information only. */
253 u_char default_only;
254
255 /* Wake up thread. */
256 struct thread *t_wakeup;
257
258 /* Passive interface. */
259 int passive;
260};
261
262/* All RIPng events. */
263enum ripng_event
264{
265 RIPNG_READ,
266 RIPNG_ZEBRA,
267 RIPNG_REQUEST_EVENT,
268 RIPNG_UPDATE_EVENT,
269 RIPNG_TRIGGERED_UPDATE,
270};
271
272/* RIPng timer on/off macro. */
273#define RIPNG_TIMER_ON(T,F,V) \
274do { \
275 if (!(T)) \
276 (T) = thread_add_timer (master, (F), rinfo, (V)); \
277} while (0)
278
279#define RIPNG_TIMER_OFF(T) \
280do { \
281 if (T) \
282 { \
283 thread_cancel(T); \
284 (T) = NULL; \
285 } \
286} while (0)
287
288/* Count prefix size from mask length */
289#define PSIZE(a) (((a) + 7) / (8))
290
291/* Extern variables. */
292extern struct ripng *ripng;
293
294extern struct thread_master *master;
295
296/* Prototypes. */
297void ripng_init ();
298void ripng_if_init ();
299void ripng_terminate ();
300void ripng_zclient_start ();
301void zebra_init ();
302struct ripng_info * ripng_info_new ();
303void ripng_info_free (struct ripng_info *rinfo);
304void ripng_event (enum ripng_event, int);
305int ripng_request (struct interface *ifp);
306void ripng_redistribute_add (int, int, struct prefix_ipv6 *, unsigned int);
307void ripng_redistribute_delete (int, int, struct prefix_ipv6 *, unsigned int);
308void ripng_redistribute_withdraw (int type);
309
310void ripng_distribute_update_interface (struct interface *);
311void ripng_if_rmap_update_interface (struct interface *);
312
313void ripng_zebra_ipv6_add (struct prefix_ipv6 *p, struct in6_addr *nexthop, unsigned int ifindex);
314void ripng_zebra_ipv6_delete (struct prefix_ipv6 *p, struct in6_addr *nexthop, unsigned int ifindex);
315void ripng_route_map_init ();
316
317#endif /* _ZEBRA_RIPNG_RIPNGD_H */