]>
Commit | Line | Data |
---|---|---|
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 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 | |
20 | */ | |
21 | ||
22 | #ifndef _ZEBRA_RIPNG_RIPNGD_H | |
23 | #define _ZEBRA_RIPNG_RIPNGD_H | |
24 | ||
25 | #include <zclient.h> | |
26 | #include <vty.h> | |
27 | ||
28 | #include "ripng_memory.h" | |
29 | ||
30 | /* RIPng version and port number. */ | |
31 | #define RIPNG_V1 1 | |
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 | |
36 | ||
37 | /* RIPng commands. */ | |
38 | #define RIPNG_REQUEST 1 | |
39 | #define RIPNG_RESPONSE 2 | |
40 | ||
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" | |
45 | ||
46 | /* RIPng timers. */ | |
47 | #define RIPNG_UPDATE_TIMER_DEFAULT 30 | |
48 | #define RIPNG_TIMEOUT_TIMER_DEFAULT 180 | |
49 | #define RIPNG_GARBAGE_TIMER_DEFAULT 120 | |
50 | ||
51 | /* RIPng peer timeout value. */ | |
52 | #define RIPNG_PEER_TIMER_DEFAULT 180 | |
53 | ||
54 | /* Default config file name. */ | |
55 | #define RIPNG_DEFAULT_CONFIG "ripngd.conf" | |
56 | ||
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 | |
64 | ||
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 | |
70 | ||
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 | |
75 | ||
76 | #define RIPNG_DEFAULT_ACCEPT_UNSPEC 0 | |
77 | #define RIPNG_DEFAULT_ACCEPT_NONE 1 | |
78 | #define RIPNG_DEFAULT_ACCEPT 2 | |
79 | ||
80 | /* Default value for "default-metric" command. */ | |
81 | #define RIPNG_DEFAULT_METRIC_DEFAULT 1 | |
82 | ||
83 | /* For max RTE calculation. */ | |
84 | #ifndef IPV6_HDRLEN | |
85 | #define IPV6_HDRLEN 40 | |
86 | #endif /* IPV6_HDRLEN */ | |
87 | ||
88 | #ifndef IFMINMTU | |
89 | #define IFMINMTU 576 | |
90 | #endif /* IFMINMTU */ | |
91 | ||
92 | /* RIPng structure. */ | |
93 | struct ripng { | |
94 | /* RIPng socket. */ | |
95 | int sock; | |
96 | ||
97 | /* RIPng Parameters.*/ | |
98 | uint8_t command; | |
99 | uint8_t version; | |
100 | unsigned long update_time; | |
101 | unsigned long timeout_time; | |
102 | unsigned long garbage_time; | |
103 | int max_mtu; | |
104 | int default_metric; | |
105 | int default_information; | |
106 | ||
107 | /* Input/output buffer of RIPng. */ | |
108 | struct stream *ibuf; | |
109 | struct stream *obuf; | |
110 | ||
111 | /* RIPng routing information base. */ | |
112 | struct agg_table *table; | |
113 | ||
114 | /* RIPng only static route information. */ | |
115 | struct agg_table *route; | |
116 | ||
117 | /* RIPng aggregate route information. */ | |
118 | struct agg_table *aggregate; | |
119 | ||
120 | /* RIPng threads. */ | |
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; | |
126 | ||
127 | /* Triggered update hack. */ | |
128 | int trigger; | |
129 | struct thread *t_triggered_update; | |
130 | struct thread *t_triggered_interval; | |
131 | ||
132 | /* RIPng ECMP flag */ | |
133 | unsigned int ecmp; | |
134 | ||
135 | /* For redistribute route map. */ | |
136 | struct { | |
137 | char *name; | |
138 | struct route_map *map; | |
139 | int metric_config; | |
140 | uint32_t metric; | |
141 | } route_map[ZEBRA_ROUTE_MAX]; | |
142 | }; | |
143 | ||
144 | /* Routing table entry. */ | |
145 | struct rte { | |
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 */ | |
152 | }; | |
153 | ||
154 | /* RIPNG send packet. */ | |
155 | struct ripng_packet { | |
156 | uint8_t command; | |
157 | uint8_t version; | |
158 | uint16_t zero; | |
159 | struct rte rte[1]; | |
160 | }; | |
161 | ||
162 | /* Each route's information. */ | |
163 | struct ripng_info { | |
164 | /* This route's type. Static, ripng or aggregate. */ | |
165 | uint8_t type; | |
166 | ||
167 | /* Sub type for static route. */ | |
168 | uint8_t sub_type; | |
169 | ||
170 | /* RIPng specific information */ | |
171 | struct in6_addr nexthop; | |
172 | struct in6_addr from; | |
173 | ||
174 | /* Which interface does this route come from. */ | |
175 | ifindex_t ifindex; | |
176 | ||
177 | /* Metric of this route. */ | |
178 | uint8_t metric; | |
179 | ||
180 | /* Tag field of RIPng packet.*/ | |
181 | uint16_t tag; | |
182 | ||
183 | /* For aggregation. */ | |
184 | unsigned int suppress; | |
185 | ||
186 | /* Flags of RIPng route. */ | |
187 | #define RIPNG_RTF_FIB 1 | |
188 | #define RIPNG_RTF_CHANGED 2 | |
189 | uint8_t flags; | |
190 | ||
191 | /* Garbage collect timer. */ | |
192 | struct thread *t_timeout; | |
193 | struct thread *t_garbage_collect; | |
194 | ||
195 | /* Route-map features - this variables can be changed. */ | |
196 | struct in6_addr nexthop_out; | |
197 | uint8_t metric_set; | |
198 | uint8_t metric_out; | |
199 | uint16_t tag_out; | |
200 | ||
201 | struct agg_node *rp; | |
202 | }; | |
203 | ||
204 | #ifdef notyet | |
205 | #if 0 | |
206 | /* RIPng tag structure. */ | |
207 | struct ripng_tag | |
208 | { | |
209 | /* Tag value. */ | |
210 | uint16_t tag; | |
211 | ||
212 | /* Port. */ | |
213 | uint16_t port; | |
214 | ||
215 | /* Multicast group. */ | |
216 | struct in6_addr maddr; | |
217 | ||
218 | /* Table number. */ | |
219 | int table; | |
220 | ||
221 | /* Distance. */ | |
222 | int distance; | |
223 | ||
224 | /* Split horizon. */ | |
225 | uint8_t split_horizon; | |
226 | ||
227 | /* Poison reverse. */ | |
228 | uint8_t poison_reverse; | |
229 | }; | |
230 | #endif /* 0 */ | |
231 | #endif /* not yet */ | |
232 | ||
233 | typedef enum { | |
234 | RIPNG_NO_SPLIT_HORIZON = 0, | |
235 | RIPNG_SPLIT_HORIZON, | |
236 | RIPNG_SPLIT_HORIZON_POISONED_REVERSE | |
237 | } split_horizon_policy_t; | |
238 | ||
239 | /* RIPng specific interface configuration. */ | |
240 | struct ripng_interface { | |
241 | /* RIPng is enabled on this interface. */ | |
242 | int enable_network; | |
243 | int enable_interface; | |
244 | ||
245 | /* RIPng is running on this interface. */ | |
246 | int running; | |
247 | ||
248 | /* Split horizon flag. */ | |
249 | split_horizon_policy_t split_horizon; | |
250 | split_horizon_policy_t split_horizon_default; | |
251 | ||
252 | /* For filter type slot. */ | |
253 | #define RIPNG_FILTER_IN 0 | |
254 | #define RIPNG_FILTER_OUT 1 | |
255 | #define RIPNG_FILTER_MAX 2 | |
256 | ||
257 | /* Access-list. */ | |
258 | struct access_list *list[RIPNG_FILTER_MAX]; | |
259 | ||
260 | /* Prefix-list. */ | |
261 | struct prefix_list *prefix[RIPNG_FILTER_MAX]; | |
262 | ||
263 | /* Route-map. */ | |
264 | struct route_map *routemap[RIPNG_FILTER_MAX]; | |
265 | ||
266 | #ifdef notyet | |
267 | #if 0 | |
268 | /* RIPng tag configuration. */ | |
269 | struct ripng_tag *rtag; | |
270 | #endif /* 0 */ | |
271 | #endif /* notyet */ | |
272 | ||
273 | /* Default information originate. */ | |
274 | uint8_t default_originate; | |
275 | ||
276 | /* Default information only. */ | |
277 | uint8_t default_only; | |
278 | ||
279 | /* Wake up thread. */ | |
280 | struct thread *t_wakeup; | |
281 | ||
282 | /* Passive interface. */ | |
283 | int passive; | |
284 | }; | |
285 | ||
286 | /* RIPng peer information. */ | |
287 | struct ripng_peer { | |
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 | uint8_t version; | |
299 | ||
300 | /* Statistics. */ | |
301 | int recv_badpackets; | |
302 | int recv_badroutes; | |
303 | ||
304 | /* Timeout thread. */ | |
305 | struct thread *t_timeout; | |
306 | }; | |
307 | ||
308 | /* All RIPng events. */ | |
309 | enum ripng_event { | |
310 | RIPNG_READ, | |
311 | RIPNG_ZEBRA, | |
312 | RIPNG_REQUEST_EVENT, | |
313 | RIPNG_UPDATE_EVENT, | |
314 | RIPNG_TRIGGERED_UPDATE, | |
315 | }; | |
316 | ||
317 | /* RIPng timer on/off macro. */ | |
318 | #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T)) | |
319 | ||
320 | #define RIPNG_TIMER_OFF(T) \ | |
321 | do { \ | |
322 | if (T) { \ | |
323 | thread_cancel(T); \ | |
324 | (T) = NULL; \ | |
325 | } \ | |
326 | } while (0) | |
327 | ||
328 | /* Extern variables. */ | |
329 | extern struct ripng *ripng; | |
330 | extern struct zebra_privs_t ripngd_privs; | |
331 | extern struct thread_master *master; | |
332 | ||
333 | /* Prototypes. */ | |
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); | |
350 | ||
351 | extern int config_write_ripng_offset_list(struct vty *); | |
352 | ||
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 *); | |
360 | ||
361 | extern int ripng_offset_list_apply_in(struct prefix_ipv6 *, struct interface *, | |
362 | uint8_t *); | |
363 | extern int ripng_offset_list_apply_out(struct prefix_ipv6 *, struct interface *, | |
364 | uint8_t *); | |
365 | extern void ripng_offset_clean(void); | |
366 | ||
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 *, | |
374 | ifindex_t); | |
375 | extern void ripng_redistribute_withdraw(int type); | |
376 | ||
377 | extern void ripng_distribute_update_interface(struct interface *); | |
378 | extern void ripng_if_rmap_update_interface(struct interface *); | |
379 | ||
380 | extern void ripng_zebra_ipv6_add(struct agg_node *node); | |
381 | extern void ripng_zebra_ipv6_delete(struct agg_node *node); | |
382 | ||
383 | extern void ripng_redistribute_clean(void); | |
384 | extern int ripng_redistribute_check(int); | |
385 | extern void ripng_redistribute_write(struct vty *, int); | |
386 | ||
387 | extern int ripng_write_rte(int num, struct stream *s, struct prefix_ipv6 *p, | |
388 | struct in6_addr *nexthop, uint16_t tag, | |
389 | uint8_t metric); | |
390 | extern int ripng_send_packet(caddr_t buf, int bufsize, struct sockaddr_in6 *to, | |
391 | struct interface *ifp); | |
392 | ||
393 | extern void ripng_packet_dump(struct ripng_packet *packet, int size, | |
394 | const char *sndrcv); | |
395 | ||
396 | extern int ripng_interface_up(int command, struct zclient *, zebra_size_t, | |
397 | vrf_id_t); | |
398 | extern int ripng_interface_down(int command, struct zclient *, zebra_size_t, | |
399 | vrf_id_t); | |
400 | extern int ripng_interface_add(int command, struct zclient *, zebra_size_t, | |
401 | vrf_id_t); | |
402 | extern int ripng_interface_delete(int command, struct zclient *, zebra_size_t, | |
403 | vrf_id_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); | |
408 | ||
409 | extern int ripng_network_write(struct vty *, int); | |
410 | ||
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 *); | |
414 | ||
415 | #endif /* _ZEBRA_RIPNG_RIPNGD_H */ |