author | mickeyl <mickeyl> | 2003-10-02 20:53:58 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-02 20:53:58 (UTC) |
commit | 78b29c765dbe70faec614796a4d1421eaf0ec773 (patch) (unidiff) | |
tree | 2db88636d14a462d8538003bcd282f3140b1d5f6 /libopie2/opienet | |
parent | e4fc6c395dd0a7400ed2cf76b3148dd7f535c2ea (diff) | |
download | opie-78b29c765dbe70faec614796a4d1421eaf0ec773.zip opie-78b29c765dbe70faec614796a4d1421eaf0ec773.tar.gz opie-78b29c765dbe70faec614796a4d1421eaf0ec773.tar.bz2 |
prepare dhcp decoding
-rw-r--r-- | libopie2/opienet/dhcp.h | 200 | ||||
-rw-r--r-- | libopie2/opienet/opcap.cpp | 79 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 28 | ||||
-rw-r--r-- | libopie2/opienet/opienet.pro | 4 |
4 files changed, 309 insertions, 2 deletions
diff --git a/libopie2/opienet/dhcp.h b/libopie2/opienet/dhcp.h new file mode 100644 index 0000000..3f2f775 --- a/dev/null +++ b/libopie2/opienet/dhcp.h | |||
@@ -0,0 +1,200 @@ | |||
1 | /* dhcp.h | ||
2 | |||
3 | Protocol structures... */ | ||
4 | |||
5 | /* | ||
6 | * Copyright (c) 1995-2001 The Internet Software Consortium. | ||
7 | * All rights reserved. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * | ||
13 | * 1. Redistributions of source code must retain the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. Neither the name of The Internet Software Consortium nor the names | ||
19 | * of its contributors may be used to endorse or promote products derived | ||
20 | * from this software without specific prior written permission. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND | ||
23 | * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
24 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
26 | * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR | ||
27 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
29 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
30 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
31 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
33 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
34 | * SUCH DAMAGE. | ||
35 | * | ||
36 | * This software has been written for the Internet Software Consortium | ||
37 | * by Ted Lemon in cooperation with Vixie Enterprises. To learn more | ||
38 | * about the Internet Software Consortium, see ``http://www.isc.org''. | ||
39 | * To learn more about Vixie Enterprises, see ``http://www.vix.com''. | ||
40 | */ | ||
41 | |||
42 | #ifndef DHCP_H | ||
43 | #define DHCP_H | ||
44 | |||
45 | #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \ | ||
46 | 20 + /* IP header */ \ | ||
47 | 8) /* UDP header */ | ||
48 | #define DHCP_SNAME_LEN 64 | ||
49 | #define DHCP_FILE_LEN 128 | ||
50 | #define DHCP_FIXED_NON_UDP236 | ||
51 | #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD) | ||
52 | /* Everything but options. */ | ||
53 | #define DHCP_MTU_MAX 1500 | ||
54 | #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN) | ||
55 | |||
56 | #define BOOTP_MIN_LEN 300 | ||
57 | #define DHCP_MIN_LEN 548 | ||
58 | |||
59 | struct dhcp_packet { | ||
60 | u_int8_t op; /* 0: Message opcode/type */ | ||
61 | u_int8_t htype;/* 1: Hardware addr type (net/if_types.h) */ | ||
62 | u_int8_t hlen; /* 2: Hardware addr length */ | ||
63 | u_int8_t hops; /* 3: Number of relay agent hops from client */ | ||
64 | u_int32_t xid; /* 4: Transaction ID */ | ||
65 | u_int16_t secs; /* 8: Seconds since client started looking */ | ||
66 | u_int16_t flags;/* 10: Flag bits */ | ||
67 | struct in_addr ciaddr;/* 12: Client IP address (if already in use) */ | ||
68 | struct in_addr yiaddr;/* 16: Client IP address */ | ||
69 | struct in_addr siaddr;/* 18: IP address of next server to talk to */ | ||
70 | struct in_addr giaddr;/* 20: DHCP relay agent IP address */ | ||
71 | unsigned char chaddr [16];/* 24: Client hardware address */ | ||
72 | char sname [DHCP_SNAME_LEN];/* 40: Server name */ | ||
73 | char file [DHCP_FILE_LEN];/* 104: Boot filename */ | ||
74 | unsigned char options [DHCP_OPTION_LEN]; | ||
75 | /* 212: Optional parameters | ||
76 | (actual length dependent on MTU). */ | ||
77 | }; | ||
78 | |||
79 | /* BOOTP (rfc951) message types */ | ||
80 | #define BOOTREQUEST1 | ||
81 | #define BOOTREPLY2 | ||
82 | |||
83 | /* Possible values for flags field... */ | ||
84 | #define BOOTP_BROADCAST 32768L | ||
85 | |||
86 | /* Possible values for hardware type (htype) field... */ | ||
87 | #define HTYPE_ETHER1 /* Ethernet 10Mbps */ | ||
88 | #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/ | ||
89 | #define HTYPE_FDDI 8 /* FDDI... */ | ||
90 | |||
91 | /* Magic cookie validating dhcp options field (and bootp vendor | ||
92 | extensions field). */ | ||
93 | #define DHCP_OPTIONS_COOKIE"\143\202\123\143" | ||
94 | |||
95 | /* DHCP Option codes: */ | ||
96 | |||
97 | #define DHO_PAD 0 | ||
98 | #define DHO_SUBNET_MASK 1 | ||
99 | #define DHO_TIME_OFFSET 2 | ||
100 | #define DHO_ROUTERS 3 | ||
101 | #define DHO_TIME_SERVERS 4 | ||
102 | #define DHO_NAME_SERVERS 5 | ||
103 | #define DHO_DOMAIN_NAME_SERVERS 6 | ||
104 | #define DHO_LOG_SERVERS 7 | ||
105 | #define DHO_COOKIE_SERVERS 8 | ||
106 | #define DHO_LPR_SERVERS 9 | ||
107 | #define DHO_IMPRESS_SERVERS 10 | ||
108 | #define DHO_RESOURCE_LOCATION_SERVERS11 | ||
109 | #define DHO_HOST_NAME 12 | ||
110 | #define DHO_BOOT_SIZE 13 | ||
111 | #define DHO_MERIT_DUMP 14 | ||
112 | #define DHO_DOMAIN_NAME 15 | ||
113 | #define DHO_SWAP_SERVER 16 | ||
114 | #define DHO_ROOT_PATH 17 | ||
115 | #define DHO_EXTENSIONS_PATH 18 | ||
116 | #define DHO_IP_FORWARDING 19 | ||
117 | #define DHO_NON_LOCAL_SOURCE_ROUTING20 | ||
118 | #define DHO_POLICY_FILTER 21 | ||
119 | #define DHO_MAX_DGRAM_REASSEMBLY22 | ||
120 | #define DHO_DEFAULT_IP_TTL 23 | ||
121 | #define DHO_PATH_MTU_AGING_TIMEOUT24 | ||
122 | #define DHO_PATH_MTU_PLATEAU_TABLE25 | ||
123 | #define DHO_INTERFACE_MTU 26 | ||
124 | #define DHO_ALL_SUBNETS_LOCAL 27 | ||
125 | #define DHO_BROADCAST_ADDRESS 28 | ||
126 | #define DHO_PERFORM_MASK_DISCOVERY29 | ||
127 | #define DHO_MASK_SUPPLIER 30 | ||
128 | #define DHO_ROUTER_DISCOVERY 31 | ||
129 | #define DHO_ROUTER_SOLICITATION_ADDRESS32 | ||
130 | #define DHO_STATIC_ROUTES 33 | ||
131 | #define DHO_TRAILER_ENCAPSULATION34 | ||
132 | #define DHO_ARP_CACHE_TIMEOUT 35 | ||
133 | #define DHO_IEEE802_3_ENCAPSULATION36 | ||
134 | #define DHO_DEFAULT_TCP_TTL 37 | ||
135 | #define DHO_TCP_KEEPALIVE_INTERVAL38 | ||
136 | #define DHO_TCP_KEEPALIVE_GARBAGE39 | ||
137 | #define DHO_NIS_DOMAIN 40 | ||
138 | #define DHO_NIS_SERVERS 41 | ||
139 | #define DHO_NTP_SERVERS 42 | ||
140 | #define DHO_VENDOR_ENCAPSULATED_OPTIONS43 | ||
141 | #define DHO_NETBIOS_NAME_SERVERS44 | ||
142 | #define DHO_NETBIOS_DD_SERVER 45 | ||
143 | #define DHO_NETBIOS_NODE_TYPE 46 | ||
144 | #define DHO_NETBIOS_SCOPE 47 | ||
145 | #define DHO_FONT_SERVERS 48 | ||
146 | #define DHO_X_DISPLAY_MANAGER 49 | ||
147 | #define DHO_DHCP_REQUESTED_ADDRESS50 | ||
148 | #define DHO_DHCP_LEASE_TIME 51 | ||
149 | #define DHO_DHCP_OPTION_OVERLOAD52 | ||
150 | #define DHO_DHCP_MESSAGE_TYPE 53 | ||
151 | #define DHO_DHCP_SERVER_IDENTIFIER54 | ||
152 | #define DHO_DHCP_PARAMETER_REQUEST_LIST55 | ||
153 | #define DHO_DHCP_MESSAGE 56 | ||
154 | #define DHO_DHCP_MAX_MESSAGE_SIZE57 | ||
155 | #define DHO_DHCP_RENEWAL_TIME 58 | ||
156 | #define DHO_DHCP_REBINDING_TIME 59 | ||
157 | #define DHO_VENDOR_CLASS_IDENTIFIER60 | ||
158 | #define DHO_DHCP_CLIENT_IDENTIFIER61 | ||
159 | #define DHO_NWIP_DOMAIN_NAME 62 | ||
160 | #define DHO_NWIP_SUBOPTIONS 63 | ||
161 | #define DHO_USER_CLASS 77 | ||
162 | #define DHO_FQDN 81 | ||
163 | #define DHO_DHCP_AGENT_OPTIONS 82 | ||
164 | #define DHO_SUBNET_SELECTION 118 /* RFC3011! */ | ||
165 | /* The DHO_AUTHENTICATE option is not a standard yet, so I've | ||
166 | allocated an option out of the "local" option space for it on a | ||
167 | temporary basis. Once an option code number is assigned, I will | ||
168 | immediately and shamelessly break this, so don't count on it | ||
169 | continuing to work. */ | ||
170 | #define DHO_AUTHENTICATE 210 | ||
171 | |||
172 | #define DHO_END 255 | ||
173 | |||
174 | /* DHCP message types. */ | ||
175 | #define DHCPDISCOVER1 | ||
176 | #define DHCPOFFER2 | ||
177 | #define DHCPREQUEST3 | ||
178 | #define DHCPDECLINE4 | ||
179 | #define DHCPACK 5 | ||
180 | #define DHCPNAK 6 | ||
181 | #define DHCPRELEASE7 | ||
182 | #define DHCPINFORM8 | ||
183 | |||
184 | /* Relay Agent Information option subtypes: */ | ||
185 | #define RAI_CIRCUIT_ID1 | ||
186 | #define RAI_REMOTE_ID2 | ||
187 | #define RAI_AGENT_ID3 | ||
188 | |||
189 | /* FQDN suboptions: */ | ||
190 | #define FQDN_NO_CLIENT_UPDATE 1 | ||
191 | #define FQDN_SERVER_UPDATE 2 | ||
192 | #define FQDN_ENCODED 3 | ||
193 | #define FQDN_RCODE1 4 | ||
194 | #define FQDN_RCODE2 5 | ||
195 | #define FQDN_HOSTNAME 6 | ||
196 | #define FQDN_DOMAINNAME 7 | ||
197 | #define FQDN_FQDN 8 | ||
198 | #define FQDN_SUBOPTION_COUNT 8 | ||
199 | |||
200 | #endif \ No newline at end of file | ||
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 1de7124..cc8ce7f 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -263,214 +263,293 @@ int OIPPacket::id() const | |||
263 | 263 | ||
264 | int OIPPacket::offset() const | 264 | int OIPPacket::offset() const |
265 | { | 265 | { |
266 | return EXTRACT_16BITS( &_iphdr->frag_off ); | 266 | return EXTRACT_16BITS( &_iphdr->frag_off ); |
267 | } | 267 | } |
268 | 268 | ||
269 | 269 | ||
270 | int OIPPacket::ttl() const | 270 | int OIPPacket::ttl() const |
271 | { | 271 | { |
272 | return _iphdr->ttl; | 272 | return _iphdr->ttl; |
273 | } | 273 | } |
274 | 274 | ||
275 | 275 | ||
276 | int OIPPacket::protocol() const | 276 | int OIPPacket::protocol() const |
277 | { | 277 | { |
278 | return _iphdr->protocol; | 278 | return _iphdr->protocol; |
279 | } | 279 | } |
280 | 280 | ||
281 | 281 | ||
282 | int OIPPacket::checksum() const | 282 | int OIPPacket::checksum() const |
283 | { | 283 | { |
284 | return EXTRACT_16BITS( &_iphdr->check ); | 284 | return EXTRACT_16BITS( &_iphdr->check ); |
285 | } | 285 | } |
286 | 286 | ||
287 | /*====================================================================================== | 287 | /*====================================================================================== |
288 | * OARPPacket | 288 | * OARPPacket |
289 | *======================================================================================*/ | 289 | *======================================================================================*/ |
290 | 290 | ||
291 | 291 | ||
292 | OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) | 292 | OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) |
293 | :QObject( parent, "ARP" ), _arphdr( data ) | 293 | :QObject( parent, "ARP" ), _arphdr( data ) |
294 | { | 294 | { |
295 | qDebug( "OARPPacket::OARPPacket(): decoding ARP header..." ); | 295 | qDebug( "OARPPacket::OARPPacket(): decoding ARP header..." ); |
296 | qDebug( "ARP type seems to be %02d - '%s'", EXTRACT_16BITS( &_arphdr->ar_op ), (const char*) type() ); | 296 | qDebug( "ARP type seems to be %02d - '%s'", EXTRACT_16BITS( &_arphdr->ar_op ), (const char*) type() ); |
297 | qDebug( "Sender: MAC %s = IP %s", (const char*) senderMacAddress().toString(), (const char*) senderIPV4Address().toString() ); | 297 | qDebug( "Sender: MAC %s = IP %s", (const char*) senderMacAddress().toString(), (const char*) senderIPV4Address().toString() ); |
298 | qDebug( "Target: MAC %s = IP %s", (const char*) targetMacAddress().toString(), (const char*) targetIPV4Address().toString() ); | 298 | qDebug( "Target: MAC %s = IP %s", (const char*) targetMacAddress().toString(), (const char*) targetIPV4Address().toString() ); |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | OARPPacket::~OARPPacket() | 302 | OARPPacket::~OARPPacket() |
303 | { | 303 | { |
304 | } | 304 | } |
305 | 305 | ||
306 | 306 | ||
307 | QString OARPPacket::type() const | 307 | QString OARPPacket::type() const |
308 | { | 308 | { |
309 | switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) | 309 | switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) |
310 | { | 310 | { |
311 | case 1: return "REQUEST"; | 311 | case 1: return "REQUEST"; |
312 | case 2: return "REPLY"; | 312 | case 2: return "REPLY"; |
313 | case 3: return "RREQUEST"; | 313 | case 3: return "RREQUEST"; |
314 | case 4: return "RREPLY"; | 314 | case 4: return "RREPLY"; |
315 | case 8: return "InREQUEST"; | 315 | case 8: return "InREQUEST"; |
316 | case 9: return "InREPLY"; | 316 | case 9: return "InREPLY"; |
317 | case 10: return "NAK"; | 317 | case 10: return "NAK"; |
318 | default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>"; | 318 | default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>"; |
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | QHostAddress OARPPacket::senderIPV4Address() const | 323 | QHostAddress OARPPacket::senderIPV4Address() const |
324 | { | 324 | { |
325 | return EXTRACT_32BITS( &_arphdr->ar_sip ); | 325 | return EXTRACT_32BITS( &_arphdr->ar_sip ); |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | QHostAddress OARPPacket::targetIPV4Address() const | 329 | QHostAddress OARPPacket::targetIPV4Address() const |
330 | { | 330 | { |
331 | return EXTRACT_32BITS( &_arphdr->ar_tip ); | 331 | return EXTRACT_32BITS( &_arphdr->ar_tip ); |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | OMacAddress OARPPacket::senderMacAddress() const | 335 | OMacAddress OARPPacket::senderMacAddress() const |
336 | { | 336 | { |
337 | return OMacAddress( _arphdr->ar_sha ); | 337 | return OMacAddress( _arphdr->ar_sha ); |
338 | } | 338 | } |
339 | 339 | ||
340 | 340 | ||
341 | OMacAddress OARPPacket::targetMacAddress() const | 341 | OMacAddress OARPPacket::targetMacAddress() const |
342 | { | 342 | { |
343 | return OMacAddress( _arphdr->ar_tha ); | 343 | return OMacAddress( _arphdr->ar_tha ); |
344 | } | 344 | } |
345 | 345 | ||
346 | 346 | ||
347 | /*====================================================================================== | 347 | /*====================================================================================== |
348 | * OUDPPacket | 348 | * OUDPPacket |
349 | *======================================================================================*/ | 349 | *======================================================================================*/ |
350 | 350 | ||
351 | 351 | ||
352 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) | 352 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) |
353 | :QObject( parent, "UDP" ), _udphdr( data ) | 353 | :QObject( parent, "UDP" ), _udphdr( data ) |
354 | 354 | ||
355 | { | 355 | { |
356 | qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); | 356 | qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); |
357 | } | 357 | } |
358 | 358 | ||
359 | |||
359 | OUDPPacket::~OUDPPacket() | 360 | OUDPPacket::~OUDPPacket() |
360 | { | 361 | { |
361 | } | 362 | } |
362 | 363 | ||
363 | 364 | ||
365 | int OUDPPacket::fromPort() const | ||
366 | { | ||
367 | return _udphdr->source; | ||
368 | } | ||
369 | |||
370 | |||
371 | int OUDPPacket::toPort() const | ||
372 | { | ||
373 | return _udphdr->dest; | ||
374 | } | ||
375 | |||
376 | |||
377 | int OUDPPacket::length() const | ||
378 | { | ||
379 | return _udphdr->len; | ||
380 | } | ||
381 | |||
382 | |||
383 | int OUDPPacket::checksum() const | ||
384 | { | ||
385 | return _udphdr->check; | ||
386 | } | ||
387 | |||
388 | |||
389 | /*====================================================================================== | ||
390 | * ODHCPPacket | ||
391 | *======================================================================================*/ | ||
392 | |||
393 | |||
394 | ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent ) | ||
395 | :QObject( parent, "DHCP" ), _dhcphdr( data ) | ||
396 | |||
397 | { | ||
398 | qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." ); | ||
399 | } | ||
400 | |||
401 | |||
402 | ODHCPPacket::~ODHCPPacket() | ||
403 | { | ||
404 | } | ||
405 | |||
406 | |||
364 | /*====================================================================================== | 407 | /*====================================================================================== |
365 | * OTCPPacket | 408 | * OTCPPacket |
366 | *======================================================================================*/ | 409 | *======================================================================================*/ |
367 | 410 | ||
368 | 411 | ||
369 | OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) | 412 | OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) |
370 | :QObject( parent, "TCP" ), _tcphdr( data ) | 413 | :QObject( parent, "TCP" ), _tcphdr( data ) |
371 | 414 | ||
372 | { | 415 | { |
373 | qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); | 416 | qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); |
374 | } | 417 | } |
375 | 418 | ||
419 | |||
376 | OTCPPacket::~OTCPPacket() | 420 | OTCPPacket::~OTCPPacket() |
377 | { | 421 | { |
378 | } | 422 | } |
379 | 423 | ||
380 | 424 | ||
425 | int OTCPPacket::fromPort() const | ||
426 | { | ||
427 | return _tcphdr->source; | ||
428 | } | ||
429 | |||
430 | |||
431 | int OTCPPacket::toPort() const | ||
432 | { | ||
433 | return _tcphdr->dest; | ||
434 | } | ||
435 | |||
436 | |||
437 | int OTCPPacket::seq() const | ||
438 | { | ||
439 | return _tcphdr->seq; | ||
440 | } | ||
441 | |||
442 | |||
443 | int OTCPPacket::ack() const | ||
444 | { | ||
445 | return _tcphdr->ack_seq; | ||
446 | } | ||
447 | |||
448 | |||
449 | int OTCPPacket::window() const | ||
450 | { | ||
451 | return _tcphdr->window; | ||
452 | } | ||
453 | |||
454 | |||
455 | int OTCPPacket::checksum() const | ||
456 | { | ||
457 | return _tcphdr->check; | ||
458 | } | ||
459 | |||
381 | /*====================================================================================== | 460 | /*====================================================================================== |
382 | * OPrismHeaderPacket | 461 | * OPrismHeaderPacket |
383 | *======================================================================================*/ | 462 | *======================================================================================*/ |
384 | 463 | ||
385 | 464 | ||
386 | OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent ) | 465 | OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent ) |
387 | :QObject( parent, "Prism" ), _header( data ) | 466 | :QObject( parent, "Prism" ), _header( data ) |
388 | 467 | ||
389 | { | 468 | { |
390 | qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." ); | 469 | qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." ); |
391 | 470 | ||
392 | qDebug( "Signal Strength = %d", data->signal.data ); | 471 | qDebug( "Signal Strength = %d", data->signal.data ); |
393 | 472 | ||
394 | new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this ); | 473 | new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this ); |
395 | } | 474 | } |
396 | 475 | ||
397 | OPrismHeaderPacket::~OPrismHeaderPacket() | 476 | OPrismHeaderPacket::~OPrismHeaderPacket() |
398 | { | 477 | { |
399 | } | 478 | } |
400 | 479 | ||
401 | 480 | ||
402 | unsigned int OPrismHeaderPacket::signalStrength() const | 481 | unsigned int OPrismHeaderPacket::signalStrength() const |
403 | { | 482 | { |
404 | return _header->signal.data; | 483 | return _header->signal.data; |
405 | } | 484 | } |
406 | 485 | ||
407 | /*====================================================================================== | 486 | /*====================================================================================== |
408 | * OWaveLanPacket | 487 | * OWaveLanPacket |
409 | *======================================================================================*/ | 488 | *======================================================================================*/ |
410 | 489 | ||
411 | 490 | ||
412 | OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) | 491 | OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) |
413 | :QObject( parent, "802.11" ), _wlanhdr( data ) | 492 | :QObject( parent, "802.11" ), _wlanhdr( data ) |
414 | 493 | ||
415 | { | 494 | { |
416 | qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); | 495 | qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); |
417 | qDebug( "type: %0X", type() ); | 496 | qDebug( "type: %0X", type() ); |
418 | qDebug( "subType: %0X", subType() ); | 497 | qDebug( "subType: %0X", subType() ); |
419 | qDebug( "duration: %d", duration() ); | 498 | qDebug( "duration: %d", duration() ); |
420 | qDebug( "powermanagement: %d", usesPowerManagement() ); | 499 | qDebug( "powermanagement: %d", usesPowerManagement() ); |
421 | qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" ); | 500 | qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" ); |
422 | qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); | 501 | qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); |
423 | qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); | 502 | qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); |
424 | qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); | 503 | qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); |
425 | qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); | 504 | qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); |
426 | 505 | ||
427 | switch ( type() ) | 506 | switch ( type() ) |
428 | { | 507 | { |
429 | case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; | 508 | case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; |
430 | case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; | 509 | case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; |
431 | case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break; | 510 | case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break; |
432 | default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() ); | 511 | default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() ); |
433 | } | 512 | } |
434 | } | 513 | } |
435 | 514 | ||
436 | OWaveLanPacket::~OWaveLanPacket() | 515 | OWaveLanPacket::~OWaveLanPacket() |
437 | { | 516 | { |
438 | } | 517 | } |
439 | 518 | ||
440 | 519 | ||
441 | int OWaveLanPacket::duration() const | 520 | int OWaveLanPacket::duration() const |
442 | { | 521 | { |
443 | return _wlanhdr->duration; | 522 | return _wlanhdr->duration; |
444 | } | 523 | } |
445 | 524 | ||
446 | 525 | ||
447 | OMacAddress OWaveLanPacket::macAddress1() const | 526 | OMacAddress OWaveLanPacket::macAddress1() const |
448 | { | 527 | { |
449 | return OMacAddress( _wlanhdr->mac1 ); | 528 | return OMacAddress( _wlanhdr->mac1 ); |
450 | } | 529 | } |
451 | 530 | ||
452 | 531 | ||
453 | OMacAddress OWaveLanPacket::macAddress2() const | 532 | OMacAddress OWaveLanPacket::macAddress2() const |
454 | { | 533 | { |
455 | return OMacAddress( _wlanhdr->mac2 ); | 534 | return OMacAddress( _wlanhdr->mac2 ); |
456 | } | 535 | } |
457 | 536 | ||
458 | 537 | ||
459 | OMacAddress OWaveLanPacket::macAddress3() const | 538 | OMacAddress OWaveLanPacket::macAddress3() const |
460 | { | 539 | { |
461 | return OMacAddress( _wlanhdr->mac3 ); | 540 | return OMacAddress( _wlanhdr->mac3 ); |
462 | } | 541 | } |
463 | 542 | ||
464 | 543 | ||
465 | OMacAddress OWaveLanPacket::macAddress4() const | 544 | OMacAddress OWaveLanPacket::macAddress4() const |
466 | { | 545 | { |
467 | return OMacAddress( _wlanhdr->mac4 ); | 546 | return OMacAddress( _wlanhdr->mac4 ); |
468 | } | 547 | } |
469 | 548 | ||
470 | 549 | ||
471 | int OWaveLanPacket::subType() const | 550 | int OWaveLanPacket::subType() const |
472 | { | 551 | { |
473 | return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 552 | return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
474 | } | 553 | } |
475 | 554 | ||
476 | 555 | ||
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index 9119972..0c9e7da 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h | |||
@@ -1,154 +1,157 @@ | |||
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 <qevent.h> | 49 | #include <qevent.h> |
50 | #include <qfile.h> | 50 | #include <qfile.h> |
51 | #include <qhostaddress.h> | 51 | #include <qhostaddress.h> |
52 | #include <qobject.h> | 52 | #include <qobject.h> |
53 | #include <qstring.h> | 53 | #include <qstring.h> |
54 | #include <qmap.h> | 54 | #include <qmap.h> |
55 | 55 | ||
56 | /* OPIE */ | 56 | /* OPIE */ |
57 | #include <opie2/onetutils.h> | 57 | #include <opie2/onetutils.h> |
58 | |||
59 | /* Custom Network Includes */ | ||
58 | #include "802_11_user.h" | 60 | #include "802_11_user.h" |
61 | #include "dhcp.h" | ||
59 | 62 | ||
60 | /* TYPEDEFS */ | 63 | /* TYPEDEFS */ |
61 | typedef struct timeval timevalstruct; | 64 | typedef struct timeval timevalstruct; |
62 | typedef struct pcap_pkthdr packetheaderstruct; | 65 | typedef struct pcap_pkthdr packetheaderstruct; |
63 | 66 | ||
64 | /* FORWARDS */ | 67 | /* FORWARDS */ |
65 | class OPacketCapturer; | 68 | class OPacketCapturer; |
66 | class QSocketNotifier; | 69 | class QSocketNotifier; |
67 | 70 | ||
68 | /*====================================================================================== | 71 | /*====================================================================================== |
69 | * OPacket - A frame on the wire | 72 | * OPacket - A frame on the wire |
70 | *======================================================================================*/ | 73 | *======================================================================================*/ |
71 | 74 | ||
72 | /** @brief A class representing a data frame on the wire. | 75 | /** @brief A class representing a data frame on the wire. |
73 | * | 76 | * |
74 | * The whole family of the packet classes are used when capturing frames from a network. | 77 | * The whole family of the packet classes are used when capturing frames from a network. |
75 | * Most standard network protocols in use share a common architecture, which mostly is | 78 | * Most standard network protocols in use share a common architecture, which mostly is |
76 | * a packet header and then the packet payload. In layered architectures, each lower layer | 79 | * a packet header and then the packet payload. In layered architectures, each lower layer |
77 | * encapsulates data from its upper layer - that is it | 80 | * encapsulates data from its upper layer - that is it |
78 | * treats the data from its upper layer as payload and prepends an own header to the packet, | 81 | * treats the data from its upper layer as payload and prepends an own header to the packet, |
79 | * which - again - is treated as the payload for the layer below. The figure below is an | 82 | * which - again - is treated as the payload for the layer below. The figure below is an |
80 | * example for how such a data frame is composed out of packets, e.g. when sending a mail. | 83 | * example for how such a data frame is composed out of packets, e.g. when sending a mail. |
81 | * | 84 | * |
82 | * <pre> | 85 | * <pre> |
83 | * | User Data | == Mail Data | 86 | * | User Data | == Mail Data |
84 | * | SMTP Header | User Data | == SMTP | 87 | * | SMTP Header | User Data | == SMTP |
85 | * | TCP Header | SMTP Header | User Data | == TCP | 88 | * | TCP Header | SMTP Header | User Data | == TCP |
86 | * | IP Header | TCP Header | SMTP Header | User Data | == IP | 89 | * | IP Header | TCP Header | SMTP Header | User Data | == IP |
87 | * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC | 90 | * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC |
88 | * | 91 | * |
89 | * </pre> | 92 | * </pre> |
90 | * | 93 | * |
91 | * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer | 94 | * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer |
92 | * also contains a few more levels of encapsulation. | 95 | * also contains a few more levels of encapsulation. |
93 | * Since the type of the payload is more or less independent from the encapsulating protocol, | 96 | * Since the type of the payload is more or less independent from the encapsulating protocol, |
94 | * the header must be inspected before attempting to decode the payload. Hence, the | 97 | * the header must be inspected before attempting to decode the payload. Hence, the |
95 | * encapsulation level varies and can't be deduced without actually looking into the packets. | 98 | * encapsulation level varies and can't be deduced without actually looking into the packets. |
96 | * | 99 | * |
97 | * For actually working with captured frames, it's useful to identify the packets via names and | 100 | * For actually working with captured frames, it's useful to identify the packets via names and |
98 | * insert them into a parent/child - relationship based on the encapsulation. This is why | 101 | * insert them into a parent/child - relationship based on the encapsulation. This is why |
99 | * all packet classes derive from QObject. The amount of overhead caused by the QObject is | 102 | * all packet classes derive from QObject. The amount of overhead caused by the QObject is |
100 | * not a problem in this case, because we're talking about a theoratical maximum of about | 103 | * not a problem in this case, because we're talking about a theoratical maximum of about |
101 | * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the | 104 | * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the |
102 | * QObject also cares about destroying the sub-, (child-) packets. | 105 | * QObject also cares about destroying the sub-, (child-) packets. |
103 | * | 106 | * |
104 | * This enables us to perform a simple look for packets of a certain type: | 107 | * This enables us to perform a simple look for packets of a certain type: |
105 | * @code | 108 | * @code |
106 | * OPacketCapturer* pcap = new OPacketCapturer(); | 109 | * OPacketCapturer* pcap = new OPacketCapturer(); |
107 | * pcap->open( "eth0" ); | 110 | * pcap->open( "eth0" ); |
108 | * OPacket* p = pcap->next(); | 111 | * OPacket* p = pcap->next(); |
109 | * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists | 112 | * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists |
110 | * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; | 113 | * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; |
111 | * | 114 | * |
112 | */ | 115 | */ |
113 | 116 | ||
114 | class OPacket : public QObject | 117 | class OPacket : public QObject |
115 | { | 118 | { |
116 | Q_OBJECT | 119 | Q_OBJECT |
117 | 120 | ||
118 | friend class OPacketCapturer; | 121 | friend class OPacketCapturer; |
119 | 122 | ||
120 | public: | 123 | public: |
121 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); | 124 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); |
122 | virtual ~OPacket(); | 125 | virtual ~OPacket(); |
123 | 126 | ||
124 | timevalstruct timeval() const; | 127 | timevalstruct timeval() const; |
125 | 128 | ||
126 | int caplen() const; | 129 | int caplen() const; |
127 | int len() const; | 130 | int len() const; |
128 | QString dump( int = 32 ) const; | 131 | QString dump( int = 32 ) const; |
129 | 132 | ||
130 | void updateStats( QMap<QString,int>&, QObjectList* ); | 133 | void updateStats( QMap<QString,int>&, QObjectList* ); |
131 | 134 | ||
132 | private: | 135 | private: |
133 | const packetheaderstruct _hdr; // pcap packet header | 136 | const packetheaderstruct _hdr; // pcap packet header |
134 | const unsigned char* _data; // pcap packet data | 137 | const unsigned char* _data; // pcap packet data |
135 | const unsigned char* _end; // end of pcap packet data | 138 | const unsigned char* _end; // end of pcap packet data |
136 | }; | 139 | }; |
137 | 140 | ||
138 | /*====================================================================================== | 141 | /*====================================================================================== |
139 | * OEthernetPacket - DLT_EN10MB frame | 142 | * OEthernetPacket - DLT_EN10MB frame |
140 | *======================================================================================*/ | 143 | *======================================================================================*/ |
141 | 144 | ||
142 | class OEthernetPacket : public QObject | 145 | class OEthernetPacket : public QObject |
143 | { | 146 | { |
144 | Q_OBJECT | 147 | Q_OBJECT |
145 | 148 | ||
146 | public: | 149 | public: |
147 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); | 150 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); |
148 | virtual ~OEthernetPacket(); | 151 | virtual ~OEthernetPacket(); |
149 | 152 | ||
150 | OMacAddress sourceAddress() const; | 153 | OMacAddress sourceAddress() const; |
151 | OMacAddress destinationAddress() const; | 154 | OMacAddress destinationAddress() const; |
152 | int type() const; | 155 | int type() const; |
153 | 156 | ||
154 | private: | 157 | private: |
@@ -384,226 +387,249 @@ class OWaveLanDataPacket : public QObject | |||
384 | * OWaveLanControlPacket - type: control (T_CTRL) | 387 | * OWaveLanControlPacket - type: control (T_CTRL) |
385 | *======================================================================================*/ | 388 | *======================================================================================*/ |
386 | 389 | ||
387 | class OWaveLanControlPacket : public QObject | 390 | class OWaveLanControlPacket : public QObject |
388 | { | 391 | { |
389 | Q_OBJECT | 392 | Q_OBJECT |
390 | 393 | ||
391 | public: | 394 | public: |
392 | OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); | 395 | OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); |
393 | virtual ~OWaveLanControlPacket(); | 396 | virtual ~OWaveLanControlPacket(); |
394 | 397 | ||
395 | private: | 398 | private: |
396 | const struct ieee_802_11_control_header* _header; | 399 | const struct ieee_802_11_control_header* _header; |
397 | }; | 400 | }; |
398 | 401 | ||
399 | /*====================================================================================== | 402 | /*====================================================================================== |
400 | * OLLCPacket - IEEE 802.2 Link Level Control | 403 | * OLLCPacket - IEEE 802.2 Link Level Control |
401 | *======================================================================================*/ | 404 | *======================================================================================*/ |
402 | 405 | ||
403 | class OLLCPacket : public QObject | 406 | class OLLCPacket : public QObject |
404 | { | 407 | { |
405 | Q_OBJECT | 408 | Q_OBJECT |
406 | 409 | ||
407 | public: | 410 | public: |
408 | OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); | 411 | OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); |
409 | virtual ~OLLCPacket(); | 412 | virtual ~OLLCPacket(); |
410 | 413 | ||
411 | private: | 414 | private: |
412 | const struct ieee_802_11_802_2_header* _header; | 415 | const struct ieee_802_11_802_2_header* _header; |
413 | }; | 416 | }; |
414 | 417 | ||
415 | /*====================================================================================== | 418 | /*====================================================================================== |
416 | * OIPPacket | 419 | * OIPPacket |
417 | *======================================================================================*/ | 420 | *======================================================================================*/ |
418 | 421 | ||
419 | class OIPPacket : public QObject | 422 | class OIPPacket : public QObject |
420 | { | 423 | { |
421 | Q_OBJECT | 424 | Q_OBJECT |
422 | 425 | ||
423 | public: | 426 | public: |
424 | OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); | 427 | OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); |
425 | virtual ~OIPPacket(); | 428 | virtual ~OIPPacket(); |
426 | 429 | ||
427 | QHostAddress fromIPAddress() const; | 430 | QHostAddress fromIPAddress() const; |
428 | QHostAddress toIPAddress() const; | 431 | QHostAddress toIPAddress() const; |
429 | 432 | ||
430 | int tos() const; | 433 | int tos() const; |
431 | int len() const; | 434 | int len() const; |
432 | int id() const; | 435 | int id() const; |
433 | int offset() const; | 436 | int offset() const; |
434 | int ttl() const; | 437 | int ttl() const; |
435 | int protocol() const; | 438 | int protocol() const; |
436 | int checksum() const; | 439 | int checksum() const; |
437 | 440 | ||
438 | private: | 441 | private: |
439 | const struct iphdr* _iphdr; | 442 | const struct iphdr* _iphdr; |
440 | }; | 443 | }; |
441 | 444 | ||
442 | /*====================================================================================== | 445 | /*====================================================================================== |
443 | * OARPPacket | 446 | * OARPPacket |
444 | *======================================================================================*/ | 447 | *======================================================================================*/ |
445 | 448 | ||
446 | class OARPPacket : public QObject | 449 | class OARPPacket : public QObject |
447 | { | 450 | { |
448 | Q_OBJECT | 451 | Q_OBJECT |
449 | 452 | ||
450 | public: | 453 | public: |
451 | OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); | 454 | OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); |
452 | virtual ~OARPPacket(); | 455 | virtual ~OARPPacket(); |
453 | 456 | ||
454 | QHostAddress senderIPV4Address() const; | 457 | QHostAddress senderIPV4Address() const; |
455 | OMacAddress senderMacAddress() const; | 458 | OMacAddress senderMacAddress() const; |
456 | QHostAddress targetIPV4Address() const; | 459 | QHostAddress targetIPV4Address() const; |
457 | OMacAddress targetMacAddress() const; | 460 | OMacAddress targetMacAddress() const; |
458 | 461 | ||
459 | //int type() const; | 462 | //int type() const; |
460 | QString type() const; | 463 | QString type() const; |
461 | 464 | ||
462 | private: | 465 | private: |
463 | const struct myarphdr* _arphdr; | 466 | const struct myarphdr* _arphdr; |
464 | }; | 467 | }; |
465 | 468 | ||
466 | /*====================================================================================== | 469 | /*====================================================================================== |
467 | * OUDPPacket | 470 | * OUDPPacket |
468 | *======================================================================================*/ | 471 | *======================================================================================*/ |
469 | 472 | ||
470 | class OUDPPacket : public QObject | 473 | class OUDPPacket : public QObject |
471 | { | 474 | { |
472 | Q_OBJECT | 475 | Q_OBJECT |
473 | 476 | ||
474 | public: | 477 | public: |
475 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); | 478 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); |
476 | virtual ~OUDPPacket(); | 479 | virtual ~OUDPPacket(); |
477 | 480 | ||
478 | int fromPort() const; | 481 | int fromPort() const; |
479 | int toPort() const; | 482 | int toPort() const; |
483 | int length() const; | ||
484 | int checksum() const; | ||
480 | 485 | ||
481 | private: | 486 | private: |
482 | const struct udphdr* _udphdr; | 487 | const struct udphdr* _udphdr; |
483 | }; | 488 | }; |
484 | 489 | ||
485 | /*====================================================================================== | 490 | /*====================================================================================== |
491 | * ODHCPPacket | ||
492 | *======================================================================================*/ | ||
493 | |||
494 | class ODHCPPacket : public QObject | ||
495 | { | ||
496 | Q_OBJECT | ||
497 | |||
498 | public: | ||
499 | ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); | ||
500 | virtual ~ODHCPPacket(); | ||
501 | |||
502 | private: | ||
503 | const struct dhcp_packet* _dhcphdr; | ||
504 | }; | ||
505 | |||
506 | /*====================================================================================== | ||
486 | * OTCPPacket | 507 | * OTCPPacket |
487 | *======================================================================================*/ | 508 | *======================================================================================*/ |
488 | 509 | ||
489 | class OTCPPacket : public QObject | 510 | class OTCPPacket : public QObject |
490 | { | 511 | { |
491 | Q_OBJECT | 512 | Q_OBJECT |
492 | 513 | ||
493 | public: | 514 | public: |
494 | OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); | 515 | OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); |
495 | virtual ~OTCPPacket(); | 516 | virtual ~OTCPPacket(); |
496 | 517 | ||
497 | int fromPort() const; | 518 | int fromPort() const; |
498 | int toPort() const; | 519 | int toPort() const; |
520 | int seq() const; | ||
521 | int ack() const; | ||
522 | int window() const; | ||
523 | int checksum() const; | ||
499 | 524 | ||
500 | private: | 525 | private: |
501 | const struct tcphdr* _tcphdr; | 526 | const struct tcphdr* _tcphdr; |
502 | }; | 527 | }; |
503 | 528 | ||
504 | 529 | ||
505 | /*====================================================================================== | 530 | /*====================================================================================== |
506 | * OPacketCapturer | 531 | * OPacketCapturer |
507 | *======================================================================================*/ | 532 | *======================================================================================*/ |
508 | 533 | ||
509 | /** | 534 | /** |
510 | * @brief A class based wrapper for network packet capturing. | 535 | * @brief A class based wrapper for network packet capturing. |
511 | * | 536 | * |
512 | * This class is the base of a high-level interface to the well known packet capturing | 537 | * This class is the base of a high-level interface to the well known packet capturing |
513 | * library libpcap. ... | 538 | * library libpcap. |
539 | * @see http://tcpdump.org | ||
514 | */ | 540 | */ |
515 | class OPacketCapturer : public QObject | 541 | class OPacketCapturer : public QObject |
516 | { | 542 | { |
517 | Q_OBJECT | 543 | Q_OBJECT |
518 | 544 | ||
519 | public: | 545 | public: |
520 | /** | 546 | /** |
521 | * Constructor. | 547 | * Constructor. |
522 | */ | 548 | */ |
523 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); | 549 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); |
524 | /** | 550 | /** |
525 | * Destructor. | 551 | * Destructor. |
526 | */ | 552 | */ |
527 | ~OPacketCapturer(); | 553 | ~OPacketCapturer(); |
528 | /** | 554 | /** |
529 | * Set the packet capturer to use blocking or non-blocking IO. This can be useful when | 555 | * Set the packet capturer to use blocking or non-blocking IO. This can be useful when |
530 | * not using the socket notifier, e.g. without an application object. | 556 | * not using the socket notifier, e.g. without an application object. |
531 | */ | 557 | */ |
532 | void setBlocking( bool ); | 558 | void setBlocking( bool ); |
533 | /** | 559 | /** |
534 | * @returns true if the packet capturer uses blocking IO calls. | 560 | * @returns true if the packet capturer uses blocking IO calls. |
535 | */ | 561 | */ |
536 | bool blocking() const; | 562 | bool blocking() const; |
537 | /** | 563 | /** |
538 | * Close the packet capturer. This is automatically done in the destructor. | 564 | * Close the packet capturer. This is automatically done in the destructor. |
539 | */ | 565 | */ |
540 | void close(); | 566 | void close(); |
541 | /** | 567 | /** |
542 | * Close the output capture file. | 568 | * Close the output capture file. |
543 | */ | 569 | */ |
544 | void closeDumpFile(); | 570 | void closeDumpFile(); |
545 | /** | 571 | /** |
546 | * @returns the data link type. | 572 | * @returns the data link type. |
547 | * @see <pcap.h> for possible values. | 573 | * @see <pcap.h> for possible values. |
548 | */ | 574 | */ |
549 | int dataLink() const; | 575 | int dataLink() const; |
550 | /** | 576 | /** |
551 | * Dump a packet to the output capture file. | 577 | * Dump a packet to the output capture file. |
552 | */ | 578 | */ |
553 | void dump( OPacket* ); | 579 | void dump( OPacket* ); |
554 | /** | 580 | /** |
555 | * @returns the file descriptor of the packet capturer. This is only useful, if | 581 | * @returns the file descriptor of the packet capturer. This is only useful, if |
556 | * not using the socket notifier, e.g. without an application object. | 582 | * not using the socket notifier, e.g. without an application object. |
557 | */ | 583 | */ |
558 | int fileno() const; | 584 | int fileno() const; |
559 | /** | 585 | /** |
560 | * @returns the next @ref OPacket from the packet capturer. | 586 | * @returns the next @ref OPacket from the packet capturer. |
561 | * @note If blocking mode is true then this call might block. | 587 | * @note If blocking mode is true then this call might block. |
562 | */ | 588 | */ |
563 | OPacket* next(); | 589 | OPacket* next(); |
564 | /** | 590 | /** |
565 | * Open the packet capturer to capture packets in live-mode from @a interface. | 591 | * Open the packet capturer to capture packets in live-mode from @a interface. |
566 | */ | 592 | */ |
567 | bool open( const QString& interface ); | 593 | bool open( const QString& interface ); |
568 | /** | 594 | /** |
569 | * Open the packet capturer to capture packets in offline-mode from @a file. | 595 | * Open the packet capturer to capture packets in offline-mode from @a file. |
570 | */ | 596 | */ |
571 | bool open( const QFile& file ); | 597 | bool open( const QFile& file ); |
572 | /** | 598 | /** |
573 | * Open a prerecorded tcpdump compatible capture file for use with @ref dump() | 599 | * Open a prerecorded tcpdump compatible capture file for use with @ref dump() |
574 | */ | 600 | */ |
575 | bool openDumpFile( const QString& filename ); | 601 | bool openDumpFile( const QString& filename ); |
576 | /** | 602 | /** |
577 | * @returns true if the packet capturer is open | 603 | * @returns true if the packet capturer is open |
578 | */ | 604 | */ |
579 | bool isOpen() const; | 605 | bool isOpen() const; |
580 | /** | 606 | /** |
581 | * @returns the snapshot length of this packet capturer | 607 | * @returns the snapshot length of this packet capturer |
582 | */ | 608 | */ |
583 | int snapShot() const; | 609 | int snapShot() const; |
584 | /** | 610 | /** |
585 | * @returns true if the input capture file has a different byte-order | 611 | * @returns true if the input capture file has a different byte-order |
586 | * than the byte-order of the running system. | 612 | * than the byte-order of the running system. |
587 | */ | 613 | */ |
588 | bool swapped() const; | 614 | bool swapped() const; |
589 | /** | 615 | /** |
590 | * @returns the libpcap version string used to write the input capture file. | 616 | * @returns the libpcap version string used to write the input capture file. |
591 | */ | 617 | */ |
592 | QString version() const; | 618 | QString version() const; |
593 | /** | 619 | /** |
594 | * @returns the packet statistic database. | 620 | * @returns the packet statistic database. |
595 | * @see QMap | 621 | * @see QMap |
596 | */ | 622 | */ |
597 | const QMap<QString,int>& statistics() const; | 623 | const QMap<QString,int>& statistics() const; |
598 | 624 | ||
599 | signals: | 625 | signals: |
600 | /** | 626 | /** |
601 | * This signal is emitted, when a packet has been received. | 627 | * This signal is emitted, when a packet has been received. |
602 | */ | 628 | */ |
603 | void receivedPacket( OPacket* ); | 629 | void receivedPacket( OPacket* ); |
604 | 630 | ||
605 | protected slots: | 631 | protected slots: |
606 | void readyToReceive(); | 632 | void readyToReceive(); |
607 | 633 | ||
608 | protected: | 634 | protected: |
609 | QString _name; // devicename | 635 | QString _name; // devicename |
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro index 93389db..7a7adde 100644 --- a/libopie2/opienet/opienet.pro +++ b/libopie2/opienet/opienet.pro | |||
@@ -1,28 +1,30 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on debug | 2 | CONFIG += qt warn_on debug |
3 | DESTDIR = $(OPIEDIR)/lib | 3 | DESTDIR = $(OPIEDIR)/lib |
4 | HEADERS = omanufacturerdb.cpp \ | 4 | HEADERS = 802_11_user.h \ |
5 | dhcp.h \ | ||
6 | omanufacturerdb.cpp \ | ||
5 | onetutils.cpp \ | 7 | onetutils.cpp \ |
6 | onetwork.h \ | 8 | onetwork.h \ |
7 | opcap.h | 9 | opcap.h |
8 | SOURCES = omanufacturerdb.cpp \ | 10 | SOURCES = omanufacturerdb.cpp \ |
9 | onetutils.cpp \ | 11 | onetutils.cpp \ |
10 | onetwork.cpp \ | 12 | onetwork.cpp \ |
11 | opcap.cpp | 13 | opcap.cpp |
12 | INTERFACES = | 14 | INTERFACES = |
13 | TARGET = opienet2 | 15 | TARGET = opienet2 |
14 | VERSION = 1.8.1 | 16 | VERSION = 1.8.1 |
15 | INCLUDEPATH += $(OPIEDIR)/include | 17 | INCLUDEPATH += $(OPIEDIR)/include |
16 | DEPENDPATH += $(OPIEDIR)/include | 18 | DEPENDPATH += $(OPIEDIR)/include |
17 | LIBS += -lpcap | 19 | LIBS += -lpcap |
18 | MOC_DIR = moc | 20 | MOC_DIR = moc |
19 | OBJECTS_DIR = obj | 21 | OBJECTS_DIR = obj |
20 | 22 | ||
21 | 23 | ||
22 | !contains( platform, x11 ) { | 24 | !contains( platform, x11 ) { |
23 | include ( $(OPIEDIR)/include.pro ) | 25 | include ( $(OPIEDIR)/include.pro ) |
24 | } | 26 | } |
25 | 27 | ||
26 | contains( platform, x11 ) { | 28 | contains( platform, x11 ) { |
27 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | 29 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib |
28 | } | 30 | } |