2 * Routing Information Base header
3 * Copyright (C) 1997 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
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
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.
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
28 #define DISTANCE_INFINITY 255
30 /* Routing information base. */
36 #endif /* HAVE_IPV6 */
41 /* Status Flags for the *route_node*, but kept in the head RIB.. */
43 #define RIB_ROUTE_QUEUED(x) (1 << (x))
49 /* Nexthop structure */
50 struct nexthop
*nexthop
;
58 /* Type fo this route. */
61 /* Which routing table */
70 /* Flags of this route.
71 * This flag's definition is in lib/zebra.h ZEBRA_FLAG_* and is exposed
72 * to clients via Zserv
76 /* RIB internal status */
78 #define RIB_ENTRY_REMOVED (1 << 0)
80 /* Nexthop information. */
82 u_char nexthop_active_num
;
83 u_char nexthop_fib_num
;
86 /* meta-queue structure:
87 * sub-queue 0: connected, kernel
89 * sub-queue 2: RIP, RIPng, OSPF, OSPF6, IS-IS
90 * sub-queue 3: iBGP, eBGP
91 * sub-queue 4: any other origin (if any)
96 struct list
*subq
[MQ_SIZE
];
97 u_int32_t size
; /* sum of lengths of all subqueues */
100 /* Static route information. */
103 /* For linked list. */
104 struct static_ipv4
*prev
;
105 struct static_ipv4
*next
;
107 /* Administrative distance. */
110 /* Flag for this static route's type. */
112 #define STATIC_IPV4_GATEWAY 1
113 #define STATIC_IPV4_IFNAME 2
114 #define STATIC_IPV4_BLACKHOLE 3
126 see ZEBRA_FLAG_REJECT
132 /* Static route information. */
135 /* For linked list. */
136 struct static_ipv6
*prev
;
137 struct static_ipv6
*next
;
139 /* Administrative distance. */
142 /* Flag for this static route's type. */
144 #define STATIC_IPV6_GATEWAY 1
145 #define STATIC_IPV6_GATEWAY_IFNAME 2
146 #define STATIC_IPV6_IFNAME 3
149 struct in6_addr ipv6
;
155 see ZEBRA_FLAG_REJECT
159 #endif /* HAVE_IPV6 */
163 NEXTHOP_TYPE_IFINDEX
= 1, /* Directly connected. */
164 NEXTHOP_TYPE_IFNAME
, /* Interface route. */
165 NEXTHOP_TYPE_IPV4
, /* IPv4 nexthop. */
166 NEXTHOP_TYPE_IPV4_IFINDEX
, /* IPv4 nexthop with ifindex. */
167 NEXTHOP_TYPE_IPV4_IFNAME
, /* IPv4 nexthop with ifname. */
168 NEXTHOP_TYPE_IPV6
, /* IPv6 nexthop. */
169 NEXTHOP_TYPE_IPV6_IFINDEX
, /* IPv6 nexthop with ifindex. */
170 NEXTHOP_TYPE_IPV6_IFNAME
, /* IPv6 nexthop with ifname. */
171 NEXTHOP_TYPE_BLACKHOLE
, /* Null0 nexthop. */
174 /* Nexthop structure. */
177 struct nexthop
*next
;
178 struct nexthop
*prev
;
180 /* Interface index. */
182 unsigned int ifindex
;
184 enum nexthop_types_t type
;
187 #define NEXTHOP_FLAG_ACTIVE (1 << 0) /* This nexthop is alive. */
188 #define NEXTHOP_FLAG_FIB (1 << 1) /* FIB nexthop. */
189 #define NEXTHOP_FLAG_RECURSIVE (1 << 2) /* Recursive nexthop. */
191 /* Nexthop address or interface name. */
194 /* Recursive lookup nexthop. */
196 unsigned int rifindex
;
201 /* Routing table instance. */
204 /* Identifier. This is same as routing table vector index. */
207 /* Routing table name. */
213 /* FIB identifier. */
217 struct route_table
*table
[AFI_MAX
][SAFI_MAX
];
219 /* Static route configuration. */
220 struct route_table
*stable
[AFI_MAX
][SAFI_MAX
];
223 extern struct nexthop
*nexthop_ifindex_add (struct rib
*, unsigned int);
224 extern struct nexthop
*nexthop_ifname_add (struct rib
*, char *);
225 extern struct nexthop
*nexthop_blackhole_add (struct rib
*);
226 extern struct nexthop
*nexthop_ipv4_add (struct rib
*, struct in_addr
*,
228 extern void rib_lookup_and_dump (struct prefix_ipv4
*);
229 extern void rib_lookup_and_pushup (struct prefix_ipv4
*);
230 extern void rib_dump (const char *, const struct prefix_ipv4
*, const struct rib
*);
231 extern int rib_lookup_ipv4_route (struct prefix_ipv4
*, union sockunion
*);
232 #define ZEBRA_RIB_LOOKUP_ERROR -1
233 #define ZEBRA_RIB_FOUND_EXACT 0
234 #define ZEBRA_RIB_FOUND_NOGATE 1
235 #define ZEBRA_RIB_FOUND_CONNECTED 2
236 #define ZEBRA_RIB_NOTFOUND 3
239 extern struct nexthop
*nexthop_ipv6_add (struct rib
*, struct in6_addr
*);
240 #endif /* HAVE_IPV6 */
242 extern struct vrf
*vrf_lookup (u_int32_t
);
243 extern struct route_table
*vrf_table (afi_t afi
, safi_t safi
, u_int32_t id
);
244 extern struct route_table
*vrf_static_table (afi_t afi
, safi_t safi
, u_int32_t id
);
247 * All rib_add_ipv[46]* functions will not just add prefix into RIB, but
248 * also implicitly withdraw equal prefix of same type. */
249 extern int rib_add_ipv4 (int type
, int flags
, struct prefix_ipv4
*p
,
250 struct in_addr
*gate
, struct in_addr
*src
,
251 unsigned int ifindex
, u_int32_t vrf_id
,
254 extern int rib_add_ipv4_multipath (struct prefix_ipv4
*, struct rib
*);
256 extern int rib_delete_ipv4 (int type
, int flags
, struct prefix_ipv4
*p
,
257 struct in_addr
*gate
, unsigned int ifindex
,
260 extern struct rib
*rib_match_ipv4 (struct in_addr
);
262 extern struct rib
*rib_lookup_ipv4 (struct prefix_ipv4
*);
264 extern void rib_update (void);
265 extern void rib_weed_tables (void);
266 extern void rib_sweep_route (void);
267 extern void rib_close (void);
268 extern void rib_init (void);
271 static_add_ipv4 (struct prefix
*p
, struct in_addr
*gate
, const char *ifname
,
272 u_char flags
, u_char distance
, u_int32_t vrf_id
);
275 static_delete_ipv4 (struct prefix
*p
, struct in_addr
*gate
, const char *ifname
,
276 u_char distance
, u_int32_t vrf_id
);
280 rib_add_ipv6 (int type
, int flags
, struct prefix_ipv6
*p
,
281 struct in6_addr
*gate
, unsigned int ifindex
, u_int32_t vrf_id
,
282 u_int32_t metric
, u_char distance
);
285 rib_delete_ipv6 (int type
, int flags
, struct prefix_ipv6
*p
,
286 struct in6_addr
*gate
, unsigned int ifindex
, u_int32_t vrf_id
);
288 extern struct rib
*rib_lookup_ipv6 (struct in6_addr
*);
290 extern struct rib
*rib_match_ipv6 (struct in6_addr
*);
292 extern struct route_table
*rib_table_ipv6
;
295 static_add_ipv6 (struct prefix
*p
, u_char type
, struct in6_addr
*gate
,
296 const char *ifname
, u_char flags
, u_char distance
,
300 static_delete_ipv6 (struct prefix
*p
, u_char type
, struct in6_addr
*gate
,
301 const char *ifname
, u_char distance
, u_int32_t vrf_id
);
303 #endif /* HAVE_IPV6 */
305 #endif /*_ZEBRA_RIB_H */