]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * Routing Information Base header | |
3 | * Copyright (C) 1997 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_RIB_H | |
24 | #define _ZEBRA_RIB_H | |
25 | ||
c6ffe645 | 26 | #include "linklist.h" |
ec1a4283 | 27 | #include "prefix.h" |
9fd92e3c | 28 | #include "table.h" |
5adc2528 | 29 | #include "queue.h" |
fb018d25 | 30 | #include "nexthop.h" |
ec1a4283 | 31 | |
718e3744 | 32 | #define DISTANCE_INFINITY 255 |
7a4bb9c5 | 33 | #define ZEBRA_KERNEL_TABLE_MAX 252 /* support for no more than this rt tables */ |
718e3744 | 34 | |
718e3744 | 35 | struct rib |
36 | { | |
37 | /* Link list. */ | |
38 | struct rib *next; | |
39 | struct rib *prev; | |
e6d7d054 PJ |
40 | |
41 | /* Nexthop structure */ | |
42 | struct nexthop *nexthop; | |
43 | ||
44 | /* Refrence count. */ | |
45 | unsigned long refcnt; | |
46 | ||
47 | /* Uptime. */ | |
48 | time_t uptime; | |
718e3744 | 49 | |
50 | /* Type fo this route. */ | |
51 | int type; | |
52 | ||
7c8ff89e DS |
53 | /* Source protocol instance */ |
54 | u_short instance; | |
55 | ||
78104b9b FL |
56 | /* VRF identifier. */ |
57 | vrf_id_t vrf_id; | |
58 | ||
718e3744 | 59 | /* Which routing table */ |
4e3afb14 | 60 | uint32_t table; |
718e3744 | 61 | |
e6d7d054 PJ |
62 | /* Metric */ |
63 | u_int32_t metric; | |
64 | ||
718e3744 | 65 | /* Distance. */ |
66 | u_char distance; | |
67 | ||
0d9551dc DS |
68 | /* Tag */ |
69 | u_short tag; | |
70 | ||
6d691129 PJ |
71 | /* Flags of this route. |
72 | * This flag's definition is in lib/zebra.h ZEBRA_FLAG_* and is exposed | |
73 | * to clients via Zserv | |
74 | */ | |
718e3744 | 75 | u_char flags; |
76 | ||
6d691129 PJ |
77 | /* RIB internal status */ |
78 | u_char status; | |
6e26278c DS |
79 | #define RIB_ENTRY_REMOVED 0x1 |
80 | /* to simplify NHT logic when NHs change, instead of doing a NH by NH cmp */ | |
81 | #define RIB_ENTRY_NEXTHOPS_CHANGED 0x2 | |
6d691129 | 82 | |
718e3744 | 83 | /* Nexthop information. */ |
84 | u_char nexthop_num; | |
85 | u_char nexthop_active_num; | |
86 | u_char nexthop_fib_num; | |
718e3744 | 87 | }; |
88 | ||
e96f9203 DO |
89 | /* meta-queue structure: |
90 | * sub-queue 0: connected, kernel | |
91 | * sub-queue 1: static | |
92 | * sub-queue 2: RIP, RIPng, OSPF, OSPF6, IS-IS | |
93 | * sub-queue 3: iBGP, eBGP | |
94 | * sub-queue 4: any other origin (if any) | |
95 | */ | |
96 | #define MQ_SIZE 5 | |
97 | struct meta_queue | |
98 | { | |
99 | struct list *subq[MQ_SIZE]; | |
100 | u_int32_t size; /* sum of lengths of all subqueues */ | |
101 | }; | |
102 | ||
9fd92e3c AS |
103 | /* |
104 | * Structure that represents a single destination (prefix). | |
105 | */ | |
106 | typedef struct rib_dest_t_ | |
107 | { | |
108 | ||
109 | /* | |
110 | * Back pointer to the route node for this destination. This helps | |
111 | * us get to the prefix that this structure is for. | |
112 | */ | |
113 | struct route_node *rnode; | |
114 | ||
115 | /* | |
116 | * Doubly-linked list of routes for this prefix. | |
117 | */ | |
118 | struct rib *routes; | |
119 | ||
120 | /* | |
121 | * Flags, see below. | |
122 | */ | |
123 | u_int32_t flags; | |
124 | ||
5adc2528 AS |
125 | /* |
126 | * Linkage to put dest on the FPM processing queue. | |
127 | */ | |
128 | TAILQ_ENTRY(rib_dest_t_) fpm_q_entries; | |
129 | ||
9fd92e3c AS |
130 | } rib_dest_t; |
131 | ||
132 | #define RIB_ROUTE_QUEUED(x) (1 << (x)) | |
133 | ||
134 | /* | |
135 | * The maximum qindex that can be used. | |
136 | */ | |
137 | #define ZEBRA_MAX_QINDEX (MQ_SIZE - 1) | |
138 | ||
5adc2528 AS |
139 | /* |
140 | * This flag indicates that a given prefix has been 'advertised' to | |
141 | * the FPM to be installed in the forwarding plane. | |
142 | */ | |
143 | #define RIB_DEST_SENT_TO_FPM (1 << (ZEBRA_MAX_QINDEX + 1)) | |
144 | ||
145 | /* | |
146 | * This flag is set when we need to send an update to the FPM about a | |
147 | * dest. | |
148 | */ | |
149 | #define RIB_DEST_UPDATE_FPM (1 << (ZEBRA_MAX_QINDEX + 2)) | |
150 | ||
9fd92e3c AS |
151 | /* |
152 | * Macro to iterate over each route for a destination (prefix). | |
153 | */ | |
154 | #define RIB_DEST_FOREACH_ROUTE(dest, rib) \ | |
155 | for ((rib) = (dest) ? (dest)->routes : NULL; (rib); (rib) = (rib)->next) | |
156 | ||
157 | /* | |
158 | * Same as above, but allows the current node to be unlinked. | |
159 | */ | |
160 | #define RIB_DEST_FOREACH_ROUTE_SAFE(dest, rib, next) \ | |
161 | for ((rib) = (dest) ? (dest)->routes : NULL; \ | |
162 | (rib) && ((next) = (rib)->next, 1); \ | |
163 | (rib) = (next)) | |
164 | ||
165 | #define RNODE_FOREACH_RIB(rn, rib) \ | |
166 | RIB_DEST_FOREACH_ROUTE (rib_dest_from_rnode (rn), rib) | |
167 | ||
168 | #define RNODE_FOREACH_RIB_SAFE(rn, rib, next) \ | |
169 | RIB_DEST_FOREACH_ROUTE_SAFE (rib_dest_from_rnode (rn), rib, next) | |
170 | ||
718e3744 | 171 | /* Static route information. */ |
172 | struct static_ipv4 | |
173 | { | |
174 | /* For linked list. */ | |
175 | struct static_ipv4 *prev; | |
176 | struct static_ipv4 *next; | |
177 | ||
8f527c5e FL |
178 | /* VRF identifier. */ |
179 | vrf_id_t vrf_id; | |
180 | ||
718e3744 | 181 | /* Administrative distance. */ |
182 | u_char distance; | |
183 | ||
0d9551dc DS |
184 | /* Tag */ |
185 | u_short tag; | |
186 | ||
718e3744 | 187 | /* Flag for this static route's type. */ |
188 | u_char type; | |
189 | #define STATIC_IPV4_GATEWAY 1 | |
190 | #define STATIC_IPV4_IFNAME 2 | |
595db7f1 | 191 | #define STATIC_IPV4_BLACKHOLE 3 |
718e3744 | 192 | |
193 | /* Nexthop value. */ | |
194 | union | |
195 | { | |
196 | struct in_addr ipv4; | |
197 | char *ifname; | |
198 | } gate; | |
81dfcaa2 | 199 | |
200 | /* bit flags */ | |
201 | u_char flags; | |
202 | /* | |
203 | see ZEBRA_FLAG_REJECT | |
204 | ZEBRA_FLAG_BLACKHOLE | |
205 | */ | |
718e3744 | 206 | }; |
207 | ||
208 | #ifdef HAVE_IPV6 | |
209 | /* Static route information. */ | |
210 | struct static_ipv6 | |
211 | { | |
212 | /* For linked list. */ | |
213 | struct static_ipv6 *prev; | |
214 | struct static_ipv6 *next; | |
215 | ||
8f527c5e FL |
216 | /* VRF identifier. */ |
217 | vrf_id_t vrf_id; | |
218 | ||
718e3744 | 219 | /* Administrative distance. */ |
220 | u_char distance; | |
221 | ||
0d9551dc DS |
222 | /* Tag */ |
223 | u_short tag; | |
224 | ||
718e3744 | 225 | /* Flag for this static route's type. */ |
226 | u_char type; | |
227 | #define STATIC_IPV6_GATEWAY 1 | |
228 | #define STATIC_IPV6_GATEWAY_IFNAME 2 | |
229 | #define STATIC_IPV6_IFNAME 3 | |
230 | ||
231 | /* Nexthop value. */ | |
232 | struct in6_addr ipv6; | |
233 | char *ifname; | |
81dfcaa2 | 234 | |
235 | /* bit flags */ | |
236 | u_char flags; | |
237 | /* | |
238 | see ZEBRA_FLAG_REJECT | |
239 | ZEBRA_FLAG_BLACKHOLE | |
240 | */ | |
718e3744 | 241 | }; |
242 | #endif /* HAVE_IPV6 */ | |
243 | ||
fa713d9e CF |
244 | /* The following for loop allows to iterate over the nexthop |
245 | * structure of routes. | |
246 | * | |
247 | * We have to maintain quite a bit of state: | |
248 | * | |
249 | * nexthop: The pointer to the current nexthop, either in the | |
250 | * top-level chain or in the resolved chain of ni. | |
251 | * tnexthop: The pointer to the current nexthop in the top-level | |
252 | * nexthop chain. | |
253 | * recursing: Information if nh currently is in the top-level chain | |
254 | * (0) or in a resolved chain (1). | |
255 | * | |
256 | * Initialization: Set `nexthop' and `tnexthop' to the head of the | |
257 | * top-level chain. As nexthop is in the top level chain, set recursing | |
258 | * to 0. | |
259 | * | |
260 | * Iteration check: Check that the `nexthop' pointer is not NULL. | |
261 | * | |
262 | * Iteration step: This is the tricky part. Check if `nexthop' has | |
263 | * NEXTHOP_FLAG_RECURSIVE set. If yes, this implies that `nexthop' is in | |
264 | * the top level chain and has at least one nexthop attached to | |
265 | * `nexthop->resolved'. As we want to descend into `nexthop->resolved', | |
266 | * set `recursing' to 1 and set `nexthop' to `nexthop->resolved'. | |
267 | * `tnexthop' is left alone in that case so we can remember which nexthop | |
268 | * in the top level chain we are currently handling. | |
269 | * | |
270 | * If NEXTHOP_FLAG_RECURSIVE is not set, `nexthop' will progress in its | |
271 | * current chain. If we are recursing, `nexthop' will be set to | |
272 | * `nexthop->next' and `tnexthop' will be left alone. If we are not | |
273 | * recursing, both `tnexthop' and `nexthop' will be set to `nexthop->next' | |
274 | * as we are progressing in the top level chain. | |
275 | * If we encounter `nexthop->next == NULL', we will clear the `recursing' | |
276 | * flag as we arived either at the end of the resolved chain or at the end | |
277 | * of the top level chain. In both cases, we set `tnexthop' and `nexthop' | |
278 | * to `tnexthop->next', progressing to the next position in the top-level | |
279 | * chain and possibly to its end marked by NULL. | |
280 | */ | |
281 | #define ALL_NEXTHOPS_RO(head, nexthop, tnexthop, recursing) \ | |
282 | (tnexthop) = (nexthop) = (head), (recursing) = 0; \ | |
283 | (nexthop); \ | |
284 | (nexthop) = CHECK_FLAG((nexthop)->flags, NEXTHOP_FLAG_RECURSIVE) \ | |
285 | ? (((recursing) = 1), (nexthop)->resolved) \ | |
286 | : ((nexthop)->next ? ((recursing) ? (nexthop)->next \ | |
287 | : ((tnexthop) = (nexthop)->next)) \ | |
288 | : (((recursing) = 0),((tnexthop) = (tnexthop)->next))) | |
289 | ||
cd80d74f FL |
290 | /* Router advertisement feature. */ |
291 | #ifndef RTADV | |
292 | #if (defined(LINUX_IPV6) && (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1)) || defined(KAME) | |
293 | #ifdef HAVE_RTADV | |
294 | #define RTADV | |
295 | #endif | |
296 | #endif | |
297 | #endif | |
298 | ||
299 | #if defined (HAVE_IPV6) && defined (RTADV) | |
300 | /* Structure which hold status of router advertisement. */ | |
301 | struct rtadv | |
302 | { | |
303 | int sock; | |
304 | ||
305 | int adv_if_count; | |
306 | int adv_msec_if_count; | |
307 | ||
308 | struct thread *ra_read; | |
309 | struct thread *ra_timer; | |
310 | }; | |
311 | #endif /* RTADV && HAVE_IPV6 */ | |
312 | ||
8f7d9fc0 FL |
313 | #ifdef HAVE_NETLINK |
314 | /* Socket interface to kernel */ | |
315 | struct nlsock | |
316 | { | |
317 | int sock; | |
318 | int seq; | |
319 | struct sockaddr_nl snl; | |
320 | const char *name; | |
321 | }; | |
322 | #endif | |
323 | ||
718e3744 | 324 | /* Routing table instance. */ |
b72ede27 | 325 | struct zebra_vrf |
718e3744 | 326 | { |
b72ede27 FL |
327 | /* Identifier. */ |
328 | vrf_id_t vrf_id; | |
718e3744 | 329 | |
330 | /* Routing table name. */ | |
331 | char *name; | |
332 | ||
333 | /* Description. */ | |
334 | char *desc; | |
335 | ||
336 | /* FIB identifier. */ | |
337 | u_char fib_id; | |
338 | ||
339 | /* Routing table. */ | |
340 | struct route_table *table[AFI_MAX][SAFI_MAX]; | |
341 | ||
342 | /* Static route configuration. */ | |
343 | struct route_table *stable[AFI_MAX][SAFI_MAX]; | |
fb018d25 DS |
344 | |
345 | /* Recursive Nexthop table */ | |
346 | struct route_table *rnh_table[AFI_MAX]; | |
7a4bb9c5 | 347 | |
078430f6 DS |
348 | /* Import check table (used mostly by BGP */ |
349 | struct route_table *import_check_table[AFI_MAX]; | |
350 | ||
7a4bb9c5 DS |
351 | /* Routing tables off of main table for redistribute table */ |
352 | struct route_table *other_table[AFI_MAX][ZEBRA_KERNEL_TABLE_MAX]; | |
c6ffe645 | 353 | |
8f7d9fc0 FL |
354 | #ifdef HAVE_NETLINK |
355 | struct nlsock netlink; /* kernel messages */ | |
356 | struct nlsock netlink_cmd; /* command channel */ | |
357 | struct thread *t_netlink; | |
358 | #endif | |
359 | ||
c6ffe645 FL |
360 | /* 2nd pointer type used primarily to quell a warning on |
361 | * ALL_LIST_ELEMENTS_RO | |
362 | */ | |
363 | struct list _rid_all_sorted_list; | |
364 | struct list _rid_lo_sorted_list; | |
365 | struct list *rid_all_sorted_list; | |
366 | struct list *rid_lo_sorted_list; | |
367 | struct prefix rid_user_assigned; | |
cd80d74f FL |
368 | |
369 | #if defined (HAVE_IPV6) && defined (RTADV) | |
370 | struct rtadv rtadv; | |
371 | #endif /* RTADV && HAVE_IPV6 */ | |
718e3744 | 372 | }; |
373 | ||
1b5ed1b0 AS |
374 | /* |
375 | * rib_table_info_t | |
376 | * | |
377 | * Structure that is hung off of a route_table that holds information about | |
378 | * the table. | |
379 | */ | |
380 | typedef struct rib_table_info_t_ | |
381 | { | |
382 | ||
383 | /* | |
b72ede27 | 384 | * Back pointer to zebra_vrf. |
1b5ed1b0 | 385 | */ |
b72ede27 | 386 | struct zebra_vrf *zvrf; |
1b5ed1b0 AS |
387 | afi_t afi; |
388 | safi_t safi; | |
389 | ||
390 | } rib_table_info_t; | |
391 | ||
0915bb0c AS |
392 | typedef enum |
393 | { | |
394 | RIB_TABLES_ITER_S_INIT, | |
395 | RIB_TABLES_ITER_S_ITERATING, | |
396 | RIB_TABLES_ITER_S_DONE | |
397 | } rib_tables_iter_state_t; | |
398 | ||
399 | /* | |
400 | * Structure that holds state for iterating over all tables in the | |
401 | * Routing Information Base. | |
402 | */ | |
403 | typedef struct rib_tables_iter_t_ | |
404 | { | |
b72ede27 | 405 | vrf_id_t vrf_id; |
0915bb0c AS |
406 | int afi_safi_ix; |
407 | ||
408 | rib_tables_iter_state_t state; | |
409 | } rib_tables_iter_t; | |
410 | ||
a1ac18c4 | 411 | extern struct nexthop *nexthop_ifindex_add (struct rib *, unsigned int); |
412 | extern struct nexthop *nexthop_ifname_add (struct rib *, char *); | |
413 | extern struct nexthop *nexthop_blackhole_add (struct rib *); | |
7514fb77 PJ |
414 | extern struct nexthop *nexthop_ipv4_add (struct rib *, struct in_addr *, |
415 | struct in_addr *); | |
c8a1cb5c DS |
416 | extern struct nexthop * nexthop_ipv4_ifindex_ol_add (struct rib *, const struct in_addr *, |
417 | const struct in_addr *, const unsigned); | |
26e2ae36 JB |
418 | extern struct nexthop *nexthop_ipv4_ifindex_add (struct rib *, |
419 | struct in_addr *, | |
420 | struct in_addr *, | |
421 | unsigned int); | |
6e26278c DS |
422 | extern void nexthop_free (struct nexthop *nexthop, struct route_node *); |
423 | extern void nexthops_free (struct nexthop *nexthop, struct route_node *); | |
fb018d25 | 424 | extern void nexthop_add (struct rib *rib, struct nexthop *nexthop); |
6e26278c | 425 | extern void copy_nexthops (struct rib *rib, struct nexthop *nh); |
fb018d25 | 426 | |
fa713d9e | 427 | extern int nexthop_has_fib_child(struct nexthop *); |
dc95824a | 428 | extern void rib_lookup_and_dump (struct prefix_ipv4 *); |
20e5ff0a | 429 | extern void rib_lookup_and_pushup (struct prefix_ipv4 *); |
f7bf4153 DL |
430 | #define rib_dump(prefix ,rib) _rib_dump(__func__, prefix, rib) |
431 | extern void _rib_dump (const char *, | |
432 | union prefix46constptr, const struct rib *); | |
78104b9b FL |
433 | extern int rib_lookup_ipv4_route (struct prefix_ipv4 *, union sockunion *, |
434 | vrf_id_t); | |
dc95824a DO |
435 | #define ZEBRA_RIB_LOOKUP_ERROR -1 |
436 | #define ZEBRA_RIB_FOUND_EXACT 0 | |
437 | #define ZEBRA_RIB_FOUND_NOGATE 1 | |
438 | #define ZEBRA_RIB_FOUND_CONNECTED 2 | |
439 | #define ZEBRA_RIB_NOTFOUND 3 | |
440 | ||
718e3744 | 441 | #ifdef HAVE_IPV6 |
a1ac18c4 | 442 | extern struct nexthop *nexthop_ipv6_add (struct rib *, struct in6_addr *); |
41fc2714 DS |
443 | extern struct nexthop *nexthop_ipv6_ifindex_add (struct rib *rib, |
444 | struct in6_addr *ipv6, unsigned int ifindex); | |
445 | extern struct nexthop *nexthop_ipv6_ifname_add (struct rib *rib, | |
446 | struct in6_addr *ipv6, | |
447 | char *ifname); | |
448 | extern int | |
449 | rib_bogus_ipv6 (int type, struct prefix_ipv6 *p, | |
450 | struct in6_addr *gate, unsigned int ifindex, int table); | |
718e3744 | 451 | #endif /* HAVE_IPV6 */ |
452 | ||
b72ede27 FL |
453 | extern struct zebra_vrf *zebra_vrf_lookup (vrf_id_t vrf_id); |
454 | extern struct zebra_vrf *zebra_vrf_alloc (vrf_id_t); | |
455 | extern struct route_table *zebra_vrf_table (afi_t, safi_t, vrf_id_t); | |
456 | extern struct route_table *zebra_vrf_static_table (afi_t, safi_t, vrf_id_t); | |
457 | extern struct route_table *zebra_vrf_other_route_table (afi_t afi, u_int32_t table_id, | |
458 | vrf_id_t vrf_id); | |
7a4bb9c5 DS |
459 | extern int is_zebra_valid_kernel_table(u_int32_t table_id); |
460 | extern int is_zebra_main_routing_table(u_int32_t table_id); | |
0aabccc0 | 461 | extern int zebra_check_addr (struct prefix *p); |
718e3744 | 462 | |
d24af186 | 463 | /* NOTE: |
464 | * All rib_add_ipv[46]* functions will not just add prefix into RIB, but | |
465 | * also implicitly withdraw equal prefix of same type. */ | |
7c8ff89e | 466 | extern int rib_add_ipv4 (int type, u_short instance, int flags, struct prefix_ipv4 *p, |
7514fb77 | 467 | struct in_addr *gate, struct in_addr *src, |
78104b9b | 468 | unsigned int ifindex, vrf_id_t vrf_id, u_int32_t table_id, |
cddf391b | 469 | u_int32_t, u_char, safi_t); |
718e3744 | 470 | |
cddf391b | 471 | extern int rib_add_ipv4_multipath (struct prefix_ipv4 *, struct rib *, safi_t); |
718e3744 | 472 | |
7c8ff89e | 473 | extern int rib_delete_ipv4 (int type, u_short instance, int flags, struct prefix_ipv4 *p, |
a1ac18c4 | 474 | struct in_addr *gate, unsigned int ifindex, |
78104b9b | 475 | vrf_id_t, u_int32_t, safi_t safi); |
718e3744 | 476 | |
78104b9b | 477 | extern struct rib *rib_match_ipv4 (struct in_addr, vrf_id_t); |
718e3744 | 478 | |
78104b9b | 479 | extern struct rib *rib_lookup_ipv4 (struct prefix_ipv4 *, vrf_id_t); |
718e3744 | 480 | |
78104b9b FL |
481 | extern void rib_update (vrf_id_t); |
482 | extern void rib_update_static (vrf_id_t); | |
a1ac18c4 | 483 | extern void rib_weed_tables (void); |
484 | extern void rib_sweep_route (void); | |
a31c5886 | 485 | extern void rib_close_table (struct route_table *); |
a1ac18c4 | 486 | extern void rib_close (void); |
487 | extern void rib_init (void); | |
7c8ff89e | 488 | extern unsigned long rib_score_proto (u_char proto, u_short instance); |
6e26278c DS |
489 | struct zebra_t; |
490 | extern void rib_queue_add (struct zebra_t *zebra, struct route_node *rn); | |
491 | ||
718e3744 | 492 | |
a1ac18c4 | 493 | extern int |
39db97e4 | 494 | static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname, |
78104b9b | 495 | u_char flags, u_short tag, u_char distance, vrf_id_t vrf_id); |
718e3744 | 496 | |
a1ac18c4 | 497 | extern int |
39db97e4 | 498 | static_delete_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname, |
78104b9b | 499 | u_short tag, u_char distance, vrf_id_t vrf_id); |
718e3744 | 500 | |
501 | #ifdef HAVE_IPV6 | |
a1ac18c4 | 502 | extern int |
7c8ff89e | 503 | rib_add_ipv6 (int type, u_short instance, int flags, struct prefix_ipv6 *p, |
78104b9b FL |
504 | struct in6_addr *gate, unsigned int ifindex, vrf_id_t vrf_id, |
505 | u_int32_t table_id, u_int32_t metric, u_char distance, safi_t safi); | |
718e3744 | 506 | |
a1ac18c4 | 507 | extern int |
7c8ff89e | 508 | rib_delete_ipv6 (int type, u_short instance, int flags, struct prefix_ipv6 *p, |
78104b9b FL |
509 | struct in6_addr *gate, unsigned int ifindex, vrf_id_t vrf_id, |
510 | u_int32_t table_id, safi_t safi); | |
718e3744 | 511 | |
78104b9b | 512 | extern struct rib *rib_lookup_ipv6 (struct in6_addr *, vrf_id_t); |
718e3744 | 513 | |
78104b9b | 514 | extern struct rib *rib_match_ipv6 (struct in6_addr *, vrf_id_t); |
718e3744 | 515 | |
516 | extern struct route_table *rib_table_ipv6; | |
517 | ||
a1ac18c4 | 518 | extern int |
718e3744 | 519 | static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, |
0d9551dc | 520 | const char *ifname, u_char flags, u_short tag, |
78104b9b | 521 | u_char distance, vrf_id_t vrf_id); |
718e3744 | 522 | |
41fc2714 | 523 | extern int |
8a92a8a0 | 524 | rib_add_ipv6_multipath (struct prefix *, struct rib *, safi_t, |
41fc2714 DS |
525 | unsigned long); |
526 | ||
a1ac18c4 | 527 | extern int |
718e3744 | 528 | static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, |
0d9551dc | 529 | const char *ifname, u_short tag, u_char distance, |
78104b9b | 530 | vrf_id_t vrf_id); |
718e3744 | 531 | |
532 | #endif /* HAVE_IPV6 */ | |
533 | ||
9fd92e3c | 534 | extern int rib_gc_dest (struct route_node *rn); |
0915bb0c | 535 | extern struct route_table *rib_tables_iter_next (rib_tables_iter_t *iter); |
9fd92e3c AS |
536 | |
537 | /* | |
538 | * Inline functions. | |
539 | */ | |
540 | ||
1b5ed1b0 AS |
541 | /* |
542 | * rib_table_info | |
543 | */ | |
544 | static inline rib_table_info_t * | |
545 | rib_table_info (struct route_table *table) | |
546 | { | |
547 | return (rib_table_info_t *) table->info; | |
548 | } | |
549 | ||
9fd92e3c AS |
550 | /* |
551 | * rib_dest_from_rnode | |
552 | */ | |
553 | static inline rib_dest_t * | |
554 | rib_dest_from_rnode (struct route_node *rn) | |
555 | { | |
556 | return (rib_dest_t *) rn->info; | |
557 | } | |
558 | ||
559 | /* | |
560 | * rnode_to_ribs | |
561 | * | |
562 | * Returns a pointer to the list of routes corresponding to the given | |
563 | * route_node. | |
564 | */ | |
565 | static inline struct rib * | |
566 | rnode_to_ribs (struct route_node *rn) | |
567 | { | |
568 | rib_dest_t *dest; | |
569 | ||
570 | dest = rib_dest_from_rnode (rn); | |
571 | if (!dest) | |
572 | return NULL; | |
573 | ||
574 | return dest->routes; | |
575 | } | |
576 | ||
577 | /* | |
578 | * rib_dest_prefix | |
579 | */ | |
580 | static inline struct prefix * | |
581 | rib_dest_prefix (rib_dest_t *dest) | |
582 | { | |
583 | return &dest->rnode->p; | |
584 | } | |
585 | ||
586 | /* | |
587 | * rib_dest_af | |
588 | * | |
589 | * Returns the address family that the destination is for. | |
590 | */ | |
591 | static inline u_char | |
592 | rib_dest_af (rib_dest_t *dest) | |
593 | { | |
594 | return dest->rnode->p.family; | |
595 | } | |
596 | ||
597 | /* | |
598 | * rib_dest_table | |
599 | */ | |
600 | static inline struct route_table * | |
601 | rib_dest_table (rib_dest_t *dest) | |
602 | { | |
603 | return dest->rnode->table; | |
604 | } | |
605 | ||
1b5ed1b0 AS |
606 | /* |
607 | * rib_dest_vrf | |
608 | */ | |
b72ede27 | 609 | static inline struct zebra_vrf * |
1b5ed1b0 AS |
610 | rib_dest_vrf (rib_dest_t *dest) |
611 | { | |
b72ede27 | 612 | return rib_table_info (rib_dest_table (dest))->zvrf; |
1b5ed1b0 AS |
613 | } |
614 | ||
0915bb0c AS |
615 | /* |
616 | * rib_tables_iter_init | |
617 | */ | |
618 | static inline void | |
619 | rib_tables_iter_init (rib_tables_iter_t *iter) | |
620 | ||
621 | { | |
622 | memset (iter, 0, sizeof (*iter)); | |
623 | iter->state = RIB_TABLES_ITER_S_INIT; | |
624 | } | |
625 | ||
626 | /* | |
627 | * rib_tables_iter_started | |
628 | * | |
629 | * Returns TRUE if this iterator has started iterating over the set of | |
630 | * tables. | |
631 | */ | |
632 | static inline int | |
633 | rib_tables_iter_started (rib_tables_iter_t *iter) | |
634 | { | |
635 | return iter->state != RIB_TABLES_ITER_S_INIT; | |
636 | } | |
637 | ||
638 | /* | |
639 | * rib_tables_iter_cleanup | |
640 | */ | |
641 | static inline void | |
642 | rib_tables_iter_cleanup (rib_tables_iter_t *iter) | |
643 | { | |
644 | iter->state = RIB_TABLES_ITER_S_DONE; | |
645 | } | |
646 | ||
718e3744 | 647 | #endif /*_ZEBRA_RIB_H */ |