#include "NetworkInterfaces.h"#include <stddef.h>#include <syslog.h>#include <string.h>#include <errno.h>#include <unistd.h>#include <sys/ioctl.h>#include <fcntl.h>#include <assert.h>#include <net/if.h>#include <netinet/in.h>#include <linux/if_ether.h>#include <linux/if_packet.h>#include <linux/if_tun.h>#include <netinet/ip.h>#include <netinet/udp.h>#include <stdlib.h>#include <stdio.h>#include "olsr.h"#include "ipcalc.h"#include "defs.h"#include "link_set.h"#include "tc_set.h"#include "net_olsr.h"#include "lq_plugin.h"#include "olsr_ip_prefix_list.h"#include "olsr_logging.h"#include "Packet.h"#include "Bmf.h"#include "Address.h"
Go to the source code of this file.
Defines | |
| #define | ETHERTUNTAPIPNOTSET 0 |
| #define | IPV4_MAX_ADDRLEN 16 |
| #define | IPV4_MAX_PREFIXLEN 32 |
| #define | MAX_NON_OLSR_IFS 32 |
Functions | |
| int | SetBmfInterfaceName (const char *ifname, void *data __attribute__((unused)), set_plugin_parameter_addon addon __attribute__((unused))) |
| int | SetBmfInterfaceIp (const char *ip, void *data __attribute__((unused)), set_plugin_parameter_addon addon __attribute__((unused))) |
| int | SetCapturePacketsOnOlsrInterfaces (const char *enable, void *data __attribute__((unused)), set_plugin_parameter_addon addon __attribute__((unused))) |
| int | SetBmfMechanism (const char *mechanism, void *data __attribute__((unused)), set_plugin_parameter_addon addon __attribute__((unused))) |
| static void | AddDescriptorToInputSet (int skfd) |
| int | DeactivateSpoofFilter (void) |
| void | RestoreSpoofFilter (void) |
| void | FindNeighbors (struct TBestNeighbors *neighbors, struct link_entry **bestNeighbor, struct TBmfInterface *intf, union olsr_ip_addr *source, union olsr_ip_addr *forwardedBy, union olsr_ip_addr *forwardedTo, int *nPossibleNeighbors) |
| static int | CreateCaptureSocket (const char *ifName) |
| static int | CreateListeningSocket (const char *ifName) |
| static int | CreateEncapsulateSocket (const char *ifName) |
| static int | CreateLocalEtherTunTap (void) |
| static int | CreateInterface (const char *ifName, struct interface *olsrIntf) |
| int | CreateBmfNetworkInterfaces (struct interface *skipThisIntf) |
| void | AddInterface (struct interface *newIntf) |
| void | CloseBmfNetworkInterfaces (void) |
| int | AddNonOlsrBmfIf (const char *ifName, void *data __attribute__((unused)), set_plugin_parameter_addon addon __attribute__((unused))) |
| int | IsNonOlsrBmfIf (const char *ifName) |
| void | CheckAndUpdateLocalBroadcast (unsigned char *ipPacket, union olsr_ip_addr *broadAddr) |
| void | AddMulticastRoute (void) |
| void | DeleteMulticastRoute (void) |
Variables | |
| struct TBmfInterface * | BmfInterfaces = NULL |
| struct TBmfInterface * | LastBmfInterface = NULL |
| int | HighestSkfd = -1 |
| fd_set | InputSet |
| int | EtherTunTapFd = -1 |
| char | EtherTunTapIfName [IFNAMSIZ] = "bmf0" |
| enum TBmfMechanism | BmfMechanism = BM_BROADCAST |
| u_int32_t | EtherTunTapIp = ETHERTUNTAPIPNOTSET |
| u_int32_t | EtherTunTapIpMask = 0xFFFFFFFF |
| u_int32_t | EtherTunTapIpBroadcast = ETHERTUNTAPIPNOTSET |
| int | TunTapIpOverruled = 0 |
| int | CapturePacketsOnOlsrInterfaces = 0 |
| static char | EthTapSpoofState = '1' |
| static char | NonOlsrIfNames [MAX_NON_OLSR_IFS][IFNAMSIZ] |
| static int | nNonOlsrIfs = 0 |
| #define ETHERTUNTAPIPNOTSET 0 |
Definition at line 102 of file NetworkInterfaces.c.
Referenced by CreateLocalEtherTunTap().
| #define IPV4_MAX_ADDRLEN 16 |
Referenced by SetBmfInterfaceIp().
| #define IPV4_MAX_PREFIXLEN 32 |
Referenced by SetBmfInterfaceIp().
| #define MAX_NON_OLSR_IFS 32 |
Definition at line 1292 of file NetworkInterfaces.c.
Referenced by AddNonOlsrBmfIf().
| static void AddDescriptorToInputSet | ( | int | skfd | ) | [static] |
Definition at line 276 of file NetworkInterfaces.c.
References HighestSkfd, and InputSet.
Referenced by CreateCaptureSocket(), CreateEncapsulateSocket(), CreateListeningSocket(), and CreateLocalEtherTunTap().
| void AddInterface | ( | struct interface * | newIntf | ) |
Definition at line 1199 of file NetworkInterfaces.c.
Referenced by InterfaceChange().
| void AddMulticastRoute | ( | void | ) |
Definition at line 1419 of file NetworkInterfaces.c.
References ARM_NOWARN_ALIGN, EtherTunTapIfName, LOG_PLUGINS, OLSR_WARN, and RTF_UP.
Referenced by InitBmf().
| int AddNonOlsrBmfIf | ( | const char * | ifName, | |
| void *data | __attribute__(unused), | |||
| set_plugin_parameter_addon addon | __attribute__(unused) | |||
| ) |
Definition at line 1308 of file NetworkInterfaces.c.
References LOG_PLUGINS, MAX_NON_OLSR_IFS, and OLSR_WARN.
| void CheckAndUpdateLocalBroadcast | ( | unsigned char * | ipPacket, | |
| union olsr_ip_addr * | broadAddr | |||
| ) |
Definition at line 1359 of file NetworkInterfaces.c.
References ARM_NOWARN_ALIGN, GetIpHeaderLength(), IsMulticast(), and olsr_ip_addr::v4.
Referenced by BmfEncapsulationPacketReceived(), BmfPacketCaptured(), and BmfTunPacketCaptured().

