--- gvpe/src/device.h 2003/03/28 04:05:10 1.2 +++ gvpe/src/device.h 2003/04/08 02:00:54 1.5 @@ -19,11 +19,6 @@ #ifndef VPE_DEVICE_H__ #define VPE_DEVICE_H__ -#include "config.h" - -#include -#include - #include #include "gettext.h" @@ -33,11 +28,24 @@ 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) { - memmove ((void *)&(*this)[0], (void *)&(*this)[hdrsize], len -= 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 () @@ -57,7 +65,7 @@ }; inline -u8 &net_packet::operator[] (u16 offset) +u8 &net_packet::operator[] (u16 offset) const { return ((data_packet *)this)->data_[offset]; }