author | mickeyl <mickeyl> | 2003-04-05 23:07:43 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-05 23:07:43 (UTC) |
commit | 6a949f685bd3fb50f810ad603eaafdb57720077c (patch) (unidiff) | |
tree | 12f1945f8eda7c58c355e25a2b267011ecde19da | |
parent | 30e5401a945ebdfd92eedb9f3def9a6acd0fc6ca (diff) | |
download | opie-6a949f685bd3fb50f810ad603eaafdb57720077c.zip opie-6a949f685bd3fb50f810ad603eaafdb57720077c.tar.gz opie-6a949f685bd3fb50f810ad603eaafdb57720077c.tar.bz2 |
improve output of OPacket::dump()
-rw-r--r-- | libopie2/opienet/opcap.cpp | 42 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 2 |
2 files changed, 35 insertions, 9 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 913d42e..6ddd457 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -1,485 +1,511 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 by the Wellenreiter team: | 3 | Copyright (C) 2003 by the Wellenreiter team: |
4 | Martin J. Muench <mjm@remote-exploit.org> | 4 | Martin J. Muench <mjm@remote-exploit.org> |
5 | Max Moser <mmo@remote-exploit.org | 5 | Max Moser <mmo@remote-exploit.org |
6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | 35 | ||
36 | #include <opie2/opcap.h> | 36 | #include <opie2/opcap.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | 39 | ||
40 | #include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) | 40 | #include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) |
41 | #include <qsocketnotifier.h> | 41 | #include <qsocketnotifier.h> |
42 | 42 | ||
43 | /*====================================================================================== | 43 | /*====================================================================================== |
44 | * OPacket | 44 | * OPacket |
45 | *======================================================================================*/ | 45 | *======================================================================================*/ |
46 | 46 | ||
47 | OPacket::OPacket( packetheaderstruct header, const unsigned char* data, QObject* parent ) | 47 | OPacket::OPacket( packetheaderstruct header, const unsigned char* data, QObject* parent ) |
48 | :QObject( parent, "Generic" ), _hdr( header ), _data( data ) | 48 | :QObject( parent, "Generic" ), _hdr( header ), _data( data ) |
49 | { | 49 | { |
50 | qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); | 50 | qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); |
51 | 51 | ||
52 | _end = (unsigned char*) data + header.len; | 52 | _end = (unsigned char*) data + header.len; |
53 | qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); | 53 | qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); |
54 | 54 | ||
55 | if ( packetCapturer()->dataLink() == DLT_EN10MB ) | 55 | if ( packetCapturer()->dataLink() == DLT_EN10MB ) |
56 | { | 56 | { |
57 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); | 57 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); |
58 | new OEthernetPacket( _end, (const struct ether_header*) data, this ); | 58 | new OEthernetPacket( _end, (const struct ether_header*) data, this ); |
59 | } | 59 | } |
60 | else | 60 | else |
61 | { | 61 | { |
62 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); | 62 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); |
63 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); | 63 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | OPacket::~OPacket() | 68 | OPacket::~OPacket() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | OPacketCapturer* OPacket::packetCapturer() const | 73 | OPacketCapturer* OPacket::packetCapturer() const |
74 | { | 74 | { |
75 | return parent()->inherits( "OPacketCapturer" ) ? static_cast<OPacketCapturer*>( parent() ) : 0; | 75 | return parent()->inherits( "OPacketCapturer" ) ? static_cast<OPacketCapturer*>( parent() ) : 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | timevalstruct OPacket::timeval() const | 79 | timevalstruct OPacket::timeval() const |
80 | { | 80 | { |
81 | return _hdr.ts; | 81 | return _hdr.ts; |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | int OPacket::caplen() const | 85 | int OPacket::caplen() const |
86 | { | 86 | { |
87 | return _hdr.caplen; | 87 | return _hdr.caplen; |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | void OPacket::dump() const | 91 | QString OPacket::dump( int bpl ) const |
92 | { | 92 | { |
93 | printf( "OPacket::dump()\n" ); | 93 | static int index = 0; |
94 | printf( "----------------\n" ); | 94 | index++; |
95 | int len = _hdr.caplen; | ||
96 | QString str; | ||
97 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); | ||
98 | str.append( "0000: " ); | ||
99 | QString tmp; | ||
100 | QString bytes; | ||
101 | QString chars; | ||
102 | |||
103 | for ( int i = 0; i < len; ++i ) | ||
104 | { | ||
105 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); | ||
106 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); | ||
107 | else chars.append( '.' ); | ||
108 | |||
109 | if ( !((i+1) % bpl) ) | ||
110 | { | ||
111 | str.append( bytes ); | ||
112 | str.append( ' ' ); | ||
113 | str.append( chars ); | ||
114 | str.append( '\n' ); | ||
115 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); | ||
116 | bytes = ""; | ||
117 | chars = ""; | ||
118 | } | ||
95 | 119 | ||
96 | for ( int i = 0; i < _hdr.caplen; ++i ) | 120 | } |
121 | if ( (len % bpl) ) | ||
97 | { | 122 | { |
98 | printf( "%02x ", _data[i] ); | 123 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); |
99 | if ( !((i+1) % 32) ) printf( "\n" ); | 124 | str.append( chars ); |
100 | } | 125 | } |
101 | printf( "\n\n" ); | 126 | str.append( '\n' ); |
127 | return str; | ||
102 | } | 128 | } |
103 | 129 | ||
104 | 130 | ||
105 | 131 | ||
106 | int OPacket::len() const | 132 | int OPacket::len() const |
107 | { | 133 | { |
108 | return _hdr.len; | 134 | return _hdr.len; |
109 | } | 135 | } |
110 | 136 | ||
111 | /*====================================================================================== | 137 | /*====================================================================================== |
112 | * OEthernetPacket | 138 | * OEthernetPacket |
113 | *======================================================================================*/ | 139 | *======================================================================================*/ |
114 | 140 | ||
115 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) | 141 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) |
116 | :QObject( parent, "Ethernet" ), _ether( data ) | 142 | :QObject( parent, "Ethernet" ), _ether( data ) |
117 | 143 | ||
118 | { | 144 | { |
119 | 145 | ||
120 | qDebug( "Source = %s", (const char*) sourceAddress().toString() ); | 146 | qDebug( "Source = %s", (const char*) sourceAddress().toString() ); |
121 | qDebug( "Destination = %s", (const char*) destinationAddress().toString() ); | 147 | qDebug( "Destination = %s", (const char*) destinationAddress().toString() ); |
122 | 148 | ||
123 | if ( sourceAddress() == OMacAddress::broadcast ) | 149 | if ( sourceAddress() == OMacAddress::broadcast ) |
124 | qDebug( "Source is broadcast address" ); | 150 | qDebug( "Source is broadcast address" ); |
125 | if ( destinationAddress() == OMacAddress::broadcast ) | 151 | if ( destinationAddress() == OMacAddress::broadcast ) |
126 | qDebug( "Destination is broadcast address" ); | 152 | qDebug( "Destination is broadcast address" ); |
127 | 153 | ||
128 | switch ( type() ) | 154 | switch ( type() ) |
129 | { | 155 | { |
130 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; | 156 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; |
131 | case ETHERTYPE_ARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = ARP" ); break; } | 157 | case ETHERTYPE_ARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = ARP" ); break; } |
132 | case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; } | 158 | case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; } |
133 | default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" ); | 159 | default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" ); |
134 | } | 160 | } |
135 | 161 | ||
136 | } | 162 | } |
137 | 163 | ||
138 | 164 | ||
139 | OEthernetPacket::~OEthernetPacket() | 165 | OEthernetPacket::~OEthernetPacket() |
140 | { | 166 | { |
141 | } | 167 | } |
142 | 168 | ||
143 | 169 | ||
144 | OMacAddress OEthernetPacket::sourceAddress() const | 170 | OMacAddress OEthernetPacket::sourceAddress() const |
145 | { | 171 | { |
146 | return OMacAddress( _ether->ether_shost ); | 172 | return OMacAddress( _ether->ether_shost ); |
147 | } | 173 | } |
148 | 174 | ||
149 | 175 | ||
150 | OMacAddress OEthernetPacket::destinationAddress() const | 176 | OMacAddress OEthernetPacket::destinationAddress() const |
151 | { | 177 | { |
152 | return OMacAddress( _ether->ether_dhost ); | 178 | return OMacAddress( _ether->ether_dhost ); |
153 | } | 179 | } |
154 | 180 | ||
155 | int OEthernetPacket::type() const | 181 | int OEthernetPacket::type() const |
156 | { | 182 | { |
157 | return ntohs( _ether->ether_type ); | 183 | return ntohs( _ether->ether_type ); |
158 | } | 184 | } |
159 | 185 | ||
160 | 186 | ||
161 | /*====================================================================================== | 187 | /*====================================================================================== |
162 | * OIPPacket | 188 | * OIPPacket |
163 | *======================================================================================*/ | 189 | *======================================================================================*/ |
164 | 190 | ||
165 | 191 | ||
166 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) | 192 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) |
167 | :QObject( parent, "IP" ), _iphdr( data ) | 193 | :QObject( parent, "IP" ), _iphdr( data ) |
168 | 194 | ||
169 | { | 195 | { |
170 | qDebug( "OIPPacket::OIPPacket(): decoding IP header..." ); | 196 | qDebug( "OIPPacket::OIPPacket(): decoding IP header..." ); |
171 | 197 | ||
172 | //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) ); | 198 | //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) ); |
173 | //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) ); | 199 | //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) ); |
174 | 200 | ||
175 | qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() ); | 201 | qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() ); |
176 | qDebug( " toAddress: %s", (const char*) toIPAddress().toString() ); | 202 | qDebug( " toAddress: %s", (const char*) toIPAddress().toString() ); |
177 | 203 | ||
178 | switch ( protocol() ) | 204 | switch ( protocol() ) |
179 | { | 205 | { |
180 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; | 206 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; |
181 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; | 207 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; |
182 | default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() ); | 208 | default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() ); |
183 | } | 209 | } |
184 | 210 | ||
185 | } | 211 | } |
186 | 212 | ||
187 | OIPPacket::~OIPPacket() | 213 | OIPPacket::~OIPPacket() |
188 | { | 214 | { |
189 | } | 215 | } |
190 | 216 | ||
191 | 217 | ||
192 | QHostAddress OIPPacket::fromIPAddress() const | 218 | QHostAddress OIPPacket::fromIPAddress() const |
193 | { | 219 | { |
194 | return EXTRACT_32BITS( &_iphdr->saddr ); | 220 | return EXTRACT_32BITS( &_iphdr->saddr ); |
195 | } | 221 | } |
196 | 222 | ||
197 | 223 | ||
198 | QHostAddress OIPPacket::toIPAddress() const | 224 | QHostAddress OIPPacket::toIPAddress() const |
199 | { | 225 | { |
200 | return EXTRACT_32BITS( &_iphdr->saddr ); | 226 | return EXTRACT_32BITS( &_iphdr->saddr ); |
201 | } | 227 | } |
202 | 228 | ||
203 | 229 | ||
204 | int OIPPacket::tos() const | 230 | int OIPPacket::tos() const |
205 | { | 231 | { |
206 | return _iphdr->tos; | 232 | return _iphdr->tos; |
207 | } | 233 | } |
208 | 234 | ||
209 | 235 | ||
210 | int OIPPacket::len() const | 236 | int OIPPacket::len() const |
211 | { | 237 | { |
212 | return EXTRACT_16BITS( &_iphdr->tot_len ); | 238 | return EXTRACT_16BITS( &_iphdr->tot_len ); |
213 | } | 239 | } |
214 | 240 | ||
215 | 241 | ||
216 | int OIPPacket::id() const | 242 | int OIPPacket::id() const |
217 | { | 243 | { |
218 | return EXTRACT_16BITS( &_iphdr->id ); | 244 | return EXTRACT_16BITS( &_iphdr->id ); |
219 | } | 245 | } |
220 | 246 | ||
221 | 247 | ||
222 | int OIPPacket::offset() const | 248 | int OIPPacket::offset() const |
223 | { | 249 | { |
224 | return EXTRACT_16BITS( &_iphdr->frag_off ); | 250 | return EXTRACT_16BITS( &_iphdr->frag_off ); |
225 | } | 251 | } |
226 | 252 | ||
227 | 253 | ||
228 | int OIPPacket::ttl() const | 254 | int OIPPacket::ttl() const |
229 | { | 255 | { |
230 | return _iphdr->ttl; | 256 | return _iphdr->ttl; |
231 | } | 257 | } |
232 | 258 | ||
233 | 259 | ||
234 | int OIPPacket::protocol() const | 260 | int OIPPacket::protocol() const |
235 | { | 261 | { |
236 | return _iphdr->protocol; | 262 | return _iphdr->protocol; |
237 | } | 263 | } |
238 | 264 | ||
239 | 265 | ||
240 | int OIPPacket::checksum() const | 266 | int OIPPacket::checksum() const |
241 | { | 267 | { |
242 | return EXTRACT_16BITS( &_iphdr->check ); | 268 | return EXTRACT_16BITS( &_iphdr->check ); |
243 | } | 269 | } |
244 | 270 | ||
245 | /*====================================================================================== | 271 | /*====================================================================================== |
246 | * OUDPPacket | 272 | * OUDPPacket |
247 | *======================================================================================*/ | 273 | *======================================================================================*/ |
248 | 274 | ||
249 | 275 | ||
250 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) | 276 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) |
251 | :QObject( parent, "UDP" ), _udphdr( data ) | 277 | :QObject( parent, "UDP" ), _udphdr( data ) |
252 | 278 | ||
253 | { | 279 | { |
254 | qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); | 280 | qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); |
255 | } | 281 | } |
256 | 282 | ||
257 | OUDPPacket::~OUDPPacket() | 283 | OUDPPacket::~OUDPPacket() |
258 | { | 284 | { |
259 | } | 285 | } |
260 | 286 | ||
261 | 287 | ||
262 | /*====================================================================================== | 288 | /*====================================================================================== |
263 | * OTCPPacket | 289 | * OTCPPacket |
264 | *======================================================================================*/ | 290 | *======================================================================================*/ |
265 | 291 | ||
266 | 292 | ||
267 | OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) | 293 | OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) |
268 | :QObject( parent, "TCP" ), _tcphdr( data ) | 294 | :QObject( parent, "TCP" ), _tcphdr( data ) |
269 | 295 | ||
270 | { | 296 | { |
271 | qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); | 297 | qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); |
272 | } | 298 | } |
273 | 299 | ||
274 | OTCPPacket::~OTCPPacket() | 300 | OTCPPacket::~OTCPPacket() |
275 | { | 301 | { |
276 | } | 302 | } |
277 | 303 | ||
278 | 304 | ||
279 | /*====================================================================================== | 305 | /*====================================================================================== |
280 | * OWaveLanPacket | 306 | * OWaveLanPacket |
281 | *======================================================================================*/ | 307 | *======================================================================================*/ |
282 | 308 | ||
283 | 309 | ||
284 | OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) | 310 | OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) |
285 | :QObject( parent, "802.11" ), _wlanhdr( data ) | 311 | :QObject( parent, "802.11" ), _wlanhdr( data ) |
286 | 312 | ||
287 | { | 313 | { |
288 | qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); | 314 | qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); |
289 | qDebug( "type: %0X", type() ); | 315 | qDebug( "type: %0X", type() ); |
290 | qDebug( "subType: %0X", subType() ); | 316 | qDebug( "subType: %0X", subType() ); |
291 | qDebug( "duration: %d", duration() ); | 317 | qDebug( "duration: %d", duration() ); |
292 | qDebug( "powermanagement: %d", usesPowerManagement() ); | 318 | qDebug( "powermanagement: %d", usesPowerManagement() ); |
293 | qDebug( "wep: %d", usesWep() ); | 319 | qDebug( "wep: %d", usesWep() ); |
294 | qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); | 320 | qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); |
295 | qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); | 321 | qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); |
296 | qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); | 322 | qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); |
297 | qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); | 323 | qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); |
298 | 324 | ||
299 | switch ( type() ) | 325 | switch ( type() ) |
300 | { | 326 | { |
301 | case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; | 327 | case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; |
302 | case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; | 328 | case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; |
303 | //case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_ctrl_header*) data, this ); break; | 329 | //case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_ctrl_header*) data, this ); break; |
304 | default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown type!" ); | 330 | default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown type!" ); |
305 | } | 331 | } |
306 | } | 332 | } |
307 | 333 | ||
308 | OWaveLanPacket::~OWaveLanPacket() | 334 | OWaveLanPacket::~OWaveLanPacket() |
309 | { | 335 | { |
310 | } | 336 | } |
311 | 337 | ||
312 | 338 | ||
313 | int OWaveLanPacket::duration() const | 339 | int OWaveLanPacket::duration() const |
314 | { | 340 | { |
315 | return _wlanhdr->duration; | 341 | return _wlanhdr->duration; |
316 | } | 342 | } |
317 | 343 | ||
318 | 344 | ||
319 | OMacAddress OWaveLanPacket::macAddress1() const | 345 | OMacAddress OWaveLanPacket::macAddress1() const |
320 | { | 346 | { |
321 | return OMacAddress( _wlanhdr->mac1 ); | 347 | return OMacAddress( _wlanhdr->mac1 ); |
322 | } | 348 | } |
323 | 349 | ||
324 | 350 | ||
325 | OMacAddress OWaveLanPacket::macAddress2() const | 351 | OMacAddress OWaveLanPacket::macAddress2() const |
326 | { | 352 | { |
327 | return OMacAddress( _wlanhdr->mac2 ); | 353 | return OMacAddress( _wlanhdr->mac2 ); |
328 | } | 354 | } |
329 | 355 | ||
330 | 356 | ||
331 | OMacAddress OWaveLanPacket::macAddress3() const | 357 | OMacAddress OWaveLanPacket::macAddress3() const |
332 | { | 358 | { |
333 | return OMacAddress( _wlanhdr->mac3 ); | 359 | return OMacAddress( _wlanhdr->mac3 ); |
334 | } | 360 | } |
335 | 361 | ||
336 | 362 | ||
337 | OMacAddress OWaveLanPacket::macAddress4() const | 363 | OMacAddress OWaveLanPacket::macAddress4() const |
338 | { | 364 | { |
339 | return OMacAddress( _wlanhdr->mac4 ); | 365 | return OMacAddress( _wlanhdr->mac4 ); |
340 | } | 366 | } |
341 | 367 | ||
342 | 368 | ||
343 | int OWaveLanPacket::subType() const | 369 | int OWaveLanPacket::subType() const |
344 | { | 370 | { |
345 | return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 371 | return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
346 | } | 372 | } |
347 | 373 | ||
348 | 374 | ||
349 | int OWaveLanPacket::type() const | 375 | int OWaveLanPacket::type() const |
350 | { | 376 | { |
351 | return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 377 | return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
352 | } | 378 | } |
353 | 379 | ||
354 | 380 | ||
355 | int OWaveLanPacket::version() const | 381 | int OWaveLanPacket::version() const |
356 | { | 382 | { |
357 | return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 383 | return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
358 | } | 384 | } |
359 | 385 | ||
360 | 386 | ||
361 | bool OWaveLanPacket::fromDS() const | 387 | bool OWaveLanPacket::fromDS() const |
362 | { | 388 | { |
363 | return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 389 | return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
364 | } | 390 | } |
365 | 391 | ||
366 | 392 | ||
367 | bool OWaveLanPacket::toDS() const | 393 | bool OWaveLanPacket::toDS() const |
368 | { | 394 | { |
369 | return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 395 | return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
370 | } | 396 | } |
371 | 397 | ||
372 | 398 | ||
373 | bool OWaveLanPacket::usesPowerManagement() const | 399 | bool OWaveLanPacket::usesPowerManagement() const |
374 | { | 400 | { |
375 | return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 401 | return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
376 | } | 402 | } |
377 | 403 | ||
378 | 404 | ||
379 | bool OWaveLanPacket::usesWep() const | 405 | bool OWaveLanPacket::usesWep() const |
380 | { | 406 | { |
381 | return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 407 | return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
382 | } | 408 | } |
383 | 409 | ||
384 | 410 | ||
385 | /*====================================================================================== | 411 | /*====================================================================================== |
386 | * OWaveLanManagementPacket | 412 | * OWaveLanManagementPacket |
387 | *======================================================================================*/ | 413 | *======================================================================================*/ |
388 | 414 | ||
389 | OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) | 415 | OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) |
390 | :QObject( parent, "802.11 Management" ), _header( data ), | 416 | :QObject( parent, "802.11 Management" ), _header( data ), |
391 | _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) | 417 | _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) |
392 | { | 418 | { |
393 | qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." ); | 419 | qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." ); |
394 | 420 | ||
395 | switch ( ((OWaveLanPacket*) this->parent() )->subType() ) | 421 | switch ( ((OWaveLanPacket*) this->parent() )->subType() ) |
396 | { | 422 | { |
397 | case ST_BEACON: | 423 | case ST_BEACON: |
398 | { | 424 | { |
399 | // nice, received a beacon... | 425 | // nice, received a beacon... |
400 | } | 426 | } |
401 | } | 427 | } |
402 | 428 | ||
403 | // grab tagged values | 429 | // grab tagged values |
404 | const unsigned char* ptr = (const unsigned char*) (_body+1); | 430 | const unsigned char* ptr = (const unsigned char*) (_body+1); |
405 | while (ptr < end) | 431 | while (ptr < end) |
406 | { | 432 | { |
407 | switch ( *ptr ) | 433 | switch ( *ptr ) |
408 | { | 434 | { |
409 | case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break; | 435 | case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break; |
410 | case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break; | 436 | case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break; |
411 | case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break; | 437 | case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break; |
412 | case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break; | 438 | case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break; |
413 | case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break; | 439 | case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break; |
414 | case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break; | 440 | case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break; |
415 | case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break; | 441 | case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break; |
416 | case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break; | 442 | case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break; |
417 | } | 443 | } |
418 | ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value | 444 | ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value |
419 | ptr+= 2; // skip tag ID and length | 445 | ptr+= 2; // skip tag ID and length |
420 | } | 446 | } |
421 | } | 447 | } |
422 | 448 | ||
423 | 449 | ||
424 | OWaveLanManagementPacket::~OWaveLanManagementPacket() | 450 | OWaveLanManagementPacket::~OWaveLanManagementPacket() |
425 | { | 451 | { |
426 | } | 452 | } |
427 | 453 | ||
428 | 454 | ||
429 | int OWaveLanManagementPacket::beaconInterval() const | 455 | int OWaveLanManagementPacket::beaconInterval() const |
430 | { | 456 | { |
431 | return EXTRACT_LE_16BITS( &_body->beacon_interval ); | 457 | return EXTRACT_LE_16BITS( &_body->beacon_interval ); |
432 | } | 458 | } |
433 | 459 | ||
434 | 460 | ||
435 | int OWaveLanManagementPacket::capabilities() const | 461 | int OWaveLanManagementPacket::capabilities() const |
436 | { | 462 | { |
437 | return EXTRACT_LE_16BITS( &_body->capability_info ); | 463 | return EXTRACT_LE_16BITS( &_body->capability_info ); |
438 | } | 464 | } |
439 | 465 | ||
440 | 466 | ||
441 | bool OWaveLanManagementPacket::canESS() const | 467 | bool OWaveLanManagementPacket::canESS() const |
442 | { | 468 | { |
443 | return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 469 | return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
444 | } | 470 | } |
445 | 471 | ||
446 | 472 | ||
447 | bool OWaveLanManagementPacket::canIBSS() const | 473 | bool OWaveLanManagementPacket::canIBSS() const |
448 | { | 474 | { |
449 | return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 475 | return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
450 | } | 476 | } |
451 | 477 | ||
452 | 478 | ||
453 | bool OWaveLanManagementPacket::canCFP() const | 479 | bool OWaveLanManagementPacket::canCFP() const |
454 | { | 480 | { |
455 | return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 481 | return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
456 | } | 482 | } |
457 | 483 | ||
458 | 484 | ||
459 | bool OWaveLanManagementPacket::canCFP_REQ() const | 485 | bool OWaveLanManagementPacket::canCFP_REQ() const |
460 | { | 486 | { |
461 | return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 487 | return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
462 | } | 488 | } |
463 | 489 | ||
464 | 490 | ||
465 | bool OWaveLanManagementPacket::canPrivacy() const | 491 | bool OWaveLanManagementPacket::canPrivacy() const |
466 | { | 492 | { |
467 | return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 493 | return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
468 | } | 494 | } |
469 | 495 | ||
470 | 496 | ||
471 | /*====================================================================================== | 497 | /*====================================================================================== |
472 | * OWaveLanManagementSSID | 498 | * OWaveLanManagementSSID |
473 | *======================================================================================*/ | 499 | *======================================================================================*/ |
474 | 500 | ||
475 | OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent ) | 501 | OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent ) |
476 | :QObject( parent, "802.11 SSID" ), _data( data ) | 502 | :QObject( parent, "802.11 SSID" ), _data( data ) |
477 | { | 503 | { |
478 | qDebug( "OWaveLanManagementSSID()" ); | 504 | qDebug( "OWaveLanManagementSSID()" ); |
479 | } | 505 | } |
480 | 506 | ||
481 | 507 | ||
482 | OWaveLanManagementSSID::~OWaveLanManagementSSID() | 508 | OWaveLanManagementSSID::~OWaveLanManagementSSID() |
483 | { | 509 | { |
484 | } | 510 | } |
485 | 511 | ||
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index 0b06572..04d22ff 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h | |||
@@ -1,436 +1,436 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 by the Wellenreiter team: | 3 | Copyright (C) 2003 by the Wellenreiter team: |
4 | Martin J. Muench <mjm@remote-exploit.org> | 4 | Martin J. Muench <mjm@remote-exploit.org> |
5 | Max Moser <mmo@remote-exploit.org | 5 | Max Moser <mmo@remote-exploit.org |
6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef OPCAP_H | 34 | #ifndef OPCAP_H |
35 | #define OPCAP_H | 35 | #define OPCAP_H |
36 | 36 | ||
37 | /* LINUX */ | 37 | /* LINUX */ |
38 | extern "C" // work around a bpf/pcap conflict in recent headers | 38 | extern "C" // work around a bpf/pcap conflict in recent headers |
39 | { | 39 | { |
40 | #include <pcap.h> | 40 | #include <pcap.h> |
41 | } | 41 | } |
42 | #include <netinet/ether.h> | 42 | #include <netinet/ether.h> |
43 | #include <netinet/ip.h> | 43 | #include <netinet/ip.h> |
44 | #include <netinet/udp.h> | 44 | #include <netinet/udp.h> |
45 | #include <netinet/tcp.h> | 45 | #include <netinet/tcp.h> |
46 | #include <time.h> | 46 | #include <time.h> |
47 | 47 | ||
48 | /* QT */ | 48 | /* QT */ |
49 | #include <qhostaddress.h> | 49 | #include <qhostaddress.h> |
50 | #include <qobject.h> | 50 | #include <qobject.h> |
51 | #include <qstring.h> | 51 | #include <qstring.h> |
52 | 52 | ||
53 | /* OPIE */ | 53 | /* OPIE */ |
54 | #include <opie2/onetutils.h> | 54 | #include <opie2/onetutils.h> |
55 | #include "802_11_user.h" | 55 | #include "802_11_user.h" |
56 | 56 | ||
57 | /* TYPEDEFS */ | 57 | /* TYPEDEFS */ |
58 | typedef struct timeval timevalstruct; | 58 | typedef struct timeval timevalstruct; |
59 | typedef struct pcap_pkthdr packetheaderstruct; | 59 | typedef struct pcap_pkthdr packetheaderstruct; |
60 | 60 | ||
61 | /* FORWARDS */ | 61 | /* FORWARDS */ |
62 | class OPacketCapturer; | 62 | class OPacketCapturer; |
63 | class QSocketNotifier; | 63 | class QSocketNotifier; |
64 | 64 | ||
65 | /*====================================================================================== | 65 | /*====================================================================================== |
66 | * OPacket - A frame on the wire | 66 | * OPacket - A frame on the wire |
67 | *======================================================================================*/ | 67 | *======================================================================================*/ |
68 | 68 | ||
69 | class OPacket : public QObject | 69 | class OPacket : public QObject |
70 | { | 70 | { |
71 | Q_OBJECT | 71 | Q_OBJECT |
72 | 72 | ||
73 | public: | 73 | public: |
74 | OPacket( packetheaderstruct, const unsigned char*, QObject* parent ); | 74 | OPacket( packetheaderstruct, const unsigned char*, QObject* parent ); |
75 | virtual ~OPacket(); | 75 | virtual ~OPacket(); |
76 | 76 | ||
77 | timevalstruct timeval() const; | 77 | timevalstruct timeval() const; |
78 | 78 | ||
79 | OPacketCapturer* packetCapturer() const; | 79 | OPacketCapturer* packetCapturer() const; |
80 | 80 | ||
81 | int caplen() const; | 81 | int caplen() const; |
82 | int len() const; | 82 | int len() const; |
83 | void dump() const; | 83 | QString dump( int = 32 ) const; |
84 | 84 | ||
85 | private: | 85 | private: |
86 | const packetheaderstruct _hdr; // pcap packet header | 86 | const packetheaderstruct _hdr; // pcap packet header |
87 | const unsigned char* _data; // pcap packet data | 87 | const unsigned char* _data; // pcap packet data |
88 | const unsigned char* _end; // end of pcap packet data | 88 | const unsigned char* _end; // end of pcap packet data |
89 | }; | 89 | }; |
90 | 90 | ||
91 | /*====================================================================================== | 91 | /*====================================================================================== |
92 | * OEthernetPacket - DLT_EN10MB frame | 92 | * OEthernetPacket - DLT_EN10MB frame |
93 | *======================================================================================*/ | 93 | *======================================================================================*/ |
94 | 94 | ||
95 | class OEthernetPacket : public QObject | 95 | class OEthernetPacket : public QObject |
96 | { | 96 | { |
97 | Q_OBJECT | 97 | Q_OBJECT |
98 | 98 | ||
99 | public: | 99 | public: |
100 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); | 100 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); |
101 | virtual ~OEthernetPacket(); | 101 | virtual ~OEthernetPacket(); |
102 | 102 | ||
103 | OMacAddress sourceAddress() const; | 103 | OMacAddress sourceAddress() const; |
104 | OMacAddress destinationAddress() const; | 104 | OMacAddress destinationAddress() const; |
105 | int type() const; | 105 | int type() const; |
106 | 106 | ||
107 | private: | 107 | private: |
108 | const struct ether_header* _ether; | 108 | const struct ether_header* _ether; |
109 | }; | 109 | }; |
110 | 110 | ||
111 | 111 | ||
112 | /*====================================================================================== | 112 | /*====================================================================================== |
113 | * OWaveLanPacket - DLT_IEEE802_11 frame | 113 | * OWaveLanPacket - DLT_IEEE802_11 frame |
114 | *======================================================================================*/ | 114 | *======================================================================================*/ |
115 | 115 | ||
116 | class OWaveLanPacket : public QObject | 116 | class OWaveLanPacket : public QObject |
117 | { | 117 | { |
118 | Q_OBJECT | 118 | Q_OBJECT |
119 | 119 | ||
120 | public: | 120 | public: |
121 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); | 121 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); |
122 | virtual ~OWaveLanPacket(); | 122 | virtual ~OWaveLanPacket(); |
123 | 123 | ||
124 | int duration() const; | 124 | int duration() const; |
125 | bool fromDS() const; | 125 | bool fromDS() const; |
126 | bool toDS() const; | 126 | bool toDS() const; |
127 | virtual OMacAddress macAddress1() const; | 127 | virtual OMacAddress macAddress1() const; |
128 | virtual OMacAddress macAddress2() const; | 128 | virtual OMacAddress macAddress2() const; |
129 | virtual OMacAddress macAddress3() const; | 129 | virtual OMacAddress macAddress3() const; |
130 | virtual OMacAddress macAddress4() const; | 130 | virtual OMacAddress macAddress4() const; |
131 | bool usesPowerManagement() const; | 131 | bool usesPowerManagement() const; |
132 | int type() const; | 132 | int type() const; |
133 | int subType() const; | 133 | int subType() const; |
134 | int version() const; | 134 | int version() const; |
135 | bool usesWep() const; | 135 | bool usesWep() const; |
136 | 136 | ||
137 | private: | 137 | private: |
138 | const struct ieee_802_11_header* _wlanhdr; | 138 | const struct ieee_802_11_header* _wlanhdr; |
139 | }; | 139 | }; |
140 | 140 | ||
141 | 141 | ||
142 | /*====================================================================================== | 142 | /*====================================================================================== |
143 | * OWaveLanManagementPacket - type: management (T_MGMT) | 143 | * OWaveLanManagementPacket - type: management (T_MGMT) |
144 | *======================================================================================*/ | 144 | *======================================================================================*/ |
145 | 145 | ||
146 | class OWaveLanManagementPacket : public QObject | 146 | class OWaveLanManagementPacket : public QObject |
147 | { | 147 | { |
148 | Q_OBJECT | 148 | Q_OBJECT |
149 | 149 | ||
150 | public: | 150 | public: |
151 | OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); | 151 | OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); |
152 | virtual ~OWaveLanManagementPacket(); | 152 | virtual ~OWaveLanManagementPacket(); |
153 | 153 | ||
154 | int beaconInterval() const; | 154 | int beaconInterval() const; |
155 | int capabilities() const; // generic | 155 | int capabilities() const; // generic |
156 | 156 | ||
157 | bool canESS() const; | 157 | bool canESS() const; |
158 | bool canIBSS() const; | 158 | bool canIBSS() const; |
159 | bool canCFP() const; | 159 | bool canCFP() const; |
160 | bool canCFP_REQ() const; | 160 | bool canCFP_REQ() const; |
161 | bool canPrivacy() const; | 161 | bool canPrivacy() const; |
162 | 162 | ||
163 | private: | 163 | private: |
164 | const struct ieee_802_11_mgmt_header* _header; | 164 | const struct ieee_802_11_mgmt_header* _header; |
165 | const struct ieee_802_11_mgmt_body* _body; | 165 | const struct ieee_802_11_mgmt_body* _body; |
166 | }; | 166 | }; |
167 | 167 | ||
168 | 168 | ||
169 | /*====================================================================================== | 169 | /*====================================================================================== |
170 | * OWaveLanManagementSSID | 170 | * OWaveLanManagementSSID |
171 | *======================================================================================*/ | 171 | *======================================================================================*/ |
172 | 172 | ||
173 | class OWaveLanManagementSSID : public QObject | 173 | class OWaveLanManagementSSID : public QObject |
174 | { | 174 | { |
175 | Q_OBJECT | 175 | Q_OBJECT |
176 | 176 | ||
177 | public: | 177 | public: |
178 | OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); | 178 | OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); |
179 | virtual ~OWaveLanManagementSSID(); | 179 | virtual ~OWaveLanManagementSSID(); |
180 | 180 | ||
181 | QString ID() const; | 181 | QString ID() const; |
182 | 182 | ||
183 | private: | 183 | private: |
184 | const struct ssid_t* _data; | 184 | const struct ssid_t* _data; |
185 | }; | 185 | }; |
186 | 186 | ||
187 | /*====================================================================================== | 187 | /*====================================================================================== |
188 | * OWaveLanManagementRates | 188 | * OWaveLanManagementRates |
189 | *======================================================================================*/ | 189 | *======================================================================================*/ |
190 | 190 | ||
191 | class OWaveLanManagementRates : public QObject | 191 | class OWaveLanManagementRates : public QObject |
192 | { | 192 | { |
193 | Q_OBJECT | 193 | Q_OBJECT |
194 | 194 | ||
195 | public: | 195 | public: |
196 | OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); | 196 | OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); |
197 | virtual ~OWaveLanManagementRates(); | 197 | virtual ~OWaveLanManagementRates(); |
198 | 198 | ||
199 | private: | 199 | private: |
200 | const struct rates_t* _data; | 200 | const struct rates_t* _data; |
201 | }; | 201 | }; |
202 | 202 | ||
203 | /*====================================================================================== | 203 | /*====================================================================================== |
204 | * OWaveLanManagementCF | 204 | * OWaveLanManagementCF |
205 | *======================================================================================*/ | 205 | *======================================================================================*/ |
206 | 206 | ||
207 | class OWaveLanManagementCF : public QObject | 207 | class OWaveLanManagementCF : public QObject |
208 | { | 208 | { |
209 | Q_OBJECT | 209 | Q_OBJECT |
210 | 210 | ||
211 | public: | 211 | public: |
212 | OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); | 212 | OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); |
213 | virtual ~OWaveLanManagementCF(); | 213 | virtual ~OWaveLanManagementCF(); |
214 | 214 | ||
215 | private: | 215 | private: |
216 | const struct cf_t* _data; | 216 | const struct cf_t* _data; |
217 | }; | 217 | }; |
218 | 218 | ||
219 | /*====================================================================================== | 219 | /*====================================================================================== |
220 | * OWaveLanManagementFH | 220 | * OWaveLanManagementFH |
221 | *======================================================================================*/ | 221 | *======================================================================================*/ |
222 | 222 | ||
223 | class OWaveLanManagementFH : public QObject | 223 | class OWaveLanManagementFH : public QObject |
224 | { | 224 | { |
225 | Q_OBJECT | 225 | Q_OBJECT |
226 | 226 | ||
227 | public: | 227 | public: |
228 | OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); | 228 | OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); |
229 | virtual ~OWaveLanManagementFH(); | 229 | virtual ~OWaveLanManagementFH(); |
230 | 230 | ||
231 | private: | 231 | private: |
232 | const struct fh_t* _data; | 232 | const struct fh_t* _data; |
233 | }; | 233 | }; |
234 | 234 | ||
235 | /*====================================================================================== | 235 | /*====================================================================================== |
236 | * OWaveLanManagementDS | 236 | * OWaveLanManagementDS |
237 | *======================================================================================*/ | 237 | *======================================================================================*/ |
238 | 238 | ||
239 | class OWaveLanManagementDS : public QObject | 239 | class OWaveLanManagementDS : public QObject |
240 | { | 240 | { |
241 | Q_OBJECT | 241 | Q_OBJECT |
242 | 242 | ||
243 | public: | 243 | public: |
244 | OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); | 244 | OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); |
245 | virtual ~OWaveLanManagementDS(); | 245 | virtual ~OWaveLanManagementDS(); |
246 | 246 | ||
247 | int channel() const; | 247 | int channel() const; |
248 | 248 | ||
249 | private: | 249 | private: |
250 | const struct ds_t* _data; | 250 | const struct ds_t* _data; |
251 | }; | 251 | }; |
252 | 252 | ||
253 | /*====================================================================================== | 253 | /*====================================================================================== |
254 | * OWaveLanManagementTim | 254 | * OWaveLanManagementTim |
255 | *======================================================================================*/ | 255 | *======================================================================================*/ |
256 | 256 | ||
257 | class OWaveLanManagementTim : public QObject | 257 | class OWaveLanManagementTim : public QObject |
258 | { | 258 | { |
259 | Q_OBJECT | 259 | Q_OBJECT |
260 | 260 | ||
261 | public: | 261 | public: |
262 | OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); | 262 | OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); |
263 | virtual ~OWaveLanManagementTim(); | 263 | virtual ~OWaveLanManagementTim(); |
264 | 264 | ||
265 | private: | 265 | private: |
266 | const struct tim_t* _data; | 266 | const struct tim_t* _data; |
267 | }; | 267 | }; |
268 | 268 | ||
269 | /*====================================================================================== | 269 | /*====================================================================================== |
270 | * OWaveLanManagementIBSS | 270 | * OWaveLanManagementIBSS |
271 | *======================================================================================*/ | 271 | *======================================================================================*/ |
272 | 272 | ||
273 | class OWaveLanManagementIBSS : public QObject | 273 | class OWaveLanManagementIBSS : public QObject |
274 | { | 274 | { |
275 | Q_OBJECT | 275 | Q_OBJECT |
276 | 276 | ||
277 | public: | 277 | public: |
278 | OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); | 278 | OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); |
279 | virtual ~OWaveLanManagementIBSS(); | 279 | virtual ~OWaveLanManagementIBSS(); |
280 | 280 | ||
281 | private: | 281 | private: |
282 | const struct ibss_t* _data; | 282 | const struct ibss_t* _data; |
283 | }; | 283 | }; |
284 | 284 | ||
285 | /*====================================================================================== | 285 | /*====================================================================================== |
286 | * OWaveLanManagementChallenge | 286 | * OWaveLanManagementChallenge |
287 | *======================================================================================*/ | 287 | *======================================================================================*/ |
288 | 288 | ||
289 | class OWaveLanManagementChallenge : public QObject | 289 | class OWaveLanManagementChallenge : public QObject |
290 | { | 290 | { |
291 | Q_OBJECT | 291 | Q_OBJECT |
292 | 292 | ||
293 | public: | 293 | public: |
294 | OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); | 294 | OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); |
295 | virtual ~OWaveLanManagementChallenge(); | 295 | virtual ~OWaveLanManagementChallenge(); |
296 | 296 | ||
297 | private: | 297 | private: |
298 | const struct challenge_t* _data; | 298 | const struct challenge_t* _data; |
299 | }; | 299 | }; |
300 | 300 | ||
301 | /*====================================================================================== | 301 | /*====================================================================================== |
302 | * OWaveLanDataPacket - type: data (T_DATA) | 302 | * OWaveLanDataPacket - type: data (T_DATA) |
303 | *======================================================================================*/ | 303 | *======================================================================================*/ |
304 | 304 | ||
305 | class OWaveLanDataPacket : public QObject | 305 | class OWaveLanDataPacket : public QObject |
306 | { | 306 | { |
307 | Q_OBJECT | 307 | Q_OBJECT |
308 | 308 | ||
309 | public: | 309 | public: |
310 | OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); | 310 | OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); |
311 | virtual ~OWaveLanDataPacket(); | 311 | virtual ~OWaveLanDataPacket(); |
312 | 312 | ||
313 | private: | 313 | private: |
314 | const struct ieee_802_11_data_header* _header; | 314 | const struct ieee_802_11_data_header* _header; |
315 | }; | 315 | }; |
316 | 316 | ||
317 | /*====================================================================================== | 317 | /*====================================================================================== |
318 | * OLLCPacket - IEEE 802.2 Link Level Control | 318 | * OLLCPacket - IEEE 802.2 Link Level Control |
319 | *======================================================================================*/ | 319 | *======================================================================================*/ |
320 | 320 | ||
321 | class OLLCPacket : public QObject | 321 | class OLLCPacket : public QObject |
322 | { | 322 | { |
323 | Q_OBJECT | 323 | Q_OBJECT |
324 | 324 | ||
325 | public: | 325 | public: |
326 | OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); | 326 | OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); |
327 | virtual ~OLLCPacket(); | 327 | virtual ~OLLCPacket(); |
328 | 328 | ||
329 | private: | 329 | private: |
330 | const struct ieee_802_11_802_2_header* _header; | 330 | const struct ieee_802_11_802_2_header* _header; |
331 | }; | 331 | }; |
332 | 332 | ||
333 | /*====================================================================================== | 333 | /*====================================================================================== |
334 | * OIPPacket | 334 | * OIPPacket |
335 | *======================================================================================*/ | 335 | *======================================================================================*/ |
336 | 336 | ||
337 | class OIPPacket : public QObject | 337 | class OIPPacket : public QObject |
338 | { | 338 | { |
339 | Q_OBJECT | 339 | Q_OBJECT |
340 | 340 | ||
341 | public: | 341 | public: |
342 | OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); | 342 | OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); |
343 | virtual ~OIPPacket(); | 343 | virtual ~OIPPacket(); |
344 | 344 | ||
345 | QHostAddress fromIPAddress() const; | 345 | QHostAddress fromIPAddress() const; |
346 | QHostAddress toIPAddress() const; | 346 | QHostAddress toIPAddress() const; |
347 | 347 | ||
348 | int tos() const; | 348 | int tos() const; |
349 | int len() const; | 349 | int len() const; |
350 | int id() const; | 350 | int id() const; |
351 | int offset() const; | 351 | int offset() const; |
352 | int ttl() const; | 352 | int ttl() const; |
353 | int protocol() const; | 353 | int protocol() const; |
354 | int checksum() const; | 354 | int checksum() const; |
355 | 355 | ||
356 | private: | 356 | private: |
357 | const struct iphdr* _iphdr; | 357 | const struct iphdr* _iphdr; |
358 | }; | 358 | }; |
359 | 359 | ||
360 | /*====================================================================================== | 360 | /*====================================================================================== |
361 | * OUDPPacket | 361 | * OUDPPacket |
362 | *======================================================================================*/ | 362 | *======================================================================================*/ |
363 | 363 | ||
364 | class OUDPPacket : public QObject | 364 | class OUDPPacket : public QObject |
365 | { | 365 | { |
366 | Q_OBJECT | 366 | Q_OBJECT |
367 | 367 | ||
368 | public: | 368 | public: |
369 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); | 369 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); |
370 | virtual ~OUDPPacket(); | 370 | virtual ~OUDPPacket(); |
371 | 371 | ||
372 | int fromPort() const; | 372 | int fromPort() const; |
373 | int toPort() const; | 373 | int toPort() const; |
374 | 374 | ||
375 | private: | 375 | private: |
376 | const struct udphdr* _udphdr; | 376 | const struct udphdr* _udphdr; |
377 | }; | 377 | }; |
378 | 378 | ||
379 | /*====================================================================================== | 379 | /*====================================================================================== |
380 | * OTCPPacket | 380 | * OTCPPacket |
381 | *======================================================================================*/ | 381 | *======================================================================================*/ |
382 | 382 | ||
383 | class OTCPPacket : public QObject | 383 | class OTCPPacket : public QObject |
384 | { | 384 | { |
385 | Q_OBJECT | 385 | Q_OBJECT |
386 | 386 | ||
387 | public: | 387 | public: |
388 | OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); | 388 | OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); |
389 | virtual ~OTCPPacket(); | 389 | virtual ~OTCPPacket(); |
390 | 390 | ||
391 | int fromPort() const; | 391 | int fromPort() const; |
392 | int toPort() const; | 392 | int toPort() const; |
393 | 393 | ||
394 | private: | 394 | private: |
395 | const struct tcphdr* _tcphdr; | 395 | const struct tcphdr* _tcphdr; |
396 | }; | 396 | }; |
397 | 397 | ||
398 | 398 | ||
399 | /*====================================================================================== | 399 | /*====================================================================================== |
400 | * OPacketCapturer | 400 | * OPacketCapturer |
401 | *======================================================================================*/ | 401 | *======================================================================================*/ |
402 | 402 | ||
403 | class OPacketCapturer : public QObject | 403 | class OPacketCapturer : public QObject |
404 | { | 404 | { |
405 | Q_OBJECT | 405 | Q_OBJECT |
406 | 406 | ||
407 | public: | 407 | public: |
408 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); | 408 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); |
409 | ~OPacketCapturer(); | 409 | ~OPacketCapturer(); |
410 | 410 | ||
411 | void setBlocking( bool ); | 411 | void setBlocking( bool ); |
412 | bool blocking() const; | 412 | bool blocking() const; |
413 | 413 | ||
414 | void close(); | 414 | void close(); |
415 | int dataLink() const; | 415 | int dataLink() const; |
416 | int fileno() const; | 416 | int fileno() const; |
417 | OPacket* next(); | 417 | OPacket* next(); |
418 | bool open( const QString& name ); | 418 | bool open( const QString& name ); |
419 | bool isOpen() const; | 419 | bool isOpen() const; |
420 | 420 | ||
421 | signals: | 421 | signals: |
422 | void receivedPacket( OPacket* ); | 422 | void receivedPacket( OPacket* ); |
423 | 423 | ||
424 | protected slots: | 424 | protected slots: |
425 | void readyToReceive(); | 425 | void readyToReceive(); |
426 | 426 | ||
427 | protected: | 427 | protected: |
428 | QString _name; // devicename | 428 | QString _name; // devicename |
429 | bool _open; // check this before doing pcap calls | 429 | bool _open; // check this before doing pcap calls |
430 | pcap_t* _pch; // pcap library handle | 430 | pcap_t* _pch; // pcap library handle |
431 | QSocketNotifier* _sn; // socket notifier for main loop | 431 | QSocketNotifier* _sn; // socket notifier for main loop |
432 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; | 432 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; |
433 | }; | 433 | }; |
434 | 434 | ||
435 | #endif // OPCAP_H | 435 | #endif // OPCAP_H |
436 | 436 | ||