--- gvpe/src/device.h 2003/10/14 03:22:09 1.6 +++ gvpe/src/device.h 2003/10/16 02:28:36 1.10 @@ -19,7 +19,7 @@ #ifndef VPE_DEVICE_H__ #define VPE_DEVICE_H__ -#define IFNAMESIZE 256 +#define IFNAMESIZE 256 // be conservative #include "gettext.h" @@ -48,7 +48,23 @@ memcpy (&((*this)[0]), &(pkt[0]), len); } - bool is_arp () + bool is_ipv4 () const + { + return (*this)[12] == 0x08 && (*this)[13] == 0x00 // IP + && ((*this)[14] & 0xf0) == 0x40; // IPv4 + } + + u32 &ipv4_src () const + { + return *(u32 *)&(*this)[26]; + } + + u32 &ipv4_dst () const + { + return *(u32 *)&(*this)[30]; + } + + bool is_arp () const { return (*this)[12] == 0x08 && (*this)[13] == 0x06 // 0806 protocol && (*this)[14] == 0x00 && (*this)[15] == 0x01 // 0001 hw_format @@ -81,7 +97,7 @@ struct tap_device { int fd; - // linux tuntap + // network interface name or identifier char ifrname[IFNAMESIZE + 1]; char *device; @@ -89,6 +105,9 @@ tap_device (); ~tap_device (); + //bool open (); + //void close (); + const char *interface () { return ifrname; } const char *info (); @@ -96,5 +115,7 @@ void send (tap_packet *pkt); }; +//extern tap_device *tap_device (); + #endif