| void CloseBmfNetworkInterfaces | ( | void | ) |
Definition at line 1227 of file NetworkInterfaces.c.
Referenced by CloseBmf(), and CloseMDNS().
| int CreateBmfNetworkInterfaces | ( | struct interface * | skipThisIntf | ) |
Definition at line 1102 of file NetworkInterfaces.c.
Referenced by InitBmf(), and InitMDNS().
| static int CreateCaptureSocket | ( | const char * | ifName | ) | [static] |
Definition at line 585 of file NetworkInterfaces.c.
References AddDescriptorToInputSet(), LOG_PLUGINS, and OLSR_WARN.
Referenced by CreateInterface().

| static int CreateEncapsulateSocket | ( | const char * | ifName | ) | [static] |
Definition at line 729 of file NetworkInterfaces.c.
References AddDescriptorToInputSet(), BMF_ENCAP_PORT, LOG_PLUGINS, and OLSR_WARN.
Referenced by CreateInterface().

| static int CreateInterface | ( | const char * | ifName, | |
| struct interface * | olsrIntf | |||
| ) | [static] |
Definition at line 948 of file NetworkInterfaces.c.
References ARM_NOWARN_ALIGN, BM_UNICAST_PROMISCUOUS, BmfMechanism, TBmfInterface::broadAddr, CapturePacketsOnOlsrInterfaces, TBmfInterface::capturingSkfd, CreateCaptureSocket(), CreateEncapsulateSocket(), CreateListeningSocket(), TBmfInterface::encapsulatingSkfd, TBmfInterface::fragmentHistory, TBmfInterface::ifName, interface::int_multicast, interface::int_src, TBmfInterface::intAddr, TBmfInterface::listeningSkfd, LOG_PLUGINS, TBmfInterface::macAddr, TBmfInterface::nBmfPacketsRx, TBmfInterface::nBmfPacketsRxDup, TBmfInterface::nBmfPacketsTx, TBmfInterface::next, TBmfInterface::nextFragmentHistoryEntry, OLSR_DEBUG, OLSR_WARN, TBmfInterface::olsrIntf, olsr_sockaddr::v4, and olsr_ip_addr::v4.
Referenced by AddInterface(), and CreateBmfNetworkInterfaces().

