… | |
… | |
27 | #define IFNAMESIZE 256 // be conservative |
27 | #define IFNAMESIZE 256 // be conservative |
28 | |
28 | |
29 | #include "global.h" |
29 | #include "global.h" |
30 | #include "util.h" |
30 | #include "util.h" |
31 | |
31 | |
32 | struct net_packet { |
32 | struct net_packet |
|
|
33 | { |
33 | u32 len; // actually u16, but padding... |
34 | u32 len; // actually u16, but padding... |
34 | |
35 | |
35 | u8 &operator[] (u16 offset) const; |
36 | u8 &operator[] (u16 offset) const; |
36 | u8 *at (u16 offset) const; |
37 | u8 *at (u16 offset) const; |
37 | |
38 | |
… | |
… | |
79 | |
80 | |
80 | void *operator new (size_t s); |
81 | void *operator new (size_t s); |
81 | void operator delete (void *p); |
82 | void operator delete (void *p); |
82 | }; |
83 | }; |
83 | |
84 | |
84 | struct data_packet : net_packet { |
85 | struct data_packet : net_packet |
|
|
86 | { |
85 | u8 data_[MAXSIZE]; |
87 | u8 data_[MAXSIZE]; |
86 | }; |
88 | }; |
87 | |
89 | |
88 | inline |
90 | inline |
89 | u8 &net_packet::operator[] (u16 offset) const |
91 | u8 &net_packet::operator[] (u16 offset) const |
… | |
… | |
95 | u8 *net_packet::at (u16 offset) const |
97 | u8 *net_packet::at (u16 offset) const |
96 | { |
98 | { |
97 | return &((*this)[offset]); |
99 | return &((*this)[offset]); |
98 | } |
100 | } |
99 | |
101 | |
100 | struct tap_packet : net_packet { |
102 | struct tap_packet : net_packet |
|
|
103 | { |
101 | mac dst; |
104 | mac dst; |
102 | mac src; |
105 | mac src; |
103 | u8 data[MAXSIZE - 12]; |
106 | u8 data[MAXSIZE - 12]; |
104 | }; |
107 | }; |
105 | |
108 | |
106 | struct tap_device { |
109 | struct tap_device |
|
|
110 | { |
107 | int fd; |
111 | int fd; |
108 | |
112 | |
109 | // network interface name or identifier |
113 | // network interface name or identifier |
110 | char ifrname[IFNAMESIZE + 1]; |
114 | char ifrname[IFNAMESIZE + 1]; |
111 | |
115 | |