3 * The olsr.org Optimized Link-State Routing daemon(olsrd)
4 * Copyright (c) 2004, Andreas Tonnesen(andreto@olsr.org)
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of olsr.org, olsrd nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
34 * Visit http://www.olsr.org for more information.
36 * If you find this software useful feel free to make a donation
37 * to the project. For more information see the website or contact
38 * the copyright holders.
42 #ifndef _OLSR_INTERFACE
43 #define _OLSR_INTERFACE
45 #include <sys/types.h>
50 #include <sys/socket.h>
54 #include "olsr_types.h"
57 #define IPV6_ADDR_ANY 0x0000U
59 #define IPV6_ADDR_UNICAST 0x0001U
60 #define IPV6_ADDR_MULTICAST 0x0002U
61 #define IPV6_ADDR_ANYCAST 0x0004U
63 #define IPV6_ADDR_LOOPBACK 0x0010U
64 #define IPV6_ADDR_LINKLOCAL 0x0020U
65 #define IPV6_ADDR_SITELOCAL 0x0040U
67 #define IPV6_ADDR_COMPATv4 0x0080U
69 #define IPV6_ADDR_SCOPE_MASK 0x00f0U
71 #define IPV6_ADDR_MAPPED 0x1000U
72 #define IPV6_ADDR_RESERVED 0x2000U
74 #define MAX_IF_METRIC 100
76 #define WEIGHT_LOWEST 0 /* No weight */
77 #define WEIGHT_LOW 1 /* Low */
78 #define WEIGHT_ETHERNET_1GBP 2 /* Ethernet 1Gb+ */
79 #define WEIGHT_ETHERNET_1GB 4 /* Ethernet 1Gb */
80 #define WEIGHT_ETHERNET_100MB 8 /* Ethernet 100Mb */
81 #define WEIGHT_ETHERNET_10MB 16 /* Ethernet 10Mb */
82 #define WEIGHT_ETHERNET_DEFAULT 32 /* Ethernet unknown rate */
83 #define WEIGHT_WLAN_HIGH 64 /* >54Mb WLAN */
84 #define WEIGHT_WLAN_54MB 128 /* 54Mb 802.11g */
85 #define WEIGHT_WLAN_11MB 256 /* 11Mb 802.11b */
86 #define WEIGHT_WLAN_LOW 512 /* <11Mb WLAN */
87 #define WEIGHT_WLAN_DEFAULT 1024 /* WLAN unknown rate */
88 #define WEIGHT_SERIAL 2048 /* Serial device */
89 #define WEIGHT_HIGH 4096 /* High */
90 #define WEIGHT_HIGHEST 8192 /* Really high */
92 #define IF_MODE_MESH 0
93 #define IF_MODE_ETHER 1
95 struct if_gen_property {
98 struct if_gen_property *next;
108 /* Output buffer structure. This should actually be in net_olsr.h but we have circular references then.
111 uint8_t *buff; /* Pointer to the allocated buffer */
112 int bufsize; /* Size of the buffer */
113 int maxsize; /* Max bytes of payload that can be added to the buffer */
114 int pending; /* How much data is currently pending in the buffer */
115 int reserved; /* Plugins can reserve space in buffers */
119 *A struct containing all necessary information about each
120 *interface participating in the OLSRD routing
124 struct sockaddr_in int_addr; /* address */
125 struct sockaddr_in int_netmask; /* netmask */
126 struct sockaddr_in int_broadaddr; /* broadcast address */
127 int mode; /* interface mode */
129 struct sockaddr_in6 int6_addr; /* Address */
130 struct sockaddr_in6 int6_multaddr; /* Multicast */
132 union olsr_ip_addr ip_addr;
133 int is_hcif; /* Is this a emulated host-client if? */
135 int olsr_socket; /* The broadcast socket for this interface */
136 int send_socket; /* The send socket for this interface */
138 int int_metric; /* metric of interface */
139 int int_mtu; /* MTU of interface */
140 int int_flags; /* see below */
141 int if_index; /* Kernels index of this interface */
142 int is_wireless; /* wireless interface or not */
143 char *int_name; /* from kernel if structure */
144 uint16_t olsr_seqnum; /* Olsr message seqno */
146 /* Periodic message generation timers */
147 struct timer_entry *hello_gen_timer;
148 struct timer_entry *hna_gen_timer;
149 struct timer_entry *mid_gen_timer;
150 struct timer_entry *tc_gen_timer;
154 /* Struct used to store original redirect/ingress setting */
156 char redirect; /* The original state of icmp redirect */
157 char spoof; /* The original state of the IP spoof filter */
161 olsr_reltime hello_etime;
162 struct vtimes valtimes;
164 uint32_t fwdtimer; /* Timeout for OLSR forwarding on this if */
166 struct olsr_netbuf netbuf; /* the buffer to construct the packet data */
168 struct if_gen_property *gen_properties; /* Generic interface properties */
170 int ttl_index; /* index in TTL array for fish-eye */
172 bool immediate_send_tc; /* Hello's are sent immediately normally, this flag prefers to send TC's */
174 struct interface *int_next;
177 #define OLSR_DEFAULT_MTU 1500
179 /* Ifchange actions */
181 #define IFCHG_IF_ADD 1
182 #define IFCHG_IF_REMOVE 2
183 #define IFCHG_IF_UPDATE 3
185 /* The interface linked-list */
186 extern struct interface *ifnet;
188 int olsr_init_interfacedb(void);
189 void olsr_delete_interfaces(void);
191 void olsr_trigger_ifchange(struct interface *, int);
193 struct interface *if_ifwithsock(int);
195 struct interface *if_ifwithaddr(const union olsr_ip_addr *);
197 struct interface *if_ifwithname(const char *);
199 const char *if_ifwithindex_name(const int if_index);
201 struct interface *if_ifwithindex(const int if_index);
203 struct olsr_if *olsr_create_olsrif(const char *name, int hemu);
205 int olsr_add_ifchange_handler(int (*f) (struct interface *, int));
207 int olsr_remove_ifchange_handler(int (*f) (struct interface *, int));
209 void olsr_remove_interface(struct olsr_if *, bool);
211 extern struct olsr_cookie_info *interface_poll_timer_cookie;
212 extern struct olsr_cookie_info *hello_gen_timer_cookie;
213 extern struct olsr_cookie_info *tc_gen_timer_cookie;
214 extern struct olsr_cookie_info *mid_gen_timer_cookie;
215 extern struct olsr_cookie_info *hna_gen_timer_cookie;
222 * indent-tabs-mode: nil