00001 #ifndef _TAPIFACE_H__
00002 #define _TAPIFACE_H__
00003
00004
00005 #include <fcntl.h>
00006 #include <sys/ioctl.h>
00007 #include <sys/socket.h>
00008 #include <sys/types.h>
00009 #include <string.h>
00010 #include <linux/if.h>
00011 #include <linux/if_tun.h>
00012 #include <unistd.h>
00013 #include <net/if_arp.h>
00014
00015 #include <gea/posix/UnixFdHandle.h>
00016 #include <gea/ObjRepository.h>
00017 #include <gea/API.h>
00018
00019 #include <awds/NodeId.h>
00020 #include <awds/routing.h>
00021 #include <awds/UnicastPacket.h>
00022 #include <awds/Flood.h>
00023
00024
00025 #define ADDR_TRNSLTR 0x04
00026 #define PROTO_NR 0x62
00027
00028 namespace awds {
00029 class TapInterface {
00030
00031 public:
00032 int fd;
00033 char devname[IFNAMSIZ+1];
00034
00035
00036 gea::UnixFdHandle *tapHandle;
00037 Routing *routing;
00038
00039 TapInterface(Routing *routing);
00040
00041 virtual ~TapInterface() {}
00042
00043 virtual void init(const char*dev);
00044
00045 virtual bool setIfaceHwAddress(const NodeId& id);
00046
00047 bool setIfaceMTU(int mtu);
00048 bool createDevice(const char *dev);
00049
00050 static void tap_recv(gea::Handle *h, gea::AbsTime t, void *data);
00051 static void recv_unicast ( BasePacket *p, void *data);
00052 static void recv_broadcast( BasePacket *p, void *data);
00053
00060 virtual bool getNodeForMacAddress(const char* mac, NodeId& id, gea::AbsTime t);
00061
00065 virtual void storeSrcAndMac(const NodeId &id, const char *bufO, gea::AbsTime t);
00066
00067
00068 };
00069 }
00070
00071
00072 #endif //TAPIFACE_H__
00073
00074
00075
00076
00077
00078