ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/device.h
(Generate patch)

Comparing gvpe/src/device.h (file contents):
Revision 1.22 by pcg, Thu Aug 7 17:54:27 2008 UTC vs.
Revision 1.26 by root, Wed Jul 17 16:40:57 2013 UTC

40#include "util.h" 40#include "util.h"
41 41
42struct net_packet 42struct net_packet
43{ 43{
44 u32 len; // actually u16, but padding... 44 u32 len; // actually u16, but padding...
45 // upto 4 bytes at the end might get overwritten when decrypting,
46 // which means len, above, is regularly overwritten with part
47 // of the random prefix when RAND_BYTES=12.
45 48
46 u8 &operator[] (u16 offset) const; 49 u8 &operator[] (u16 offset) const;
47 u8 *at (u16 offset) const; 50 u8 *at (u16 offset) const;
48 51
49 void unshift_hdr (u16 hdrsize) 52 void unshift_hdr (u16 hdrsize)
54 57
55 void skip_hdr (u16 hdrsize) 58 void skip_hdr (u16 hdrsize)
56 { 59 {
57 len -= hdrsize; 60 len -= hdrsize;
58 memmove ((void *)&(*this)[0], (void *)&(*this)[hdrsize], len); 61 memmove ((void *)&(*this)[0], (void *)&(*this)[hdrsize], len);
62 }
63
64 u16 ipv4_hdr_len () const
65 {
66 return ((*this)[0] & 15) << 2;
59 } 67 }
60 68
61 void set (const net_packet &pkt) 69 void set (const net_packet &pkt)
62 { 70 {
63 len = pkt.len; 71 len = pkt.len;
95struct data_packet : net_packet 103struct data_packet : net_packet
96{ 104{
97 u8 data_[MAXSIZE]; 105 u8 data_[MAXSIZE];
98}; 106};
99 107
100inline 108inline
101u8 &net_packet::operator[] (u16 offset) const 109u8 &net_packet::operator[] (u16 offset) const
102{ 110{
103 return ((data_packet *)this)->data_[offset]; 111 return ((data_packet *)this)->data_[offset];
104} 112}
105 113
106inline 114inline
107u8 *net_packet::at (u16 offset) const 115u8 *net_packet::at (u16 offset) const
108{ 116{
109 return &((*this)[offset]); 117 return &((*this)[offset]);
110} 118}
111 119

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines