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 (1 << 0)
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 /* Static route information. */
89 /* For linked list. */
90 struct static_ipv4
*prev
;
91 struct static_ipv4
*next
;
93 /* Administrative distance. */
96 /* Flag for this static route's type. */
98 #define STATIC_IPV4_GATEWAY 1
99 #define STATIC_IPV4_IFNAME 2
100 #define STATIC_IPV4_BLACKHOLE 3
112 see ZEBRA_FLAG_REJECT
118 /* Static route information. */
121 /* For linked list. */
122 struct static_ipv6
*prev
;
123 struct static_ipv6
*next
;
125 /* Administrative distance. */
128 /* Flag for this static route's type. */
130 #define STATIC_IPV6_GATEWAY 1
131 #define STATIC_IPV6_GATEWAY_IFNAME 2
132 #define STATIC_IPV6_IFNAME 3
135 struct in6_addr ipv6
;
141 see ZEBRA_FLAG_REJECT
145 #endif /* HAVE_IPV6 */
149 NEXTHOP_TYPE_IFINDEX
= 1, /* Directly connected. */
150 NEXTHOP_TYPE_IFNAME
, /* Interface route. */
151 NEXTHOP_TYPE_IPV4
, /* IPv4 nexthop. */
152 NEXTHOP_TYPE_IPV4_IFINDEX
, /* IPv4 nexthop with ifindex. */
153 NEXTHOP_TYPE_IPV4_IFNAME
, /* IPv4 nexthop with ifname. */
154 NEXTHOP_TYPE_IPV6
, /* IPv6 nexthop. */
155 NEXTHOP_TYPE_IPV6_IFINDEX
, /* IPv6 nexthop with ifindex. */
156 NEXTHOP_TYPE_IPV6_IFNAME
, /* IPv6 nexthop with ifname. */
157 NEXTHOP_TYPE_BLACKHOLE
, /* Null0 nexthop. */
160 /* Nexthop structure. */
163 struct nexthop
*next
;
164 struct nexthop
*prev
;
166 /* Interface index. */
168 unsigned int ifindex
;
170 enum nexthop_types_t type
;
173 #define NEXTHOP_FLAG_ACTIVE (1 << 0) /* This nexthop is alive. */
174 #define NEXTHOP_FLAG_FIB (1 << 1) /* FIB nexthop. */
175 #define NEXTHOP_FLAG_RECURSIVE (1 << 2) /* Recursive nexthop. */
177 /* Nexthop address or interface name. */
180 /* Recursive lookup nexthop. */
182 unsigned int rifindex
;
187 /* Routing table instance. */
190 /* Identifier. This is same as routing table vector index. */
193 /* Routing table name. */
199 /* FIB identifier. */
203 struct route_table
*table
[AFI_MAX
][SAFI_MAX
];
205 /* Static route configuration. */
206 struct route_table
*stable
[AFI_MAX
][SAFI_MAX
];
209 extern struct nexthop
*nexthop_ifindex_add (struct rib
*, unsigned int);
210 extern struct nexthop
*nexthop_ifname_add (struct rib
*, char *);
211 extern struct nexthop
*nexthop_blackhole_add (struct rib
*);
212 extern struct nexthop
*nexthop_ipv4_add (struct rib
*, struct in_addr
*,
214 extern void rib_lookup_and_dump (struct prefix_ipv4
*);
215 extern void rib_dump (const char *, const struct prefix_ipv4
*, const struct rib
*);
216 extern int rib_lookup_ipv4_route (struct prefix_ipv4
*, union sockunion
*);
217 #define ZEBRA_RIB_LOOKUP_ERROR -1
218 #define ZEBRA_RIB_FOUND_EXACT 0
219 #define ZEBRA_RIB_FOUND_NOGATE 1
220 #define ZEBRA_RIB_FOUND_CONNECTED 2
221 #define ZEBRA_RIB_NOTFOUND 3
224 extern struct nexthop
*nexthop_ipv6_add (struct rib
*, struct in6_addr
*);
225 #endif /* HAVE_IPV6 */
227 extern struct vrf
*vrf_lookup (u_int32_t
);
228 extern struct route_table
*vrf_table (afi_t afi
, safi_t safi
, u_int32_t id
);
229 extern struct route_table
*vrf_static_table (afi_t afi
, safi_t safi
, u_int32_t id
);
232 * All rib_add_ipv[46]* functions will not just add prefix into RIB, but
233 * also implicitly withdraw equal prefix of same type. */
234 extern int rib_add_ipv4 (int type
, int flags
, struct prefix_ipv4
*p
,
235 struct in_addr
*gate
, struct in_addr
*src
,
236 unsigned int ifindex
, u_int32_t vrf_id
,
239 extern int rib_add_ipv4_multipath (struct prefix_ipv4
*, struct rib
*);
241 extern int rib_delete_ipv4 (int type
, int flags
, struct prefix_ipv4
*p
,
242 struct in_addr
*gate
, unsigned int ifindex
,
245 extern struct rib
*rib_match_ipv4 (struct in_addr
);
247 extern struct rib
*rib_lookup_ipv4 (struct prefix_ipv4
*);
249 extern void rib_update (void);
250 extern void rib_weed_tables (void);
251 extern void rib_sweep_route (void);
252 extern void rib_close (void);
253 extern void rib_init (void);
256 static_add_ipv4 (struct prefix
*p
, struct in_addr
*gate
, const char *ifname
,
257 u_char flags
, u_char distance
, u_int32_t vrf_id
);
260 static_delete_ipv4 (struct prefix
*p
, struct in_addr
*gate
, const char *ifname
,
261 u_char distance
, u_int32_t vrf_id
);
265 rib_add_ipv6 (int type
, int flags
, struct prefix_ipv6
*p
,
266 struct in6_addr
*gate
, unsigned int ifindex
, u_int32_t vrf_id
,
267 u_int32_t metric
, u_char distance
);
270 rib_delete_ipv6 (int type
, int flags
, struct prefix_ipv6
*p
,
271 struct in6_addr
*gate
, unsigned int ifindex
, u_int32_t vrf_id
);
273 extern struct rib
*rib_lookup_ipv6 (struct in6_addr
*);
275 extern struct rib
*rib_match_ipv6 (struct in6_addr
*);
277 extern struct route_table
*rib_table_ipv6
;
280 static_add_ipv6 (struct prefix
*p
, u_char type
, struct in6_addr
*gate
,
281 const char *ifname
, u_char flags
, u_char distance
,
285 static_delete_ipv6 (struct prefix
*p
, u_char type
, struct in6_addr
*gate
,
286 const char *ifname
, u_char distance
, u_int32_t vrf_id
);
288 #endif /* HAVE_IPV6 */
290 #endif /*_ZEBRA_RIB_H */