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
26 #define DISTANCE_INFINITY 255
28 /* Routing information base. */
35 /* Type fo this route. */
38 /* Which routing table */
44 /* Flags of this route. This flag's definition is in lib/zebra.h
57 /* Nexthop information. */
59 u_char nexthop_active_num
;
60 u_char nexthop_fib_num
;
62 struct nexthop
*nexthop
;
65 /* Static route information. */
68 /* For linked list. */
69 struct static_ipv4
*prev
;
70 struct static_ipv4
*next
;
72 /* Administrative distance. */
75 /* Flag for this static route's type. */
77 #define STATIC_IPV4_GATEWAY 1
78 #define STATIC_IPV4_IFNAME 2
79 #define STATIC_IPV4_BLACKHOLE 3
90 /* Static route information. */
93 /* For linked list. */
94 struct static_ipv6
*prev
;
95 struct static_ipv6
*next
;
97 /* Administrative distance. */
100 /* Flag for this static route's type. */
102 #define STATIC_IPV6_GATEWAY 1
103 #define STATIC_IPV6_GATEWAY_IFNAME 2
104 #define STATIC_IPV6_IFNAME 3
107 struct in6_addr ipv6
;
110 #endif /* HAVE_IPV6 */
112 /* Nexthop structure. */
115 struct nexthop
*next
;
116 struct nexthop
*prev
;
119 #define NEXTHOP_TYPE_IFINDEX 1 /* Directly connected. */
120 #define NEXTHOP_TYPE_IFNAME 2 /* Interface route. */
121 #define NEXTHOP_TYPE_IPV4 3 /* IPv4 nexthop. */
122 #define NEXTHOP_TYPE_IPV4_IFINDEX 4 /* IPv4 nexthop with ifindex. */
123 #define NEXTHOP_TYPE_IPV4_IFNAME 5 /* IPv4 nexthop with ifname. */
124 #define NEXTHOP_TYPE_IPV6 6 /* IPv6 nexthop. */
125 #define NEXTHOP_TYPE_IPV6_IFINDEX 7 /* IPv6 nexthop with ifindex. */
126 #define NEXTHOP_TYPE_IPV6_IFNAME 8 /* IPv6 nexthop with ifname. */
127 #define NEXTHOP_TYPE_BLACKHOLE 9 /* Null0 nexthop. */
130 #define NEXTHOP_FLAG_ACTIVE (1 << 0) /* This nexthop is alive. */
131 #define NEXTHOP_FLAG_FIB (1 << 1) /* FIB nexthop. */
132 #define NEXTHOP_FLAG_RECURSIVE (1 << 2) /* Recursive nexthop. */
134 /* Interface index. */
135 unsigned int ifindex
;
138 /* Nexthop address or interface name. */
143 struct in6_addr ipv6
;
144 #endif /* HAVE_IPV6*/
147 /* Recursive lookup nexthop. */
149 unsigned int rifindex
;
154 struct in6_addr ipv6
;
155 #endif /* HAVE_IPV6 */
158 struct nexthop
*indirect
;
161 /* Routing table instance. */
164 /* Identifier. This is same as routing table vector index. */
167 /* Routing table name. */
173 /* FIB identifier. */
177 struct route_table
*table
[AFI_MAX
][SAFI_MAX
];
179 /* Static route configuration. */
180 struct route_table
*stable
[AFI_MAX
][SAFI_MAX
];
183 struct nexthop
*nexthop_ifindex_add (struct rib
*, unsigned int);
184 struct nexthop
*nexthop_ifname_add (struct rib
*, char *);
185 struct nexthop
*nexthop_blackhole_add (struct rib
*);
186 struct nexthop
*nexthop_ipv4_add (struct rib
*, struct in_addr
*);
188 struct nexthop
*nexthop_ipv6_add (struct rib
*, struct in6_addr
*);
189 #endif /* HAVE_IPV6 */
191 struct vrf
*vrf_lookup (u_int32_t
);
192 struct route_table
*vrf_table (afi_t afi
, safi_t safi
, u_int32_t id
);
193 struct route_table
*vrf_static_table (afi_t afi
, safi_t safi
, u_int32_t id
);
196 rib_add_ipv4 (int type
, int flags
, struct prefix_ipv4
*p
,
197 struct in_addr
*gate
, unsigned int ifindex
, u_int32_t vrf_id
,
201 rib_add_ipv4_multipath (struct prefix_ipv4
*, struct rib
*);
204 rib_delete_ipv4 (int type
, int flags
, struct prefix_ipv4
*p
,
205 struct in_addr
*gate
, unsigned int ifindex
, u_int32_t
);
208 rib_match_ipv4 (struct in_addr
);
211 rib_lookup_ipv4 (struct prefix_ipv4
*);
214 void rib_sweep_route ();
219 static_add_ipv4 (struct prefix
*p
, struct in_addr
*gate
, char *ifname
,
220 u_char distance
, u_int32_t vrf_id
);
223 static_delete_ipv4 (struct prefix
*p
, struct in_addr
*gate
, char *ifname
,
224 u_char distance
, u_int32_t vrf_id
);
228 rib_add_ipv6 (int type
, int flags
, struct prefix_ipv6
*p
,
229 struct in6_addr
*gate
, unsigned int ifindex
, u_int32_t vrf_id
);
232 rib_delete_ipv6 (int type
, int flags
, struct prefix_ipv6
*p
,
233 struct in6_addr
*gate
, unsigned int ifindex
, u_int32_t vrf_id
);
235 struct rib
*rib_lookup_ipv6 (struct in6_addr
*);
237 struct rib
*rib_match_ipv6 (struct in6_addr
*);
239 extern struct route_table
*rib_table_ipv6
;
242 static_add_ipv6 (struct prefix
*p
, u_char type
, struct in6_addr
*gate
,
243 char *ifname
, u_char distance
, u_int32_t vrf_id
);
246 static_delete_ipv6 (struct prefix
*p
, u_char type
, struct in6_addr
*gate
,
247 char *ifname
, u_char distance
, u_int32_t vrf_id
);
249 #endif /* HAVE_IPV6 */
251 #endif /*_ZEBRA_RIB_H */