| static int CreateListeningSocket | ( | const char * | ifName | ) | [static] |
Definition at line 657 of file NetworkInterfaces.c.
References AddDescriptorToInputSet(), LOG_PLUGINS, and OLSR_WARN.
Referenced by CreateInterface().

| static int CreateLocalEtherTunTap | ( | void | ) | [static] |
Definition at line 796 of file NetworkInterfaces.c.
References AddDescriptorToInputSet(), ARM_NOWARN_ALIGN, ETHERTUNTAPDEFAULTIP, EtherTunTapIfName, EtherTunTapIp, EtherTunTapIpBroadcast, EtherTunTapIpMask, ETHERTUNTAPIPNOTSET, olsr_config::hna_entries, TBmfInterface::intAddr, ip_prefix_list_add(), LOG_PLUGINS, TBmfInterface::next, olsr_cnf, OLSR_DEBUG, OLSR_WARN, TBmfInterface::olsrIntf, TunTapIpOverruled, and olsr_ip_addr::v4.
Referenced by CreateBmfNetworkInterfaces().

| int DeactivateSpoofFilter | ( | void | ) |
Definition at line 301 of file NetworkInterfaces.c.
References EtherTunTapIfName, LOG_PLUGINS, and OLSR_WARN.
Referenced by InitBmf().
| void DeleteMulticastRoute | ( | void | ) |
Definition at line 1461 of file NetworkInterfaces.c.
References ARM_NOWARN_ALIGN, ETHERTUNTAPDEFAULTIP, EtherTunTapIfName, EtherTunTapIp, LOG_PLUGINS, OLSR_WARN, and RTF_UP.
Referenced by CloseBmf().
| void FindNeighbors | ( | struct TBestNeighbors * | neighbors, | |
| struct link_entry ** | bestNeighbor, | |||
| struct TBmfInterface * | intf, | |||
| union olsr_ip_addr * | source, | |||
| union olsr_ip_addr * | forwardedBy, | |||
| union olsr_ip_addr * | forwardedTo, | |||
| int * | nPossibleNeighbors | |||
| ) |
Definition at line 386 of file NetworkInterfaces.c.
References ipaddr_str::buf, tc_edge_entry::cost, FanOutLimit, get_best_link_to_neighbor_ip(), if_ifwithaddr(), TBmfInterface::ifName, interface::int_name, TBmfInterface::intAddr, LINK_COST_BROKEN, link_entry::linkcost, TBestNeighbors::links, link_entry::local_iface_addr, LOG_PLUGINS, LQTEXT_MAXLENGTH, MainAddressOf(), MAX_UNICAST_NEIGHBORS, link_entry::neighbor_iface_addr, OLSR_DEBUG, OLSR_FOR_ALL_LINK_ENTRIES, olsr_get_linkcost_text(), olsr_ip_to_string(), olsr_ipcmp(), olsr_lookup_tc_edge(), and olsr_lookup_tc_entry().
Referenced by BmfEncapsulationPacketReceived(), and EncapsulateAndForwardPacket().

| int IsNonOlsrBmfIf | ( | const char * | ifName | ) |
Definition at line 1332 of file NetworkInterfaces.c.
Referenced by CreateBmfNetworkInterfaces().
| void RestoreSpoofFilter | ( | void | ) |
Definition at line 351 of file NetworkInterfaces.c.
References EtherTunTapIfName, LOG_PLUGINS, and OLSR_WARN.
Referenced by CloseBmf().
| int SetBmfInterfaceIp | ( | const char * | ip, | |
| void *data | __attribute__(unused), | |||
| set_plugin_parameter_addon addon | __attribute__(unused) | |||
| ) |
Definition at line 158 of file NetworkInterfaces.c.
References EtherTunTapIp, EtherTunTapIpBroadcast, EtherTunTapIpMask, inet_aton(), IPV4_MAX_ADDRLEN, IPV4_MAX_PREFIXLEN, and TunTapIpOverruled.

