--- gvpe/src/device.h 2003/03/01 15:53:03 1.1 +++ gvpe/src/device.h 2003/10/14 03:22:09 1.6 @@ -19,11 +19,7 @@ #ifndef VPE_DEVICE_H__ #define VPE_DEVICE_H__ -#include "config.h" - -#include - -#include +#define IFNAMESIZE 256 #include "gettext.h" @@ -32,7 +28,25 @@ struct net_packet { u32 len; // actually u16, but padding... - u8 &operator[] (u16 offset); + u8 &operator[] (u16 offset) const; + + void unshift_hdr (u16 hdrsize) + { + memmove ((void *)&(*this)[hdrsize], (void *)&(*this)[0], len); + len += hdrsize; + } + + void skip_hdr (u16 hdrsize) + { + len -= hdrsize; + memmove ((void *)&(*this)[0], (void *)&(*this)[hdrsize], len); + } + + void set (const net_packet &pkt) + { + len = pkt.len; + memcpy (&((*this)[0]), &(pkt[0]), len); + } bool is_arp () { @@ -51,7 +65,7 @@ }; inline -u8 &net_packet::operator[] (u16 offset) +u8 &net_packet::operator[] (u16 offset) const { return ((data_packet *)this)->data_[offset]; } @@ -68,7 +82,7 @@ int fd; // linux tuntap - char ifrname[IFNAMSIZ + 1]; + char ifrname[IFNAMESIZE + 1]; char *device; @@ -76,7 +90,7 @@ ~tap_device (); const char *interface () { return ifrname; } - const char *info () { return _("Linux tun/tap device"); } + const char *info (); tap_packet *recv (); void send (tap_packet *pkt);