]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripngd.h
debian: move ubuntu 16.04 files into new backports system
[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
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 #include <zclient.h>
27 #include <vty.h>
28
29 #include "ripng_memory.h"
30
31 /* RIPng version and port number. */
32 #define RIPNG_V1 1
33 #define RIPNG_PORT_DEFAULT 521
34 #define RIPNG_VTY_PORT 2603
35 #define RIPNG_MAX_PACKET_SIZE 1500
36 #define RIPNG_PRIORITY_DEFAULT 0
37
38 /* RIPng commands. */
39 #define RIPNG_REQUEST 1
40 #define RIPNG_RESPONSE 2
41
42 /* RIPng metric and multicast group address. */
43 #define RIPNG_METRIC_INFINITY 16
44 #define RIPNG_METRIC_NEXTHOP 0xff
45 #define RIPNG_GROUP "ff02::9"
46
47 /* RIPng timers. */
48 #define RIPNG_UPDATE_TIMER_DEFAULT 30
49 #define RIPNG_TIMEOUT_TIMER_DEFAULT 180
50 #define RIPNG_GARBAGE_TIMER_DEFAULT 120
51
52 /* RIPng peer timeout value. */
53 #define RIPNG_PEER_TIMER_DEFAULT 180
54
55 /* Default config file name. */
56 #define RIPNG_DEFAULT_CONFIG "ripngd.conf"
57
58 /* RIPng route types. */
59 #define RIPNG_ROUTE_RTE 0
60 #define RIPNG_ROUTE_STATIC 1
61 #define RIPNG_ROUTE_DEFAULT 2
62 #define RIPNG_ROUTE_REDISTRIBUTE 3
63 #define RIPNG_ROUTE_INTERFACE 4
64 #define RIPNG_ROUTE_AGGREGATE 5
65
66 /* Interface send/receive configuration. */
67 #define RIPNG_SEND_UNSPEC 0
68 #define RIPNG_SEND_OFF 1
69 #define RIPNG_RECEIVE_UNSPEC 0
70 #define RIPNG_RECEIVE_OFF 1
71
72 /* RIP default route's accept/announce methods. */
73 #define RIPNG_DEFAULT_ADVERTISE_UNSPEC 0
74 #define RIPNG_DEFAULT_ADVERTISE_NONE 1
75 #define RIPNG_DEFAULT_ADVERTISE 2
76
77 #define RIPNG_DEFAULT_ACCEPT_UNSPEC 0
78 #define RIPNG_DEFAULT_ACCEPT_NONE 1
79 #define RIPNG_DEFAULT_ACCEPT 2
80
81 /* Default value for "default-metric" command. */
82 #define RIPNG_DEFAULT_METRIC_DEFAULT 1
83
84 /* For max RTE calculation. */
85 #ifndef IPV6_HDRLEN
86 #define IPV6_HDRLEN 40
87 #endif /* IPV6_HDRLEN */
88
89 #ifndef IFMINMTU
90 #define IFMINMTU 576
91 #endif /* IFMINMTU */
92
93 /* RIPng structure. */
94 struct ripng {
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 char *name;
139 struct route_map *map;
140 int metric_config;
141 u_int32_t metric;
142 } route_map[ZEBRA_ROUTE_MAX];
143 };
144
145 /* Routing table entry. */
146 struct rte {
147 struct in6_addr addr; /* RIPng destination prefix */
148 u_int16_t tag; /* RIPng tag */
149 u_char prefixlen; /* Length of the RIPng prefix */
150 u_char metric; /* Metric of the RIPng route */
151 /* The nexthop is stored by the structure
152 * ripng_nexthop within ripngd.c */
153 };
154
155 /* RIPNG send packet. */
156 struct ripng_packet {
157 u_char command;
158 u_char version;
159 u_int16_t zero;
160 struct rte rte[1];
161 };
162
163 /* Each route's information. */
164 struct ripng_info {
165 /* This route's type. Static, ripng or aggregate. */
166 u_char type;
167
168 /* Sub type for static route. */
169 u_char sub_type;
170
171 /* RIPng specific information */
172 struct in6_addr nexthop;
173 struct in6_addr from;
174
175 /* Which interface does this route come from. */
176 ifindex_t ifindex;
177
178 /* Metric of this route. */
179 u_char metric;
180
181 /* Tag field of RIPng packet.*/
182 u_int16_t tag;
183
184 /* For aggregation. */
185 unsigned int suppress;
186
187 /* Flags of RIPng route. */
188 #define RIPNG_RTF_FIB 1
189 #define RIPNG_RTF_CHANGED 2
190 u_char flags;
191
192 /* Garbage collect timer. */
193 struct thread *t_timeout;
194 struct thread *t_garbage_collect;
195
196 /* Route-map features - this variables can be changed. */
197 struct in6_addr nexthop_out;
198 u_char metric_set;
199 u_char metric_out;
200 u_int16_t tag_out;
201
202 struct route_node *rp;
203 };
204
205 #ifdef notyet
206 #if 0
207 /* RIPng tag structure. */
208 struct ripng_tag
209 {
210 /* Tag value. */
211 u_int16_t tag;
212
213 /* Port. */
214 u_int16_t port;
215
216 /* Multicast group. */
217 struct in6_addr maddr;
218
219 /* Table number. */
220 int table;
221
222 /* Distance. */
223 int distance;
224
225 /* Split horizon. */
226 u_char split_horizon;
227
228 /* Poison reverse. */
229 u_char poison_reverse;
230 };
231 #endif /* 0 */
232 #endif /* not yet */
233
234 typedef enum {
235 RIPNG_NO_SPLIT_HORIZON = 0,
236 RIPNG_SPLIT_HORIZON,
237 RIPNG_SPLIT_HORIZON_POISONED_REVERSE
238 } split_horizon_policy_t;
239
240 /* RIPng specific interface configuration. */
241 struct ripng_interface {
242 /* RIPng is enabled on this interface. */
243 int enable_network;
244 int enable_interface;
245
246 /* RIPng is running on this interface. */
247 int running;
248
249 /* Split horizon flag. */
250 split_horizon_policy_t split_horizon;
251 split_horizon_policy_t split_horizon_default;
252
253 /* For filter type slot. */
254 #define RIPNG_FILTER_IN 0
255 #define RIPNG_FILTER_OUT 1
256 #define RIPNG_FILTER_MAX 2
257
258 /* Access-list. */
259 struct access_list *list[RIPNG_FILTER_MAX];
260
261 /* Prefix-list. */
262 struct prefix_list *prefix[RIPNG_FILTER_MAX];
263
264 /* Route-map. */
265 struct route_map *routemap[RIPNG_FILTER_MAX];
266
267 #ifdef notyet
268 #if 0
269 /* RIPng tag configuration. */
270 struct ripng_tag *rtag;
271 #endif /* 0 */
272 #endif /* notyet */
273
274 /* Default information originate. */
275 u_char default_originate;
276
277 /* Default information only. */
278 u_char default_only;
279
280 /* Wake up thread. */
281 struct thread *t_wakeup;
282
283 /* Passive interface. */
284 int passive;
285 };
286
287 /* RIPng peer information. */
288 struct ripng_peer {
289 /* Peer address. */
290 struct in6_addr addr;
291
292 /* Peer RIPng tag value. */
293 int domain;
294
295 /* Last update time. */
296 time_t uptime;
297
298 /* Peer RIP version. */
299 u_char version;
300
301 /* Statistics. */
302 int recv_badpackets;
303 int recv_badroutes;
304
305 /* Timeout thread. */
306 struct thread *t_timeout;
307 };
308
309 /* All RIPng events. */
310 enum ripng_event {
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) \
320 do { \
321 if (!(T)) \
322 (T) = thread_add_timer(master, (F), rinfo, (V)); \
323 } while (0)
324
325 #define RIPNG_TIMER_OFF(T) \
326 do { \
327 if (T) { \
328 thread_cancel(T); \
329 (T) = NULL; \
330 } \
331 } while (0)
332
333 /* Extern variables. */
334 extern struct ripng *ripng;
335
336 extern struct thread_master *master;
337
338 /* Prototypes. */
339 extern void ripng_init(void);
340 extern void ripng_reset(void);
341 extern void ripng_clean(void);
342 extern void ripng_clean_network(void);
343 extern void ripng_interface_clean(void);
344 extern void ripng_interface_reset(void);
345 extern void ripng_passive_interface_clean(void);
346 extern void ripng_if_init(void);
347 extern void ripng_route_map_init(void);
348 extern void ripng_route_map_reset(void);
349 extern void ripng_terminate(void);
350 /* zclient_init() is done by ripng_zebra.c:zebra_init() */
351 extern void zebra_init(struct thread_master *);
352 extern void ripng_zclient_reset(void);
353 extern void ripng_offset_init(void);
354
355 extern int config_write_ripng_offset_list(struct vty *);
356
357 extern void ripng_peer_init(void);
358 extern void ripng_peer_update(struct sockaddr_in6 *, u_char);
359 extern void ripng_peer_bad_route(struct sockaddr_in6 *);
360 extern void ripng_peer_bad_packet(struct sockaddr_in6 *);
361 extern void ripng_peer_display(struct vty *);
362 extern struct ripng_peer *ripng_peer_lookup(struct in6_addr *);
363 extern struct ripng_peer *ripng_peer_lookup_next(struct in6_addr *);
364
365 extern int ripng_offset_list_apply_in(struct prefix_ipv6 *, struct interface *,
366 u_char *);
367 extern int ripng_offset_list_apply_out(struct prefix_ipv6 *, struct interface *,
368 u_char *);
369 extern void ripng_offset_clean(void);
370
371 extern struct ripng_info *ripng_info_new(void);
372 extern void ripng_info_free(struct ripng_info *rinfo);
373 extern void ripng_event(enum ripng_event, int);
374 extern int ripng_request(struct interface *ifp);
375 extern void ripng_redistribute_add(int, int, struct prefix_ipv6 *, ifindex_t,
376 struct in6_addr *, route_tag_t);
377 extern void ripng_redistribute_delete(int, int, struct prefix_ipv6 *,
378 ifindex_t);
379 extern void ripng_redistribute_withdraw(int type);
380
381 extern void ripng_distribute_update_interface(struct interface *);
382 extern void ripng_if_rmap_update_interface(struct interface *);
383
384 extern void ripng_zebra_ipv6_add(struct route_node *);
385 extern void ripng_zebra_ipv6_delete(struct route_node *);
386
387 extern void ripng_redistribute_clean(void);
388 extern int ripng_redistribute_check(int);
389 extern void ripng_redistribute_write(struct vty *, int);
390
391 extern int ripng_write_rte(int num, struct stream *s, struct prefix_ipv6 *p,
392 struct in6_addr *nexthop, u_int16_t tag,
393 u_char metric);
394 extern int ripng_send_packet(caddr_t buf, int bufsize, struct sockaddr_in6 *to,
395 struct interface *ifp);
396
397 extern void ripng_packet_dump(struct ripng_packet *packet, int size,
398 const char *sndrcv);
399
400 extern int ripng_interface_up(int command, struct zclient *, zebra_size_t,
401 vrf_id_t);
402 extern int ripng_interface_down(int command, struct zclient *, zebra_size_t,
403 vrf_id_t);
404 extern int ripng_interface_add(int command, struct zclient *, zebra_size_t,
405 vrf_id_t);
406 extern int ripng_interface_delete(int command, struct zclient *, zebra_size_t,
407 vrf_id_t);
408 extern int ripng_interface_address_add(int command, struct zclient *,
409 zebra_size_t, vrf_id_t);
410 extern int ripng_interface_address_delete(int command, struct zclient *,
411 zebra_size_t, vrf_id_t);
412
413 extern int ripng_network_write(struct vty *, int);
414
415 extern struct ripng_info *ripng_ecmp_add(struct ripng_info *);
416 extern struct ripng_info *ripng_ecmp_replace(struct ripng_info *);
417 extern struct ripng_info *ripng_ecmp_delete(struct ripng_info *);
418
419 #endif /* _ZEBRA_RIPNG_RIPNGD_H */