2 * The olsr.org Optimized Link-State Routing daemon(olsrd)
3 * Copyright (c) 2004-2009, the olsr.org team - see HISTORY file
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.
42 #ifndef _NETWORKINTERFACES_H
43 #define _NETWORKINTERFACES_H
46 #include <netinet/in.h> /* struct in_addr */
49 #include "olsr_types.h" /* olsr_ip_addr */
50 #include "olsrd_plugin.h" /* union set_plugin_parameter_addon */
53 #include "Packet.h" /* IFHWADDRLEN */
56 /* Size of buffer in which packets are received */
57 #define P2PD_BUFFER_SIZE 2048
59 struct NonOlsrInterface {
60 /* File descriptor of raw packet socket, used for capturing multicast packets */
63 /* File descriptor of UDP (datagram) socket for encapsulated multicast packets.
64 * Only used for OLSR-enabled interfaces; set to -1 if interface is not OLSR-enabled. */
65 int encapsulatingSkfd;
67 /* File descriptor of UDP packet socket, used for listening to encapsulation packets.
68 * Used only when PlParam "P2pdMechanism" is set to "UnicastPromiscuous". */
71 unsigned char macAddr[IFHWADDRLEN];
73 char ifName[IFNAMSIZ];
75 /* OLSRs idea of this network interface. NULL if this interface is not
77 struct interface *olsrIntf;
79 /* IP address of this network interface */
80 union olsr_ip_addr intAddr;
82 /* Broadcast address of this network interface */
83 union olsr_ip_addr broadAddr;
85 #define FRAGMENT_HISTORY_SIZE 10
86 struct TFragmentHistory {
91 } fragmentHistory[FRAGMENT_HISTORY_SIZE];
93 int nextFragmentHistoryEntry;
95 /* Number of received and transmitted BMF packets on this interface */
97 u_int32_t nPacketsRxDup;
100 /* Next element in list */
101 struct NonOlsrInterface *next;
104 extern struct NonOlsrInterface *nonOlsrInterfaces;
106 extern int HighestSkfd;
107 extern fd_set InputSet;
109 extern int EtherTunTapFd;
111 extern char EtherTunTapIfName[];
113 /* 10.255.255.253 in host byte order */
114 #define ETHERTUNTAPDEFAULTIP 0x0AFFFFFD
116 extern u_int32_t EtherTunTapIp;
117 extern u_int32_t EtherTunTapIpMask;
118 extern u_int32_t EtherTunTapIpBroadcast;
121 enum P2pdMechanism { BM_BROADCAST = 0, BM_UNICAST_PROMISCUOUS };
122 extern enum P2pdMechanism P2pdMechanism;
124 int SetNonOlsrInterfaceName(const char *ifname, void *data, set_plugin_parameter_addon addon);
125 int SetNonOlsrInterfaceIp(const char *ip, void *data, set_plugin_parameter_addon addon);
126 int SetCapturePacketsOnOlsrInterfaces(const char *enable, void *data, set_plugin_parameter_addon addon);
127 int SetP2pdMechanism(const char *mechanism, void *data, set_plugin_parameter_addon addon);
128 int DeactivateSpoofFilter(void);
129 void RestoreSpoofFilter(void);
131 #define MAX_UNICAST_NEIGHBORS 10
132 struct TBestNeighbors {
133 struct link_entry *links[MAX_UNICAST_NEIGHBORS];
136 void FindNeighbors(struct TBestNeighbors *neighbors,
137 struct link_entry **bestNeighbor,
138 struct NonOlsrInterface *intf,
139 union olsr_ip_addr *source,
140 union olsr_ip_addr *forwardedBy, union olsr_ip_addr *forwardedTo, int *nPossibleNeighbors);
142 int CreateNonOlsrNetworkInterfaces(struct interface *skipThisIntf);
143 void AddInterface(struct interface *newIntf);
144 void CloseNonOlsrNetworkInterfaces(void);
145 int AddNonOlsrIf(const char *ifName, void *data, set_plugin_parameter_addon addon);
146 int IsNonOlsrIf(const char *ifName);
147 void CheckAndUpdateLocalBroadcast(unsigned char *ipPacket, union olsr_ip_addr *broadAddr);
148 void AddMulticastRoute(void);
149 void DeleteMulticastRoute(void);
150 int CreateCaptureSocket(const char *ifName);
152 #endif /* _BMF_NETWORKINTERFACES_H */
157 * indent-tabs-mode: nil