… | |
… | |
23 | #define IFNAMESIZE 256 // be conservative |
23 | #define IFNAMESIZE 256 // be conservative |
24 | |
24 | |
25 | #include "gettext.h" |
25 | #include "gettext.h" |
26 | |
26 | |
27 | #include "global.h" |
27 | #include "global.h" |
|
|
28 | #include "util.h" |
28 | |
29 | |
29 | struct net_packet { |
30 | struct net_packet { |
30 | u32 len; // actually u16, but padding... |
31 | u32 len; // actually u16, but padding... |
31 | |
32 | |
32 | u8 &operator[] (u16 offset) const; |
33 | u8 &operator[] (u16 offset) const; |
… | |
… | |
85 | u8 &net_packet::operator[] (u16 offset) const |
86 | u8 &net_packet::operator[] (u16 offset) const |
86 | { |
87 | { |
87 | return ((data_packet *)this)->data_[offset]; |
88 | return ((data_packet *)this)->data_[offset]; |
88 | } |
89 | } |
89 | |
90 | |
90 | typedef u8 mac[6]; |
|
|
91 | |
|
|
92 | struct tap_packet : net_packet { |
91 | struct tap_packet : net_packet { |
93 | mac dst; |
92 | mac dst; |
94 | mac src; |
93 | mac src; |
95 | u8 data[MAXSIZE - 12]; |
94 | u8 data[MAXSIZE - 12]; |
96 | }; |
95 | }; |
… | |
… | |
98 | struct tap_device { |
97 | struct tap_device { |
99 | int fd; |
98 | int fd; |
100 | |
99 | |
101 | // network interface name or identifier |
100 | // network interface name or identifier |
102 | char ifrname[IFNAMESIZE + 1]; |
101 | char ifrname[IFNAMESIZE + 1]; |
103 | |
|
|
104 | char *device; |
|
|
105 | |
102 | |
106 | tap_device (); |
103 | tap_device (); |
107 | ~tap_device (); |
104 | ~tap_device (); |
108 | |
105 | |
109 | //bool open (); |
106 | //bool open (); |