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 _MDNS_NETWORKINTERFACES_H
43 #define _MDNS_NETWORKINTERFACES_H
46 #include <netinet/in.h> /* struct in_addr */
47 #include <stdbool.h> /* bool */
50 #include "olsr_types.h" /* olsr_ip_addr */
51 #include "olsrd_plugin.h" /* union set_plugin_parameter_addon */
54 #include "Packet.h" /* IFHWADDRLEN */
57 /* Size of buffer in which packets are received */
58 #define BMF_BUFFER_SIZE 2048
59 #define HELLO_BUFFER_SIZE 2048
61 struct TBmfInterface {
62 /* File descriptor of raw packet socket, used for capturing multicast packets */
65 /* File descriptor of UDP (datagram) socket for encapsulated multicast packets.
66 * Only used for OLSR-enabled interfaces; set to -1 if interface is not OLSR-enabled. */
67 int encapsulatingSkfd;
69 /* File descriptor of UDP packet socket, used for listening to encapsulation packets.
70 * Used only when PlParam "BmfMechanism" is set to "UnicastPromiscuous". */
73 /* File descriptor of UDP packet socket, used for listening router election hello
77 /* File descriptor of UDP packet socket, used for sending router election hello
81 /* Used to check if the router is master on the selected interface */
84 unsigned char macAddr[IFHWADDRLEN];
86 char ifName[IFNAMSIZ];
88 /* OLSRs idea of this network interface. NULL if this interface is not
90 struct interface_olsr *olsrIntf;
92 /* IP address of this network interface */
93 union olsr_ip_addr intAddr;
95 /* Broadcast address of this network interface */
96 union olsr_ip_addr broadAddr;
98 #define FRAGMENT_HISTORY_SIZE 10
99 struct TFragmentHistory {
102 struct in_addr ipSrc;
103 struct in_addr ipDst;
104 } fragmentHistory[FRAGMENT_HISTORY_SIZE];
106 int nextFragmentHistoryEntry;
108 /* Number of received and transmitted BMF packets on this interface */
109 u_int32_t nBmfPacketsRx;
110 u_int32_t nBmfPacketsRxDup;
111 u_int32_t nBmfPacketsTx;
113 /* Next element in list */
114 struct TBmfInterface *next;
117 extern struct TBmfInterface *BmfInterfaces;
119 extern int my_MDNS_TTL;
120 extern bool my_TTL_Check;
122 extern int HighestSkfd;
123 extern fd_set InputSet;
125 extern int EtherTunTapFd;
127 extern char EtherTunTapIfName[];
129 /* 10.255.255.253 in host byte order */
130 #define ETHERTUNTAPDEFAULTIP 0x0AFFFFFD
132 extern u_int32_t EtherTunTapIp;
133 extern u_int32_t EtherTunTapIpMask;
134 extern u_int32_t EtherTunTapIpBroadcast;
137 enum TBmfMechanism { BM_BROADCAST = 0, BM_UNICAST_PROMISCUOUS };
138 extern enum TBmfMechanism BmfMechanism;
140 int SetBmfInterfaceName(const char *ifname, void *data, set_plugin_parameter_addon addon);
141 int SetBmfInterfaceIp(const char *ip, void *data, set_plugin_parameter_addon addon);
142 int SetCapturePacketsOnOlsrInterfaces(const char *enable, void *data, set_plugin_parameter_addon addon);
143 int SetBmfMechanism(const char *mechanism, void *data, set_plugin_parameter_addon addon);
144 int DeactivateSpoofFilter(void);
145 void RestoreSpoofFilter(void);
147 #define MAX_UNICAST_NEIGHBORS 10
148 struct TBestNeighbors {
149 struct link_entry *links[MAX_UNICAST_NEIGHBORS];
152 void FindNeighbors(struct TBestNeighbors *neighbors,
153 struct link_entry **bestNeighbor,
154 struct TBmfInterface *intf,
155 union olsr_ip_addr *source,
156 union olsr_ip_addr *forwardedBy, union olsr_ip_addr *forwardedTo, int *nPossibleNeighbors);
158 int CreateBmfNetworkInterfaces(struct interface_olsr *skipThisIntf);
159 void AddInterface(struct interface_olsr *newIntf);
160 void CloseBmfNetworkInterfaces(void);
161 int AddNonOlsrBmfIf(const char *ifName, void *data, set_plugin_parameter_addon addon);
162 int set_TTL_Check(const char *TTL_Check, void *data, set_plugin_parameter_addon addon);
163 int set_MDNS_TTL(const char *MDNS_TTL, void *data, set_plugin_parameter_addon addon);
164 int IsNonOlsrBmfIf(const char *ifName);
165 void CheckAndUpdateLocalBroadcast(unsigned char *ipPacket, union olsr_ip_addr *broadAddr);
166 void AddMulticastRoute(void);
167 void DeleteMulticastRoute(void);
169 #endif /* _MDNS_NETWORKINTERFACES_H */
174 * indent-tabs-mode: nil