1 /* Zebra common header.
2 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 #endif /* HAVE_CONFIG_H */
30 #define __EXTENSIONS__
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 */
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
58 #endif /* HAVE_SYS_CONF_H */
59 #ifdef HAVE_SYS_KSYM_H
61 #endif /* HAVE_SYS_KSYM_H */
65 #include <sys/utsname.h>
67 #include <sys/resource.h>
68 #endif /* HAVE_RUSAGE */
70 /* machine dependent includes */
76 /* machine dependent includes */
77 #ifdef HAVE_LINUX_VERSION_H
78 #include <linux/version.h>
79 #endif /* HAVE_LINUX_VERSION_H */
81 #ifdef HAVE_ASM_TYPES_H
82 #include <asm/types.h>
83 #endif /* HAVE_ASM_TYPES_H */
85 /* misc include group */
89 /* network include group */
91 #include <sys/socket.h>
93 #ifdef HAVE_SYS_SOCKIO_H
94 #include <sys/sockio.h>
95 #endif /* HAVE_SYS_SOCKIO_H */
97 #ifdef HAVE_NETINET_IN_H
98 #include <netinet/in.h>
99 #endif /* HAVE_NETINET_IN_H */
100 #include <netinet/in_systm.h>
101 #include <netinet/ip.h>
102 #include <netinet/tcp.h>
104 #ifdef HAVE_NET_NETOPT_H
105 #include <net/netopt.h>
106 #endif /* HAVE_NET_NETOPT_H */
110 #ifdef HAVE_NET_IF_DL_H
111 #include <net/if_dl.h>
112 #endif /* HAVE_NET_IF_DL_H */
114 #ifdef HAVE_NET_IF_VAR_H
115 #include <net/if_var.h>
116 #endif /* HAVE_NET_IF_VAR_H */
118 #include <net/route.h>
121 #include <linux/netlink.h>
122 #include <linux/rtnetlink.h>
124 #define RT_TABLE_MAIN 0
125 #endif /* HAVE_NETLINK */
129 #endif /* HAVE_NETDB_H */
131 #include <arpa/inet.h>
132 #include <arpa/telnet.h>
134 #ifdef HAVE_INET_ND_H
136 #endif /* HAVE_INET_ND_H */
138 #ifdef HAVE_NETINET_IN_VAR_H
139 #include <netinet/in_var.h>
140 #endif /* HAVE_NETINET_IN_VAR_H */
142 #ifdef HAVE_NETINET_IN6_VAR_H
143 #include <netinet/in6_var.h>
144 #endif /* HAVE_NETINET_IN6_VAR_H */
146 #ifdef HAVE_NETINET6_IN_H
147 #include <netinet6/in.h>
148 #endif /* HAVE_NETINET6_IN_H */
151 #ifdef HAVE_NETINET6_IP6_H
152 #include <netinet6/ip6.h>
153 #endif /* HAVE_NETINET6_IP6_H */
155 #ifdef HAVE_NETINET_ICMP6_H
156 #include <netinet/icmp6.h>
157 #endif /* HAVE_NETINET_ICMP6_H */
159 #ifdef HAVE_NETINET6_ND6_H
160 #include <netinet6/nd6.h>
161 #endif /* HAVE_NETINET6_ND6_H */
163 #ifdef HAVE_LIBUTIL_H
165 #endif /* HAVE_LIBUTIL_H */
169 #ifdef HAVE_NETINET6_IN6_H
170 #include <netinet6/in6.h>
171 #endif /* HAVE_NETINET6_IN6_H */
174 #include <netinet6/in6.h>
177 #define IN6_ARE_ADDR_EQUAL IN6_IS_ADDR_EQUAL
179 /* BSD/OS 4.0 has lost belows defines, it should appear at
180 /usr/include/sys/socket.h. */
181 #define CMSG_ALIGN(n) (((n) + 3) & ~3)
182 #define CMSG_SPACE(l) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(l))
183 #define CMSG_LEN(l) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (l))
185 #endif /* BSDI_NRL */
187 /* The definition of struct in_pktinfo is missing in old version of
188 GLIBC 2.1 (Redhat 6.1). */
189 #if defined (GNU_LINUX) && ! defined (HAVE_INPKTINFO)
193 struct in_addr ipi_spec_dst;
194 struct in_addr ipi_addr;
198 /* For old definition. */
199 #ifndef IN6_ARE_ADDR_EQUAL
200 #define IN6_ARE_ADDR_EQUAL IN6_IS_ADDR_EQUAL
201 #endif /* IN6_ARE_ADDR_EQUAL */
203 /* Zebra message types. */
204 #define ZEBRA_INTERFACE_ADD 1
205 #define ZEBRA_INTERFACE_DELETE 2
206 #define ZEBRA_INTERFACE_ADDRESS_ADD 3
207 #define ZEBRA_INTERFACE_ADDRESS_DELETE 4
208 #define ZEBRA_INTERFACE_UP 5
209 #define ZEBRA_INTERFACE_DOWN 6
210 #define ZEBRA_IPV4_ROUTE_ADD 7
211 #define ZEBRA_IPV4_ROUTE_DELETE 8
212 #define ZEBRA_IPV6_ROUTE_ADD 9
213 #define ZEBRA_IPV6_ROUTE_DELETE 10
214 #define ZEBRA_REDISTRIBUTE_ADD 11
215 #define ZEBRA_REDISTRIBUTE_DELETE 12
216 #define ZEBRA_REDISTRIBUTE_DEFAULT_ADD 13
217 #define ZEBRA_REDISTRIBUTE_DEFAULT_DELETE 14
218 #define ZEBRA_IPV4_NEXTHOP_LOOKUP 15
219 #define ZEBRA_IPV6_NEXTHOP_LOOKUP 16
220 #define ZEBRA_IPV4_IMPORT_LOOKUP 17
221 #define ZEBRA_IPV6_IMPORT_LOOKUP 18
222 #define ZEBRA_MESSAGE_MAX 19
224 /* Zebra route's types. */
225 #define ZEBRA_ROUTE_SYSTEM 0
226 #define ZEBRA_ROUTE_KERNEL 1
227 #define ZEBRA_ROUTE_CONNECT 2
228 #define ZEBRA_ROUTE_STATIC 3
229 #define ZEBRA_ROUTE_RIP 4
230 #define ZEBRA_ROUTE_RIPNG 5
231 #define ZEBRA_ROUTE_OSPF 6
232 #define ZEBRA_ROUTE_OSPF6 7
233 #define ZEBRA_ROUTE_BGP 8
234 #define ZEBRA_ROUTE_MAX 9
236 /* Zebra's family types. */
237 #define ZEBRA_FAMILY_IPV4 1
238 #define ZEBRA_FAMILY_IPV6 2
239 #define ZEBRA_FAMILY_MAX 3
241 /* Error codes of zebra. */
242 #define ZEBRA_ERR_RTEXIST -1
243 #define ZEBRA_ERR_RTUNREACH -2
244 #define ZEBRA_ERR_EPERM -3
245 #define ZEBRA_ERR_RTNOEXIST -4
247 /* Zebra message flags */
248 #define ZEBRA_FLAG_INTERNAL 0x01
249 #define ZEBRA_FLAG_SELFROUTE 0x02
250 #define ZEBRA_FLAG_BLACKHOLE 0x04
251 #define ZEBRA_FLAG_IBGP 0x08
252 #define ZEBRA_FLAG_SELECTED 0x10
253 #define ZEBRA_FLAG_CHANGED 0x20
254 #define ZEBRA_FLAG_STATIC 0x40
256 /* Zebra nexthop flags. */
257 #define ZEBRA_NEXTHOP_IFINDEX 1
258 #define ZEBRA_NEXTHOP_IFNAME 2
259 #define ZEBRA_NEXTHOP_IPV4 3
260 #define ZEBRA_NEXTHOP_IPV4_IFINDEX 4
261 #define ZEBRA_NEXTHOP_IPV4_IFNAME 5
262 #define ZEBRA_NEXTHOP_IPV6 6
263 #define ZEBRA_NEXTHOP_IPV6_IFINDEX 7
264 #define ZEBRA_NEXTHOP_IPV6_IFNAME 8
266 #ifndef INADDR_LOOPBACK
267 #define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */
270 /* Address family numbers from RFC1700. */
275 /* Subsequent Address Family Identifier. */
276 #define SAFI_UNICAST 1
277 #define SAFI_MULTICAST 2
278 #define SAFI_UNICAST_MULTICAST 3
279 #define SAFI_MPLS_VPN 4
282 /* Filter direction. */
287 /* Default Administrative Distance of each protocol. */
288 #define ZEBRA_KERNEL_DISTANCE_DEFAULT 0
289 #define ZEBRA_CONNECT_DISTANCE_DEFAULT 0
290 #define ZEBRA_STATIC_DISTANCE_DEFAULT 1
291 #define ZEBRA_RIP_DISTANCE_DEFAULT 120
292 #define ZEBRA_RIPNG_DISTANCE_DEFAULT 120
293 #define ZEBRA_OSPF_DISTANCE_DEFAULT 110
294 #define ZEBRA_OSPF6_DISTANCE_DEFAULT 110
295 #define ZEBRA_IBGP_DISTANCE_DEFAULT 200
296 #define ZEBRA_EBGP_DISTANCE_DEFAULT 20
298 /* Flag manipulation macros. */
299 #define CHECK_FLAG(V,F) ((V) & (F))
300 #define SET_FLAG(V,F) (V) = (V) | (F)
301 #define UNSET_FLAG(V,F) (V) = (V) & ~(F)
303 /* AFI and SAFI type. */
304 typedef u_int16_t afi_t;
305 typedef u_char safi_t;
308 typedef u_int16_t zebra_size_t;
309 typedef u_int8_t zebra_command_t;
311 #endif /* _ZEBRA_H */