2 * The olsr.org Optimized Link-State Routing daemon(olsrd)
3 * Copyright (c) 2004, Andreas Tønnesen(andreto@olsr.org)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of olsr.org, olsrd nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
33 * Visit http://www.olsr.org for more information.
35 * If you find this software useful feel free to make a donation
36 * to the project. For more information see the website or contact
37 * the copyright holders.
39 * $Id: interfaces.h,v 1.36 2007/01/30 16:52:41 bernd67 Exp $
43 #ifndef _OLSR_INTERFACE
44 #define _OLSR_INTERFACE
46 #include <sys/types.h>
47 #include <sys/socket.h>
50 #include "olsr_types.h"
52 #define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
55 #define IPV6_ADDR_ANY 0x0000U
57 #define IPV6_ADDR_UNICAST 0x0001U
58 #define IPV6_ADDR_MULTICAST 0x0002U
59 #define IPV6_ADDR_ANYCAST 0x0004U
61 #define IPV6_ADDR_LOOPBACK 0x0010U
62 #define IPV6_ADDR_LINKLOCAL 0x0020U
63 #define IPV6_ADDR_SITELOCAL 0x0040U
65 #define IPV6_ADDR_COMPATv4 0x0080U
67 #define IPV6_ADDR_SCOPE_MASK 0x00f0U
69 #define IPV6_ADDR_MAPPED 0x1000U
70 #define IPV6_ADDR_RESERVED 0x2000U
73 #define MAX_IF_METRIC 100
80 WEIGHT_ETHERNET_1GBP, /* Ethernet 1Gb+ */
81 WEIGHT_ETHERNET_1GB, /* Ethernet 1Gb */
82 WEIGHT_ETHERNET_100MB, /* Ethernet 100Mb */
83 WEIGHT_ETHERNET_10MB, /* Ethernet 10Mb */
84 WEIGHT_ETHERNET_DEFAULT, /* Ethernet unknown rate*/
85 WEIGHT_WLAN_HIGH, /* >54Mb WLAN */
86 WEIGHT_WLAN_54MB, /* 54Mb 802.11g */
87 WEIGHT_WLAN_11MB, /* 11Mb 802.11b */
88 WEIGHT_WLAN_LOW, /* <11Mb WLAN */
89 WEIGHT_WLAN_DEFAULT, /* WLAN unknown rate */
90 WEIGHT_SERIAL, /* Serial device */
91 WEIGHT_HIGH, /* Max */
92 WEIGHT_HIGHEST = WEIGHT_HIGH
95 struct if_gen_property
99 struct if_gen_property *next;
110 /* Output buffer structure. This should actually be in net_olsr.h but we have circular references then.
114 olsr_u8_t *buff;/* Pointer to the allocated buffer */
115 int bufsize; /* Size of the buffer */
116 int maxsize; /* Max bytes of payload that can be added to the buffer */
117 int pending; /* How much data is currently pending in the buffer */
118 int reserved; /* Plugins can reserve space in buffers */
123 *A struct containing all necessary information about each
124 *interface participating in the OLSD routing
129 struct sockaddr int_addr; /* address */
130 struct sockaddr int_netmask; /* netmask */
131 struct sockaddr int_broadaddr; /* broadcast address */
133 struct sockaddr_in6 int6_addr; /* Address */
134 struct sockaddr_in6 int6_multaddr; /* Multicast */
136 union olsr_ip_addr ip_addr;
137 int is_hcif; /* Is this a emulated host-client if? */
138 int olsr_socket; /* The broadcast socket for this interface */
139 int int_metric; /* metric of interface */
140 int int_mtu; /* MTU of interface */
141 int int_flags; /* see below */
142 char *int_name; /* from kernel if structure */
143 int if_index; /* Kernels index of this interface */
144 int if_nr; /* This interfaces index internally*/
145 int is_wireless; /* wireless interface or not*/
146 olsr_u16_t olsr_seqnum; /* Olsr message seqno */
149 struct vtimes valtimes;
151 clock_t fwdtimer; /* Timeout for OLSR forwarding on this if */
154 void *libnet_ctx; /* libnet context(void to avoid dependency */
156 struct olsr_netbuf netbuf; /* the buffer to construct the packet data */
158 struct if_gen_property *gen_properties;/* Generic interface properties */
160 int ttl_index; /* index in TTL array for fish-eye */
162 struct interface *int_next;
166 #define OLSR_DEFAULT_MTU 1500
168 /* Ifchange actions */
170 #define IFCHG_IF_ADD 1
171 #define IFCHG_IF_REMOVE 2
172 #define IFCHG_IF_UPDATE 3
174 /* The interface linked-list */
175 extern struct interface *ifnet;
177 /* Datastructures to use when creating new sockets */
178 extern struct sockaddr_in addrsock;
179 extern struct sockaddr_in6 addrsock6;
186 get_if_property_id(void);
189 add_if_geninfo(struct interface *, void *, olsr_u32_t);
192 get_if_geninfo(struct interface *, olsr_u32_t);
195 del_if_geninfo(struct interface *, olsr_u32_t);
198 run_ifchg_cbs(struct interface *, int);
204 if_ifwithaddr(union olsr_ip_addr *);
207 if_ifwithname(const char *);
210 queue_if(char *, int);
213 add_ifchgf(int (*f)(struct interface *, int));
216 del_ifchgf(int (*f)(struct interface *, int));