Tomato 1.28
[tomato.git] / release / src / router / zebra / lib / zebra.h
blob410be95671a2af8b9d22659629685dd860910abd
1 /* Zebra common header.
3 * This file is part of GNU Zebra.
5 * GNU Zebra is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2, or (at your option) any
8 * later version.
10 * GNU Zebra is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Zebra; see the file COPYING. If not, write to the Free
17 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 * 02111-1307, USA.
21 #ifndef _ZEBRA_H
22 #define _ZEBRA_H
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif /* HAVE_CONFIG_H */
28 #ifdef SUNOS_5
29 #define _XPG4_2
30 #define __EXTENSIONS__
31 #endif /* SUNOS_5 */
33 #include <unistd.h>
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <ctype.h>
37 #include <errno.h>
38 #include <fcntl.h>
39 #include <signal.h>
40 #include <string.h>
41 #ifdef HAVE_STROPTS_H
42 #include <stropts.h>
43 #endif /* HAVE_STROPTS_H */
44 #include <sys/fcntl.h>
45 #ifdef HAVE_SYS_SELECT_H
46 #include <sys/select.h>
47 #endif /* HAVE_SYS_SELECT_H */
48 #include <sys/stat.h>
49 #include <sys/time.h>
50 #include <sys/types.h>
51 #include <sys/param.h>
52 #ifdef HAVE_SYS_SYSCTL_H
53 #include <sys/sysctl.h>
54 #endif /* HAVE_SYS_SYSCTL_H */
55 #include <sys/ioctl.h>
56 #ifdef HAVE_SYS_CONF_H
57 #include <sys/conf.h>
58 #endif /* HAVE_SYS_CONF_H */
59 #ifdef HAVE_SYS_KSYM_H
60 #include <sys/ksym.h>
61 #endif /* HAVE_SYS_KSYM_H */
62 #include <syslog.h>
63 #include <time.h>
64 #include <sys/uio.h>
65 #include <sys/utsname.h>
67 /* machine dependent includes */
68 #ifdef SUNOS_5
69 #include <limits.h>
70 #include <strings.h>
71 #endif /* SUNOS_5 */
73 /* machine dependent includes */
74 #ifdef HAVE_LINUX_VERSION_H
75 #include <linux/version.h>
76 #endif /* HAVE_LINUX_VERSION_H */
78 #ifdef HAVE_ASM_TYPES_H
79 #include <asm/types.h>
80 #endif /* HAVE_ASM_TYPES_H */
82 /* misc include group */
83 #include <stdarg.h>
84 #include <assert.h>
86 /* network include group */
88 #include <sys/socket.h>
90 #ifdef HAVE_SYS_SOCKIO_H
91 #include <sys/sockio.h>
92 #endif /* HAVE_SYS_SOCKIO_H */
94 #ifdef HAVE_NETINET_IN_H
95 #include <netinet/in.h>
96 #endif /* HAVE_NETINET_IN_H */
97 #include <netinet/in_systm.h>
98 #include <netinet/ip.h>
99 #include <netinet/tcp.h>
101 #ifdef HAVE_NET_NETOPT_H
102 #include <net/netopt.h>
103 #endif /* HAVE_NET_NETOPT_H */
105 #include <net/if.h>
107 #ifdef HAVE_NET_IF_DL_H
108 #include <net/if_dl.h>
109 #endif /* HAVE_NET_IF_DL_H */
111 #ifdef HAVE_NET_IF_VAR_H
112 #include <net/if_var.h>
113 #endif /* HAVE_NET_IF_VAR_H */
115 #include <net/route.h>
117 #ifdef HAVE_LINUX_RTNETLINK_H
118 #include <linux/netlink.h>
119 #include <linux/rtnetlink.h>
120 #else
121 #define RT_TABLE_MAIN 0
122 #endif /* HAVE_LINUX_RTNETLINK_H */
124 #ifdef HAVE_NETDB_H
125 #include <netdb.h>
126 #endif /* HAVE_NETDB_H */
128 #include <arpa/inet.h>
129 #include <arpa/telnet.h>
131 #ifdef HAVE_INET_ND_H
132 #include <inet/nd.h>
133 #endif /* HAVE_INET_ND_H */
135 #ifdef HAVE_NETINET_IN_VAR_H
136 #include <netinet/in_var.h>
137 #endif /* HAVE_NETINET_IN_VAR_H */
139 #ifdef HAVE_NETINET_IN6_VAR_H
140 #include <netinet/in6_var.h>
141 #endif /* HAVE_NETINET_IN6_VAR_H */
143 #ifdef HAVE_NETINET6_IN_H
144 #include <netinet6/in.h>
145 #endif /* HAVE_NETINET6_IN_H */
148 #ifdef HAVE_NETINET6_IP6_H
149 #include <netinet6/ip6.h>
150 #endif /* HAVE_NETINET6_IP6_H */
152 #ifdef HAVE_NETINET_ICMP6_H
153 #include <netinet/icmp6.h>
154 #endif /* HAVE_NETINET_ICMP6_H */
156 #ifdef HAVE_LIBUTIL_H
157 #include <libutil.h>
158 #endif /* HAVE_LIBUTIL_H */
160 #ifdef BSDI_NRL
162 #ifdef HAVE_NETINET6_IN6_H
163 #include <netinet6/in6.h>
164 #endif /* HAVE_NETINET6_IN6_H */
166 #ifdef NRL
167 #include <netinet6/in6.h>
168 #endif /* NRL */
170 #define IN6_ARE_ADDR_EQUAL IN6_IS_ADDR_EQUAL
172 /* XXX:
173 Stupid BSD/OS 4.0 has lost belows defines,
174 it should appear at /usr/include/sys/socket.h
176 #define CMSG_ALIGN(n) (((n) + 3) & ~3)
177 #define CMSG_SPACE(l) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(l))
178 #define CMSG_LEN(l) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (l))
180 #endif /* BSDI_NRL */
183 The definition of struct in_pktinfo is missing in old version of GLIBC 2.1
184 (Redhat 6.1)
186 #if defined (GNU_LINUX) && ! defined (HAVE_INPKTINFO)
187 struct in_pktinfo
189 int ipi_ifindex;
190 struct in_addr ipi_spec_dst;
191 struct in_addr ipi_addr;
193 #endif
196 /* For old definition. */
197 #ifndef IN6_ARE_ADDR_EQUAL
198 #define IN6_ARE_ADDR_EQUAL IN6_IS_ADDR_EQUAL
199 #endif /* IN6_ARE_ADDR_EQUAL */
201 /* Zebra message types. */
202 #define ZEBRA_INTERFACE_ADD 1
203 #define ZEBRA_INTERFACE_DELETE 2
204 #define ZEBRA_INTERFACE_ADDRESS_ADD 3
205 #define ZEBRA_INTERFACE_ADDRESS_DELETE 4
206 #define ZEBRA_INTERFACE_UP 5
207 #define ZEBRA_INTERFACE_DOWN 6
208 #define ZEBRA_IPV4_ROUTE_ADD 7
209 #define ZEBRA_IPV4_ROUTE_DELETE 8
210 #define ZEBRA_IPV6_ROUTE_ADD 9
211 #define ZEBRA_IPV6_ROUTE_DELETE 10
212 #define ZEBRA_REDISTRIBUTE_ADD 11
213 #define ZEBRA_REDISTRIBUTE_DELETE 12
214 #define ZEBRA_REDISTRIBUTE_DEFAULT_ADD 13
215 #define ZEBRA_REDISTRIBUTE_DEFAULT_DELETE 14
216 #define ZEBRA_IPV4_NEXTHOP_LOOKUP 15
217 #define ZEBRA_IPV6_NEXTHOP_LOOKUP 16
218 #define ZEBRA_IPV4_IMPORT_LOOKUP 17
219 #define ZEBRA_IPV6_IMPORT_LOOKUP 18
220 #define ZEBRA_MESSAGE_MAX 19
222 /* Zebra route's types. */
223 #define ZEBRA_ROUTE_SYSTEM 0
224 #define ZEBRA_ROUTE_KERNEL 1
225 #define ZEBRA_ROUTE_CONNECT 2
226 #define ZEBRA_ROUTE_STATIC 3
227 #define ZEBRA_ROUTE_RIP 4
228 #define ZEBRA_ROUTE_RIPNG 5
229 #define ZEBRA_ROUTE_OSPF 6
230 #define ZEBRA_ROUTE_OSPF6 7
231 #define ZEBRA_ROUTE_BGP 8
232 #define ZEBRA_ROUTE_MAX 9
234 /* Zebra's family types. */
235 #define ZEBRA_FAMILY_IPV4 1
236 #define ZEBRA_FAMILY_IPV6 2
237 #define ZEBRA_FAMILY_MAX 3
239 /* Error codes of zebra. */
240 #define ZEBRA_ERR_RTEXIST -1
241 #define ZEBRA_ERR_RTUNREACH -2
242 #define ZEBRA_ERR_EPERM -3
243 #define ZEBRA_ERR_RTNOEXIST -4
245 /* Zebra message flags */
246 #define ZEBRA_FLAG_INTERNAL 0x01
247 #define ZEBRA_FLAG_SELFROUTE 0x02
248 #define ZEBRA_FLAG_BLACKHOLE 0x04
249 #define ZEBRA_FLAG_IBGP 0x08
250 #define ZEBRA_FLAG_SELECTED 0x10
251 #define ZEBRA_FLAG_CHANGED 0x20
252 #define ZEBRA_FLAG_STATIC 0x40
254 /* Zebra nexthop flags. */
255 #define ZEBRA_NEXTHOP_IFINDEX 1
256 #define ZEBRA_NEXTHOP_IFNAME 2
257 #define ZEBRA_NEXTHOP_IPV4 3
258 #define ZEBRA_NEXTHOP_IPV4_IFINDEX 4
259 #define ZEBRA_NEXTHOP_IPV4_IFNAME 5
260 #define ZEBRA_NEXTHOP_IPV6 6
261 #define ZEBRA_NEXTHOP_IPV6_IFINDEX 7
262 #define ZEBRA_NEXTHOP_IPV6_IFNAME 8
264 #ifndef INADDR_LOOPBACK
265 #define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */
266 #endif
268 /* Address family numbers from RFC1700. */
269 #define AFI_IP 1
270 #define AFI_IP6 2
271 #define AFI_MAX 3
273 /* Subsequent Address Family Identifier. */
274 #define SAFI_UNICAST 1
275 #define SAFI_MULTICAST 2
276 #define SAFI_UNICAST_MULTICAST 3
277 #define SAFI_MPLS_VPN 4
278 #define SAFI_MAX 5
280 /* Filter direction. */
281 #define FILTER_IN 0
282 #define FILTER_OUT 1
283 #define FILTER_MAX 2
285 /* Default Administrative Distance of each protocol. */
286 #define ZEBRA_KERNEL_DISTANCE_DEFAULT 0
287 #define ZEBRA_CONNECT_DISTANCE_DEFAULT 0
288 #define ZEBRA_STATIC_DISTANCE_DEFAULT 1
289 #define ZEBRA_RIP_DISTANCE_DEFAULT 120
290 #define ZEBRA_RIPNG_DISTANCE_DEFAULT 120
291 #define ZEBRA_OSPF_DISTANCE_DEFAULT 110
292 #define ZEBRA_OSPF6_DISTANCE_DEFAULT 110
293 #define ZEBRA_IBGP_DISTANCE_DEFAULT 200
294 #define ZEBRA_EBGP_DISTANCE_DEFAULT 20
296 /* Flag manipulation macros. */
297 #define CHECK_FLAG(V,F) ((V) & (F))
298 #define SET_FLAG(V,F) (V) = (V) | (F)
299 #define UNSET_FLAG(V,F) (V) = (V) & ~(F)
301 /* AFI and SAFI type. */
302 typedef u_int16_t afi_t;
303 typedef u_char safi_t;
305 /* Zebra types. */
306 typedef u_int16_t zebra_size_t;
307 typedef u_int8_t zebra_command_t;
309 #endif /* _ZEBRA_H */