00001 #ifndef _BMF_NETWORKINTERFACES_H
00002 #define _BMF_NETWORKINTERFACES_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include <netinet/in.h>
00045
00046
00047 #include "olsr_types.h"
00048 #include "plugin.h"
00049
00050
00051 #include "Packet.h"
00052
00053
00054 #define BMF_BUFFER_SIZE 2048
00055
00056 struct TBmfInterface {
00057
00058 int capturingSkfd;
00059
00060
00061
00062 int encapsulatingSkfd;
00063
00064
00065
00066 int listeningSkfd;
00067
00068 unsigned char macAddr[IFHWADDRLEN];
00069
00070 char ifName[IFNAMSIZ];
00071
00072
00073
00074 struct interface *olsrIntf;
00075
00076
00077 union olsr_ip_addr intAddr;
00078
00079
00080 union olsr_ip_addr broadAddr;
00081
00082 #define FRAGMENT_HISTORY_SIZE 10
00083 struct TFragmentHistory {
00084 u_int16_t ipId;
00085 u_int8_t ipProto;
00086 struct in_addr ipSrc;
00087 struct in_addr ipDst;
00088 } fragmentHistory[FRAGMENT_HISTORY_SIZE];
00089
00090 int nextFragmentHistoryEntry;
00091
00092
00093 u_int32_t nBmfPacketsRx;
00094 u_int32_t nBmfPacketsRxDup;
00095 u_int32_t nBmfPacketsTx;
00096
00097
00098 struct TBmfInterface *next;
00099 };
00100
00101 extern struct TBmfInterface *BmfInterfaces;
00102
00103 extern int HighestSkfd;
00104 extern fd_set InputSet;
00105
00106 extern int EtherTunTapFd;
00107
00108 extern char EtherTunTapIfName[];
00109
00110
00111 #define ETHERTUNTAPDEFAULTIP 0x0AFFFFFD
00112
00113 extern u_int32_t EtherTunTapIp;
00114 extern u_int32_t EtherTunTapIpMask;
00115 extern u_int32_t EtherTunTapIpBroadcast;
00116
00117 extern int CapturePacketsOnOlsrInterfaces;
00118
00119 enum TBmfMechanism { BM_BROADCAST = 0, BM_UNICAST_PROMISCUOUS };
00120 extern enum TBmfMechanism BmfMechanism;
00121
00122 int SetBmfInterfaceName(const char *ifname, void *data, set_plugin_parameter_addon addon);
00123 int SetBmfInterfaceIp(const char *ip, void *data, set_plugin_parameter_addon addon);
00124 int SetCapturePacketsOnOlsrInterfaces(const char *enable, void *data, set_plugin_parameter_addon addon);
00125 int SetBmfMechanism(const char *mechanism, void *data, set_plugin_parameter_addon addon);
00126 int DeactivateSpoofFilter(void);
00127 void RestoreSpoofFilter(void);
00128
00129 #define MAX_UNICAST_NEIGHBORS 10
00130 struct TBestNeighbors {
00131 struct link_entry *links[MAX_UNICAST_NEIGHBORS];
00132 };
00133
00134 void FindNeighbors(struct TBestNeighbors *neighbors,
00135 struct link_entry **bestNeighbor,
00136 struct TBmfInterface *intf,
00137 union olsr_ip_addr *source,
00138 union olsr_ip_addr *forwardedBy, union olsr_ip_addr *forwardedTo, int *nPossibleNeighbors);
00139
00140 int CreateBmfNetworkInterfaces(struct interface *skipThisIntf);
00141 void AddInterface(struct interface *newIntf);
00142 void CloseBmfNetworkInterfaces(void);
00143 int AddNonOlsrBmfIf(const char *ifName, void *data, set_plugin_parameter_addon addon);
00144 int IsNonOlsrBmfIf(const char *ifName);
00145 void CheckAndUpdateLocalBroadcast(unsigned char *ipPacket, union olsr_ip_addr *broadAddr);
00146 void AddMulticastRoute(void);
00147 void DeleteMulticastRoute(void);
00148
00149 #endif
00150
00151
00152
00153
00154
00155
00156