]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripngd.h
Initial revision
[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 /* RIPng version and port number. */
27 #define RIPNG_V1 1
28 #define RIPNG_PORT_DEFAULT 521
29 #define RIPNG_VTY_PORT 2603
30 #define RIPNG_VTYSH_PATH "/tmp/.ripngd"
31 #define RIPNG_MAX_PACKET_SIZE 1500
32 #define RIPNG_PRIORITY_DEFAULT 0
33
34 /* RIPng commands. */
35 #define RIPNG_REQUEST 1
36 #define RIPNG_RESPONSE 2
37
38 /* RIPng metric and multicast group address. */
39 #define RIPNG_METRIC_INFINITY 16
40 #define RIPNG_METRIC_NEXTHOP 0xff
41 #define RIPNG_GROUP "ff02::9"
42
43 /* RIPng timers. */
44 #define RIPNG_UPDATE_TIMER_DEFAULT 30
45 #define RIPNG_TIMEOUT_TIMER_DEFAULT 180
46 #define RIPNG_GARBAGE_TIMER_DEFAULT 120
47
48 /* Default config file name. */
49 #define RIPNG_DEFAULT_CONFIG "ripngd.conf"
50
51 /* RIPng route types. */
52 #define RIPNG_ROUTE_RTE 0
53 #define RIPNG_ROUTE_STATIC 1
54 #define RIPNG_ROUTE_AGGREGATE 2
55
56 /* Interface send/receive configuration. */
57 #define RIPNG_SEND_UNSPEC 0
58 #define RIPNG_SEND_OFF 1
59 #define RIPNG_RECEIVE_UNSPEC 0
60 #define RIPNG_RECEIVE_OFF 1
61
62 /* Split horizon definitions. */
63 #define RIPNG_SPLIT_HORIZON_UNSPEC 0
64 #define RIPNG_SPLIT_HORIZON_NONE 1
65 #define RIPNG_SPLIT_HORIZON 2
66 #define RIPNG_SPLIT_HORIZON_POISONED 3
67
68 /* RIP default route's accept/announce methods. */
69 #define RIPNG_DEFAULT_ADVERTISE_UNSPEC 0
70 #define RIPNG_DEFAULT_ADVERTISE_NONE 1
71 #define RIPNG_DEFAULT_ADVERTISE 2
72
73 #define RIPNG_DEFAULT_ACCEPT_UNSPEC 0
74 #define RIPNG_DEFAULT_ACCEPT_NONE 1
75 #define RIPNG_DEFAULT_ACCEPT 2
76
77 /* Default value for "default-metric" command. */
78 #define RIPNG_DEFAULT_METRIC_DEFAULT 1
79
80 /* For max RTE calculation. */
81 #ifndef IPV6_HDRLEN
82 #define IPV6_HDRLEN 40
83 #endif /* IPV6_HDRLEN */
84
85 #ifndef IFMINMTU
86 #define IFMINMTU 576
87 #endif /* IFMINMTU */
88
89 /* RIPng structure. */
90 struct ripng
91 {
92 /* RIPng socket. */
93 int sock;
94
95 /* RIPng Parameters.*/
96 u_char command;
97 u_char version;
98 unsigned long update_time;
99 unsigned long timeout_time;
100 unsigned long garbage_time;
101 int max_mtu;
102 int default_metric;
103 int default_information;
104
105 /* Input/output buffer of RIPng. */
106 struct stream *ibuf;
107 struct stream *obuf;
108
109 /* RIPng routing information base. */
110 struct route_table *table;
111
112 /* RIPng only static route information. */
113 struct route_table *route;
114
115 /* RIPng aggregate route information. */
116 struct route_table *aggregate;
117
118 /* RIPng threads. */
119 struct thread *t_read;
120 struct thread *t_write;
121 struct thread *t_update;
122 struct thread *t_garbage;
123 struct thread *t_zebra;
124
125 /* Triggered update hack. */
126 int trigger;
127 struct thread *t_triggered_update;
128 struct thread *t_triggered_interval;
129
130 /* For redistribute route map. */
131 struct
132 {
133 char *name;
134 struct route_map *map;
135 int metric_config;
136 u_int32_t metric;
137 } route_map[ZEBRA_ROUTE_MAX];
138 };
139
140 /* Routing table entry. */
141 struct rte
142 {
143 struct in6_addr addr;
144 u_short tag;
145 u_char prefixlen;
146 u_char metric;
147 };
148
149 /* RIPNG send packet. */
150 struct ripng_packet
151 {
152 u_char command;
153 u_char version;
154 u_int16_t zero;
155 struct rte rte[1];
156 };
157
158 /* Each route's information. */
159 struct ripng_info
160 {
161 /* This route's type. Static, ripng or aggregate. */
162 u_char type;
163
164 /* Sub type for static route. */
165 u_char sub_type;
166
167 /* RIPng specific information */
168 struct in6_addr nexthop;
169 struct in6_addr from;
170
171 /* Which interface does this route come from. */
172 unsigned int ifindex;
173
174 /* Metric of this route. */
175 u_char metric;
176
177 /* Tag field of RIPng packet.*/
178 u_int16_t tag;
179
180 /* For aggregation. */
181 unsigned int suppress;
182
183 /* Flags of RIPng route. */
184 #define RIPNG_RTF_FIB 1
185 #define RIPNG_RTF_CHANGED 2
186 u_char flags;
187
188 /* Garbage collect timer. */
189 struct thread *t_timeout;
190 struct thread *t_garbage_collect;
191
192 /* Route-map features - this variables can be changed. */
193 u_char metric_set;
194
195 struct route_node *rp;
196 };
197
198 /* RIPng tag structure. */
199 struct ripng_tag
200 {
201 /* Tag value. */
202 u_int16_t tag;
203
204 /* Port. */
205 u_int16_t port;
206
207 /* Multicast group. */
208 struct in6_addr maddr;
209
210 /* Table number. */
211 int table;
212
213 /* Distance. */
214 int distance;
215
216 /* Split horizon. */
217 u_char split_horizon;
218
219 /* Poison reverse. */
220 u_char poison_reverse;
221 };
222
223 /* RIPng specific interface configuration. */
224 struct ripng_interface
225 {
226 /* RIPng is enabled on this interface. */
227 int enable_network;
228 int enable_interface;
229
230 /* RIPng is running on this interface. */
231 int running;
232
233 /* For filter type slot. */
234 #define RIPNG_FILTER_IN 0
235 #define RIPNG_FILTER_OUT 1
236 #define RIPNG_FILTER_MAX 2
237
238 /* Access-list. */
239 struct access_list *list[RIPNG_FILTER_MAX];
240
241 /* Prefix-list. */
242 struct prefix_list *prefix[RIPNG_FILTER_MAX];
243
244 /* Route-map. */
245 struct route_map *routemap[RIPNG_FILTER_MAX];
246
247 /* RIPng tag configuration. */
248 struct ripng_tag *rtag;
249
250 /* Default information originate. */
251 u_char default_originate;
252
253 /* Default information only. */
254 u_char default_only;
255
256 /* Wake up thread. */
257 struct thread *t_wakeup;
258
259 /* Passive interface. */
260 int passive;
261 };
262
263 /* All RIPng events. */
264 enum ripng_event
265 {
266 RIPNG_READ,
267 RIPNG_ZEBRA,
268 RIPNG_REQUEST_EVENT,
269 RIPNG_UPDATE_EVENT,
270 RIPNG_TRIGGERED_UPDATE,
271 };
272
273 /* RIPng timer on/off macro. */
274 #define RIPNG_TIMER_ON(T,F,V) \
275 do { \
276 if (!(T)) \
277 (T) = thread_add_timer (master, (F), rinfo, (V)); \
278 } while (0)
279
280 #define RIPNG_TIMER_OFF(T) \
281 do { \
282 if (T) \
283 { \
284 thread_cancel(T); \
285 (T) = NULL; \
286 } \
287 } while (0)
288
289 /* Count prefix size from mask length */
290 #define PSIZE(a) (((a) + 7) / (8))
291
292 /* Extern variables. */
293 extern struct ripng *ripng;
294
295 extern struct thread_master *master;
296
297 /* Prototypes. */
298 void ripng_init ();
299 void ripng_if_init ();
300 void ripng_terminate ();
301 void ripng_zclient_start ();
302 void zebra_init ();
303 struct ripng_info * ripng_info_new ();
304 void ripng_info_free (struct ripng_info *rinfo);
305 void ripng_event (enum ripng_event, int);
306 int ripng_request (struct interface *ifp);
307 void ripng_redistribute_add (int, int, struct prefix_ipv6 *, unsigned int);
308 void ripng_redistribute_delete (int, int, struct prefix_ipv6 *, unsigned int);
309 void ripng_redistribute_withdraw (int type);
310
311 void ripng_distribute_update_interface (struct interface *);
312 void ripng_if_rmap_update_interface (struct interface *);
313
314 void ripng_zebra_ipv6_add (struct prefix_ipv6 *p, struct in6_addr *nexthop, unsigned int ifindex);
315 void ripng_zebra_ipv6_delete (struct prefix_ipv6 *p, struct in6_addr *nexthop, unsigned int ifindex);
316 void ripng_route_map_init ();
317
318 #endif /* _ZEBRA_RIPNG_RIPNGD_H */