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.25 2005/03/07 06:28:44 kattemat Exp $
43 #ifndef _OLSR_INTERFACE
44 #define _OLSR_INTERFACE
46 #include <sys/types.h>
47 #include <sys/socket.h>
49 #include "olsr_types.h"
51 #define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
54 #define IPV6_ADDR_ANY 0x0000U
56 #define IPV6_ADDR_UNICAST 0x0001U
57 #define IPV6_ADDR_MULTICAST 0x0002U
58 #define IPV6_ADDR_ANYCAST 0x0004U
60 #define IPV6_ADDR_LOOPBACK 0x0010U
61 #define IPV6_ADDR_LINKLOCAL 0x0020U
62 #define IPV6_ADDR_SITELOCAL 0x0040U
64 #define IPV6_ADDR_COMPATv4 0x0080U
66 #define IPV6_ADDR_SCOPE_MASK 0x00f0U
68 #define IPV6_ADDR_MAPPED 0x1000U
69 #define IPV6_ADDR_RESERVED 0x2000U
72 #define MAX_IF_METRIC 100
79 WEIGHT_ETHERNET_1GBP, /* Ethernet 1Gb+ */
80 WEIGHT_ETHERNET_1GB, /* Ethernet 1Gb */
81 WEIGHT_ETHERNET_100MB, /* Ethernet 100Mb */
82 WEIGHT_ETHERNET_10MB, /* Ethernet 10Mb */
83 WEIGHT_ETHERNET_DEFAULT, /* Ethernet unknown rate*/
84 WEIGHT_WLAN_HIGH, /* >54Mb WLAN */
85 WEIGHT_WLAN_54MB, /* 54Mb 802.11g */
86 WEIGHT_WLAN_11MB, /* 11Mb 802.11b */
87 WEIGHT_WLAN_LOW, /* <11Mb WLAN */
88 WEIGHT_WLAN_DEFAULT, /* WLAN unknown rate */
89 WEIGHT_SERIAL, /* Serial device */
90 WEIGHT_HIGH, /* Max */
91 WEIGHT_HIGHEST = WEIGHT_HIGH
94 struct if_gen_property
98 struct if_gen_property *next;
110 *A struct containing all necessary information about each
111 *interface participating in the OLSD routing
116 struct sockaddr int_addr; /* address */
117 struct sockaddr int_netmask; /* netmask */
118 struct sockaddr int_broadaddr; /* broadcast address */
120 struct sockaddr_in6 int6_addr; /* Address */
121 struct sockaddr_in6 int6_multaddr; /* Multicast */
123 union olsr_ip_addr ip_addr;
124 int olsr_socket; /* The broadcast socket for this interface */
125 int int_metric; /* metric of interface */
126 int int_mtu; /* MTU of interface */
127 int int_flags; /* see below */
128 char *int_name; /* from kernel if structure */
129 int if_index; /* Kernels index of this interface */
130 int if_nr; /* This interfaces index internally*/
131 int is_wireless; /* wireless interface or not*/
132 olsr_u16_t olsr_seqnum; /* Olsr message seqno */
135 struct vtimes valtimes;
137 struct if_gen_property *gen_properties;/* Generic interface properties */
139 struct interface *int_next;
143 #define OLSR_DEFAULT_MTU 1500
147 /* Ifchange actions */
149 #define IFCHG_IF_ADD 1
150 #define IFCHG_IF_REMOVE 2
151 #define IFCHG_IF_UPDATE 3
153 /* The interface linked-list */
154 struct interface *ifnet;
156 /* Datastructures to use when creating new sockets */
157 struct sockaddr_in addrsock;
158 struct sockaddr_in6 addrsock6;
164 get_if_property_id(void);
167 add_if_geninfo(struct interface *, void *, olsr_u32_t);
170 get_if_geninfo(struct interface *, olsr_u32_t);
173 del_if_geninfo(struct interface *, olsr_u32_t);
176 run_ifchg_cbs(struct interface *, int);
182 if_ifwithaddr(union olsr_ip_addr *);
185 if_ifwithname(const char *);
191 add_ifchgf(int (*f)(struct interface *, int));
194 del_ifchgf(int (*f)(struct interface *, int));