| int SetBmfInterfaceName | ( | const char * | ifname, | |
| void *data | __attribute__(unused), | |||
| set_plugin_parameter_addon addon | __attribute__(unused) | |||
| ) |
Definition at line 137 of file NetworkInterfaces.c.
References EtherTunTapIfName.
| int SetBmfMechanism | ( | const char * | mechanism, | |
| void *data | __attribute__(unused), | |||
| set_plugin_parameter_addon addon | __attribute__(unused) | |||
| ) |
Definition at line 251 of file NetworkInterfaces.c.
References BM_BROADCAST, BM_UNICAST_PROMISCUOUS, and BmfMechanism.
| int SetCapturePacketsOnOlsrInterfaces | ( | const char * | enable, | |
| void *data | __attribute__(unused), | |||
| set_plugin_parameter_addon addon | __attribute__(unused) | |||
| ) |
Definition at line 224 of file NetworkInterfaces.c.
References CapturePacketsOnOlsrInterfaces.
| struct TBmfInterface* BmfInterfaces = NULL |
Definition at line 79 of file NetworkInterfaces.c.
Referenced by BmfEncapsulationPacketReceived(), BmfPacketCaptured(), BmfTunPacketCaptured(), DoBmf(), and PacketReceivedFromOLSR().
| enum TBmfMechanism BmfMechanism = BM_BROADCAST |
Definition at line 100 of file NetworkInterfaces.c.
Referenced by BmfEncapsulationPacketReceived(), CreateInterface(), EncapsulateAndForwardPacket(), and SetBmfMechanism().
| int CapturePacketsOnOlsrInterfaces = 0 |
Definition at line 123 of file NetworkInterfaces.c.
Referenced by CreateInterface(), and SetCapturePacketsOnOlsrInterfaces().
| int EtherTunTapFd = -1 |
Definition at line 90 of file NetworkInterfaces.c.
Referenced by BmfEncapsulationPacketReceived(), CloseBmf(), CloseBmfNetworkInterfaces(), CreateBmfNetworkInterfaces(), DoBmf(), and InitBmf().
| char EtherTunTapIfName[IFNAMSIZ] = "bmf0" |
Definition at line 94 of file NetworkInterfaces.c.
Referenced by AddMulticastRoute(), BmfEncapsulationPacketReceived(), BmfTunPacketCaptured(), CloseBmfNetworkInterfaces(), CreateBmfNetworkInterfaces(), CreateLocalEtherTunTap(), DeactivateSpoofFilter(), DeleteMulticastRoute(), DoBmf(), RestoreSpoofFilter(), and SetBmfInterfaceName().
| u_int32_t EtherTunTapIp = ETHERTUNTAPIPNOTSET |
Definition at line 106 of file NetworkInterfaces.c.
Referenced by CreateLocalEtherTunTap(), DeleteMulticastRoute(), InitBmf(), and SetBmfInterfaceIp().
| u_int32_t EtherTunTapIpBroadcast = ETHERTUNTAPIPNOTSET |
Definition at line 114 of file NetworkInterfaces.c.
Referenced by BmfEncapsulationPacketReceived(), BmfTunPacketCaptured(), CreateLocalEtherTunTap(), and SetBmfInterfaceIp().
| u_int32_t EtherTunTapIpMask = 0xFFFFFFFF |
Definition at line 110 of file NetworkInterfaces.c.
Referenced by CreateLocalEtherTunTap(), and SetBmfInterfaceIp().
char EthTapSpoofState = '1' [static] |
Definition at line 288 of file NetworkInterfaces.c.
| int HighestSkfd = -1 |
Definition at line 84 of file NetworkInterfaces.c.
Referenced by AddDescriptorToInputSet(), and DoBmf().
| fd_set InputSet |
Definition at line 87 of file NetworkInterfaces.c.
Referenced by AddDescriptorToInputSet(), CreateBmfNetworkInterfaces(), and DoBmf().
| struct TBmfInterface* LastBmfInterface = NULL |
Definition at line 80 of file NetworkInterfaces.c.
int nNonOlsrIfs = 0 [static] |
Definition at line 1294 of file NetworkInterfaces.c.
char NonOlsrIfNames[MAX_NON_OLSR_IFS][IFNAMSIZ] [static] |
Definition at line 1293 of file NetworkInterfaces.c.
| int TunTapIpOverruled = 0 |
Definition at line 118 of file NetworkInterfaces.c.
Referenced by CreateLocalEtherTunTap(), and SetBmfInterfaceIp().
1.6.3