3 Written by Saverio Proto <zioproto@gmail.com> and Claudio Pisa <clauz@ninux.org>.
5 This file is part of OLSR MDNS PLUGIN.
7 The OLSR MDNS PLUGIN is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 The OLSR MDNS PLUGIN is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Foobar. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef _BMF_NETWORKINTERFACES_H
25 #define _BMF_NETWORKINTERFACES_H
28 #include <netinet/in.h> /* struct in_addr */
31 #include "olsr_types.h" /* olsr_ip_addr */
32 #include "plugin.h" /* union set_plugin_parameter_addon */
35 #include "Packet.h" /* IFHWADDRLEN */
37 /* Size of buffer in which packets are received */
38 #define BMF_BUFFER_SIZE 2048
42 /* File descriptor of raw packet socket, used for capturing multicast packets */
45 /* File descriptor of UDP (datagram) socket for encapsulated multicast packets.
46 * Only used for OLSR-enabled interfaces; set to -1 if interface is not OLSR-enabled. */
47 int encapsulatingSkfd;
49 /* File descriptor of UDP packet socket, used for listening to encapsulation packets.
50 * Used only when PlParam "BmfMechanism" is set to "UnicastPromiscuous". */
53 unsigned char macAddr[IFHWADDRLEN];
55 char ifName[IFNAMSIZ];
57 /* OLSRs idea of this network interface. NULL if this interface is not
59 struct interface* olsrIntf;
61 /* IP address of this network interface */
62 union olsr_ip_addr intAddr;
64 /* Broadcast address of this network interface */
65 union olsr_ip_addr broadAddr;
67 #define FRAGMENT_HISTORY_SIZE 10
68 struct TFragmentHistory
74 } fragmentHistory [FRAGMENT_HISTORY_SIZE];
76 int nextFragmentHistoryEntry;
78 /* Number of received and transmitted BMF packets on this interface */
79 u_int32_t nBmfPacketsRx;
80 u_int32_t nBmfPacketsRxDup;
81 u_int32_t nBmfPacketsTx;
83 /* Next element in list */
84 struct TBmfInterface* next;
87 extern struct TBmfInterface* BmfInterfaces;
89 extern int HighestSkfd;
90 extern fd_set InputSet;
92 extern int EtherTunTapFd;
94 extern char EtherTunTapIfName[];
96 /* 10.255.255.253 in host byte order */
97 #define ETHERTUNTAPDEFAULTIP 0x0AFFFFFD
99 extern u_int32_t EtherTunTapIp;
100 extern u_int32_t EtherTunTapIpMask;
101 extern u_int32_t EtherTunTapIpBroadcast;
104 enum TBmfMechanism { BM_BROADCAST = 0, BM_UNICAST_PROMISCUOUS };
105 extern enum TBmfMechanism BmfMechanism;
107 int SetBmfInterfaceName(const char* ifname, void* data, set_plugin_parameter_addon addon);
108 int SetBmfInterfaceIp(const char* ip, void* data, set_plugin_parameter_addon addon);
109 int SetCapturePacketsOnOlsrInterfaces(const char* enable, void* data, set_plugin_parameter_addon addon);
110 int SetBmfMechanism(const char* mechanism, void* data, set_plugin_parameter_addon addon);
111 int DeactivateSpoofFilter(void);
112 void RestoreSpoofFilter(void);
114 #define MAX_UNICAST_NEIGHBORS 10
115 struct TBestNeighbors
117 struct link_entry* links[MAX_UNICAST_NEIGHBORS];
121 struct TBestNeighbors* neighbors,
122 struct link_entry** bestNeighbor,
123 struct TBmfInterface* intf,
124 union olsr_ip_addr* source,
125 union olsr_ip_addr* forwardedBy,
126 union olsr_ip_addr* forwardedTo,
127 int* nPossibleNeighbors);
129 int CreateBmfNetworkInterfaces(struct interface* skipThisIntf);
130 void AddInterface(struct interface* newIntf);
131 void CloseBmfNetworkInterfaces(void);
132 int AddNonOlsrBmfIf(const char* ifName, void* data, set_plugin_parameter_addon addon);
133 int IsNonOlsrBmfIf(const char* ifName);
134 void CheckAndUpdateLocalBroadcast(unsigned char* ipPacket, union olsr_ip_addr* broadAddr);
135 void AddMulticastRoute(void);
136 void DeleteMulticastRoute(void);
138 #endif /* _BMF_NETWORKINTERFACES_H */
143 * indent-tabs-mode: nil