]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripngd.h
Merge remote-tracking branch 'origin/stable/3.0'
[mirror_frr.git] / ripngd / ripngd.h
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 {
95 /* RIPng socket. */
96 int sock;
97
98 /* RIPng Parameters.*/
99 u_char command;
100 u_char version;
101 unsigned long update_time;
102 unsigned long timeout_time;
103 unsigned long garbage_time;
104 int max_mtu;
105 int default_metric;
106 int default_information;
107
108 /* Input/output buffer of RIPng. */
109 struct stream *ibuf;
110 struct stream *obuf;
111
112 /* RIPng routing information base. */
113 struct route_table *table;
114
115 /* RIPng only static route information. */
116 struct route_table *route;
117
118 /* RIPng aggregate route information. */
119 struct route_table *aggregate;
120
121 /* RIPng threads. */
122 struct thread *t_read;
123 struct thread *t_write;
124 struct thread *t_update;
125 struct thread *t_garbage;
126 struct thread *t_zebra;
127
128 /* Triggered update hack. */
129 int trigger;
130 struct thread *t_triggered_update;
131 struct thread *t_triggered_interval;
132
133 /* RIPng ECMP flag */
134 unsigned int ecmp;
135
136 /* For redistribute route map. */
137 struct
138 {
139 char *name;
140 struct route_map *map;
141 int metric_config;
142 u_int32_t metric;
143 } route_map[ZEBRA_ROUTE_MAX];
144 };
145
146 /* Routing table entry. */
147 struct rte
148 {
149 struct in6_addr addr; /* RIPng destination prefix */
150 u_int16_t tag; /* RIPng tag */
151 u_char prefixlen; /* Length of the RIPng prefix */
152 u_char metric; /* Metric of the RIPng route */
153 /* The nexthop is stored by the structure
154 * ripng_nexthop within ripngd.c */
155 };
156
157 /* RIPNG send packet. */
158 struct ripng_packet
159 {
160 u_char command;
161 u_char version;
162 u_int16_t zero;
163 struct rte rte[1];
164 };
165
166 /* Each route's information. */
167 struct ripng_info
168 {
169 /* This route's type. Static, ripng or aggregate. */
170 u_char type;
171
172 /* Sub type for static route. */
173 u_char sub_type;
174
175 /* RIPng specific information */
176 struct in6_addr nexthop;
177 struct in6_addr from;
178
179 /* Which interface does this route come from. */
180 ifindex_t ifindex;
181
182 /* Metric of this route. */
183 u_char metric;
184
185 /* Tag field of RIPng packet.*/
186 u_int16_t tag;
187
188 /* For aggregation. */
189 unsigned int suppress;
190
191 /* Flags of RIPng route. */
192 #define RIPNG_RTF_FIB 1
193 #define RIPNG_RTF_CHANGED 2
194 u_char flags;
195
196 /* Garbage collect timer. */
197 struct thread *t_timeout;
198 struct thread *t_garbage_collect;
199
200 /* Route-map features - this variables can be changed. */
201 struct in6_addr nexthop_out;
202 u_char metric_set;
203 u_char metric_out;
204 u_int16_t tag_out;
205
206 struct route_node *rp;
207 };
208
209 #ifdef notyet
210 #if 0
211 /* RIPng tag structure. */
212 struct ripng_tag
213 {
214 /* Tag value. */
215 u_int16_t tag;
216
217 /* Port. */
218 u_int16_t port;
219
220 /* Multicast group. */
221 struct in6_addr maddr;
222
223 /* Table number. */
224 int table;
225
226 /* Distance. */
227 int distance;
228
229 /* Split horizon. */
230 u_char split_horizon;
231
232 /* Poison reverse. */
233 u_char poison_reverse;
234 };
235 #endif /* 0 */
236 #endif /* not yet */
237
238 typedef enum {
239 RIPNG_NO_SPLIT_HORIZON = 0,
240 RIPNG_SPLIT_HORIZON,
241 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
242 } split_horizon_policy_t;
243
244 /* RIPng specific interface configuration. */
245 struct ripng_interface
246 {
247 /* RIPng is enabled on this interface. */
248 int enable_network;
249 int enable_interface;
250
251 /* RIPng is running on this interface. */
252 int running;
253
254 /* Split horizon flag. */
255 split_horizon_policy_t split_horizon;
256 split_horizon_policy_t split_horizon_default;
257
258 /* For filter type slot. */
259 #define RIPNG_FILTER_IN 0
260 #define RIPNG_FILTER_OUT 1
261 #define RIPNG_FILTER_MAX 2
262
263 /* Access-list. */
264 struct access_list *list[RIPNG_FILTER_MAX];
265
266 /* Prefix-list. */
267 struct prefix_list *prefix[RIPNG_FILTER_MAX];
268
269 /* Route-map. */
270 struct route_map *routemap[RIPNG_FILTER_MAX];
271
272 #ifdef notyet
273 #if 0
274 /* RIPng tag configuration. */
275 struct ripng_tag *rtag;
276 #endif /* 0 */
277 #endif /* notyet */
278
279 /* Default information originate. */
280 u_char default_originate;
281
282 /* Default information only. */
283 u_char default_only;
284
285 /* Wake up thread. */
286 struct thread *t_wakeup;
287
288 /* Passive interface. */
289 int passive;
290 };
291
292 /* RIPng peer information. */
293 struct ripng_peer
294 {
295 /* Peer address. */
296 struct in6_addr addr;
297
298 /* Peer RIPng tag value. */
299 int domain;
300
301 /* Last update time. */
302 time_t uptime;
303
304 /* Peer RIP version. */
305 u_char version;
306
307 /* Statistics. */
308 int recv_badpackets;
309 int recv_badroutes;
310
311 /* Timeout thread. */
312 struct thread *t_timeout;
313 };
314
315 /* All RIPng events. */
316 enum ripng_event
317 {
318 RIPNG_READ,
319 RIPNG_ZEBRA,
320 RIPNG_REQUEST_EVENT,
321 RIPNG_UPDATE_EVENT,
322 RIPNG_TRIGGERED_UPDATE,
323 };
324
325 /* RIPng timer on/off macro. */
326 #define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
327
328 #define RIPNG_TIMER_OFF(T) \
329 do { \
330 if (T) \
331 { \
332 thread_cancel(T); \
333 (T) = NULL; \
334 } \
335 } while (0)
336
337 /* Extern variables. */
338 extern struct ripng *ripng;
339
340 extern struct thread_master *master;
341
342 /* Prototypes. */
343 extern void ripng_init (void);
344 extern void ripng_reset (void);
345 extern void ripng_clean (void);
346 extern void ripng_clean_network (void);
347 extern void ripng_interface_clean (void);
348 extern void ripng_interface_reset (void);
349 extern void ripng_passive_interface_clean (void);
350 extern void ripng_if_init (void);
351 extern void ripng_route_map_init (void);
352 extern void ripng_route_map_reset (void);
353 extern void ripng_terminate (void);
354 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
355 extern void zebra_init(struct thread_master *);
356 extern void ripng_zclient_reset (void);
357 extern void ripng_offset_init (void);
358
359 extern int config_write_ripng_offset_list (struct vty *);
360
361 extern void ripng_peer_init (void);
362 extern void ripng_peer_update (struct sockaddr_in6 *, u_char);
363 extern void ripng_peer_bad_route (struct sockaddr_in6 *);
364 extern void ripng_peer_bad_packet (struct sockaddr_in6 *);
365 extern void ripng_peer_display (struct vty *);
366 extern struct ripng_peer *ripng_peer_lookup (struct in6_addr *);
367 extern struct ripng_peer *ripng_peer_lookup_next (struct in6_addr *);
368
369 extern int ripng_offset_list_apply_in (struct prefix_ipv6 *,
370 struct interface *, u_char *);
371 extern int ripng_offset_list_apply_out (struct prefix_ipv6 *,
372 struct interface *, u_char *);
373 extern void ripng_offset_clean (void);
374
375 extern struct ripng_info * ripng_info_new (void);
376 extern void ripng_info_free (struct ripng_info *rinfo);
377 extern void ripng_event (enum ripng_event, int);
378 extern int ripng_request (struct interface *ifp);
379 extern void ripng_redistribute_add (int, int, struct prefix_ipv6 *,
380 ifindex_t, struct in6_addr *, route_tag_t);
381 extern void ripng_redistribute_delete (int, int, struct prefix_ipv6 *,
382 ifindex_t);
383 extern void ripng_redistribute_withdraw (int type);
384
385 extern void ripng_distribute_update_interface (struct interface *);
386 extern void ripng_if_rmap_update_interface (struct interface *);
387
388 extern void ripng_zebra_ipv6_add (struct route_node *);
389 extern void ripng_zebra_ipv6_delete (struct route_node *);
390
391 extern void ripng_redistribute_clean (void);
392 extern int ripng_redistribute_check (int);
393 extern void ripng_redistribute_write (struct vty *, int);
394
395 extern int ripng_write_rte (int num, struct stream *s, struct prefix_ipv6 *p,
396 struct in6_addr *nexthop,
397 u_int16_t tag, u_char metric);
398 extern int ripng_send_packet (caddr_t buf, int bufsize,
399 struct sockaddr_in6 *to, struct interface *ifp);
400
401 extern void ripng_packet_dump (struct ripng_packet *packet, int size,
402 const char *sndrcv);
403
404 extern int ripng_interface_up (int command, struct zclient *, zebra_size_t,
405 vrf_id_t);
406 extern int ripng_interface_down (int command, struct zclient *, zebra_size_t,
407 vrf_id_t);
408 extern int ripng_interface_add (int command, struct zclient *, zebra_size_t,
409 vrf_id_t);
410 extern int ripng_interface_delete (int command, struct zclient *, zebra_size_t,
411 vrf_id_t);
412 extern int ripng_interface_address_add (int command, struct zclient *, zebra_size_t,
413 vrf_id_t);
414 extern int ripng_interface_address_delete (int command, struct zclient *, zebra_size_t,
415 vrf_id_t);
416
417 extern int ripng_network_write (struct vty *, int);
418
419 extern struct ripng_info *ripng_ecmp_add (struct ripng_info *);
420 extern struct ripng_info *ripng_ecmp_replace (struct ripng_info *);
421 extern struct ripng_info *ripng_ecmp_delete (struct ripng_info *);
422
423 #endif /* _ZEBRA_RIPNG_RIPNGD_H */