summaryrefslogtreecommitdiff
path: root/libopie2/opienet
authorzecke <zecke>2004-03-13 19:51:45 (UTC)
committer zecke <zecke>2004-03-13 19:51:45 (UTC)
commit6d08277737e22b7a1527124623f3571969073ddf (patch) (unidiff)
tree4129e674e21df767b31299e873dd44e33a308e1b /libopie2/opienet
parent8e28911f7199f4450ac5eef09482069f9b9caea2 (diff)
downloadopie-6d08277737e22b7a1527124623f3571969073ddf.zip
opie-6d08277737e22b7a1527124623f3571969073ddf.tar.gz
opie-6d08277737e22b7a1527124623f3571969073ddf.tar.bz2
Move XML class to internal PIM
Add namespaces!!! Opie::Core and Opie::Core::Private Opie::Net and Opie::Net::Private Opie::Ui and Opie::Ui::Private Opie::MM and Opie::MM::Private Opie::DB and Opie::DB::Private PIM classes are not yet converted because we will do other work on it as well
Diffstat (limited to 'libopie2/opienet') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/802_11_user.h1
-rw-r--r--libopie2/opienet/dhcp.h2
-rw-r--r--libopie2/opienet/odebugmapper.cpp10
-rw-r--r--libopie2/opienet/odebugmapper.h10
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp7
-rw-r--r--libopie2/opienet/omanufacturerdb.h8
-rw-r--r--libopie2/opienet/onetutils.cpp9
-rw-r--r--libopie2/opienet/onetutils.h15
-rw-r--r--libopie2/opienet/onetwork.cpp9
-rw-r--r--libopie2/opienet/onetwork.h31
-rw-r--r--libopie2/opienet/opcap.cpp8
-rw-r--r--libopie2/opienet/opcap.h52
-rw-r--r--libopie2/opienet/ostation.cpp8
-rw-r--r--libopie2/opienet/ostation.h9
14 files changed, 176 insertions, 3 deletions
diff --git a/libopie2/opienet/802_11_user.h b/libopie2/opienet/802_11_user.h
index 7ae27c5..1a9a7a0 100644
--- a/libopie2/opienet/802_11_user.h
+++ b/libopie2/opienet/802_11_user.h
@@ -410,49 +410,50 @@ struct ctrl_cts_t {
410 u_int8_tfcs[4]; 410 u_int8_tfcs[4];
411}; 411};
412 412
413 #define CTRL_CTS_LEN(2+2+6+4) 413 #define CTRL_CTS_LEN(2+2+6+4)
414 414
415struct ctrl_ack_t { 415struct ctrl_ack_t {
416 u_int16_tfc; 416 u_int16_tfc;
417 u_int16_tduration; 417 u_int16_tduration;
418 u_int8_tra[6]; 418 u_int8_tra[6];
419 u_int8_tfcs[4]; 419 u_int8_tfcs[4];
420}; 420};
421 421
422 #define CTRL_ACK_LEN(2+2+6+4) 422 #define CTRL_ACK_LEN(2+2+6+4)
423 423
424struct ctrl_ps_poll_t { 424struct ctrl_ps_poll_t {
425 u_int16_tfc; 425 u_int16_tfc;
426 u_int16_taid; 426 u_int16_taid;
427 u_int8_tbssid[6]; 427 u_int8_tbssid[6];
428 u_int8_tta[6]; 428 u_int8_tta[6];
429 u_int8_tfcs[4]; 429 u_int8_tfcs[4];
430}; 430};
431 431
432 #define CTRL_PS_POLL_LEN(2+2+6+6+4) 432 #define CTRL_PS_POLL_LEN(2+2+6+6+4)
433 433
434struct ctrl_end_t { 434struct ctrl_end_t {
435 u_int16_tfc; 435 u_int16_tfc;
436 u_int16_tduration; 436 u_int16_tduration;
437 u_int8_tra[6]; 437 u_int8_tra[6];
438 u_int8_tbssid[6]; 438 u_int8_tbssid[6];
439 u_int8_tfcs[4]; 439 u_int8_tfcs[4];
440}; 440};
441 441
442 #define CTRL_END_LEN(2+2+6+6+4) 442 #define CTRL_END_LEN(2+2+6+6+4)
443 443
444struct ctrl_end_ack_t { 444struct ctrl_end_ack_t {
445 u_int16_tfc; 445 u_int16_tfc;
446 u_int16_tduration; 446 u_int16_tduration;
447 u_int8_tra[6]; 447 u_int8_tra[6];
448 u_int8_tbssid[6]; 448 u_int8_tbssid[6];
449 u_int8_tfcs[4]; 449 u_int8_tfcs[4];
450}; 450};
451 451
452 #define CTRL_END_ACK_LEN(2+2+6+6+4) 452 #define CTRL_END_ACK_LEN(2+2+6+6+4)
453 453
454 #define IV_IV(iv)((iv) & 0xFFFFFF) 454 #define IV_IV(iv)((iv) & 0xFFFFFF)
455 #define IV_PAD(iv)(((iv) >> 24) & 0x3F) 455 #define IV_PAD(iv)(((iv) >> 24) & 0x3F)
456 #define IV_KEYID(iv)(((iv) >> 30) & 0x03) 456 #define IV_KEYID(iv)(((iv) >> 30) & 0x03)
457 457
458
458#endif 459#endif
diff --git a/libopie2/opienet/dhcp.h b/libopie2/opienet/dhcp.h
index 368e375..6ba4c53 100644
--- a/libopie2/opienet/dhcp.h
+++ b/libopie2/opienet/dhcp.h
@@ -1,92 +1,93 @@
1/* dhcp.h 1/* dhcp.h
2 2
3 Protocol structures... */ 3 Protocol structures... */
4 4
5/* 5/*
6 * Copyright (c) 1995-2001 The Internet Software Consortium. 6 * Copyright (c) 1995-2001 The Internet Software Consortium.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 12 *
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of The Internet Software Consortium nor the names 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 19 * of its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission. 20 * from this software without specific prior written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND 22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR 26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 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 33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * This software has been written for the Internet Software Consortium 36 * This software has been written for the Internet Software Consortium
37 * by Ted Lemon in cooperation with Vixie Enterprises. To learn more 37 * by Ted Lemon in cooperation with Vixie Enterprises. To learn more
38 * about the Internet Software Consortium, see ``http://www.isc.org''. 38 * about the Internet Software Consortium, see ``http://www.isc.org''.
39 * To learn more about Vixie Enterprises, see ``http://www.vix.com''. 39 * To learn more about Vixie Enterprises, see ``http://www.vix.com''.
40 */ 40 */
41 41
42#ifndef DHCP_H 42#ifndef DHCP_H
43#define DHCP_H 43#define DHCP_H
44 44
45
45 #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \ 46 #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \
46 20 + /* IP header */ \ 47 20 + /* IP header */ \
47 8) /* UDP header */ 48 8) /* UDP header */
48 #define DHCP_SNAME_LEN 64 49 #define DHCP_SNAME_LEN 64
49 #define DHCP_FILE_LEN 128 50 #define DHCP_FILE_LEN 128
50 #define DHCP_FIXED_NON_UDP236 51 #define DHCP_FIXED_NON_UDP236
51 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD) 52 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
52 /* Everything but options. */ 53 /* Everything but options. */
53 #define DHCP_MTU_MAX 1500 54 #define DHCP_MTU_MAX 1500
54 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN) 55 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
55 56
56 #define BOOTP_MIN_LEN 300 57 #define BOOTP_MIN_LEN 300
57#define DHCP_MIN_LEN 548 58#define DHCP_MIN_LEN 548
58 59
59struct dhcp_packet { 60struct dhcp_packet {
60 u_int8_t op; /* 0: Message opcode/type */ 61 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 htype;/* 1: Hardware addr type (net/if_types.h) */
62 u_int8_t hlen; /* 2: Hardware addr length */ 63 u_int8_t hlen; /* 2: Hardware addr length */
63 u_int8_t hops; /* 3: Number of relay agent hops from client */ 64 u_int8_t hops; /* 3: Number of relay agent hops from client */
64 u_int32_t xid; /* 4: Transaction ID */ 65 u_int32_t xid; /* 4: Transaction ID */
65 u_int16_t secs; /* 8: Seconds since client started looking */ 66 u_int16_t secs; /* 8: Seconds since client started looking */
66 u_int16_t flags;/* 10: Flag bits */ 67 u_int16_t flags;/* 10: Flag bits */
67 struct in_addr ciaddr;/* 12: Client IP address (if already in use) */ 68 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 yiaddr;/* 16: Client IP address */
69 struct in_addr siaddr;/* 18: IP address of next server to talk to */ 70 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 struct in_addr giaddr;/* 20: DHCP relay agent IP address */
71 unsigned char chaddr [16];/* 24: Client hardware address */ 72 unsigned char chaddr [16];/* 24: Client hardware address */
72 char sname [DHCP_SNAME_LEN];/* 40: Server name */ 73 char sname [DHCP_SNAME_LEN];/* 40: Server name */
73 char file [DHCP_FILE_LEN];/* 104: Boot filename */ 74 char file [DHCP_FILE_LEN];/* 104: Boot filename */
74 unsigned char options [DHCP_OPTION_LEN]; 75 unsigned char options [DHCP_OPTION_LEN];
75 /* 212: Optional parameters 76 /* 212: Optional parameters
76 (actual length dependent on MTU). */ 77 (actual length dependent on MTU). */
77}; 78};
78 79
79/* BOOTP (rfc951) message types */ 80/* BOOTP (rfc951) message types */
80 #define BOOTREQUEST1 81 #define BOOTREQUEST1
81 #define BOOTREPLY2 82 #define BOOTREPLY2
82 83
83/* Possible values for flags field... */ 84/* Possible values for flags field... */
84#define BOOTP_BROADCAST 32768L 85#define BOOTP_BROADCAST 32768L
85 86
86/* Possible values for hardware type (htype) field... */ 87/* Possible values for hardware type (htype) field... */
87 #define HTYPE_ETHER1 /* Ethernet 10Mbps */ 88 #define HTYPE_ETHER1 /* Ethernet 10Mbps */
88 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/ 89 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/
89 #define HTYPE_FDDI 8 /* FDDI... */ 90 #define HTYPE_FDDI 8 /* FDDI... */
90 91
91/* Magic cookie validating dhcp options field (and bootp vendor 92/* Magic cookie validating dhcp options field (and bootp vendor
92 extensions field). */ 93 extensions field). */
@@ -152,50 +153,51 @@ struct dhcp_packet {
152 #define DHO_DHCP_PARAMETER_REQUEST_LIST55 153 #define DHO_DHCP_PARAMETER_REQUEST_LIST55
153 #define DHO_DHCP_MESSAGE 56 154 #define DHO_DHCP_MESSAGE 56
154 #define DHO_DHCP_MAX_MESSAGE_SIZE57 155 #define DHO_DHCP_MAX_MESSAGE_SIZE57
155 #define DHO_DHCP_RENEWAL_TIME 58 156 #define DHO_DHCP_RENEWAL_TIME 58
156 #define DHO_DHCP_REBINDING_TIME 59 157 #define DHO_DHCP_REBINDING_TIME 59
157 #define DHO_VENDOR_CLASS_IDENTIFIER60 158 #define DHO_VENDOR_CLASS_IDENTIFIER60
158 #define DHO_DHCP_CLIENT_IDENTIFIER61 159 #define DHO_DHCP_CLIENT_IDENTIFIER61
159 #define DHO_NWIP_DOMAIN_NAME 62 160 #define DHO_NWIP_DOMAIN_NAME 62
160 #define DHO_NWIP_SUBOPTIONS 63 161 #define DHO_NWIP_SUBOPTIONS 63
161 #define DHO_USER_CLASS 77 162 #define DHO_USER_CLASS 77
162 #define DHO_FQDN 81 163 #define DHO_FQDN 81
163 #define DHO_DHCP_AGENT_OPTIONS 82 164 #define DHO_DHCP_AGENT_OPTIONS 82
164 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */ 165 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */
165/* The DHO_AUTHENTICATE option is not a standard yet, so I've 166/* 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 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 temporary basis. Once an option code number is assigned, I will
168 immediately and shamelessly break this, so don't count on it 169 immediately and shamelessly break this, so don't count on it
169 continuing to work. */ 170 continuing to work. */
170 #define DHO_AUTHENTICATE 210 171 #define DHO_AUTHENTICATE 210
171 172
172 #define DHO_END 255 173 #define DHO_END 255
173 174
174/* DHCP message types. */ 175/* DHCP message types. */
175 #define DHCPDISCOVER1 176 #define DHCPDISCOVER1
176 #define DHCPOFFER2 177 #define DHCPOFFER2
177 #define DHCPREQUEST3 178 #define DHCPREQUEST3
178 #define DHCPDECLINE4 179 #define DHCPDECLINE4
179 #define DHCPACK 5 180 #define DHCPACK 5
180 #define DHCPNAK 6 181 #define DHCPNAK 6
181 #define DHCPRELEASE7 182 #define DHCPRELEASE7
182 #define DHCPINFORM8 183 #define DHCPINFORM8
183 184
184/* Relay Agent Information option subtypes: */ 185/* Relay Agent Information option subtypes: */
185 #define RAI_CIRCUIT_ID1 186 #define RAI_CIRCUIT_ID1
186 #define RAI_REMOTE_ID2 187 #define RAI_REMOTE_ID2
187 #define RAI_AGENT_ID3 188 #define RAI_AGENT_ID3
188 189
189/* FQDN suboptions: */ 190/* FQDN suboptions: */
190 #define FQDN_NO_CLIENT_UPDATE 1 191 #define FQDN_NO_CLIENT_UPDATE 1
191 #define FQDN_SERVER_UPDATE 2 192 #define FQDN_SERVER_UPDATE 2
192 #define FQDN_ENCODED 3 193 #define FQDN_ENCODED 3
193 #define FQDN_RCODE1 4 194 #define FQDN_RCODE1 4
194 #define FQDN_RCODE2 5 195 #define FQDN_RCODE2 5
195 #define FQDN_HOSTNAME 6 196 #define FQDN_HOSTNAME 6
196 #define FQDN_DOMAINNAME 7 197 #define FQDN_DOMAINNAME 7
197 #define FQDN_FQDN 8 198 #define FQDN_FQDN 8
198 #define FQDN_SUBOPTION_COUNT 8 199 #define FQDN_SUBOPTION_COUNT 8
199 200
201
200#endif 202#endif
201 203
diff --git a/libopie2/opienet/odebugmapper.cpp b/libopie2/opienet/odebugmapper.cpp
index 7e4ab2b..f679afb 100644
--- a/libopie2/opienet/odebugmapper.cpp
+++ b/libopie2/opienet/odebugmapper.cpp
@@ -1,57 +1,63 @@
1 1
2/* 2/*
3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
4 */ 4 */
5 5
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7 7
8#include "odebugmapper.h" 8#include "odebugmapper.h"
9 9
10using namespace Opie::Core;
11
12namespace Opie {
13namespace Net {
14namespace Private {
15
10DebugMapper::DebugMapper() 16DebugMapper::DebugMapper()
11{ 17{
12 odebug << "DebugMapper::DebugMapper()" << oendl; 18 odebug << "DebugMapper::DebugMapper()" << oendl;
13 19
14 20
15 _map.insert( 0x8902, new QString("SIOCSPGRP") ); 21 _map.insert( 0x8902, new QString("SIOCSPGRP") );
16 _map.insert( 0x8904, new QString("SIOCGPGRP") ); 22 _map.insert( 0x8904, new QString("SIOCGPGRP") );
17 _map.insert( 0x8905, new QString("SIOCATMARK") ); 23 _map.insert( 0x8905, new QString("SIOCATMARK") );
18 _map.insert( 0x8906, new QString("SIOCGSTAMP") ); 24 _map.insert( 0x8906, new QString("SIOCGSTAMP") );
19 _map.insert( 0x890B, new QString("SIOCADDRT") ); 25 _map.insert( 0x890B, new QString("SIOCADDRT") );
20 _map.insert( 0x890C, new QString("SIOCDELRT") ); 26 _map.insert( 0x890C, new QString("SIOCDELRT") );
21 _map.insert( 0x890D, new QString("SIOCRTMSG") ); 27 _map.insert( 0x890D, new QString("SIOCRTMSG") );
22 _map.insert( 0x8910, new QString("SIOCGIFNAME") ); 28 _map.insert( 0x8910, new QString("SIOCGIFNAME") );
23 _map.insert( 0x8911, new QString("SIOCSIFLINK") ); 29 _map.insert( 0x8911, new QString("SIOCSIFLINK") );
24 _map.insert( 0x8912, new QString("SIOCGIFCONF") ); 30 _map.insert( 0x8912, new QString("SIOCGIFCONF") );
25 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); 31 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
26 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); 32 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
27 _map.insert( 0x8915, new QString("SIOCGIFADDR") ); 33 _map.insert( 0x8915, new QString("SIOCGIFADDR") );
28 _map.insert( 0x8916, new QString("SIOCSIFADDR") ); 34 _map.insert( 0x8916, new QString("SIOCSIFADDR") );
29 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); 35 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
30 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); 36 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
31 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); 37 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
32 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); 38 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
33 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); 39 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
34 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") ); 40 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
35 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") ); 41 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
36 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") ); 42 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
37 _map.insert( 0x891f, new QString("SIOCGIFMEM") ); 43 _map.insert( 0x891f, new QString("SIOCGIFMEM") );
38 _map.insert( 0x8920, new QString("SIOCSIFMEM") ); 44 _map.insert( 0x8920, new QString("SIOCSIFMEM") );
39 _map.insert( 0x8921, new QString("SIOCGIFMTU") ); 45 _map.insert( 0x8921, new QString("SIOCGIFMTU") );
40 _map.insert( 0x8922, new QString("SIOCSIFMTU") ); 46 _map.insert( 0x8922, new QString("SIOCSIFMTU") );
41 _map.insert( 0x8923, new QString("SIOCSIFNAME") ); 47 _map.insert( 0x8923, new QString("SIOCSIFNAME") );
42 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") ); 48 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
43 _map.insert( 0x8925, new QString("SIOCGIFENCAP") ); 49 _map.insert( 0x8925, new QString("SIOCGIFENCAP") );
44 _map.insert( 0x8926, new QString("SIOCSIFENCAP") ); 50 _map.insert( 0x8926, new QString("SIOCSIFENCAP") );
45 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") ); 51 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
46 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") ); 52 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
47 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") ); 53 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
48 _map.insert( 0x8931, new QString("SIOCADDMULTI") ); 54 _map.insert( 0x8931, new QString("SIOCADDMULTI") );
49 _map.insert( 0x8932, new QString("SIOCDELMULTI") ); 55 _map.insert( 0x8932, new QString("SIOCDELMULTI") );
50 _map.insert( 0x8933, new QString("SIOCGIFINDEX") ); 56 _map.insert( 0x8933, new QString("SIOCGIFINDEX") );
51 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") ); 57 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
52 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") ); 58 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
53 _map.insert( 0x8936, new QString("SIOCDIFADDR") ); 59 _map.insert( 0x8936, new QString("SIOCDIFADDR") );
54 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); 60 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
55 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") ); 61 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
56 _map.insert( 0x8940, new QString("SIOCGIFBR") ); 62 _map.insert( 0x8940, new QString("SIOCGIFBR") );
57 _map.insert( 0x8941, new QString("SIOCSIFBR") ); 63 _map.insert( 0x8941, new QString("SIOCSIFBR") );
@@ -167,49 +173,51 @@ DebugMapper::DebugMapper()
167 _map.insert( 0x8948, new QString("SIOCGMIIREG") ); 173 _map.insert( 0x8948, new QString("SIOCGMIIREG") );
168 _map.insert( 0x8949, new QString("SIOCSMIIREG") ); 174 _map.insert( 0x8949, new QString("SIOCSMIIREG") );
169 _map.insert( 0x894A, new QString("SIOCWANDEV") ); 175 _map.insert( 0x894A, new QString("SIOCWANDEV") );
170 _map.insert( 0x8953, new QString("SIOCDARP") ); 176 _map.insert( 0x8953, new QString("SIOCDARP") );
171 _map.insert( 0x8954, new QString("SIOCGARP") ); 177 _map.insert( 0x8954, new QString("SIOCGARP") );
172 _map.insert( 0x8955, new QString("SIOCSARP") ); 178 _map.insert( 0x8955, new QString("SIOCSARP") );
173 _map.insert( 0x8960, new QString("SIOCDRARP") ); 179 _map.insert( 0x8960, new QString("SIOCDRARP") );
174 _map.insert( 0x8961, new QString("SIOCGRARP") ); 180 _map.insert( 0x8961, new QString("SIOCGRARP") );
175 _map.insert( 0x8962, new QString("SIOCSRARP") ); 181 _map.insert( 0x8962, new QString("SIOCSRARP") );
176 _map.insert( 0x8970, new QString("SIOCGIFMAP") ); 182 _map.insert( 0x8970, new QString("SIOCGIFMAP") );
177 _map.insert( 0x8971, new QString("SIOCSIFMAP") ); 183 _map.insert( 0x8971, new QString("SIOCSIFMAP") );
178 _map.insert( 0x8980, new QString("SIOCADDDLCI") ); 184 _map.insert( 0x8980, new QString("SIOCADDDLCI") );
179 _map.insert( 0x8981, new QString("SIOCDELDLCI") ); 185 _map.insert( 0x8981, new QString("SIOCDELDLCI") );
180 _map.insert( 0x8982, new QString("SIOCGIFVLAN") ); 186 _map.insert( 0x8982, new QString("SIOCGIFVLAN") );
181 _map.insert( 0x8983, new QString("SIOCSIFVLAN") ); 187 _map.insert( 0x8983, new QString("SIOCSIFVLAN") );
182 _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") ); 188 _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") );
183 _map.insert( 0x8991, new QString("SIOCBONDRELEASE") ); 189 _map.insert( 0x8991, new QString("SIOCBONDRELEASE") );
184 _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") ); 190 _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") );
185 _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") ); 191 _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") );
186 _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") ); 192 _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") );
187 _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") ); 193 _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") );
188 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); 194 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
189 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); 195 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
190 196
191}; 197};
192 198
193 199
194DebugMapper::~DebugMapper() 200DebugMapper::~DebugMapper()
195{ 201{
196 odebug << "DebugMapper::~DebugMapper()" << oendl; 202 odebug << "DebugMapper::~DebugMapper()" << oendl;
197} 203}
198 204
199 205
200const QString& DebugMapper::map( int value ) const 206const QString& DebugMapper::map( int value ) const
201{ 207{
202 QString* result = _map[ value ]; 208 QString* result = _map[ value ];
203 209
204 if ( !result ) 210 if ( !result )
205 { 211 {
206 owarn << "DebugMapper::map() - value " << value << " is not found." << oendl; 212 owarn << "DebugMapper::map() - value " << value << " is not found." << oendl;
207 return QString::null; 213 return QString::null;
208 } 214 }
209 else 215 else
210 { 216 {
211 return *result; 217 return *result;
212 } 218 }
213} 219}
214 220
215 221}
222}
223}
diff --git a/libopie2/opienet/odebugmapper.h b/libopie2/opienet/odebugmapper.h
index 66b331d..f47db47 100644
--- a/libopie2/opienet/odebugmapper.h
+++ b/libopie2/opienet/odebugmapper.h
@@ -1,26 +1,36 @@
1 1
2/* 2/*
3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
4 */ 4 */
5 5
6#ifndef DEBUGMAPPER_H 6#ifndef DEBUGMAPPER_H
7#define DEBUGMAPPER_H 7#define DEBUGMAPPER_H
8 8
9#include <qstring.h> 9#include <qstring.h>
10#include <qintdict.h> 10#include <qintdict.h>
11 11
12namespace Opie {
13namespace Net {
14namespace Private {
15
12typedef QIntDict<QString> IntStringMap; 16typedef QIntDict<QString> IntStringMap;
13 17
14class DebugMapper 18class DebugMapper
15{ 19{
16 public: 20 public:
17 DebugMapper(); 21 DebugMapper();
18 ~DebugMapper(); 22 ~DebugMapper();
19 23
20 const QString& map( int value ) const; 24 const QString& map( int value ) const;
21 private: 25 private:
22 IntStringMap _map; 26 IntStringMap _map;
27 class Private;
28 Private *d;
23}; 29};
24 30
31}
32}
33}
34
25#endif 35#endif
26 36
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index b93b752..209ec94 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,135 +1,142 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#include "omanufacturerdb.h" 31#include "omanufacturerdb.h"
32 32
33#define OPIE_IMPROVE_GUI_LATENCY 1 33#define OPIE_IMPROVE_GUI_LATENCY 1
34 34
35/* OPIE */ 35/* OPIE */
36#include <opie2/odebug.h> 36#include <opie2/odebug.h>
37#ifdef OPIE_IMPROVE_GUI_LATENCY 37#ifdef OPIE_IMPROVE_GUI_LATENCY
38#include <qpe/global.h> 38#include <qpe/global.h>
39#endif 39#endif
40 40
41/* QT */ 41/* QT */
42#include <qapplication.h> 42#include <qapplication.h>
43#include <qfile.h> 43#include <qfile.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45 45
46using namespace Opie::Core;
47namespace Opie {
48namespace Net {
49
46OManufacturerDB* OManufacturerDB::_instance = 0; 50OManufacturerDB* OManufacturerDB::_instance = 0;
47 51
48OManufacturerDB* OManufacturerDB::instance() 52OManufacturerDB* OManufacturerDB::instance()
49{ 53{
50 if ( !OManufacturerDB::_instance ) 54 if ( !OManufacturerDB::_instance )
51 { 55 {
52 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; 56 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
53 _instance = new OManufacturerDB(); 57 _instance = new OManufacturerDB();
54 } 58 }
55 return _instance; 59 return _instance;
56} 60}
57 61
58 62
59OManufacturerDB::OManufacturerDB() 63OManufacturerDB::OManufacturerDB()
60{ 64{
61 #ifdef OPIE_IMPROVE_GUI_LATENCY 65 #ifdef OPIE_IMPROVE_GUI_LATENCY
62 Global::statusMessage( "Reading Manufacturers..." ); 66 Global::statusMessage( "Reading Manufacturers..." );
63 #endif 67 #endif
64 QString filename( "/etc/manufacturers" ); 68 QString filename( "/etc/manufacturers" );
65 odebug << "OManufacturerDB: trying to read " << filename << oendl; 69 odebug << "OManufacturerDB: trying to read " << filename << oendl;
66 if ( !QFile::exists( filename ) ) 70 if ( !QFile::exists( filename ) )
67 { 71 {
68 filename = "/opt/QtPalmtop/etc/manufacturers"; 72 filename = "/opt/QtPalmtop/etc/manufacturers";
69 odebug << "OManufacturerDB: trying to read " << filename << oendl; 73 odebug << "OManufacturerDB: trying to read " << filename << oendl;
70 if ( !QFile::exists( filename ) ) 74 if ( !QFile::exists( filename ) )
71 { 75 {
72 filename = "/usr/share/wellenreiter/manufacturers"; 76 filename = "/usr/share/wellenreiter/manufacturers";
73 odebug << "OManufacturerDB: trying to read " << filename << oendl; 77 odebug << "OManufacturerDB: trying to read " << filename << oendl;
74 } 78 }
75 } 79 }
76 80
77 QFile file( filename ); 81 QFile file( filename );
78 bool hasFile = file.open( IO_ReadOnly ); 82 bool hasFile = file.open( IO_ReadOnly );
79 if (!hasFile) 83 if (!hasFile)
80 { 84 {
81 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; 85 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
82 } 86 }
83 else 87 else
84 { 88 {
85 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; 89 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
86 QTextStream s( &file ); 90 QTextStream s( &file );
87 QString addr; 91 QString addr;
88 QString manu; 92 QString manu;
89 QString extManu; 93 QString extManu;
90 #ifdef OPIE_IMPROVE_GUI_LATENCY 94 #ifdef OPIE_IMPROVE_GUI_LATENCY
91 int counter = 0; 95 int counter = 0;
92 #endif 96 #endif
93 while (!s.atEnd()) 97 while (!s.atEnd())
94 { 98 {
95 s >> addr; 99 s >> addr;
96 s >> manu; 100 s >> manu;
97 s >> extManu; 101 s >> extManu;
98 102
99 manufacturers.insert( addr, manu ); 103 manufacturers.insert( addr, manu );
100 manufacturersExt.insert( addr, extManu ); 104 manufacturersExt.insert( addr, extManu );
101 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; 105 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl;
102 #ifdef OPIE_IMPROVE_GUI_LATENCY 106 #ifdef OPIE_IMPROVE_GUI_LATENCY
103 counter++; 107 counter++;
104 if ( counter == 50 ) 108 if ( counter == 50 )
105 { 109 {
106 qApp->processEvents(); 110 qApp->processEvents();
107 counter = 0; 111 counter = 0;
108 } 112 }
109 #endif 113 #endif
110 } 114 }
111 odebug << "OManufacturerDB: manufacturer list completed." << oendl; 115 odebug << "OManufacturerDB: manufacturer list completed." << oendl;
112 #ifdef OPIE_IMPROVE_GUI_LATENCY 116 #ifdef OPIE_IMPROVE_GUI_LATENCY
113 Global::statusMessage( "Manufacturers Complete..." ); 117 Global::statusMessage( "Manufacturers Complete..." );
114 #endif 118 #endif
115 } 119 }
116} 120}
117 121
118 122
119OManufacturerDB::~OManufacturerDB() 123OManufacturerDB::~OManufacturerDB()
120{ 124{
121} 125}
122 126
123 127
124const QString& OManufacturerDB::lookup( const QString& macaddr ) const 128const QString& OManufacturerDB::lookup( const QString& macaddr ) const
125{ 129{
126 return manufacturers[macaddr.upper().left(8)]; 130 return manufacturers[macaddr.upper().left(8)];
127} 131}
128 132
129 133
130const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const 134const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
131{ 135{
132 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); 136 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
133 return it == manufacturersExt.end() ? lookup( macaddr ) : *it; 137 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
134} 138}
135 139
140}
141}
142
diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h
index c2712e5..5c1940e 100644
--- a/libopie2/opienet/omanufacturerdb.h
+++ b/libopie2/opienet/omanufacturerdb.h
@@ -1,69 +1,77 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef OMANUFACTURERDB_H 31#ifndef OMANUFACTURERDB_H
32#define OMANUFACTURERDB_H 32#define OMANUFACTURERDB_H
33 33
34#include <qmap.h> 34#include <qmap.h>
35 35
36namespace Opie {
37namespace Net {
38
36/** 39/**
37 * @brief A Ethernet card vendor database. 40 * @brief A Ethernet card vendor database.
38 * 41 *
39 * This class encapsulates the lookup of Ethernet vendor given a 42 * This class encapsulates the lookup of Ethernet vendor given a
40 * certain Mac Address. Only the first three bytes define the vendor. 43 * certain Mac Address. Only the first three bytes define the vendor.
41 */ 44 */
42class OManufacturerDB 45class OManufacturerDB
43{ 46{
44 public: 47 public:
45 /** 48 /**
46 * @returns the one-and-only @ref OManufacturerDB instance. 49 * @returns the one-and-only @ref OManufacturerDB instance.
47 */ 50 */
48 static OManufacturerDB* instance(); 51 static OManufacturerDB* instance();
49 /** 52 /**
50 * @returns the short manufacturer string given a @a macaddr. 53 * @returns the short manufacturer string given a @a macaddr.
51 */ 54 */
52 const QString& lookup( const QString& macaddr ) const; 55 const QString& lookup( const QString& macaddr ) const;
53 /** 56 /**
54 * @returns the enhanced manufacturer string given a @a macaddr. 57 * @returns the enhanced manufacturer string given a @a macaddr.
55 */ 58 */
56 const QString& lookupExt( const QString& macaddr ) const; 59 const QString& lookupExt( const QString& macaddr ) const;
57 60
58 protected: 61 protected:
59 OManufacturerDB(); 62 OManufacturerDB();
60 virtual ~OManufacturerDB(); 63 virtual ~OManufacturerDB();
61 64
62 private: 65 private:
63 QMap<QString, QString> manufacturers; 66 QMap<QString, QString> manufacturers;
64 QMap<QString, QString> manufacturersExt; 67 QMap<QString, QString> manufacturersExt;
65 static OManufacturerDB* _instance; 68 static OManufacturerDB* _instance;
69 class Private;
70 Private *d;
66}; 71};
67 72
73}
74}
75
68#endif 76#endif
69 77
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index 48cfa43..7794334 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -1,87 +1,90 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 4              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include <opie2/onetutils.h> 32#include <opie2/onetutils.h>
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/omanufacturerdb.h> 34#include <opie2/omanufacturerdb.h>
35 35
36#include <net/if.h> 36#include <net/if.h>
37#include <assert.h> 37#include <assert.h>
38#include <stdio.h> 38#include <stdio.h>
39 39
40namespace Opie {
41namespace Net {
42
40/*====================================================================================== 43/*======================================================================================
41 * OMacAddress 44 * OMacAddress
42 *======================================================================================*/ 45 *======================================================================================*/
43 46
44// static initializer for broadcast and unknown MAC Adresses 47// static initializer for broadcast and unknown MAC Adresses
45const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 48const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
46const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); 49const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
47const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; 50const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
48const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); 51const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
49 52
50//TODO: Incorporate Ethernet Manufacturer database here! (inline or so) 53//TODO: Incorporate Ethernet Manufacturer database here! (inline or so)
51 54
52OMacAddress::OMacAddress() 55OMacAddress::OMacAddress()
53{ 56{
54 memcpy( _bytes, __unknown, 6 ); 57 memcpy( _bytes, __unknown, 6 );
55} 58}
56 59
57 60
58OMacAddress::OMacAddress( unsigned char* p ) 61OMacAddress::OMacAddress( unsigned char* p )
59{ 62{
60 memcpy( _bytes, p, 6 ); 63 memcpy( _bytes, p, 6 );
61} 64}
62 65
63 66
64OMacAddress::OMacAddress( const unsigned char* p ) 67OMacAddress::OMacAddress( const unsigned char* p )
65{ 68{
66 memcpy( _bytes, p, 6 ); 69 memcpy( _bytes, p, 6 );
67} 70}
68 71
69 72
70OMacAddress::OMacAddress( struct ifreq& ifr ) 73OMacAddress::OMacAddress( struct ifreq& ifr )
71{ 74{
72 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); 75 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 );
73} 76}
74 77
75 78
76OMacAddress::~OMacAddress() 79OMacAddress::~OMacAddress()
77{ 80{
78} 81}
79 82
80 83
81//#ifdef QT_NO_DEBUG 84//#ifdef QT_NO_DEBUG
82//inline 85//inline
83//#endif 86//#endif
84const unsigned char* OMacAddress::native() const 87const unsigned char* OMacAddress::native() const
85{ 88{
86 return (const unsigned char*) &_bytes; 89 return (const unsigned char*) &_bytes;
87} 90}
@@ -140,93 +143,99 @@ bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
140 143
141OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) 144OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
142 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) 145 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
143{ 146{
144} 147}
145 148
146 149
147OPrivateIOCTL::~OPrivateIOCTL() 150OPrivateIOCTL::~OPrivateIOCTL()
148{ 151{
149} 152}
150 153
151 154
152int OPrivateIOCTL::numberGetArgs() const 155int OPrivateIOCTL::numberGetArgs() const
153{ 156{
154 return _getargs & IW_PRIV_SIZE_MASK; 157 return _getargs & IW_PRIV_SIZE_MASK;
155} 158}
156 159
157 160
158int OPrivateIOCTL::typeGetArgs() const 161int OPrivateIOCTL::typeGetArgs() const
159{ 162{
160 return _getargs & IW_PRIV_TYPE_MASK >> 12; 163 return _getargs & IW_PRIV_TYPE_MASK >> 12;
161} 164}
162 165
163 166
164int OPrivateIOCTL::numberSetArgs() const 167int OPrivateIOCTL::numberSetArgs() const
165{ 168{
166 return _setargs & IW_PRIV_SIZE_MASK; 169 return _setargs & IW_PRIV_SIZE_MASK;
167} 170}
168 171
169 172
170int OPrivateIOCTL::typeSetArgs() const 173int OPrivateIOCTL::typeSetArgs() const
171{ 174{
172 return _setargs & IW_PRIV_TYPE_MASK >> 12; 175 return _setargs & IW_PRIV_TYPE_MASK >> 12;
173} 176}
174 177
175 178
176void OPrivateIOCTL::invoke() const 179void OPrivateIOCTL::invoke() const
177{ 180{
178 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); 181 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
179} 182}
180 183
181 184
182void OPrivateIOCTL::setParameter( int num, u_int32_t value ) 185void OPrivateIOCTL::setParameter( int num, u_int32_t value )
183{ 186{
184 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; 187 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
185 arglist[num] = value; 188 arglist[num] = value;
186} 189}
187 190
191
192
193namespace Private {
188/*====================================================================================== 194/*======================================================================================
189 * assorted functions 195 * assorted functions
190 *======================================================================================*/ 196 *======================================================================================*/
191 197
192void dumpBytes( const unsigned char* data, int num ) 198void dumpBytes( const unsigned char* data, int num )
193{ 199{
194 printf( "Dumping %d bytes @ %0x", num, data ); 200 printf( "Dumping %d bytes @ %0x", num, data );
195 printf( "-------------------------------------------\n" ); 201 printf( "-------------------------------------------\n" );
196 202
197 for ( int i = 0; i < num; ++i ) 203 for ( int i = 0; i < num; ++i )
198 { 204 {
199 printf( "%02x ", data[i] ); 205 printf( "%02x ", data[i] );
200 if ( !((i+1) % 32) ) printf( "\n" ); 206 if ( !((i+1) % 32) ) printf( "\n" );
201 } 207 }
202 printf( "\n\n" ); 208 printf( "\n\n" );
203} 209}
204 210
205 211
206int stringToMode( const QString& mode ) 212int stringToMode( const QString& mode )
207{ 213{
208 if ( mode == "auto" ) return IW_MODE_AUTO; 214 if ( mode == "auto" ) return IW_MODE_AUTO;
209 else if ( mode == "adhoc" ) return IW_MODE_ADHOC; 215 else if ( mode == "adhoc" ) return IW_MODE_ADHOC;
210 else if ( mode == "managed" ) return IW_MODE_INFRA; 216 else if ( mode == "managed" ) return IW_MODE_INFRA;
211 else if ( mode == "master" ) return IW_MODE_MASTER; 217 else if ( mode == "master" ) return IW_MODE_MASTER;
212 else if ( mode == "repeater" ) return IW_MODE_REPEAT; 218 else if ( mode == "repeater" ) return IW_MODE_REPEAT;
213 else if ( mode == "secondary" ) return IW_MODE_SECOND; 219 else if ( mode == "secondary" ) return IW_MODE_SECOND;
214 else if ( mode == "monitor" ) return IW_MODE_MONITOR; 220 else if ( mode == "monitor" ) return IW_MODE_MONITOR;
215 else assert( 0 ); 221 else assert( 0 );
216} 222}
217 223
218 224
219QString modeToString( int mode ) 225QString modeToString( int mode )
220{ 226{
221 switch ( mode ) 227 switch ( mode )
222 { 228 {
223 case IW_MODE_AUTO: return "auto"; 229 case IW_MODE_AUTO: return "auto";
224 case IW_MODE_ADHOC: return "adhoc"; 230 case IW_MODE_ADHOC: return "adhoc";
225 case IW_MODE_INFRA: return "managed"; 231 case IW_MODE_INFRA: return "managed";
226 case IW_MODE_MASTER: return "master"; 232 case IW_MODE_MASTER: return "master";
227 case IW_MODE_REPEAT: return "repeater"; 233 case IW_MODE_REPEAT: return "repeater";
228 case IW_MODE_SECOND: return "second"; 234 case IW_MODE_SECOND: return "second";
229 case IW_MODE_MONITOR: return "monitor"; 235 case IW_MODE_MONITOR: return "monitor";
230 default: assert( 0 ); 236 default: assert( 0 );
231 } 237 }
232} 238}
239}
240}
241}
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h
index bddfab9..ca6815d 100644
--- a/libopie2/opienet/onetutils.h
+++ b/libopie2/opienet/onetutils.h
@@ -1,174 +1,189 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef ONETUTILS_H 32#ifndef ONETUTILS_H
33#define ONETUTILS_H 33#define ONETUTILS_H
34 34
35#include <qdict.h> 35#include <qdict.h>
36#include <qmap.h> 36#include <qmap.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qhostaddress.h> 38#include <qhostaddress.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42 42
43struct ifreq; 43struct ifreq;
44
45namespace Opie {
46namespace Net {
47
44class OWirelessNetworkInterface; 48class OWirelessNetworkInterface;
45 49
46/*====================================================================================== 50/*======================================================================================
47 * OMacAddress 51 * OMacAddress
48 *======================================================================================*/ 52 *======================================================================================*/
49 53
50class OMacAddress 54class OMacAddress
51{ 55{
52 public: 56 public:
53 // QString c'tor? -zecke 57 // QString c'tor? -zecke
54 OMacAddress(); 58 OMacAddress();
55 OMacAddress( unsigned char* ); 59 OMacAddress( unsigned char* );
56 OMacAddress( const unsigned char* ); 60 OMacAddress( const unsigned char* );
57 OMacAddress( struct ifreq& ); 61 OMacAddress( struct ifreq& );
58 ~OMacAddress(); 62 ~OMacAddress();
59 63
60 QString manufacturer() const; 64 QString manufacturer() const;
61 QString toString( bool substitute = false ) const; 65 QString toString( bool substitute = false ) const;
62 const unsigned char* native() const; 66 const unsigned char* native() const;
63 67
64 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? 68 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem?
65 static OMacAddress fromString( const QString& ); 69 static OMacAddress fromString( const QString& );
66 70
67 public: 71 public:
68 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff 72 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff
69 static const OMacAddress& unknown; // 44:44:44:44:44:44 73 static const OMacAddress& unknown; // 44:44:44:44:44:44
70 74
71 private: 75 private:
72 unsigned char _bytes[6]; 76 unsigned char _bytes[6];
73 77
74 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 78 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
79 class Private;
80 Private *d;
75 81
76}; 82};
77 83
78bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 84bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
79 85
80 86
81/*====================================================================================== 87/*======================================================================================
82 * OHostAddress 88 * OHostAddress
83 *======================================================================================*/ 89 *======================================================================================*/
84 90
85class OHostAddress : public QHostAddress 91class OHostAddress : public QHostAddress
86{ 92{
87 /*public: 93 /*public:
88 OHostAddress(); 94 OHostAddress();
89 ~OHostAddress(); 95 ~OHostAddress();
90 */ 96 */
97 private:
98 class Private;
99 Private *d;
91}; 100};
92 101
93 102
94/*====================================================================================== 103/*======================================================================================
95 * OPrivateIOCTL 104 * OPrivateIOCTL
96 *======================================================================================*/ 105 *======================================================================================*/
97 106
98class OPrivateIOCTL : public QObject 107class OPrivateIOCTL : public QObject
99{ 108{
100 public: 109 public:
101 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); 110 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs );
102 ~OPrivateIOCTL(); 111 ~OPrivateIOCTL();
103 112
104 int numberGetArgs() const; 113 int numberGetArgs() const;
105 int typeGetArgs() const; 114 int typeGetArgs() const;
106 int numberSetArgs() const; 115 int numberSetArgs() const;
107 int typeSetArgs() const; 116 int typeSetArgs() const;
108 117
109 // FIXME return int? as ::ioctl does? -zecke 118 // FIXME return int? as ::ioctl does? -zecke
110 void invoke() const; 119 void invoke() const;
111 void setParameter( int, u_int32_t ); 120 void setParameter( int, u_int32_t );
112 121
113 private: 122 private:
114 u_int32_t _ioctl; 123 u_int32_t _ioctl;
115 u_int16_t _getargs; 124 u_int16_t _getargs;
116 u_int16_t _setargs; 125 u_int16_t _setargs;
117 126
127 class Private;
128 Private *d;
118}; 129};
119 130
120 /*====================================================================================== 131 /*======================================================================================
121 * Miscellaneous 132 * Miscellaneous
122 *======================================================================================*/ 133 *======================================================================================*/
123 134
135namespace Private {
124void dumpBytes( const unsigned char* data, int num ); 136void dumpBytes( const unsigned char* data, int num );
125QString modeToString( int ); 137QString modeToString( int );
126int stringToMode( const QString& ); 138int stringToMode( const QString& );
139}
140}
141}
127 142
128#define IW_PRIV_TYPE_MASK 0x7000 143#define IW_PRIV_TYPE_MASK 0x7000
129#define IW_PRIV_TYPE_NONE 0x0000 144#define IW_PRIV_TYPE_NONE 0x0000
130#define IW_PRIV_TYPE_BYTE 0x1000 145#define IW_PRIV_TYPE_BYTE 0x1000
131#define IW_PRIV_TYPE_CHAR 0x2000 146#define IW_PRIV_TYPE_CHAR 0x2000
132#define IW_PRIV_TYPE_INT 0x4000 147#define IW_PRIV_TYPE_INT 0x4000
133#define IW_PRIV_TYPE_FLOAT 0x5000 148#define IW_PRIV_TYPE_FLOAT 0x5000
134#define IW_PRIV_TYPE_ADDR 0x6000 149#define IW_PRIV_TYPE_ADDR 0x6000
135#define IW_PRIV_SIZE_FIXED 0x0800 150#define IW_PRIV_SIZE_FIXED 0x0800
136#define IW_PRIV_SIZE_MASK 0x07FF 151#define IW_PRIV_SIZE_MASK 0x07FF
137 152
138#ifndef ARPHRD_IEEE80211 153#ifndef ARPHRD_IEEE80211
139#define ARPHRD_IEEE80211 801 154#define ARPHRD_IEEE80211 801
140#endif 155#endif
141#ifndef ARPHRD_IEEE80211_PRISM 156#ifndef ARPHRD_IEEE80211_PRISM
142#define ARPHRD_IEEE80211_PRISM 802 157#define ARPHRD_IEEE80211_PRISM 802
143#endif 158#endif
144 159
145 160
146/* Network to host order macros */ 161/* Network to host order macros */
147 162
148#ifdef LBL_ALIGN 163#ifdef LBL_ALIGN
149#define EXTRACT_16BITS(p) \ 164#define EXTRACT_16BITS(p) \
150 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ 165 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
151 (u_int16_t)*((const u_int8_t *)(p) + 1))) 166 (u_int16_t)*((const u_int8_t *)(p) + 1)))
152#define EXTRACT_32BITS(p) \ 167#define EXTRACT_32BITS(p) \
153 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ 168 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
154 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ 169 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
155 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ 170 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
156 (u_int32_t)*((const u_int8_t *)(p) + 3))) 171 (u_int32_t)*((const u_int8_t *)(p) + 3)))
157#else 172#else
158#define EXTRACT_16BITS(p) \ 173#define EXTRACT_16BITS(p) \
159 ((u_int16_t)ntohs(*(const u_int16_t *)(p))) 174 ((u_int16_t)ntohs(*(const u_int16_t *)(p)))
160#define EXTRACT_32BITS(p) \ 175#define EXTRACT_32BITS(p) \
161 ((u_int32_t)ntohl(*(const u_int32_t *)(p))) 176 ((u_int32_t)ntohl(*(const u_int32_t *)(p)))
162#endif 177#endif
163 178
164#define EXTRACT_24BITS(p) \ 179#define EXTRACT_24BITS(p) \
165 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ 180 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
166 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ 181 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
167 (u_int32_t)*((const u_int8_t *)(p) + 2))) 182 (u_int32_t)*((const u_int8_t *)(p) + 2)))
168 183
169/* Little endian protocol host order macros */ 184/* Little endian protocol host order macros */
170#define EXTRACT_LE_8BITS(p) (*(p)) 185#define EXTRACT_LE_8BITS(p) (*(p))
171#define EXTRACT_LE_16BITS(p) \ 186#define EXTRACT_LE_16BITS(p) \
172 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ 187 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
173 (u_int16_t)*((const u_int8_t *)(p) + 0))) 188 (u_int16_t)*((const u_int8_t *)(p) + 0)))
174#define EXTRACT_LE_32BITS(p) \ 189#define EXTRACT_LE_32BITS(p) \
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index e5b091f..ab3e77f 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -12,103 +12,109 @@
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31/* OPIE */ 31/* OPIE */
32 32
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/ostation.h> 34#include <opie2/ostation.h>
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36 36
37/* QT */ 37/* QT */
38 38
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41 41
42/* UNIX */ 42/* UNIX */
43 43
44#include <assert.h> 44#include <assert.h>
45#include <arpa/inet.h> 45#include <arpa/inet.h>
46#include <errno.h> 46#include <errno.h>
47#include <string.h> 47#include <string.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <math.h> 49#include <math.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/socket.h> 51#include <sys/socket.h>
52#include <sys/types.h> 52#include <sys/types.h>
53#include <unistd.h> 53#include <unistd.h>
54#include <linux/sockios.h> 54#include <linux/sockios.h>
55#include <net/if_arp.h> 55#include <net/if_arp.h>
56#include <stdarg.h> 56#include <stdarg.h>
57 57
58#ifndef NODEBUG 58#ifndef NODEBUG
59#include <opie2/odebugmapper.h> 59#include <opie2/odebugmapper.h>
60
61
62using namespace Opie::Core;
63using namespace Opie::Net::Private;
60DebugMapper* debugmapper = new DebugMapper(); 64DebugMapper* debugmapper = new DebugMapper();
61#endif 65#endif
62 66
63/*====================================================================================== 67/*======================================================================================
64 * ONetwork 68 * ONetwork
65 *======================================================================================*/ 69 *======================================================================================*/
66 70
71namespace Opie {
72namespace Net {
67ONetwork* ONetwork::_instance = 0; 73ONetwork* ONetwork::_instance = 0;
68 74
69ONetwork::ONetwork() 75ONetwork::ONetwork()
70{ 76{
71 odebug << "ONetwork::ONetwork()" << oendl; 77 odebug << "ONetwork::ONetwork()" << oendl;
72 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; 78 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl;
73 synchronize(); 79 synchronize();
74} 80}
75 81
76void ONetwork::synchronize() 82void ONetwork::synchronize()
77{ 83{
78 // gather available interfaces by inspecting /proc/net/dev 84 // gather available interfaces by inspecting /proc/net/dev
79 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 85 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
80 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 86 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
81 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev 87 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
82 88
83 _interfaces.clear(); 89 _interfaces.clear();
84 QString str; 90 QString str;
85 QFile f( "/proc/net/dev" ); 91 QFile f( "/proc/net/dev" );
86 bool hasFile = f.open( IO_ReadOnly ); 92 bool hasFile = f.open( IO_ReadOnly );
87 if ( !hasFile ) 93 if ( !hasFile )
88 { 94 {
89 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; 95 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl;
90 return; 96 return;
91 } 97 }
92 QTextStream s( &f ); 98 QTextStream s( &f );
93 s.readLine(); 99 s.readLine();
94 s.readLine(); 100 s.readLine();
95 while ( !s.atEnd() ) 101 while ( !s.atEnd() )
96 { 102 {
97 s >> str; 103 s >> str;
98 str.truncate( str.find( ':' ) ); 104 str.truncate( str.find( ':' ) );
99 odebug << "ONetwork: found interface '" << str << "'" << oendl; 105 odebug << "ONetwork: found interface '" << str << "'" << oendl;
100 ONetworkInterface* iface; 106 ONetworkInterface* iface;
101 if ( isWirelessInterface( str ) ) 107 if ( isWirelessInterface( str ) )
102 { 108 {
103 iface = new OWirelessNetworkInterface( this, (const char*) str ); 109 iface = new OWirelessNetworkInterface( this, (const char*) str );
104 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; 110 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl;
105 } 111 }
106 else 112 else
107 { 113 {
108 iface = new ONetworkInterface( this, (const char*) str ); 114 iface = new ONetworkInterface( this, (const char*) str );
109 } 115 }
110 _interfaces.insert( str, iface ); 116 _interfaces.insert( str, iface );
111 s.readLine(); 117 s.readLine();
112 } 118 }
113} 119}
114 120
@@ -1192,48 +1198,51 @@ QString OHostAPMonitoringInterface::name() const
1192 1198
1193/*====================================================================================== 1199/*======================================================================================
1194 * OOrinocoNetworkInterface 1200 * OOrinocoNetworkInterface
1195 *======================================================================================*/ 1201 *======================================================================================*/
1196 1202
1197OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1203OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1198 :OMonitoringInterface( iface, prismHeader ) 1204 :OMonitoringInterface( iface, prismHeader )
1199{ 1205{
1200 iface->setMonitoring( this ); 1206 iface->setMonitoring( this );
1201} 1207}
1202 1208
1203 1209
1204OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 1210OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
1205{ 1211{
1206} 1212}
1207 1213
1208 1214
1209void OOrinocoMonitoringInterface::setChannel( int c ) 1215void OOrinocoMonitoringInterface::setChannel( int c )
1210{ 1216{
1211 if ( !_if->hasPrivate( "monitor" ) ) 1217 if ( !_if->hasPrivate( "monitor" ) )
1212 { 1218 {
1213 this->OMonitoringInterface::setChannel( c ); 1219 this->OMonitoringInterface::setChannel( c );
1214 } 1220 }
1215 else 1221 else
1216 { 1222 {
1217 int monitorCode = _prismHeader ? 1 : 2; 1223 int monitorCode = _prismHeader ? 1 : 2;
1218 _if->setPrivate( "monitor", 2, monitorCode, c ); 1224 _if->setPrivate( "monitor", 2, monitorCode, c );
1219 } 1225 }
1220} 1226}
1221 1227
1222 1228
1223void OOrinocoMonitoringInterface::setEnabled( bool b ) 1229void OOrinocoMonitoringInterface::setEnabled( bool b )
1224{ 1230{
1225 if ( b ) 1231 if ( b )
1226 { 1232 {
1227 setChannel( 1 ); 1233 setChannel( 1 );
1228 } 1234 }
1229 else 1235 else
1230 { 1236 {
1231 _if->setPrivate( "monitor", 2, 0, 0 ); 1237 _if->setPrivate( "monitor", 2, 0, 0 );
1232 } 1238 }
1233} 1239}
1234 1240
1235 1241
1236QString OOrinocoMonitoringInterface::name() const 1242QString OOrinocoMonitoringInterface::name() const
1237{ 1243{
1238 return "orinoco"; 1244 return "orinoco";
1239} 1245}
1246
1247}
1248}
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 93b129f..a953296 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -11,163 +11,168 @@
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef ONETWORK_H 31#ifndef ONETWORK_H
32#define ONETWORK_H 32#define ONETWORK_H
33 33
34#if !defined( OPIE_WE_VERSION ) 34#if !defined( OPIE_WE_VERSION )
35#error Need to define a wireless extension version to build against! 35#error Need to define a wireless extension version to build against!
36#endif 36#endif
37 37
38#if OPIE_WE_VERSION == 15 38#if OPIE_WE_VERSION == 15
39#include "wireless.15.h" 39#include "wireless.15.h"
40#endif 40#endif
41 41
42#if OPIE_WE_VERSION == 16 42#if OPIE_WE_VERSION == 16
43#include "wireless.16.h" 43#include "wireless.16.h"
44#endif 44#endif
45 45
46/* OPIE */ 46/* OPIE */
47 47
48#include <opie2/onetutils.h> 48#include <opie2/onetutils.h>
49#include <opie2/ostation.h> 49#include <opie2/ostation.h>
50 50
51/* QT */ 51/* QT */
52 52
53#include <qvaluelist.h> 53#include <qvaluelist.h>
54#include <qdict.h> 54#include <qdict.h>
55#include <qmap.h> 55#include <qmap.h>
56#include <qobject.h> 56#include <qobject.h>
57#include <qhostaddress.h> 57#include <qhostaddress.h>
58 58
59namespace Opie {
60namespace Net {
61
59class ONetworkInterface; 62class ONetworkInterface;
60class OWirelessNetworkInterface; 63class OWirelessNetworkInterface;
61class OChannelHopper; 64class OChannelHopper;
62class OMonitoringInterface; 65class OMonitoringInterface;
63 66
64/*====================================================================================== 67/*======================================================================================
65 * ONetwork 68 * ONetwork
66 *======================================================================================*/ 69 *======================================================================================*/
67 70
68/** 71/**
69 * @brief A container class for all network interfaces 72 * @brief A container class for all network interfaces
70 * 73 *
71 * This class provides access to all available network interfaces of your computer. 74 * This class provides access to all available network interfaces of your computer.
72 * 75 *
73 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 76 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
74 */ 77 */
75class ONetwork : public QObject 78class ONetwork : public QObject
76{ 79{
77 Q_OBJECT 80 Q_OBJECT
78 81
79 public: 82 public:
80 typedef QDict<ONetworkInterface> InterfaceMap; 83 typedef QDict<ONetworkInterface> InterfaceMap;
81 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 84 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
82 85
83 public: 86 public:
84 /** 87 /**
85 * @returns the number of available interfaces 88 * @returns the number of available interfaces
86 */ 89 */
87 int count() const; 90 int count() const;
88 /** 91 /**
89 * @returns a pointer to the (one and only) @ref ONetwork instance. 92 * @returns a pointer to the (one and only) @ref ONetwork instance.
90 */ 93 */
91 static ONetwork* instance(); 94 static ONetwork* instance();
92 /** 95 /**
93 * @returns an iterator usable for iterating through all network interfaces. 96 * @returns an iterator usable for iterating through all network interfaces.
94 */ 97 */
95 InterfaceIterator iterator() const; 98 InterfaceIterator iterator() const;
96 /** 99 /**
97 * @returns true, if the @a interface is present. 100 * @returns true, if the @a interface is present.
98 */ 101 */
99 bool isPresent( const char* interface ) const; 102 bool isPresent( const char* interface ) const;
100 /** 103 /**
101 * @returns true, if the @a interface supports the wireless extension protocol. 104 * @returns true, if the @a interface supports the wireless extension protocol.
102 */ 105 */
103 bool isWirelessInterface( const char* interface ) const; 106 bool isWirelessInterface( const char* interface ) const;
104 /** 107 /**
105 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. 108 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found.
106 * @see ONetworkInterface 109 * @see ONetworkInterface
107 */ 110 */
108 ONetworkInterface* interface( const QString& interface ) const; 111 ONetworkInterface* interface( const QString& interface ) const;
109 /** 112 /**
110 * @internal Rebuild the internal interface database 113 * @internal Rebuild the internal interface database
111 * @note Sometimes it might be useful to call this from client code, 114 * @note Sometimes it might be useful to call this from client code,
112 * e.g. after issuing a cardctl insert 115 * e.g. after issuing a cardctl insert
113 */ 116 */
114 void synchronize(); 117 void synchronize();
115 /** 118 /**
116 * @returns the wireless extension version used at compile time. 119 * @returns the wireless extension version used at compile time.
117 **/ 120 **/
118 static short wirelessExtensionVersion(); 121 static short wirelessExtensionVersion();
119 122
120 protected: 123 protected:
121 ONetwork(); 124 ONetwork();
122 125
123 private: 126 private:
124 static ONetwork* _instance; 127 static ONetwork* _instance;
125 InterfaceMap _interfaces; 128 InterfaceMap _interfaces;
129 class Private;
130 Private *d;
126}; 131};
127 132
128 133
129/*====================================================================================== 134/*======================================================================================
130 * ONetworkInterface 135 * ONetworkInterface
131 *======================================================================================*/ 136 *======================================================================================*/
132 137
133/** 138/**
134 * @brief A network interface wrapper. 139 * @brief A network interface wrapper.
135 * 140 *
136 * This class provides a wrapper for a network interface. All the cumbersume details of 141 * This class provides a wrapper for a network interface. All the cumbersume details of
137 * Linux ioctls are hidden under a convenient high-level interface. 142 * Linux ioctls are hidden under a convenient high-level interface.
138 * @warning Most of the setting methods contained in this class require the appropriate 143 * @warning Most of the setting methods contained in this class require the appropriate
139 * process permissions to work. 144 * process permissions to work.
140 * 145 *
141 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 146 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
142 */ 147 */
143class ONetworkInterface : public QObject 148class ONetworkInterface : public QObject
144{ 149{
145 friend class OMonitoringInterface; 150 friend class OMonitoringInterface;
146 friend class OCiscoMonitoringInterface; 151 friend class OCiscoMonitoringInterface;
147 friend class OWlanNGMonitoringInterface; 152 friend class OWlanNGMonitoringInterface;
148 friend class OHostAPMonitoringInterface; 153 friend class OHostAPMonitoringInterface;
149 friend class OOrinocoMonitoringInterface; 154 friend class OOrinocoMonitoringInterface;
150 155
151 public: 156 public:
152 /** 157 /**
153 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, 158 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself,
154 * but access them via @ref ONetwork::interface(). 159 * but access them via @ref ONetwork::interface().
155 */ 160 */
156 ONetworkInterface( QObject* parent, const char* name ); 161 ONetworkInterface( QObject* parent, const char* name );
157 /** 162 /**
158 * Destructor. 163 * Destructor.
159 */ 164 */
160 virtual ~ONetworkInterface(); 165 virtual ~ONetworkInterface();
161 /** 166 /**
162 * Associates a @a monitoring interface with this network interface. 167 * Associates a @a monitoring interface with this network interface.
163 * @note This is currently only useful with @ref OWirelessNetworkInterface objects. 168 * @note This is currently only useful with @ref OWirelessNetworkInterface objects.
164 */ 169 */
165 void setMonitoring( OMonitoringInterface* monitoring ); 170 void setMonitoring( OMonitoringInterface* monitoring );
166 /** 171 /**
167 * @returns the currently associated monitoring interface or 0, if no monitoring is associated. 172 * @returns the currently associated monitoring interface or 0, if no monitoring is associated.
168 */ 173 */
169 OMonitoringInterface* monitoring() const; 174 OMonitoringInterface* monitoring() const;
170 /** 175 /**
171 * Setting an interface to promiscuous mode enables the device to receive 176 * Setting an interface to promiscuous mode enables the device to receive
172 * all packets on the shared medium - as opposed to packets which are addressed to this interface. 177 * all packets on the shared medium - as opposed to packets which are addressed to this interface.
173 */ 178 */
@@ -189,158 +194,163 @@ class ONetworkInterface : public QObject
189 */ 194 */
190 bool isLoopback() const; 195 bool isLoopback() const;
191 /** 196 /**
192 * @returns true if the interface is featuring supports the wireless extension protocol. 197 * @returns true if the interface is featuring supports the wireless extension protocol.
193 */ 198 */
194 bool isWireless() const; 199 bool isWireless() const;
195 /** 200 /**
196 * Associate the IP address @ addr with the interface. 201 * Associate the IP address @ addr with the interface.
197 */ 202 */
198 void setIPV4Address( const QHostAddress& addr ); 203 void setIPV4Address( const QHostAddress& addr );
199 /** 204 /**
200 * @returns the IPv4 address associated with the interface. 205 * @returns the IPv4 address associated with the interface.
201 */ 206 */
202 QString ipV4Address() const; //TODO: make this return an OHostAddress 207 QString ipV4Address() const; //TODO: make this return an OHostAddress
203 /** 208 /**
204 * Associate the MAC address @a addr with the interface. 209 * Associate the MAC address @a addr with the interface.
205 * @note It can be necessary to shut down the interface prior to calling this method. 210 * @note It can be necessary to shut down the interface prior to calling this method.
206 * @warning This is not supported by all drivers. 211 * @warning This is not supported by all drivers.
207 */ 212 */
208 void setMacAddress( const OMacAddress& addr ); 213 void setMacAddress( const OMacAddress& addr );
209 /** 214 /**
210 * @returns the MAC address associated with the interface. 215 * @returns the MAC address associated with the interface.
211 */ 216 */
212 OMacAddress macAddress() const; 217 OMacAddress macAddress() const;
213 /** 218 /**
214 * Associate the IPv4 @a netmask with the interface. 219 * Associate the IPv4 @a netmask with the interface.
215 */ 220 */
216 void setIPV4Netmask( const QHostAddress& netmask ); 221 void setIPV4Netmask( const QHostAddress& netmask );
217 /** 222 /**
218 * @returns the IPv4 netmask associated with the interface. 223 * @returns the IPv4 netmask associated with the interface.
219 */ 224 */
220 QString ipV4Netmask() const; //TODO: make this return an OHostAddress 225 QString ipV4Netmask() const; //TODO: make this return an OHostAddress
221 /** 226 /**
222 * @returns the data link type currently associated with the interface. 227 * @returns the data link type currently associated with the interface.
223 * @see #include <net/if_arp.h> for possible values. 228 * @see #include <net/if_arp.h> for possible values.
224 */ 229 */
225 int dataLinkType() const; 230 int dataLinkType() const;
226 231
227 protected: 232 protected:
228 const int _sfd; 233 const int _sfd;
229 mutable ifreq _ifr; 234 mutable ifreq _ifr;
230 OMonitoringInterface* _mon; 235 OMonitoringInterface* _mon;
231 236
232 protected: 237 protected:
233 struct ifreq& ifr() const; 238 struct ifreq& ifr() const;
234 virtual void init(); 239 virtual void init();
235 bool ioctl( int call ) const; 240 bool ioctl( int call ) const;
236 bool ioctl( int call, struct ifreq& ) const; 241 bool ioctl( int call, struct ifreq& ) const;
242 private:
243 class Private;
244 Private *d;
237}; 245};
238 246
239/*====================================================================================== 247/*======================================================================================
240 * OChannelHopper 248 * OChannelHopper
241 *======================================================================================*/ 249 *======================================================================================*/
242 250
243/** 251/**
244 * @brief A radio frequency channel hopper. 252 * @brief A radio frequency channel hopper.
245 * 253 *
246 * This class provides a channel hopper for radio frequencies. A channel hopper frequently 254 * This class provides a channel hopper for radio frequencies. A channel hopper frequently
247 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. 255 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface.
248 * This is necessary when in monitoring mode and scanning for other devices, because 256 * This is necessary when in monitoring mode and scanning for other devices, because
249 * the radio frequency hardware can only detect packets sent on the same frequency. 257 * the radio frequency hardware can only detect packets sent on the same frequency.
250 * 258 *
251 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 259 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
252 */ 260 */
253class OChannelHopper : public QObject 261class OChannelHopper : public QObject
254{ 262{
255 Q_OBJECT 263 Q_OBJECT
256 264
257 public: 265 public:
258 /** 266 /**
259 * Constructor. 267 * Constructor.
260 */ 268 */
261 OChannelHopper( OWirelessNetworkInterface* ); 269 OChannelHopper( OWirelessNetworkInterface* );
262 /** 270 /**
263 * Destructor. 271 * Destructor.
264 */ 272 */
265 virtual ~OChannelHopper(); 273 virtual ~OChannelHopper();
266 /** 274 /**
267 * @returns true, if the channel hopper is hopping channels 275 * @returns true, if the channel hopper is hopping channels
268 */ 276 */
269 bool isActive() const; 277 bool isActive() const;
270 /** 278 /**
271 * @returns the last hopped channel 279 * @returns the last hopped channel
272 */ 280 */
273 int channel() const; 281 int channel() const;
274 /** 282 /**
275 * Set the channel hopping @a interval. 283 * Set the channel hopping @a interval.
276 * An interval of 0 deactivates the channel hopper. 284 * An interval of 0 deactivates the channel hopper.
277 */ 285 */
278 void setInterval( int interval ); 286 void setInterval( int interval );
279 /** 287 /**
280 * @returns the channel hopping interval 288 * @returns the channel hopping interval
281 */ 289 */
282 int interval() const; 290 int interval() const;
283 291
284 signals: 292 signals:
285 /** 293 /**
286 * This signal is emitted right after the channel hopper performed a hop 294 * This signal is emitted right after the channel hopper performed a hop
287 */ 295 */
288 void hopped( int ); 296 void hopped( int );
289 297
290 protected: 298 protected:
291 virtual void timerEvent( QTimerEvent* ); 299 virtual void timerEvent( QTimerEvent* );
292 300
293 private: 301 private:
294 OWirelessNetworkInterface* _iface; 302 OWirelessNetworkInterface* _iface;
295 int _interval; 303 int _interval;
296 int _tid; 304 int _tid;
297 QValueList<int> _channels; 305 QValueList<int> _channels;
298 QValueList<int>::Iterator _channel; 306 QValueList<int>::Iterator _channel;
307 class Private;
308 Private *d;
299}; 309};
300 310
301 311
302/*====================================================================================== 312/*======================================================================================
303 * OWirelessNetworkInterface 313 * OWirelessNetworkInterface
304 *======================================================================================*/ 314 *======================================================================================*/
305 315
306/** 316/**
307 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. 317 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol.
308 * 318 *
309 * This class provides a high-level encapsulation of the Linux wireless extension API. 319 * This class provides a high-level encapsulation of the Linux wireless extension API.
310 * 320 *
311 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 321 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
312 */ 322 */
313class OWirelessNetworkInterface : public ONetworkInterface 323class OWirelessNetworkInterface : public ONetworkInterface
314{ 324{
315 friend class OMonitoringInterface; 325 friend class OMonitoringInterface;
316 friend class OCiscoMonitoringInterface; 326 friend class OCiscoMonitoringInterface;
317 friend class OWlanNGMonitoringInterface; 327 friend class OWlanNGMonitoringInterface;
318 friend class OHostAPMonitoringInterface; 328 friend class OHostAPMonitoringInterface;
319 friend class OOrinocoMonitoringInterface; 329 friend class OOrinocoMonitoringInterface;
320 330
321 friend class OPrivateIOCTL; 331 friend class OPrivateIOCTL;
322 332
323 public: 333 public:
324 /** 334 /**
325 * Constructor. 335 * Constructor.
326 */ 336 */
327 OWirelessNetworkInterface( QObject* parent, const char* name ); 337 OWirelessNetworkInterface( QObject* parent, const char* name );
328 /** 338 /**
329 * Destructor. 339 * Destructor.
330 */ 340 */
331 virtual ~OWirelessNetworkInterface(); 341 virtual ~OWirelessNetworkInterface();
332 /** 342 /**
333 * Setting the @a channel of the interface changes the radio frequency (RF) 343 * Setting the @a channel of the interface changes the radio frequency (RF)
334 * of the corresponding wireless network device. 344 * of the corresponding wireless network device.
335 * @note Common channel range is within [1-14]. A value of 0 is not allowed. 345 * @note Common channel range is within [1-14]. A value of 0 is not allowed.
336 * @see channels() 346 * @see channels()
337 */ 347 */
338 virtual void setChannel( int channel ) const; 348 virtual void setChannel( int channel ) const;
339 /** 349 /**
340 * @returns the channel index of the current radio frequency. 350 * @returns the channel index of the current radio frequency.
341 */ 351 */
342 virtual int channel() const; 352 virtual int channel() const;
343 /** 353 /**
344 * @returns the current radio frequency (in MHz). 354 * @returns the current radio frequency (in MHz).
345 */ 355 */
346 virtual double frequency() const; 356 virtual double frequency() const;
@@ -410,150 +420,171 @@ class OWirelessNetworkInterface : public ONetworkInterface
410 */ 420 */
411 virtual bool isAssociated() const; 421 virtual bool isAssociated() const;
412 /** 422 /**
413 * @returns the MAC address of the Access Point if the device is in infrastructure mode. 423 * @returns the MAC address of the Access Point if the device is in infrastructure mode.
414 * @returns a (more or less random) cell ID address if the device is in adhoc mode. 424 * @returns a (more or less random) cell ID address if the device is in adhoc mode.
415 */ 425 */
416 virtual OMacAddress associatedAP() const; 426 virtual OMacAddress associatedAP() const;
417 /** 427 /**
418 * Set the @a ssid (Service Set ID) string. This is used to decide 428 * Set the @a ssid (Service Set ID) string. This is used to decide
419 * which network to associate with (use "any" to let the driver decide). 429 * which network to associate with (use "any" to let the driver decide).
420 */ 430 */
421 virtual void setSSID( const QString& ssid ); 431 virtual void setSSID( const QString& ssid );
422 /** 432 /**
423 * @returns the current SSID (Service Set ID). 433 * @returns the current SSID (Service Set ID).
424 */ 434 */
425 virtual QString SSID() const; 435 virtual QString SSID() const;
426 /** 436 /**
427 * Perform scanning the wireless network neighbourhood. 437 * Perform scanning the wireless network neighbourhood.
428 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! 438 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE!
429 */ 439 */
430 virtual OStationList* scanNetwork(); 440 virtual OStationList* scanNetwork();
431 /** 441 /**
432 * @return signal strength to associated neighbour (in percent). 442 * @return signal strength to associated neighbour (in percent).
433 * In infrastructure mode, this is the signal strength of the Access Point. 443 * In infrastructure mode, this is the signal strength of the Access Point.
434 * In other modes the result is driver dependent. 444 * In other modes the result is driver dependent.
435 */ 445 */
436 virtual int signalStrength() const; 446 virtual int signalStrength() const;
437 /** @internal commit pending changes to the driver 447 /** @internal commit pending changes to the driver
438 * 448 *
439 */ 449 */
440 void commit() const; 450 void commit() const;
441 451
442 protected: 452 protected:
443 void buildInformation(); 453 void buildInformation();
444 void buildPrivateList(); 454 void buildPrivateList();
445 void dumpInformation() const; 455 void dumpInformation() const;
446 virtual void init(); 456 virtual void init();
447 struct iwreq& iwr() const; 457 struct iwreq& iwr() const;
448 bool wioctl( int call ) const; 458 bool wioctl( int call ) const;
449 bool wioctl( int call, struct iwreq& ) const; 459 bool wioctl( int call, struct iwreq& ) const;
450 460
451 protected: 461 protected:
452 mutable struct iwreq _iwr; 462 mutable struct iwreq _iwr;
453 QMap<int,int> _channels; 463 QMap<int,int> _channels;
454 struct iw_range _range; 464 struct iw_range _range;
455 465
456 private: 466 private:
457 OChannelHopper* _hopper; 467 OChannelHopper* _hopper;
468 class Private;
469 Private *d;
458}; 470};
459 471
460 472
461/*====================================================================================== 473/*======================================================================================
462 * OMonitoringInterface 474 * OMonitoringInterface
463 *======================================================================================*/ 475 *======================================================================================*/
464 476
465 477
466class OMonitoringInterface 478class OMonitoringInterface
467{ 479{
468 public: 480 public:
469 OMonitoringInterface(); 481 OMonitoringInterface();
470 OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 482 OMonitoringInterface( ONetworkInterface*, bool _prismHeader );
471 virtual ~OMonitoringInterface(); 483 virtual ~OMonitoringInterface();
472 484
473 public: 485 public:
474 virtual void setEnabled( bool ); 486 virtual void setEnabled( bool );
475 virtual void setChannel( int ); 487 virtual void setChannel( int );
476 488
477 virtual QString name() const = 0; 489 virtual QString name() const = 0;
478 490
479 protected: 491 protected:
480 OWirelessNetworkInterface* _if; 492 OWirelessNetworkInterface* _if;
481 bool _prismHeader; 493 bool _prismHeader;
494 private:
495 class Private;
496 Private *d;
482 497
483}; 498};
484 499
485 500
486/*====================================================================================== 501/*======================================================================================
487 * OCiscoMonitoring 502 * OCiscoMonitoring
488 *======================================================================================*/ 503 *======================================================================================*/
489 504
490 505
491class OCiscoMonitoringInterface : public OMonitoringInterface 506class OCiscoMonitoringInterface : public OMonitoringInterface
492{ 507{
493 public: 508 public:
494 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 509 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
495 virtual ~OCiscoMonitoringInterface(); 510 virtual ~OCiscoMonitoringInterface();
496 511
497 virtual void setEnabled( bool ); 512 virtual void setEnabled( bool );
498 virtual QString name() const; 513 virtual QString name() const;
499 virtual void setChannel( int ); 514 virtual void setChannel( int );
515 private:
516 class Private;
517 Private *d;
500 518
501}; 519};
502 520
503 521
504/*====================================================================================== 522/*======================================================================================
505 * OWlanNGMonitoringInterface 523 * OWlanNGMonitoringInterface
506 *======================================================================================*/ 524 *======================================================================================*/
507 525
508 526
509class OWlanNGMonitoringInterface : public OMonitoringInterface 527class OWlanNGMonitoringInterface : public OMonitoringInterface
510{ 528{
511 public: 529 public:
512 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 530 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader );
513 virtual ~OWlanNGMonitoringInterface(); 531 virtual ~OWlanNGMonitoringInterface();
514 532
515 public: 533 public:
516 virtual void setEnabled( bool ); 534 virtual void setEnabled( bool );
517 virtual QString name() const; 535 virtual QString name() const;
518 virtual void setChannel( int ); 536 virtual void setChannel( int );
537 private:
538 class Private;
539 Private *d;
519 540
520}; 541};
521 542
522 543
523/*====================================================================================== 544/*======================================================================================
524 * OHostAPMonitoringInterface 545 * OHostAPMonitoringInterface
525 *======================================================================================*/ 546 *======================================================================================*/
526 547
527 548
528class OHostAPMonitoringInterface : public OMonitoringInterface 549class OHostAPMonitoringInterface : public OMonitoringInterface
529{ 550{
530 public: 551 public:
531 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 552 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader );
532 virtual ~OHostAPMonitoringInterface(); 553 virtual ~OHostAPMonitoringInterface();
533 554
534 public: 555 public:
535 virtual void setEnabled( bool ); 556 virtual void setEnabled( bool );
536 virtual QString name() const; 557 virtual QString name() const;
558
559 private:
560 class Private;
561 Private *d;
537 }; 562 };
538 563
539 564
540/*====================================================================================== 565/*======================================================================================
541 * OOrinocoMonitoringInterface 566 * OOrinocoMonitoringInterface
542 *======================================================================================*/ 567 *======================================================================================*/
543 568
544 569
545class OOrinocoMonitoringInterface : public OMonitoringInterface 570class OOrinocoMonitoringInterface : public OMonitoringInterface
546{ 571{
547 public: 572 public:
548 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 573 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
549 virtual ~OOrinocoMonitoringInterface(); 574 virtual ~OOrinocoMonitoringInterface();
550 575
551 public: 576 public:
552 virtual void setChannel( int ); 577 virtual void setChannel( int );
553 virtual void setEnabled( bool ); 578 virtual void setEnabled( bool );
554 virtual QString name() const; 579 virtual QString name() const;
555 580
581 private:
582 class Private;
583 Private *d;
556}; 584};
557 585
586}
587}
588
558#endif // ONETWORK_H 589#endif // ONETWORK_H
559 590
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index fdd519c..4081d4f 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -1,95 +1,100 @@
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 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31/* OPIE */ 31/* OPIE */
32#include <opie2/opcap.h> 32#include <opie2/opcap.h>
33#include <opie2/odebug.h> 33#include <opie2/odebug.h>
34 34
35/* QT */ 35/* QT */
36#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) 36#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
37#include <qsocketnotifier.h> 37#include <qsocketnotifier.h>
38#include <qobjectlist.h> 38#include <qobjectlist.h>
39 39
40/* SYSTEM */ 40/* SYSTEM */
41#include <sys/time.h> 41#include <sys/time.h>
42#include <sys/types.h> 42#include <sys/types.h>
43#include <unistd.h> 43#include <unistd.h>
44 44
45/* LOCAL */ 45/* LOCAL */
46#include "udp_ports.h" 46#include "udp_ports.h"
47 47
48using namespace Opie::Core;
49
50namespace Opie {
51namespace Net {
52
48/*====================================================================================== 53/*======================================================================================
49 * OPacket 54 * OPacket
50 *======================================================================================*/ 55 *======================================================================================*/
51 56
52OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) 57OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
53 :QObject( parent, "Generic" ), _hdr( header ), _data( data ) 58 :QObject( parent, "Generic" ), _hdr( header ), _data( data )
54{ 59{
55 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); 60 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
56 61
57 _end = (unsigned char*) data + header.len; 62 _end = (unsigned char*) data + header.len;
58 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); 63 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end );
59 64
60 switch ( datalink ) 65 switch ( datalink )
61 { 66 {
62 case DLT_EN10MB: 67 case DLT_EN10MB:
63 odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl; 68 odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl;
64 new OEthernetPacket( _end, (const struct ether_header*) data, this ); 69 new OEthernetPacket( _end, (const struct ether_header*) data, this );
65 break; 70 break;
66 71
67 case DLT_IEEE802_11: 72 case DLT_IEEE802_11:
68 odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl; 73 odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl;
69 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); 74 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this );
70 break; 75 break;
71 76
72 case DLT_PRISM_HEADER: 77 case DLT_PRISM_HEADER:
73 odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl; 78 odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl;
74 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); 79 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this );
75 break; 80 break;
76 81
77 default: 82 default:
78 owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl; 83 owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl;
79 } 84 }
80} 85}
81 86
82 87
83OPacket::~OPacket() 88OPacket::~OPacket()
84{ 89{
85} 90}
86 91
87 92
88timevalstruct OPacket::timeval() const 93timevalstruct OPacket::timeval() const
89{ 94{
90 return _hdr.ts; 95 return _hdr.ts;
91} 96}
92 97
93 98
94int OPacket::caplen() const 99int OPacket::caplen() const
95{ 100{
@@ -1299,49 +1304,50 @@ bool OPacketCapturer::open( const QFile& file )
1299 else 1304 else
1300 { 1305 {
1301 odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl; 1306 odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl;
1302 return false; 1307 return false;
1303 } 1308 }
1304 1309
1305} 1310}
1306 1311
1307 1312
1308bool OPacketCapturer::isOpen() const 1313bool OPacketCapturer::isOpen() const
1309{ 1314{
1310 return _open; 1315 return _open;
1311} 1316}
1312 1317
1313 1318
1314void OPacketCapturer::readyToReceive() 1319void OPacketCapturer::readyToReceive()
1315{ 1320{
1316 odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl; 1321 odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl;
1317 OPacket* p = next(); 1322 OPacket* p = next();
1318 emit receivedPacket( p ); 1323 emit receivedPacket( p );
1319 // emit is synchronous - packet has been dealt with, now it's safe to delete 1324 // emit is synchronous - packet has been dealt with, now it's safe to delete
1320 delete p; 1325 delete p;
1321} 1326}
1322 1327
1323 1328
1324const QMap<QString,int>& OPacketCapturer::statistics() const 1329const QMap<QString,int>& OPacketCapturer::statistics() const
1325{ 1330{
1326 return _stats; 1331 return _stats;
1327} 1332}
1328 1333
1329 1334
1330int OPacketCapturer::snapShot() const 1335int OPacketCapturer::snapShot() const
1331{ 1336{
1332 return pcap_snapshot( _pch ); 1337 return pcap_snapshot( _pch );
1333} 1338}
1334 1339
1335 1340
1336bool OPacketCapturer::swapped() const 1341bool OPacketCapturer::swapped() const
1337{ 1342{
1338 return pcap_is_swapped( _pch ); 1343 return pcap_is_swapped( _pch );
1339} 1344}
1340 1345
1341 1346
1342QString OPacketCapturer::version() const 1347QString OPacketCapturer::version() const
1343{ 1348{
1344 return QString().sprintf( "%d.%d", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); 1349 return QString().sprintf( "%d.%d", pcap_major_version( _pch ), pcap_minor_version( _pch ) );
1345} 1350}
1346 1351
1347 1352}
1353}
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index b873b49..dc609a3 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -19,577 +19,623 @@
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef OPCAP_H 31#ifndef OPCAP_H
32#define OPCAP_H 32#define OPCAP_H
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/onetutils.h> 35#include <opie2/onetutils.h>
36 36
37/* QT */ 37/* QT */
38#include <qevent.h> 38#include <qevent.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qhostaddress.h> 40#include <qhostaddress.h>
41#include <qobject.h> 41#include <qobject.h>
42#include <qstring.h> 42#include <qstring.h>
43#include <qtextstream.h> 43#include <qtextstream.h>
44#include <qmap.h> 44#include <qmap.h>
45 45
46/* STD */ 46/* STD */
47extern "C" // work around a bpf/pcap conflict in recent headers 47extern "C" // work around a bpf/pcap conflict in recent headers
48{ 48{
49 #include <pcap.h> 49 #include <pcap.h>
50} 50}
51#include <netinet/ether.h> 51#include <netinet/ether.h>
52#include <netinet/ip.h> 52#include <netinet/ip.h>
53#include <netinet/udp.h> 53#include <netinet/udp.h>
54#include <netinet/tcp.h> 54#include <netinet/tcp.h>
55#include <time.h> 55#include <time.h>
56 56
57/* Custom Network Includes (must go here, don't reorder!) */ 57/* Custom Network Includes (must go here, don't reorder!) */
58#include "802_11_user.h" 58#include "802_11_user.h"
59#include "dhcp.h" 59#include "dhcp.h"
60 60
61 61
62/* TYPEDEFS */ 62/* TYPEDEFS */
63typedef struct timeval timevalstruct; 63typedef struct timeval timevalstruct;
64typedef struct pcap_pkthdr packetheaderstruct; 64typedef struct pcap_pkthdr packetheaderstruct;
65 65
66/* FORWARDS */ 66/* FORWARDS */
67class OPacketCapturer;
68class QSocketNotifier; 67class QSocketNotifier;
68namespace Opie {
69namespace Net {
70class OPacketCapturer;
69 71
70/*====================================================================================== 72/*======================================================================================
71 * OPacket - A frame on the wire 73 * OPacket - A frame on the wire
72 *======================================================================================*/ 74 *======================================================================================*/
73 75
74/** @brief A class representing a data frame on the wire. 76/** @brief A class representing a data frame on the wire.
75 * 77 *
76 * The whole family of the packet classes are used when capturing frames from a network. 78 * The whole family of the packet classes are used when capturing frames from a network.
77 * Most standard network protocols in use share a common architecture, which mostly is 79 * Most standard network protocols in use share a common architecture, which mostly is
78 * a packet header and then the packet payload. In layered architectures, each lower layer 80 * a packet header and then the packet payload. In layered architectures, each lower layer
79 * encapsulates data from its upper layer - that is it 81 * encapsulates data from its upper layer - that is it
80 * treats the data from its upper layer as payload and prepends an own header to the packet, 82 * treats the data from its upper layer as payload and prepends an own header to the packet,
81 * which - again - is treated as the payload for the layer below. The figure below is an 83 * which - again - is treated as the payload for the layer below. The figure below is an
82 * example for how such a data frame is composed out of packets, e.g. when sending a mail. 84 * example for how such a data frame is composed out of packets, e.g. when sending a mail.
83 * 85 *
84 * <pre> 86 * <pre>
85 * | User Data | == Mail Data 87 * | User Data | == Mail Data
86 * | SMTP Header | User Data | == SMTP 88 * | SMTP Header | User Data | == SMTP
87 * | TCP Header | SMTP Header | User Data | == TCP 89 * | TCP Header | SMTP Header | User Data | == TCP
88 * | IP Header | TCP Header | SMTP Header | User Data | == IP 90 * | IP Header | TCP Header | SMTP Header | User Data | == IP
89 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC 91 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC
90 * 92 *
91 * </pre> 93 * </pre>
92 * 94 *
93 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer 95 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer
94 * also contains a few more levels of encapsulation. 96 * also contains a few more levels of encapsulation.
95 * Since the type of the payload is more or less independent from the encapsulating protocol, 97 * Since the type of the payload is more or less independent from the encapsulating protocol,
96 * the header must be inspected before attempting to decode the payload. Hence, the 98 * the header must be inspected before attempting to decode the payload. Hence, the
97 * encapsulation level varies and can't be deduced without actually looking into the packets. 99 * encapsulation level varies and can't be deduced without actually looking into the packets.
98 * 100 *
99 * For actually working with captured frames, it's useful to identify the packets via names and 101 * For actually working with captured frames, it's useful to identify the packets via names and
100 * insert them into a parent/child - relationship based on the encapsulation. This is why 102 * insert them into a parent/child - relationship based on the encapsulation. This is why
101 * all packet classes derive from QObject. The amount of overhead caused by the QObject is 103 * all packet classes derive from QObject. The amount of overhead caused by the QObject is
102 * not a problem in this case, because we're talking about a theoratical maximum of about 104 * not a problem in this case, because we're talking about a theoratical maximum of about
103 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the 105 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the
104 * QObject also cares about destroying the sub-, (child-) packets. 106 * QObject also cares about destroying the sub-, (child-) packets.
105 * 107 *
106 * This enables us to perform a simple look for packets of a certain type: 108 * This enables us to perform a simple look for packets of a certain type:
107 * @code 109 * @code
108 * OPacketCapturer* pcap = new OPacketCapturer(); 110 * OPacketCapturer* pcap = new OPacketCapturer();
109 * pcap->open( "eth0" ); 111 * pcap->open( "eth0" );
110 * OPacket* p = pcap->next(); 112 * OPacket* p = pcap->next();
111 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists 113 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists
112 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; 114 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl;
113 * 115 *
114 */ 116 */
115 117
116class OPacket : public QObject 118class OPacket : public QObject
117{ 119{
118 Q_OBJECT 120 Q_OBJECT
119 121
120 friend class OPacketCapturer; 122 friend class OPacketCapturer;
121 friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); 123 friend QTextStream& operator<<( QTextStream& s, const OPacket& p );
122 124
123 public: 125 public:
124 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); 126 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent );
125 virtual ~OPacket(); 127 virtual ~OPacket();
126 128
127 timevalstruct timeval() const; 129 timevalstruct timeval() const;
128 130
129 int caplen() const; 131 int caplen() const;
130 int len() const; 132 int len() const;
131 QString dump( int = 32 ) const; 133 QString dump( int = 32 ) const;
132 134
133 void updateStats( QMap<QString,int>&, QObjectList* ); 135 void updateStats( QMap<QString,int>&, QObjectList* );
134 136
135 private: 137 private:
136 138
137 QString dumpStructure() const; 139 QString dumpStructure() const;
138 QString _dumpStructure( QObjectList* ) const; 140 QString _dumpStructure( QObjectList* ) const;
139 141
140 private: 142 private:
141 const packetheaderstruct _hdr; // pcap packet header 143 const packetheaderstruct _hdr; // pcap packet header
142 const unsigned char* _data; // pcap packet data 144 const unsigned char* _data; // pcap packet data
143 const unsigned char* _end; // end of pcap packet data 145 const unsigned char* _end; // end of pcap packet data
146 private:
147 class Private;
148 Private *d;
144}; 149};
145 150
146QTextStream& operator<<( QTextStream& s, const OPacket& p ); 151QTextStream& operator<<( QTextStream& s, const OPacket& p );
147 152
148/*====================================================================================== 153/*======================================================================================
149 * OEthernetPacket - DLT_EN10MB frame 154 * OEthernetPacket - DLT_EN10MB frame
150 *======================================================================================*/ 155 *======================================================================================*/
151 156
152class OEthernetPacket : public QObject 157class OEthernetPacket : public QObject
153{ 158{
154 Q_OBJECT 159 Q_OBJECT
155 160
156 public: 161 public:
157 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); 162 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 );
158 virtual ~OEthernetPacket(); 163 virtual ~OEthernetPacket();
159 164
160 OMacAddress sourceAddress() const; 165 OMacAddress sourceAddress() const;
161 OMacAddress destinationAddress() const; 166 OMacAddress destinationAddress() const;
162 int type() const; 167 int type() const;
163 168
164 private: 169 private:
165 const struct ether_header* _ether; 170 const struct ether_header* _ether;
171 private:
172 class Private;
173 Private *d;
166}; 174};
167 175
168/*====================================================================================== 176/*======================================================================================
169 * OPrismHeaderPacket - DLT_PRISM_HEADER frame 177 * OPrismHeaderPacket - DLT_PRISM_HEADER frame
170 *======================================================================================*/ 178 *======================================================================================*/
171 179
172class OPrismHeaderPacket : public QObject 180class OPrismHeaderPacket : public QObject
173{ 181{
174 Q_OBJECT 182 Q_OBJECT
175 183
176 public: 184 public:
177 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); 185 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 );
178 virtual ~OPrismHeaderPacket(); 186 virtual ~OPrismHeaderPacket();
179 187
180 unsigned int signalStrength() const; 188 unsigned int signalStrength() const;
181 189
182 private: 190 private:
183 const struct prism_hdr* _header; 191 const struct prism_hdr* _header;
192 class Private;
193 Private *d;
184}; 194};
185 195
186/*====================================================================================== 196/*======================================================================================
187 * OWaveLanPacket - DLT_IEEE802_11 frame 197 * OWaveLanPacket - DLT_IEEE802_11 frame
188 *======================================================================================*/ 198 *======================================================================================*/
189 199
190class OWaveLanPacket : public QObject 200class OWaveLanPacket : public QObject
191{ 201{
192 Q_OBJECT 202 Q_OBJECT
193 203
194 public: 204 public:
195 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); 205 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 );
196 virtual ~OWaveLanPacket(); 206 virtual ~OWaveLanPacket();
197 207
198 int duration() const; 208 int duration() const;
199 bool fromDS() const; 209 bool fromDS() const;
200 bool toDS() const; 210 bool toDS() const;
201 virtual OMacAddress macAddress1() const; 211 virtual OMacAddress macAddress1() const;
202 virtual OMacAddress macAddress2() const; 212 virtual OMacAddress macAddress2() const;
203 virtual OMacAddress macAddress3() const; 213 virtual OMacAddress macAddress3() const;
204 virtual OMacAddress macAddress4() const; 214 virtual OMacAddress macAddress4() const;
205 bool usesPowerManagement() const; 215 bool usesPowerManagement() const;
206 int type() const; 216 int type() const;
207 int subType() const; 217 int subType() const;
208 int version() const; 218 int version() const;
209 bool usesWep() const; 219 bool usesWep() const;
210 220
211 private: 221 private:
212 const struct ieee_802_11_header* _wlanhdr; 222 const struct ieee_802_11_header* _wlanhdr;
223 class Private;
224 Private *d;
213}; 225};
214 226
215 227
216/*====================================================================================== 228/*======================================================================================
217 * OWaveLanManagementPacket - type: management (T_MGMT) 229 * OWaveLanManagementPacket - type: management (T_MGMT)
218 *======================================================================================*/ 230 *======================================================================================*/
219 231
220class OWaveLanManagementPacket : public QObject 232class OWaveLanManagementPacket : public QObject
221{ 233{
222 Q_OBJECT 234 Q_OBJECT
223 235
224 public: 236 public:
225 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); 237 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 );
226 virtual ~OWaveLanManagementPacket(); 238 virtual ~OWaveLanManagementPacket();
227 239
228 QString managementType() const; 240 QString managementType() const;
229 241
230 int beaconInterval() const; 242 int beaconInterval() const;
231 int capabilities() const; // generic 243 int capabilities() const; // generic
232 244
233 bool canESS() const; 245 bool canESS() const;
234 bool canIBSS() const; 246 bool canIBSS() const;
235 bool canCFP() const; 247 bool canCFP() const;
236 bool canCFP_REQ() const; 248 bool canCFP_REQ() const;
237 bool canPrivacy() const; 249 bool canPrivacy() const;
238 250
239 private: 251 private:
240 const struct ieee_802_11_mgmt_header* _header; 252 const struct ieee_802_11_mgmt_header* _header;
241 const struct ieee_802_11_mgmt_body* _body; 253 const struct ieee_802_11_mgmt_body* _body;
254 class Private;
255 Private *d;
242}; 256};
243 257
244 258
245/*====================================================================================== 259/*======================================================================================
246 * OWaveLanManagementSSID 260 * OWaveLanManagementSSID
247 *======================================================================================*/ 261 *======================================================================================*/
248 262
249class OWaveLanManagementSSID : public QObject 263class OWaveLanManagementSSID : public QObject
250{ 264{
251 Q_OBJECT 265 Q_OBJECT
252 266
253 public: 267 public:
254 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); 268 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 );
255 virtual ~OWaveLanManagementSSID(); 269 virtual ~OWaveLanManagementSSID();
256 270
257 QString ID( bool decloak = false ) const; 271 QString ID( bool decloak = false ) const;
258 272
259 private: 273 private:
260 const struct ssid_t* _data; 274 const struct ssid_t* _data;
275 class Private;
276 Private *d;
261}; 277};
262 278
263/*====================================================================================== 279/*======================================================================================
264 * OWaveLanManagementRates 280 * OWaveLanManagementRates
265 *======================================================================================*/ 281 *======================================================================================*/
266 282
267class OWaveLanManagementRates : public QObject 283class OWaveLanManagementRates : public QObject
268{ 284{
269 Q_OBJECT 285 Q_OBJECT
270 286
271 public: 287 public:
272 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); 288 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 );
273 virtual ~OWaveLanManagementRates(); 289 virtual ~OWaveLanManagementRates();
274 290
275 private: 291 private:
276 const struct rates_t* _data; 292 const struct rates_t* _data;
293 class Private;
294 Private *d;
277}; 295};
278 296
279/*====================================================================================== 297/*======================================================================================
280 * OWaveLanManagementCF 298 * OWaveLanManagementCF
281 *======================================================================================*/ 299 *======================================================================================*/
282 300
283class OWaveLanManagementCF : public QObject 301class OWaveLanManagementCF : public QObject
284{ 302{
285 Q_OBJECT 303 Q_OBJECT
286 304
287 public: 305 public:
288 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); 306 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 );
289 virtual ~OWaveLanManagementCF(); 307 virtual ~OWaveLanManagementCF();
290 308
291 private: 309 private:
292 const struct cf_t* _data; 310 const struct cf_t* _data;
311 class Private;
312 Private *d;
293}; 313};
294 314
295/*====================================================================================== 315/*======================================================================================
296 * OWaveLanManagementFH 316 * OWaveLanManagementFH
297 *======================================================================================*/ 317 *======================================================================================*/
298 318
299class OWaveLanManagementFH : public QObject 319class OWaveLanManagementFH : public QObject
300{ 320{
301 Q_OBJECT 321 Q_OBJECT
302 322
303 public: 323 public:
304 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); 324 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 );
305 virtual ~OWaveLanManagementFH(); 325 virtual ~OWaveLanManagementFH();
306 326
307 private: 327 private:
308 const struct fh_t* _data; 328 const struct fh_t* _data;
329 class Private;
330 Private *d;
309}; 331};
310 332
311/*====================================================================================== 333/*======================================================================================
312 * OWaveLanManagementDS 334 * OWaveLanManagementDS
313 *======================================================================================*/ 335 *======================================================================================*/
314 336
315class OWaveLanManagementDS : public QObject 337class OWaveLanManagementDS : public QObject
316{ 338{
317 Q_OBJECT 339 Q_OBJECT
318 340
319 public: 341 public:
320 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); 342 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 );
321 virtual ~OWaveLanManagementDS(); 343 virtual ~OWaveLanManagementDS();
322 344
323 int channel() const; 345 int channel() const;
324 346
325 private: 347 private:
326 const struct ds_t* _data; 348 const struct ds_t* _data;
349 class Private;
350 Private *d;
327}; 351};
328 352
329/*====================================================================================== 353/*======================================================================================
330 * OWaveLanManagementTim 354 * OWaveLanManagementTim
331 *======================================================================================*/ 355 *======================================================================================*/
332 356
333class OWaveLanManagementTim : public QObject 357class OWaveLanManagementTim : public QObject
334{ 358{
335 Q_OBJECT 359 Q_OBJECT
336 360
337 public: 361 public:
338 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); 362 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 );
339 virtual ~OWaveLanManagementTim(); 363 virtual ~OWaveLanManagementTim();
340 364
341 private: 365 private:
342 const struct tim_t* _data; 366 const struct tim_t* _data;
367 class Private;
368 Private *d;
343}; 369};
344 370
345/*====================================================================================== 371/*======================================================================================
346 * OWaveLanManagementIBSS 372 * OWaveLanManagementIBSS
347 *======================================================================================*/ 373 *======================================================================================*/
348 374
349class OWaveLanManagementIBSS : public QObject 375class OWaveLanManagementIBSS : public QObject
350{ 376{
351 Q_OBJECT 377 Q_OBJECT
352 378
353 public: 379 public:
354 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); 380 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 );
355 virtual ~OWaveLanManagementIBSS(); 381 virtual ~OWaveLanManagementIBSS();
356 382
357 private: 383 private:
358 const struct ibss_t* _data; 384 const struct ibss_t* _data;
385 class Private;
386 Private *d;
359}; 387};
360 388
361/*====================================================================================== 389/*======================================================================================
362 * OWaveLanManagementChallenge 390 * OWaveLanManagementChallenge
363 *======================================================================================*/ 391 *======================================================================================*/
364 392
365class OWaveLanManagementChallenge : public QObject 393class OWaveLanManagementChallenge : public QObject
366{ 394{
367 Q_OBJECT 395 Q_OBJECT
368 396
369 public: 397 public:
370 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); 398 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 );
371 virtual ~OWaveLanManagementChallenge(); 399 virtual ~OWaveLanManagementChallenge();
372 400
373 private: 401 private:
374 const struct challenge_t* _data; 402 const struct challenge_t* _data;
403 class Private;
404 Private *d;
375}; 405};
376 406
377/*====================================================================================== 407/*======================================================================================
378 * OWaveLanDataPacket - type: data (T_DATA) 408 * OWaveLanDataPacket - type: data (T_DATA)
379 *======================================================================================*/ 409 *======================================================================================*/
380 410
381class OWaveLanDataPacket : public QObject 411class OWaveLanDataPacket : public QObject
382{ 412{
383 Q_OBJECT 413 Q_OBJECT
384 414
385 public: 415 public:
386 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); 416 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 );
387 virtual ~OWaveLanDataPacket(); 417 virtual ~OWaveLanDataPacket();
388 418
389 private: 419 private:
390 const struct ieee_802_11_data_header* _header; 420 const struct ieee_802_11_data_header* _header;
421 class Private;
422 Private *d;
391}; 423};
392 424
393/*====================================================================================== 425/*======================================================================================
394 * OWaveLanControlPacket - type: control (T_CTRL) 426 * OWaveLanControlPacket - type: control (T_CTRL)
395 *======================================================================================*/ 427 *======================================================================================*/
396 428
397class OWaveLanControlPacket : public QObject 429class OWaveLanControlPacket : public QObject
398{ 430{
399 Q_OBJECT 431 Q_OBJECT
400 432
401 public: 433 public:
402 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); 434 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 );
403 virtual ~OWaveLanControlPacket(); 435 virtual ~OWaveLanControlPacket();
404 436
405 QString controlType() const; 437 QString controlType() const;
406 438
407 private: 439 private:
408 const struct ieee_802_11_control_header* _header; 440 const struct ieee_802_11_control_header* _header;
441 class Private;
442 Private *d;
409}; 443};
410 444
411/*====================================================================================== 445/*======================================================================================
412 * OLLCPacket - IEEE 802.2 Link Level Control 446 * OLLCPacket - IEEE 802.2 Link Level Control
413 *======================================================================================*/ 447 *======================================================================================*/
414 448
415class OLLCPacket : public QObject 449class OLLCPacket : public QObject
416{ 450{
417 Q_OBJECT 451 Q_OBJECT
418 452
419 public: 453 public:
420 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); 454 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 );
421 virtual ~OLLCPacket(); 455 virtual ~OLLCPacket();
422 456
423 private: 457 private:
424 const struct ieee_802_11_802_2_header* _header; 458 const struct ieee_802_11_802_2_header* _header;
459 class Private;
460 Private *d;
425}; 461};
426 462
427/*====================================================================================== 463/*======================================================================================
428 * OIPPacket 464 * OIPPacket
429 *======================================================================================*/ 465 *======================================================================================*/
430 466
431class OIPPacket : public QObject 467class OIPPacket : public QObject
432{ 468{
433 Q_OBJECT 469 Q_OBJECT
434 470
435 public: 471 public:
436 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); 472 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 );
437 virtual ~OIPPacket(); 473 virtual ~OIPPacket();
438 474
439 QHostAddress fromIPAddress() const; 475 QHostAddress fromIPAddress() const;
440 QHostAddress toIPAddress() const; 476 QHostAddress toIPAddress() const;
441 477
442 int tos() const; 478 int tos() const;
443 int len() const; 479 int len() const;
444 int id() const; 480 int id() const;
445 int offset() const; 481 int offset() const;
446 int ttl() const; 482 int ttl() const;
447 int protocol() const; 483 int protocol() const;
448 int checksum() const; 484 int checksum() const;
449 485
450 private: 486 private:
451 const struct iphdr* _iphdr; 487 const struct iphdr* _iphdr;
488 class Private;
489 Private *d;
452}; 490};
453 491
454/*====================================================================================== 492/*======================================================================================
455 * OARPPacket 493 * OARPPacket
456 *======================================================================================*/ 494 *======================================================================================*/
457 495
458class OARPPacket : public QObject 496class OARPPacket : public QObject
459{ 497{
460 Q_OBJECT 498 Q_OBJECT
461 499
462 public: 500 public:
463 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); 501 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 );
464 virtual ~OARPPacket(); 502 virtual ~OARPPacket();
465 503
466 QHostAddress senderIPV4Address() const; 504 QHostAddress senderIPV4Address() const;
467 OMacAddress senderMacAddress() const; 505 OMacAddress senderMacAddress() const;
468 QHostAddress targetIPV4Address() const; 506 QHostAddress targetIPV4Address() const;
469 OMacAddress targetMacAddress() const; 507 OMacAddress targetMacAddress() const;
470 508
471 //int type() const; 509 //int type() const;
472 QString type() const; 510 QString type() const;
473 511
474 private: 512 private:
475 const struct myarphdr* _arphdr; 513 const struct myarphdr* _arphdr;
514 class Private;
515 Private *d;
476}; 516};
477 517
478/*====================================================================================== 518/*======================================================================================
479 * OUDPPacket 519 * OUDPPacket
480 *======================================================================================*/ 520 *======================================================================================*/
481 521
482class OUDPPacket : public QObject 522class OUDPPacket : public QObject
483{ 523{
484 Q_OBJECT 524 Q_OBJECT
485 525
486 public: 526 public:
487 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); 527 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
488 virtual ~OUDPPacket(); 528 virtual ~OUDPPacket();
489 529
490 int fromPort() const; 530 int fromPort() const;
491 int toPort() const; 531 int toPort() const;
492 int length() const; 532 int length() const;
493 int checksum() const; 533 int checksum() const;
494 534
495 private: 535 private:
496 const struct udphdr* _udphdr; 536 const struct udphdr* _udphdr;
537 class Private;
538 Private *d;
497}; 539};
498 540
499/*====================================================================================== 541/*======================================================================================
500 * ODHCPPacket 542 * ODHCPPacket
501 *======================================================================================*/ 543 *======================================================================================*/
502 544
503class ODHCPPacket : public QObject 545class ODHCPPacket : public QObject
504{ 546{
505 Q_OBJECT 547 Q_OBJECT
506 548
507 public: 549 public:
508 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); 550 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 );
509 virtual ~ODHCPPacket(); 551 virtual ~ODHCPPacket();
510 552
511 QHostAddress clientAddress() const; 553 QHostAddress clientAddress() const;
512 QHostAddress yourAddress() const; 554 QHostAddress yourAddress() const;
513 QHostAddress serverAddress() const; 555 QHostAddress serverAddress() const;
514 QHostAddress relayAddress() const; 556 QHostAddress relayAddress() const;
515 557
516 OMacAddress clientMacAddress() const; 558 OMacAddress clientMacAddress() const;
517 559
518 bool isRequest() const; 560 bool isRequest() const;
519 bool isReply() const; 561 bool isReply() const;
520 QString type() const; 562 QString type() const;
521 563
522 private: 564 private:
523 const struct dhcp_packet* _dhcphdr; 565 const struct dhcp_packet* _dhcphdr;
524 unsigned char _type; 566 unsigned char _type;
567 class Private;
568 Private *d;
525}; 569};
526 570
527/*====================================================================================== 571/*======================================================================================
528 * OTCPPacket 572 * OTCPPacket
529 *======================================================================================*/ 573 *======================================================================================*/
530 574
531class OTCPPacket : public QObject 575class OTCPPacket : public QObject
532{ 576{
533 Q_OBJECT 577 Q_OBJECT
534 578
535 public: 579 public:
536 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); 580 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
537 virtual ~OTCPPacket(); 581 virtual ~OTCPPacket();
538 582
539 int fromPort() const; 583 int fromPort() const;
540 int toPort() const; 584 int toPort() const;
541 int seq() const; 585 int seq() const;
542 int ack() const; 586 int ack() const;
543 int window() const; 587 int window() const;
544 int checksum() const; 588 int checksum() const;
545 589
546 private: 590 private:
547 const struct tcphdr* _tcphdr; 591 const struct tcphdr* _tcphdr;
592 class Private;
593 Private *d;
548}; 594};
549 595
550 596
551/*====================================================================================== 597/*======================================================================================
552 * OPacketCapturer 598 * OPacketCapturer
553 *======================================================================================*/ 599 *======================================================================================*/
554 600
555/** 601/**
556 * @brief A class based wrapper for network packet capturing. 602 * @brief A class based wrapper for network packet capturing.
557 * 603 *
558 * This class is the base of a high-level interface to the well known packet capturing 604 * This class is the base of a high-level interface to the well known packet capturing
559 * library libpcap. 605 * library libpcap.
560 * @see http://tcpdump.org 606 * @see http://tcpdump.org
561 */ 607 */
562class OPacketCapturer : public QObject 608class OPacketCapturer : public QObject
563{ 609{
564 Q_OBJECT 610 Q_OBJECT
565 611
566 public: 612 public:
567 /** 613 /**
568 * Constructor. 614 * Constructor.
569 */ 615 */
570 OPacketCapturer( QObject* parent = 0, const char* name = 0 ); 616 OPacketCapturer( QObject* parent = 0, const char* name = 0 );
571 /** 617 /**
572 * Destructor. 618 * Destructor.
573 */ 619 */
574 ~OPacketCapturer(); 620 ~OPacketCapturer();
575 /** 621 /**
576 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when 622 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when
577 * not using the socket notifier, e.g. without an application object. 623 * not using the socket notifier, e.g. without an application object.
578 */ 624 */
579 void setBlocking( bool ); 625 void setBlocking( bool );
580 /** 626 /**
581 * @returns true if the packet capturer uses blocking IO calls. 627 * @returns true if the packet capturer uses blocking IO calls.
582 */ 628 */
583 bool blocking() const; 629 bool blocking() const;
584 /** 630 /**
585 * Close the packet capturer. This is automatically done in the destructor. 631 * Close the packet capturer. This is automatically done in the destructor.
586 */ 632 */
587 void close(); 633 void close();
588 /** 634 /**
589 * Close the output capture file. 635 * Close the output capture file.
590 */ 636 */
591 void closeDumpFile(); 637 void closeDumpFile();
592 /** 638 /**
593 * @returns the data link type. 639 * @returns the data link type.
594 * @see <pcap.h> for possible values. 640 * @see <pcap.h> for possible values.
595 */ 641 */
@@ -620,52 +666,56 @@ class OPacketCapturer : public QObject
620 /** 666 /**
621 * Open the packet capturer to capture packets in offline-mode from @a file. 667 * Open the packet capturer to capture packets in offline-mode from @a file.
622 */ 668 */
623 bool open( const QFile& file ); 669 bool open( const QFile& file );
624 /** 670 /**
625 * Open a prerecorded tcpdump compatible capture file for use with @ref dump() 671 * Open a prerecorded tcpdump compatible capture file for use with @ref dump()
626 */ 672 */
627 bool openDumpFile( const QString& filename ); 673 bool openDumpFile( const QString& filename );
628 /** 674 /**
629 * @returns true if the packet capturer is open 675 * @returns true if the packet capturer is open
630 */ 676 */
631 bool isOpen() const; 677 bool isOpen() const;
632 /** 678 /**
633 * @returns the snapshot length of this packet capturer 679 * @returns the snapshot length of this packet capturer
634 */ 680 */
635 int snapShot() const; 681 int snapShot() const;
636 /** 682 /**
637 * @returns true if the input capture file has a different byte-order 683 * @returns true if the input capture file has a different byte-order
638 * than the byte-order of the running system. 684 * than the byte-order of the running system.
639 */ 685 */
640 bool swapped() const; 686 bool swapped() const;
641 /** 687 /**
642 * @returns the libpcap version string used to write the input capture file. 688 * @returns the libpcap version string used to write the input capture file.
643 */ 689 */
644 QString version() const; 690 QString version() const;
645 /** 691 /**
646 * @returns the packet statistic database. 692 * @returns the packet statistic database.
647 * @see QMap 693 * @see QMap
648 */ 694 */
649 const QMap<QString,int>& statistics() const; 695 const QMap<QString,int>& statistics() const;
650 696
651 signals: 697 signals:
652 /** 698 /**
653 * This signal is emitted, when a packet has been received. 699 * This signal is emitted, when a packet has been received.
654 */ 700 */
655 void receivedPacket( OPacket* ); 701 void receivedPacket( OPacket* );
656 702
657 protected slots: 703 protected slots:
658 void readyToReceive(); 704 void readyToReceive();
659 705
660 protected: 706 protected:
661 QString _name; // devicename 707 QString _name; // devicename
662 bool _open; // check this before doing pcap calls 708 bool _open; // check this before doing pcap calls
663 pcap_t* _pch; // pcap library handle 709 pcap_t* _pch; // pcap library handle
664 pcap_dumper_t* _pcd; // pcap dumper handle 710 pcap_dumper_t* _pcd; // pcap dumper handle
665 QSocketNotifier* _sn; // socket notifier for main loop 711 QSocketNotifier* _sn; // socket notifier for main loop
666 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap 712 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap
667 QMap<QString, int> _stats; // statistics; 713 QMap<QString, int> _stats; // statistics;
714 class Private; // Private Forward declaration
715 Private *d; // if we need to add data
668}; 716};
717}
718}
669 719
670#endif // OPCAP_H 720#endif // OPCAP_H
671 721
diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp
index 8c989d8..140b924 100644
--- a/libopie2/opienet/ostation.cpp
+++ b/libopie2/opienet/ostation.cpp
@@ -1,64 +1,72 @@
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 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#include <opie2/ostation.h> 31#include <opie2/ostation.h>
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33 33
34
35using namespace Opie::Core;
36
37namespace Opie {
38namespace Net {
34/*====================================================================================== 39/*======================================================================================
35 * OStation 40 * OStation
36 *======================================================================================*/ 41 *======================================================================================*/
37 42
38OStation::OStation() 43OStation::OStation()
39{ 44{
40 odebug << "OStation::OStation()" << oendl; 45 odebug << "OStation::OStation()" << oendl;
41 46
42 type = "<unknown>"; 47 type = "<unknown>";
43 macAddress = OMacAddress::unknown; 48 macAddress = OMacAddress::unknown;
44 ssid = "<unknown>"; 49 ssid = "<unknown>";
45 channel = 0; 50 channel = 0;
46 apAddress = OMacAddress::unknown; 51 apAddress = OMacAddress::unknown;
47 52
48} 53}
49 54
50 55
51OStation::~OStation() 56OStation::~OStation()
52{ 57{
53 odebug << "OStation::~OStation()" << oendl; 58 odebug << "OStation::~OStation()" << oendl;
54} 59}
55 60
56 61
57void OStation::dump() 62void OStation::dump()
58{ 63{
59 odebug << "------- OStation::dump() ------------" << oendl; 64 odebug << "------- OStation::dump() ------------" << oendl;
60 qDebug( "type: %s", (const char*) type ); 65 qDebug( "type: %s", (const char*) type );
61 qDebug( "mac: %s", (const char*) macAddress.toString() ); 66 qDebug( "mac: %s", (const char*) macAddress.toString() );
62 qDebug( "ap: %s", (const char*) apAddress.toString() ); 67 qDebug( "ap: %s", (const char*) apAddress.toString() );
63 qDebug( "ip: %s", (const char*) ipAddress.toString() ); 68 qDebug( "ip: %s", (const char*) ipAddress.toString() );
64} 69}
70
71}
72} \ No newline at end of file
diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h
index 1e7366d..68f1114 100644
--- a/libopie2/opienet/ostation.h
+++ b/libopie2/opienet/ostation.h
@@ -1,73 +1,82 @@
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 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef OSTATION_H 31#ifndef OSTATION_H
32#define OSTATION_H 32#define OSTATION_H
33 33
34#include <opie2/onetutils.h> 34#include <opie2/onetutils.h>
35 35
36#include <qlist.h> 36#include <qlist.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qhostaddress.h> 38#include <qhostaddress.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42 42
43namespace Opie {
44namespace Net {
45
43class OStation; 46class OStation;
44 47
48
45typedef QList<OStation> OStationList; 49typedef QList<OStation> OStationList;
46 50
47/*====================================================================================== 51/*======================================================================================
48 * OStation 52 * OStation
49 *======================================================================================*/ 53 *======================================================================================*/
50 54
51class OStation 55class OStation
52{ 56{
53 public: 57 public:
54 OStation(); 58 OStation();
55 ~OStation(); 59 ~OStation();
56 60
57 void dump(); 61 void dump();
58 62
59 /* Ethernet */ 63 /* Ethernet */
60 QString type; 64 QString type;
61 OMacAddress macAddress; 65 OMacAddress macAddress;
62 QHostAddress ipAddress; 66 QHostAddress ipAddress;
63 67
64 /* WaveLan */ 68 /* WaveLan */
65 QString ssid; 69 QString ssid;
66 OMacAddress apAddress; 70 OMacAddress apAddress;
67 int channel; 71 int channel;
68 bool encrypted; 72 bool encrypted;
73 private:
74 class Private;
75 Private *d;
69}; 76};
70 77
78}
79}
71 80
72#endif // OSTATION_H 81#endif // OSTATION_H
73 82