--- gvpe/src/device.h 2008/08/07 17:54:27 1.22 +++ gvpe/src/device.h 2013/07/17 16:40:57 1.26 @@ -42,6 +42,9 @@ struct net_packet { u32 len; // actually u16, but padding... + // upto 4 bytes at the end might get overwritten when decrypting, + // which means len, above, is regularly overwritten with part + // of the random prefix when RAND_BYTES=12. u8 &operator[] (u16 offset) const; u8 *at (u16 offset) const; @@ -58,6 +61,11 @@ memmove ((void *)&(*this)[0], (void *)&(*this)[hdrsize], len); } + u16 ipv4_hdr_len () const + { + return ((*this)[0] & 15) << 2; + } + void set (const net_packet &pkt) { len = pkt.len; @@ -97,13 +105,13 @@ u8 data_[MAXSIZE]; }; -inline +inline u8 &net_packet::operator[] (u16 offset) const { return ((data_packet *)this)->data_[offset]; } -inline +inline u8 *net_packet::at (u16 offset) const { return &((*this)[offset]);