summaryrefslogtreecommitdiff
path: root/libopie2/opienet
Unidiff
Diffstat (limited to 'libopie2/opienet') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/dhcp.h3
-rw-r--r--libopie2/opienet/libopienet2.control4
-rw-r--r--libopie2/opienet/odebugmapper.cpp8
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp67
-rw-r--r--libopie2/opienet/omanufacturerdb.h43
-rw-r--r--libopie2/opienet/onetutils.cpp2
-rw-r--r--libopie2/opienet/onetwork.cpp6
-rw-r--r--libopie2/opienet/onetwork.h5
-rw-r--r--libopie2/opienet/opcap.cpp5
-rw-r--r--libopie2/opienet/opcap.h5
-rw-r--r--libopie2/opienet/opienet.pro2
-rw-r--r--libopie2/opienet/ostation.cpp3
-rw-r--r--libopie2/opienet/ostation.h3
-rw-r--r--libopie2/opienet/udp_ports.h2
14 files changed, 88 insertions, 70 deletions
diff --git a/libopie2/opienet/dhcp.h b/libopie2/opienet/dhcp.h
index 3f2f775..368e375 100644
--- a/libopie2/opienet/dhcp.h
+++ b/libopie2/opienet/dhcp.h
@@ -1,200 +1,201 @@
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 #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \ 45 #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \
46 20 + /* IP header */ \ 46 20 + /* IP header */ \
47 8) /* UDP header */ 47 8) /* UDP header */
48 #define DHCP_SNAME_LEN 64 48 #define DHCP_SNAME_LEN 64
49 #define DHCP_FILE_LEN 128 49 #define DHCP_FILE_LEN 128
50 #define DHCP_FIXED_NON_UDP236 50 #define DHCP_FIXED_NON_UDP236
51 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD) 51 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
52 /* Everything but options. */ 52 /* Everything but options. */
53 #define DHCP_MTU_MAX 1500 53 #define DHCP_MTU_MAX 1500
54 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN) 54 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
55 55
56 #define BOOTP_MIN_LEN 300 56 #define BOOTP_MIN_LEN 300
57#define DHCP_MIN_LEN 548 57#define DHCP_MIN_LEN 548
58 58
59struct dhcp_packet { 59struct dhcp_packet {
60 u_int8_t op; /* 0: Message opcode/type */ 60 u_int8_t op; /* 0: Message opcode/type */
61 u_int8_t htype;/* 1: Hardware addr type (net/if_types.h) */ 61 u_int8_t htype;/* 1: Hardware addr type (net/if_types.h) */
62 u_int8_t hlen; /* 2: Hardware addr length */ 62 u_int8_t hlen; /* 2: Hardware addr length */
63 u_int8_t hops; /* 3: Number of relay agent hops from client */ 63 u_int8_t hops; /* 3: Number of relay agent hops from client */
64 u_int32_t xid; /* 4: Transaction ID */ 64 u_int32_t xid; /* 4: Transaction ID */
65 u_int16_t secs; /* 8: Seconds since client started looking */ 65 u_int16_t secs; /* 8: Seconds since client started looking */
66 u_int16_t flags;/* 10: Flag bits */ 66 u_int16_t flags;/* 10: Flag bits */
67 struct in_addr ciaddr;/* 12: Client IP address (if already in use) */ 67 struct in_addr ciaddr;/* 12: Client IP address (if already in use) */
68 struct in_addr yiaddr;/* 16: Client IP address */ 68 struct in_addr yiaddr;/* 16: Client IP address */
69 struct in_addr siaddr;/* 18: IP address of next server to talk to */ 69 struct in_addr siaddr;/* 18: IP address of next server to talk to */
70 struct in_addr giaddr;/* 20: DHCP relay agent IP address */ 70 struct in_addr giaddr;/* 20: DHCP relay agent IP address */
71 unsigned char chaddr [16];/* 24: Client hardware address */ 71 unsigned char chaddr [16];/* 24: Client hardware address */
72 char sname [DHCP_SNAME_LEN];/* 40: Server name */ 72 char sname [DHCP_SNAME_LEN];/* 40: Server name */
73 char file [DHCP_FILE_LEN];/* 104: Boot filename */ 73 char file [DHCP_FILE_LEN];/* 104: Boot filename */
74 unsigned char options [DHCP_OPTION_LEN]; 74 unsigned char options [DHCP_OPTION_LEN];
75 /* 212: Optional parameters 75 /* 212: Optional parameters
76 (actual length dependent on MTU). */ 76 (actual length dependent on MTU). */
77}; 77};
78 78
79/* BOOTP (rfc951) message types */ 79/* BOOTP (rfc951) message types */
80 #define BOOTREQUEST1 80 #define BOOTREQUEST1
81 #define BOOTREPLY2 81 #define BOOTREPLY2
82 82
83/* Possible values for flags field... */ 83/* Possible values for flags field... */
84#define BOOTP_BROADCAST 32768L 84#define BOOTP_BROADCAST 32768L
85 85
86/* Possible values for hardware type (htype) field... */ 86/* Possible values for hardware type (htype) field... */
87 #define HTYPE_ETHER1 /* Ethernet 10Mbps */ 87 #define HTYPE_ETHER1 /* Ethernet 10Mbps */
88 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/ 88 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/
89 #define HTYPE_FDDI 8 /* FDDI... */ 89 #define HTYPE_FDDI 8 /* FDDI... */
90 90
91/* Magic cookie validating dhcp options field (and bootp vendor 91/* Magic cookie validating dhcp options field (and bootp vendor
92 extensions field). */ 92 extensions field). */
93 #define DHCP_OPTIONS_COOKIE"\143\202\123\143" 93 #define DHCP_OPTIONS_COOKIE"\143\202\123\143"
94 94
95/* DHCP Option codes: */ 95/* DHCP Option codes: */
96 96
97 #define DHO_PAD 0 97 #define DHO_PAD 0
98 #define DHO_SUBNET_MASK 1 98 #define DHO_SUBNET_MASK 1
99 #define DHO_TIME_OFFSET 2 99 #define DHO_TIME_OFFSET 2
100 #define DHO_ROUTERS 3 100 #define DHO_ROUTERS 3
101 #define DHO_TIME_SERVERS 4 101 #define DHO_TIME_SERVERS 4
102 #define DHO_NAME_SERVERS 5 102 #define DHO_NAME_SERVERS 5
103 #define DHO_DOMAIN_NAME_SERVERS 6 103 #define DHO_DOMAIN_NAME_SERVERS 6
104 #define DHO_LOG_SERVERS 7 104 #define DHO_LOG_SERVERS 7
105 #define DHO_COOKIE_SERVERS 8 105 #define DHO_COOKIE_SERVERS 8
106 #define DHO_LPR_SERVERS 9 106 #define DHO_LPR_SERVERS 9
107 #define DHO_IMPRESS_SERVERS 10 107 #define DHO_IMPRESS_SERVERS 10
108 #define DHO_RESOURCE_LOCATION_SERVERS11 108 #define DHO_RESOURCE_LOCATION_SERVERS11
109 #define DHO_HOST_NAME 12 109 #define DHO_HOST_NAME 12
110 #define DHO_BOOT_SIZE 13 110 #define DHO_BOOT_SIZE 13
111 #define DHO_MERIT_DUMP 14 111 #define DHO_MERIT_DUMP 14
112 #define DHO_DOMAIN_NAME 15 112 #define DHO_DOMAIN_NAME 15
113 #define DHO_SWAP_SERVER 16 113 #define DHO_SWAP_SERVER 16
114 #define DHO_ROOT_PATH 17 114 #define DHO_ROOT_PATH 17
115 #define DHO_EXTENSIONS_PATH 18 115 #define DHO_EXTENSIONS_PATH 18
116 #define DHO_IP_FORWARDING 19 116 #define DHO_IP_FORWARDING 19
117 #define DHO_NON_LOCAL_SOURCE_ROUTING20 117 #define DHO_NON_LOCAL_SOURCE_ROUTING20
118 #define DHO_POLICY_FILTER 21 118 #define DHO_POLICY_FILTER 21
119 #define DHO_MAX_DGRAM_REASSEMBLY22 119 #define DHO_MAX_DGRAM_REASSEMBLY22
120 #define DHO_DEFAULT_IP_TTL 23 120 #define DHO_DEFAULT_IP_TTL 23
121 #define DHO_PATH_MTU_AGING_TIMEOUT24 121 #define DHO_PATH_MTU_AGING_TIMEOUT24
122 #define DHO_PATH_MTU_PLATEAU_TABLE25 122 #define DHO_PATH_MTU_PLATEAU_TABLE25
123 #define DHO_INTERFACE_MTU 26 123 #define DHO_INTERFACE_MTU 26
124 #define DHO_ALL_SUBNETS_LOCAL 27 124 #define DHO_ALL_SUBNETS_LOCAL 27
125 #define DHO_BROADCAST_ADDRESS 28 125 #define DHO_BROADCAST_ADDRESS 28
126 #define DHO_PERFORM_MASK_DISCOVERY29 126 #define DHO_PERFORM_MASK_DISCOVERY29
127 #define DHO_MASK_SUPPLIER 30 127 #define DHO_MASK_SUPPLIER 30
128 #define DHO_ROUTER_DISCOVERY 31 128 #define DHO_ROUTER_DISCOVERY 31
129 #define DHO_ROUTER_SOLICITATION_ADDRESS32 129 #define DHO_ROUTER_SOLICITATION_ADDRESS32
130 #define DHO_STATIC_ROUTES 33 130 #define DHO_STATIC_ROUTES 33
131 #define DHO_TRAILER_ENCAPSULATION34 131 #define DHO_TRAILER_ENCAPSULATION34
132 #define DHO_ARP_CACHE_TIMEOUT 35 132 #define DHO_ARP_CACHE_TIMEOUT 35
133 #define DHO_IEEE802_3_ENCAPSULATION36 133 #define DHO_IEEE802_3_ENCAPSULATION36
134 #define DHO_DEFAULT_TCP_TTL 37 134 #define DHO_DEFAULT_TCP_TTL 37
135 #define DHO_TCP_KEEPALIVE_INTERVAL38 135 #define DHO_TCP_KEEPALIVE_INTERVAL38
136 #define DHO_TCP_KEEPALIVE_GARBAGE39 136 #define DHO_TCP_KEEPALIVE_GARBAGE39
137 #define DHO_NIS_DOMAIN 40 137 #define DHO_NIS_DOMAIN 40
138 #define DHO_NIS_SERVERS 41 138 #define DHO_NIS_SERVERS 41
139 #define DHO_NTP_SERVERS 42 139 #define DHO_NTP_SERVERS 42
140 #define DHO_VENDOR_ENCAPSULATED_OPTIONS43 140 #define DHO_VENDOR_ENCAPSULATED_OPTIONS43
141 #define DHO_NETBIOS_NAME_SERVERS44 141 #define DHO_NETBIOS_NAME_SERVERS44
142 #define DHO_NETBIOS_DD_SERVER 45 142 #define DHO_NETBIOS_DD_SERVER 45
143 #define DHO_NETBIOS_NODE_TYPE 46 143 #define DHO_NETBIOS_NODE_TYPE 46
144 #define DHO_NETBIOS_SCOPE 47 144 #define DHO_NETBIOS_SCOPE 47
145 #define DHO_FONT_SERVERS 48 145 #define DHO_FONT_SERVERS 48
146 #define DHO_X_DISPLAY_MANAGER 49 146 #define DHO_X_DISPLAY_MANAGER 49
147 #define DHO_DHCP_REQUESTED_ADDRESS50 147 #define DHO_DHCP_REQUESTED_ADDRESS50
148 #define DHO_DHCP_LEASE_TIME 51 148 #define DHO_DHCP_LEASE_TIME 51
149 #define DHO_DHCP_OPTION_OVERLOAD52 149 #define DHO_DHCP_OPTION_OVERLOAD52
150 #define DHO_DHCP_MESSAGE_TYPE 53 150 #define DHO_DHCP_MESSAGE_TYPE 53
151 #define DHO_DHCP_SERVER_IDENTIFIER54 151 #define DHO_DHCP_SERVER_IDENTIFIER54
152 #define DHO_DHCP_PARAMETER_REQUEST_LIST55 152 #define DHO_DHCP_PARAMETER_REQUEST_LIST55
153 #define DHO_DHCP_MESSAGE 56 153 #define DHO_DHCP_MESSAGE 56
154 #define DHO_DHCP_MAX_MESSAGE_SIZE57 154 #define DHO_DHCP_MAX_MESSAGE_SIZE57
155 #define DHO_DHCP_RENEWAL_TIME 58 155 #define DHO_DHCP_RENEWAL_TIME 58
156 #define DHO_DHCP_REBINDING_TIME 59 156 #define DHO_DHCP_REBINDING_TIME 59
157 #define DHO_VENDOR_CLASS_IDENTIFIER60 157 #define DHO_VENDOR_CLASS_IDENTIFIER60
158 #define DHO_DHCP_CLIENT_IDENTIFIER61 158 #define DHO_DHCP_CLIENT_IDENTIFIER61
159 #define DHO_NWIP_DOMAIN_NAME 62 159 #define DHO_NWIP_DOMAIN_NAME 62
160 #define DHO_NWIP_SUBOPTIONS 63 160 #define DHO_NWIP_SUBOPTIONS 63
161 #define DHO_USER_CLASS 77 161 #define DHO_USER_CLASS 77
162 #define DHO_FQDN 81 162 #define DHO_FQDN 81
163 #define DHO_DHCP_AGENT_OPTIONS 82 163 #define DHO_DHCP_AGENT_OPTIONS 82
164 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */ 164 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */
165/* The DHO_AUTHENTICATE option is not a standard yet, so I've 165/* The DHO_AUTHENTICATE option is not a standard yet, so I've
166 allocated an option out of the "local" option space for it on a 166 allocated an option out of the "local" option space for it on a
167 temporary basis. Once an option code number is assigned, I will 167 temporary basis. Once an option code number is assigned, I will
168 immediately and shamelessly break this, so don't count on it 168 immediately and shamelessly break this, so don't count on it
169 continuing to work. */ 169 continuing to work. */
170 #define DHO_AUTHENTICATE 210 170 #define DHO_AUTHENTICATE 210
171 171
172 #define DHO_END 255 172 #define DHO_END 255
173 173
174/* DHCP message types. */ 174/* DHCP message types. */
175 #define DHCPDISCOVER1 175 #define DHCPDISCOVER1
176 #define DHCPOFFER2 176 #define DHCPOFFER2
177 #define DHCPREQUEST3 177 #define DHCPREQUEST3
178 #define DHCPDECLINE4 178 #define DHCPDECLINE4
179 #define DHCPACK 5 179 #define DHCPACK 5
180 #define DHCPNAK 6 180 #define DHCPNAK 6
181 #define DHCPRELEASE7 181 #define DHCPRELEASE7
182 #define DHCPINFORM8 182 #define DHCPINFORM8
183 183
184/* Relay Agent Information option subtypes: */ 184/* Relay Agent Information option subtypes: */
185 #define RAI_CIRCUIT_ID1 185 #define RAI_CIRCUIT_ID1
186 #define RAI_REMOTE_ID2 186 #define RAI_REMOTE_ID2
187 #define RAI_AGENT_ID3 187 #define RAI_AGENT_ID3
188 188
189/* FQDN suboptions: */ 189/* FQDN suboptions: */
190 #define FQDN_NO_CLIENT_UPDATE 1 190 #define FQDN_NO_CLIENT_UPDATE 1
191 #define FQDN_SERVER_UPDATE 2 191 #define FQDN_SERVER_UPDATE 2
192 #define FQDN_ENCODED 3 192 #define FQDN_ENCODED 3
193 #define FQDN_RCODE1 4 193 #define FQDN_RCODE1 4
194 #define FQDN_RCODE2 5 194 #define FQDN_RCODE2 5
195 #define FQDN_HOSTNAME 6 195 #define FQDN_HOSTNAME 6
196 #define FQDN_DOMAINNAME 7 196 #define FQDN_DOMAINNAME 7
197 #define FQDN_FQDN 8 197 #define FQDN_FQDN 8
198 #define FQDN_SUBOPTION_COUNT 8 198 #define FQDN_SUBOPTION_COUNT 8
199 199
200#endif \ No newline at end of file 200#endif
201
diff --git a/libopie2/opienet/libopienet2.control b/libopie2/opienet/libopienet2.control
index 65d8464..8eb0704 100644
--- a/libopie2/opienet/libopienet2.control
+++ b/libopie2/opienet/libopienet2.control
@@ -1,11 +1,11 @@
1Package: libopienet2 1Package: libopienet2
2Files: $OPIEDIR/lib/libopienet2.so.* $OPIEDIR/etc/manufacturers 2Files: $OPIEDIR/lib/libopienet2.so.* $OPIEDIR/etc/manufacturers
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.8.1-$SUB_VERSION.2 7Version: 1.8.2-$SUB_VERSION.2
8Depends: libqpe1, libopiecore2 (1.8.1) 8Depends: libopiecore2 (1.8.2)
9Provides: libopienet2 9Provides: libopienet2
10Description: Opie library 2.0 NET 10Description: Opie library 2.0 NET
11 11
diff --git a/libopie2/opienet/odebugmapper.cpp b/libopie2/opienet/odebugmapper.cpp
index d62b3ba..7e4ab2b 100644
--- a/libopie2/opienet/odebugmapper.cpp
+++ b/libopie2/opienet/odebugmapper.cpp
@@ -1,213 +1,215 @@
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>
7
6#include "odebugmapper.h" 8#include "odebugmapper.h"
7 9
8DebugMapper::DebugMapper() 10DebugMapper::DebugMapper()
9{ 11{
10 qDebug( "DebugMapper::DebugMapper()" ); 12 odebug << "DebugMapper::DebugMapper()" << oendl;
11 13
12 14
13 _map.insert( 0x8902, new QString("SIOCSPGRP") ); 15 _map.insert( 0x8902, new QString("SIOCSPGRP") );
14 _map.insert( 0x8904, new QString("SIOCGPGRP") ); 16 _map.insert( 0x8904, new QString("SIOCGPGRP") );
15 _map.insert( 0x8905, new QString("SIOCATMARK") ); 17 _map.insert( 0x8905, new QString("SIOCATMARK") );
16 _map.insert( 0x8906, new QString("SIOCGSTAMP") ); 18 _map.insert( 0x8906, new QString("SIOCGSTAMP") );
17 _map.insert( 0x890B, new QString("SIOCADDRT") ); 19 _map.insert( 0x890B, new QString("SIOCADDRT") );
18 _map.insert( 0x890C, new QString("SIOCDELRT") ); 20 _map.insert( 0x890C, new QString("SIOCDELRT") );
19 _map.insert( 0x890D, new QString("SIOCRTMSG") ); 21 _map.insert( 0x890D, new QString("SIOCRTMSG") );
20 _map.insert( 0x8910, new QString("SIOCGIFNAME") ); 22 _map.insert( 0x8910, new QString("SIOCGIFNAME") );
21 _map.insert( 0x8911, new QString("SIOCSIFLINK") ); 23 _map.insert( 0x8911, new QString("SIOCSIFLINK") );
22 _map.insert( 0x8912, new QString("SIOCGIFCONF") ); 24 _map.insert( 0x8912, new QString("SIOCGIFCONF") );
23 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); 25 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
24 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); 26 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
25 _map.insert( 0x8915, new QString("SIOCGIFADDR") ); 27 _map.insert( 0x8915, new QString("SIOCGIFADDR") );
26 _map.insert( 0x8916, new QString("SIOCSIFADDR") ); 28 _map.insert( 0x8916, new QString("SIOCSIFADDR") );
27 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); 29 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
28 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); 30 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
29 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); 31 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
30 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); 32 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
31 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); 33 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
32 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") ); 34 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
33 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") ); 35 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
34 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") ); 36 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
35 _map.insert( 0x891f, new QString("SIOCGIFMEM") ); 37 _map.insert( 0x891f, new QString("SIOCGIFMEM") );
36 _map.insert( 0x8920, new QString("SIOCSIFMEM") ); 38 _map.insert( 0x8920, new QString("SIOCSIFMEM") );
37 _map.insert( 0x8921, new QString("SIOCGIFMTU") ); 39 _map.insert( 0x8921, new QString("SIOCGIFMTU") );
38 _map.insert( 0x8922, new QString("SIOCSIFMTU") ); 40 _map.insert( 0x8922, new QString("SIOCSIFMTU") );
39 _map.insert( 0x8923, new QString("SIOCSIFNAME") ); 41 _map.insert( 0x8923, new QString("SIOCSIFNAME") );
40 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") ); 42 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
41 _map.insert( 0x8925, new QString("SIOCGIFENCAP") ); 43 _map.insert( 0x8925, new QString("SIOCGIFENCAP") );
42 _map.insert( 0x8926, new QString("SIOCSIFENCAP") ); 44 _map.insert( 0x8926, new QString("SIOCSIFENCAP") );
43 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") ); 45 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
44 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") ); 46 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
45 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") ); 47 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
46 _map.insert( 0x8931, new QString("SIOCADDMULTI") ); 48 _map.insert( 0x8931, new QString("SIOCADDMULTI") );
47 _map.insert( 0x8932, new QString("SIOCDELMULTI") ); 49 _map.insert( 0x8932, new QString("SIOCDELMULTI") );
48 _map.insert( 0x8933, new QString("SIOCGIFINDEX") ); 50 _map.insert( 0x8933, new QString("SIOCGIFINDEX") );
49 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") ); 51 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
50 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") ); 52 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
51 _map.insert( 0x8936, new QString("SIOCDIFADDR") ); 53 _map.insert( 0x8936, new QString("SIOCDIFADDR") );
52 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); 54 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
53 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") ); 55 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
54 _map.insert( 0x8940, new QString("SIOCGIFBR") ); 56 _map.insert( 0x8940, new QString("SIOCGIFBR") );
55 _map.insert( 0x8941, new QString("SIOCSIFBR") ); 57 _map.insert( 0x8941, new QString("SIOCSIFBR") );
56 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") ); 58 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") );
57 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") ); 59 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") );
58 _map.insert( 0x8953, new QString("SIOCDARP") ); 60 _map.insert( 0x8953, new QString("SIOCDARP") );
59 _map.insert( 0x8954, new QString("SIOCGARP") ); 61 _map.insert( 0x8954, new QString("SIOCGARP") );
60 _map.insert( 0x8955, new QString("SIOCSARP") ); 62 _map.insert( 0x8955, new QString("SIOCSARP") );
61 _map.insert( 0x8960, new QString("SIOCDRARP") ); 63 _map.insert( 0x8960, new QString("SIOCDRARP") );
62 _map.insert( 0x8961, new QString("SIOCGRARP") ); 64 _map.insert( 0x8961, new QString("SIOCGRARP") );
63 _map.insert( 0x8962, new QString("SIOCSRARP") ); 65 _map.insert( 0x8962, new QString("SIOCSRARP") );
64 _map.insert( 0x8970, new QString("SIOCGIFMAP") ); 66 _map.insert( 0x8970, new QString("SIOCGIFMAP") );
65 _map.insert( 0x8971, new QString("SIOCSIFMAP") ); 67 _map.insert( 0x8971, new QString("SIOCSIFMAP") );
66 _map.insert( 0x8980, new QString("SIOCADDDLCI") ); 68 _map.insert( 0x8980, new QString("SIOCADDDLCI") );
67 _map.insert( 0x8981, new QString("SIOCDELDLCI") ); 69 _map.insert( 0x8981, new QString("SIOCDELDLCI") );
68 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); 70 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
69 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); 71 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
70 _map.insert( 0x1fff, new QString("SIOCPARM_MASK") ); 72 _map.insert( 0x1fff, new QString("SIOCPARM_MASK") );
71 _map.insert( 0x00000000, new QString("SIOC_VOID") ); 73 _map.insert( 0x00000000, new QString("SIOC_VOID") );
72 _map.insert( 0x20000000, new QString("SIOC_OUT") ); 74 _map.insert( 0x20000000, new QString("SIOC_OUT") );
73 _map.insert( 0x40000000, new QString("SIOC_IN") ); 75 _map.insert( 0x40000000, new QString("SIOC_IN") );
74 _map.insert( 0x8B00, new QString("SIOCSIWCOMMIT") ); 76 _map.insert( 0x8B00, new QString("SIOCSIWCOMMIT") );
75 _map.insert( 0x8B01, new QString("SIOCGIWNAME") ); 77 _map.insert( 0x8B01, new QString("SIOCGIWNAME") );
76 _map.insert( 0x8B02, new QString("SIOCSIWNWID") ); 78 _map.insert( 0x8B02, new QString("SIOCSIWNWID") );
77 _map.insert( 0x8B03, new QString("SIOCGIWNWID") ); 79 _map.insert( 0x8B03, new QString("SIOCGIWNWID") );
78 _map.insert( 0x8B04, new QString("SIOCSIWFREQ") ); 80 _map.insert( 0x8B04, new QString("SIOCSIWFREQ") );
79 _map.insert( 0x8B05, new QString("SIOCGIWFREQ") ); 81 _map.insert( 0x8B05, new QString("SIOCGIWFREQ") );
80 _map.insert( 0x8B06, new QString("SIOCSIWMODE") ); 82 _map.insert( 0x8B06, new QString("SIOCSIWMODE") );
81 _map.insert( 0x8B07, new QString("SIOCGIWMODE") ); 83 _map.insert( 0x8B07, new QString("SIOCGIWMODE") );
82 _map.insert( 0x8B08, new QString("SIOCSIWSENS") ); 84 _map.insert( 0x8B08, new QString("SIOCSIWSENS") );
83 _map.insert( 0x8B09, new QString("SIOCGIWSENS") ); 85 _map.insert( 0x8B09, new QString("SIOCGIWSENS") );
84 _map.insert( 0x8B0A, new QString("SIOCSIWRANGE") ); 86 _map.insert( 0x8B0A, new QString("SIOCSIWRANGE") );
85 _map.insert( 0x8B0B, new QString("SIOCGIWRANGE") ); 87 _map.insert( 0x8B0B, new QString("SIOCGIWRANGE") );
86 _map.insert( 0x8B0C, new QString("SIOCSIWPRIV") ); 88 _map.insert( 0x8B0C, new QString("SIOCSIWPRIV") );
87 _map.insert( 0x8B0D, new QString("SIOCGIWPRIV") ); 89 _map.insert( 0x8B0D, new QString("SIOCGIWPRIV") );
88 _map.insert( 0x8B0E, new QString("SIOCSIWSTATS") ); 90 _map.insert( 0x8B0E, new QString("SIOCSIWSTATS") );
89 _map.insert( 0x8B0F, new QString("SIOCGIWSTATS") ); 91 _map.insert( 0x8B0F, new QString("SIOCGIWSTATS") );
90 _map.insert( 0x8B10, new QString("SIOCSIWSPY") ); 92 _map.insert( 0x8B10, new QString("SIOCSIWSPY") );
91 _map.insert( 0x8B11, new QString("SIOCGIWSPY") ); 93 _map.insert( 0x8B11, new QString("SIOCGIWSPY") );
92 _map.insert( 0x8B14, new QString("SIOCSIWAP") ); 94 _map.insert( 0x8B14, new QString("SIOCSIWAP") );
93 _map.insert( 0x8B15, new QString("SIOCGIWAP") ); 95 _map.insert( 0x8B15, new QString("SIOCGIWAP") );
94 _map.insert( 0x8B17, new QString("SIOCGIWAPLIST") ); 96 _map.insert( 0x8B17, new QString("SIOCGIWAPLIST") );
95 _map.insert( 0x8B18, new QString("SIOCSIWSCAN") ); 97 _map.insert( 0x8B18, new QString("SIOCSIWSCAN") );
96 _map.insert( 0x8B19, new QString("SIOCGIWSCAN") ); 98 _map.insert( 0x8B19, new QString("SIOCGIWSCAN") );
97 _map.insert( 0x8B1A, new QString("SIOCSIWESSID") ); 99 _map.insert( 0x8B1A, new QString("SIOCSIWESSID") );
98 _map.insert( 0x8B1B, new QString("SIOCGIWESSID") ); 100 _map.insert( 0x8B1B, new QString("SIOCGIWESSID") );
99 _map.insert( 0x8B1C, new QString("SIOCSIWNICKN") ); 101 _map.insert( 0x8B1C, new QString("SIOCSIWNICKN") );
100 _map.insert( 0x8B1D, new QString("SIOCGIWNICKN") ); 102 _map.insert( 0x8B1D, new QString("SIOCGIWNICKN") );
101 _map.insert( 0x8B20, new QString("SIOCSIWRATE") ); 103 _map.insert( 0x8B20, new QString("SIOCSIWRATE") );
102 _map.insert( 0x8B21, new QString("SIOCGIWRATE") ); 104 _map.insert( 0x8B21, new QString("SIOCGIWRATE") );
103 _map.insert( 0x8B22, new QString("SIOCSIWRTS") ); 105 _map.insert( 0x8B22, new QString("SIOCSIWRTS") );
104 _map.insert( 0x8B23, new QString("SIOCGIWRTS") ); 106 _map.insert( 0x8B23, new QString("SIOCGIWRTS") );
105 _map.insert( 0x8B24, new QString("SIOCSIWFRAG") ); 107 _map.insert( 0x8B24, new QString("SIOCSIWFRAG") );
106 _map.insert( 0x8B25, new QString("SIOCGIWFRAG") ); 108 _map.insert( 0x8B25, new QString("SIOCGIWFRAG") );
107 _map.insert( 0x8B26, new QString("SIOCSIWTXPOW") ); 109 _map.insert( 0x8B26, new QString("SIOCSIWTXPOW") );
108 _map.insert( 0x8B27, new QString("SIOCGIWTXPOW") ); 110 _map.insert( 0x8B27, new QString("SIOCGIWTXPOW") );
109 _map.insert( 0x8B28, new QString("SIOCSIWRETRY") ); 111 _map.insert( 0x8B28, new QString("SIOCSIWRETRY") );
110 _map.insert( 0x8B29, new QString("SIOCGIWRETRY") ); 112 _map.insert( 0x8B29, new QString("SIOCGIWRETRY") );
111 _map.insert( 0x8B2A, new QString("SIOCSIWENCODE") ); 113 _map.insert( 0x8B2A, new QString("SIOCSIWENCODE") );
112 _map.insert( 0x8B2B, new QString("SIOCGIWENCODE") ); 114 _map.insert( 0x8B2B, new QString("SIOCGIWENCODE") );
113 _map.insert( 0x8B2C, new QString("SIOCSIWPOWER") ); 115 _map.insert( 0x8B2C, new QString("SIOCSIWPOWER") );
114 _map.insert( 0x8B2D, new QString("SIOCGIWPOWER") ); 116 _map.insert( 0x8B2D, new QString("SIOCGIWPOWER") );
115 _map.insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") ); 117 _map.insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") );
116 _map.insert( 0x8BFF, new QString("SIOCIWLASTPRIV") ); 118 _map.insert( 0x8BFF, new QString("SIOCIWLASTPRIV") );
117 _map.insert( 0x8B00, new QString("SIOCIWFIRST") ); 119 _map.insert( 0x8B00, new QString("SIOCIWFIRST") );
118 _map.insert( 0x5000, new QString("SIOCGBPQETHPARAM") ); 120 _map.insert( 0x5000, new QString("SIOCGBPQETHPARAM") );
119 _map.insert( 0x5001, new QString("SIOCSBPQETHPARAM") ); 121 _map.insert( 0x5001, new QString("SIOCSBPQETHPARAM") );
120 _map.insert( 0x890B, new QString("SIOCADDRT") ); 122 _map.insert( 0x890B, new QString("SIOCADDRT") );
121 _map.insert( 0x890C, new QString("SIOCDELRT") ); 123 _map.insert( 0x890C, new QString("SIOCDELRT") );
122 _map.insert( 0x890D, new QString("SIOCRTMSG") ); 124 _map.insert( 0x890D, new QString("SIOCRTMSG") );
123 _map.insert( 0x8910, new QString("SIOCGIFNAME") ); 125 _map.insert( 0x8910, new QString("SIOCGIFNAME") );
124 _map.insert( 0x8911, new QString("SIOCSIFLINK") ); 126 _map.insert( 0x8911, new QString("SIOCSIFLINK") );
125 _map.insert( 0x8912, new QString("SIOCGIFCONF") ); 127 _map.insert( 0x8912, new QString("SIOCGIFCONF") );
126 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); 128 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
127 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); 129 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
128 _map.insert( 0x8915, new QString("SIOCGIFADDR") ); 130 _map.insert( 0x8915, new QString("SIOCGIFADDR") );
129 _map.insert( 0x8916, new QString("SIOCSIFADDR") ); 131 _map.insert( 0x8916, new QString("SIOCSIFADDR") );
130 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); 132 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
131 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); 133 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
132 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); 134 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
133 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); 135 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
134 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); 136 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
135 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") ); 137 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
136 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") ); 138 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
137 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") ); 139 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
138 _map.insert( 0x891f, new QString("SIOCGIFMEM") ); 140 _map.insert( 0x891f, new QString("SIOCGIFMEM") );
139 _map.insert( 0x8920, new QString("SIOCSIFMEM") ); 141 _map.insert( 0x8920, new QString("SIOCSIFMEM") );
140 _map.insert( 0x8921, new QString("SIOCGIFMTU") ); 142 _map.insert( 0x8921, new QString("SIOCGIFMTU") );
141 _map.insert( 0x8922, new QString("SIOCSIFMTU") ); 143 _map.insert( 0x8922, new QString("SIOCSIFMTU") );
142 _map.insert( 0x8923, new QString("SIOCSIFNAME") ); 144 _map.insert( 0x8923, new QString("SIOCSIFNAME") );
143 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") ); 145 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
144 _map.insert( 0x8925, new QString("SIOCGIFENCAP") ); 146 _map.insert( 0x8925, new QString("SIOCGIFENCAP") );
145 _map.insert( 0x8926, new QString("SIOCSIFENCAP") ); 147 _map.insert( 0x8926, new QString("SIOCSIFENCAP") );
146 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") ); 148 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
147 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") ); 149 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
148 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") ); 150 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
149 _map.insert( 0x8931, new QString("SIOCADDMULTI") ); 151 _map.insert( 0x8931, new QString("SIOCADDMULTI") );
150 _map.insert( 0x8932, new QString("SIOCDELMULTI") ); 152 _map.insert( 0x8932, new QString("SIOCDELMULTI") );
151 _map.insert( 0x8933, new QString("SIOCGIFINDEX") ); 153 _map.insert( 0x8933, new QString("SIOCGIFINDEX") );
152 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") ); 154 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
153 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") ); 155 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
154 _map.insert( 0x8936, new QString("SIOCDIFADDR") ); 156 _map.insert( 0x8936, new QString("SIOCDIFADDR") );
155 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); 157 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
156 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") ); 158 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
157 _map.insert( 0x8940, new QString("SIOCGIFBR") ); 159 _map.insert( 0x8940, new QString("SIOCGIFBR") );
158 _map.insert( 0x8941, new QString("SIOCSIFBR") ); 160 _map.insert( 0x8941, new QString("SIOCSIFBR") );
159 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") ); 161 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") );
160 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") ); 162 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") );
161 _map.insert( 0x8944, new QString("SIOCGIFDIVERT") ); 163 _map.insert( 0x8944, new QString("SIOCGIFDIVERT") );
162 _map.insert( 0x8945, new QString("SIOCSIFDIVERT") ); 164 _map.insert( 0x8945, new QString("SIOCSIFDIVERT") );
163 _map.insert( 0x8946, new QString("SIOCETHTOOL") ); 165 _map.insert( 0x8946, new QString("SIOCETHTOOL") );
164 _map.insert( 0x8947, new QString("SIOCGMIIPHY") ); 166 _map.insert( 0x8947, new QString("SIOCGMIIPHY") );
165 _map.insert( 0x8948, new QString("SIOCGMIIREG") ); 167 _map.insert( 0x8948, new QString("SIOCGMIIREG") );
166 _map.insert( 0x8949, new QString("SIOCSMIIREG") ); 168 _map.insert( 0x8949, new QString("SIOCSMIIREG") );
167 _map.insert( 0x894A, new QString("SIOCWANDEV") ); 169 _map.insert( 0x894A, new QString("SIOCWANDEV") );
168 _map.insert( 0x8953, new QString("SIOCDARP") ); 170 _map.insert( 0x8953, new QString("SIOCDARP") );
169 _map.insert( 0x8954, new QString("SIOCGARP") ); 171 _map.insert( 0x8954, new QString("SIOCGARP") );
170 _map.insert( 0x8955, new QString("SIOCSARP") ); 172 _map.insert( 0x8955, new QString("SIOCSARP") );
171 _map.insert( 0x8960, new QString("SIOCDRARP") ); 173 _map.insert( 0x8960, new QString("SIOCDRARP") );
172 _map.insert( 0x8961, new QString("SIOCGRARP") ); 174 _map.insert( 0x8961, new QString("SIOCGRARP") );
173 _map.insert( 0x8962, new QString("SIOCSRARP") ); 175 _map.insert( 0x8962, new QString("SIOCSRARP") );
174 _map.insert( 0x8970, new QString("SIOCGIFMAP") ); 176 _map.insert( 0x8970, new QString("SIOCGIFMAP") );
175 _map.insert( 0x8971, new QString("SIOCSIFMAP") ); 177 _map.insert( 0x8971, new QString("SIOCSIFMAP") );
176 _map.insert( 0x8980, new QString("SIOCADDDLCI") ); 178 _map.insert( 0x8980, new QString("SIOCADDDLCI") );
177 _map.insert( 0x8981, new QString("SIOCDELDLCI") ); 179 _map.insert( 0x8981, new QString("SIOCDELDLCI") );
178 _map.insert( 0x8982, new QString("SIOCGIFVLAN") ); 180 _map.insert( 0x8982, new QString("SIOCGIFVLAN") );
179 _map.insert( 0x8983, new QString("SIOCSIFVLAN") ); 181 _map.insert( 0x8983, new QString("SIOCSIFVLAN") );
180 _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") ); 182 _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") );
181 _map.insert( 0x8991, new QString("SIOCBONDRELEASE") ); 183 _map.insert( 0x8991, new QString("SIOCBONDRELEASE") );
182 _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") ); 184 _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") );
183 _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") ); 185 _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") );
184 _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") ); 186 _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") );
185 _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") ); 187 _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") );
186 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); 188 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
187 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); 189 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
188 190
189}; 191};
190 192
191 193
192DebugMapper::~DebugMapper() 194DebugMapper::~DebugMapper()
193{ 195{
194 qDebug( "DebugMapper::~DebugMapper()" ); 196 odebug << "DebugMapper::~DebugMapper()" << oendl;
195} 197}
196 198
197 199
198const QString& DebugMapper::map( int value ) const 200const QString& DebugMapper::map( int value ) const
199{ 201{
200 QString* result = _map[ value ]; 202 QString* result = _map[ value ];
201 203
202 if ( !result ) 204 if ( !result )
203 { 205 {
204 qDebug( "DebugMapper::map() - value not found." ); 206 owarn << "DebugMapper::map() - value " << value << " is not found." << oendl;
205 return QString::null; 207 return QString::null;
206 } 208 }
207 else 209 else
208 { 210 {
209 return *result; 211 return *result;
210 } 212 }
211} 213}
212 214
213 215
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index c3c213c..bcce11f 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,118 +1,131 @@
1/********************************************************************** 1/*
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2                 This file is part of the Opie Project
3** 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4** This file is part of Opie Environment. 4 =.
5** 5 .=l.
6** This file may be distributed and/or modified under the terms of the 6           .>+-=
7** GNU General Public License version 2 as published by the Free Software 7 _;:,     .>    :=|. This program is free software; you can
8** Foundation and appearing in the file LICENSE.GPL included in the 8.> <`_,   >  .   <= redistribute it and/or modify it under
9** packaging of this file. 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10** 10.="- .-=="i,     .._ License as published by the Free Software
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12     ._= =}       : or (at your option) any later version.
13** 13    .%`+i>       _;_.
14**********************************************************************/ 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28
29*/
15 30
16#include "omanufacturerdb.h" 31#include "omanufacturerdb.h"
17 32
33/* OPIE CORE */
34#include <opie2/odebug.h>
35
18/* QT */ 36/* QT */
19#include <qstring.h> 37#include <qstring.h>
20#include <qfile.h> 38#include <qfile.h>
21#include <qtextstream.h> 39#include <qtextstream.h>
22 40
23OManufacturerDB* OManufacturerDB::_instance = 0; 41OManufacturerDB* OManufacturerDB::_instance = 0;
24 42
25OManufacturerDB* OManufacturerDB::instance() 43OManufacturerDB* OManufacturerDB::instance()
26{ 44{
27 if ( !OManufacturerDB::_instance ) 45 if ( !OManufacturerDB::_instance )
28 { 46 {
29 qDebug( "OManufacturerDB::instance(): creating OManufacturerDB..." ); 47 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
30 _instance = new OManufacturerDB(); 48 _instance = new OManufacturerDB();
31 } 49 }
32 return _instance; 50 return _instance;
33} 51}
34 52
35 53
36OManufacturerDB::OManufacturerDB() 54OManufacturerDB::OManufacturerDB()
37{ 55{
38 QString filename( "/etc/manufacturers" ); 56 QString filename( "/etc/manufacturers" );
39 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 57 odebug << "OManufacturerDB: trying to read " << filename << oendl;
40 if ( !QFile::exists( filename ) ) 58 if ( !QFile::exists( filename ) )
41 { 59 {
42 filename = "/opt/QtPalmtop/etc/manufacturers"; 60 filename = "/opt/QtPalmtop/etc/manufacturers";
43 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 61 odebug << "OManufacturerDB: trying to read " << filename << oendl;
44 if ( !QFile::exists( filename ) ) 62 if ( !QFile::exists( filename ) )
45 { 63 {
46 filename = "/usr/share/wellenreiter/manufacturers"; 64 filename = "/usr/share/wellenreiter/manufacturers";
47 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 65 odebug << "OManufacturerDB: trying to read " << filename << oendl;
48 } 66 }
49 } 67 }
50 68
51 QFile file( filename ); 69 QFile file( filename );
52 bool hasFile = file.open( IO_ReadOnly ); 70 bool hasFile = file.open( IO_ReadOnly );
53 if (!hasFile) 71 if (!hasFile)
54 { 72 {
55 qWarning( "OManufacturerDB: no valid manufacturer list found.", (const char*) filename ); 73 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
56 } 74 }
57 else 75 else
58 { 76 {
59 qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename ); 77 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
60 QTextStream s( &file ); 78 QTextStream s( &file );
61 QString addr; 79 QString addr;
62 QString manu; 80 QString manu;
63 QString extManu; 81 QString extManu;
64 while (!s.atEnd()) 82 while (!s.atEnd())
65 { 83 {
66 s >> addr; 84 s >> addr;
67 if ( !addr ) // read nothing!? 85 if ( !addr ) // read nothing!?
68 { 86 {
69 continue; 87 continue;
70 } 88 }
71 else 89 else
72 if ( addr[0] == '#' ) 90 if ( addr[0] == '#' )
73 { 91 {
74 continue; 92 continue;
75 } 93 }
76 s.skipWhiteSpace(); 94 s.skipWhiteSpace();
77 s >> manu; 95 s >> manu;
78 s.skipWhiteSpace(); 96 s.skipWhiteSpace();
79 s >> extManu; 97 s >> extManu;
80 if ( extManu[0] == '#' ) // we have an extended manufacturer 98 if ( extManu[0] == '#' ) // we have an extended manufacturer
81 { 99 {
82 s.skipWhiteSpace(); 100 s.skipWhiteSpace();
83 extManu = s.readLine(); 101 extManu = s.readLine();
84 #ifdef DEBUG 102 odebug << "OManufacturerDB: read " << extManu << " as extended manufacturer string" << oendl;
85 qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu );
86 #endif
87 manufacturersExt.insert( addr, extManu ); 103 manufacturersExt.insert( addr, extManu );
88 } 104 }
89 else 105 else
90 s.readLine(); 106 s.readLine();
91 #ifdef DEBUG 107 odebug << "OManufacturerDB: read tuple " << addr << ", " << manu << oendl;
92 qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu );
93 #endif
94 manufacturers.insert( addr, manu ); 108 manufacturers.insert( addr, manu );
95
96 } 109 }
97 } 110 }
98 111
99} 112}
100 113
101 114
102OManufacturerDB::~OManufacturerDB() 115OManufacturerDB::~OManufacturerDB()
103{ 116{
104} 117}
105 118
106 119
107const QString& OManufacturerDB::lookup( const QString& macaddr ) const 120const QString& OManufacturerDB::lookup( const QString& macaddr ) const
108{ 121{
109 return manufacturers[macaddr.upper().left(8)]; 122 return manufacturers[macaddr.upper().left(8)];
110} 123}
111 124
112 125
113const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const 126const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
114{ 127{
115 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); 128 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
116 return it == manufacturersExt.end() ? lookup( macaddr ) : *it; 129 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
117} 130}
118 131
diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h
index 651f624..c2712e5 100644
--- a/libopie2/opienet/omanufacturerdb.h
+++ b/libopie2/opienet/omanufacturerdb.h
@@ -1,54 +1,69 @@
1/********************************************************************** 1/*
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2                 This file is part of the Opie Project
3** 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4** This file is part of Opie Environment. 4 =.
5** 5 .=l.
6** This file may be distributed and/or modified under the terms of the 6           .>+-=
7** GNU General Public License version 2 as published by the Free Software 7 _;:,     .>    :=|. This program is free software; you can
8** Foundation and appearing in the file LICENSE.GPL included in the 8.> <`_,   >  .   <= redistribute it and/or modify it under
9** packaging of this file. 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10** 10.="- .-=="i,     .._ License as published by the Free Software
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12     ._= =}       : or (at your option) any later version.
13** 13    .%`+i>       _;_.
14**********************************************************************/ 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28
29*/
15 30
16#ifndef OMANUFACTURERDB_H 31#ifndef OMANUFACTURERDB_H
17#define OMANUFACTURERDB_H 32#define OMANUFACTURERDB_H
18 33
19#include <qmap.h> 34#include <qmap.h>
20 35
21/** 36/**
22 * @brief A Ethernet card vendor database. 37 * @brief A Ethernet card vendor database.
23 * 38 *
24 * This class encapsulates the lookup of Ethernet vendor given a 39 * This class encapsulates the lookup of Ethernet vendor given a
25 * certain Mac Address. Only the first three bytes define the vendor. 40 * certain Mac Address. Only the first three bytes define the vendor.
26 */ 41 */
27class OManufacturerDB 42class OManufacturerDB
28{ 43{
29 public: 44 public:
30 /** 45 /**
31 * @returns the one-and-only @ref OManufacturerDB instance. 46 * @returns the one-and-only @ref OManufacturerDB instance.
32 */ 47 */
33 static OManufacturerDB* instance(); 48 static OManufacturerDB* instance();
34 /** 49 /**
35 * @returns the short manufacturer string given a @a macaddr. 50 * @returns the short manufacturer string given a @a macaddr.
36 */ 51 */
37 const QString& lookup( const QString& macaddr ) const; 52 const QString& lookup( const QString& macaddr ) const;
38 /** 53 /**
39 * @returns the enhanced manufacturer string given a @a macaddr. 54 * @returns the enhanced manufacturer string given a @a macaddr.
40 */ 55 */
41 const QString& lookupExt( const QString& macaddr ) const; 56 const QString& lookupExt( const QString& macaddr ) const;
42 57
43 protected: 58 protected:
44 OManufacturerDB(); 59 OManufacturerDB();
45 virtual ~OManufacturerDB(); 60 virtual ~OManufacturerDB();
46 61
47 private: 62 private:
48 QMap<QString, QString> manufacturers; 63 QMap<QString, QString> manufacturers;
49 QMap<QString, QString> manufacturersExt; 64 QMap<QString, QString> manufacturersExt;
50 static OManufacturerDB* _instance; 65 static OManufacturerDB* _instance;
51}; 66};
52 67
53#endif 68#endif
54 69
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index e3eb327..48cfa43 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -1,232 +1,232 @@
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@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
40/*====================================================================================== 40/*======================================================================================
41 * OMacAddress 41 * OMacAddress
42 *======================================================================================*/ 42 *======================================================================================*/
43 43
44// static initializer for broadcast and unknown MAC Adresses 44// static initializer for broadcast and unknown MAC Adresses
45const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 45const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
46const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); 46const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
47const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; 47const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
48const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); 48const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
49 49
50//TODO: Incorporate Ethernet Manufacturer database here! (inline or so) 50//TODO: Incorporate Ethernet Manufacturer database here! (inline or so)
51 51
52OMacAddress::OMacAddress() 52OMacAddress::OMacAddress()
53{ 53{
54 memcpy( _bytes, __unknown, 6 ); 54 memcpy( _bytes, __unknown, 6 );
55} 55}
56 56
57 57
58OMacAddress::OMacAddress( unsigned char* p ) 58OMacAddress::OMacAddress( unsigned char* p )
59{ 59{
60 memcpy( _bytes, p, 6 ); 60 memcpy( _bytes, p, 6 );
61} 61}
62 62
63 63
64OMacAddress::OMacAddress( const unsigned char* p ) 64OMacAddress::OMacAddress( const unsigned char* p )
65{ 65{
66 memcpy( _bytes, p, 6 ); 66 memcpy( _bytes, p, 6 );
67} 67}
68 68
69 69
70OMacAddress::OMacAddress( struct ifreq& ifr ) 70OMacAddress::OMacAddress( struct ifreq& ifr )
71{ 71{
72 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); 72 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 );
73} 73}
74 74
75 75
76OMacAddress::~OMacAddress() 76OMacAddress::~OMacAddress()
77{ 77{
78} 78}
79 79
80 80
81//#ifdef QT_NO_DEBUG 81//#ifdef QT_NO_DEBUG
82//inline 82//inline
83//#endif 83//#endif
84const unsigned char* OMacAddress::native() const 84const unsigned char* OMacAddress::native() const
85{ 85{
86 return (const unsigned char*) &_bytes; 86 return (const unsigned char*) &_bytes;
87} 87}
88 88
89 89
90OMacAddress OMacAddress::fromString( const QString& str ) 90OMacAddress OMacAddress::fromString( const QString& str )
91{ 91{
92 QString addr( str ); 92 QString addr( str );
93 unsigned char buf[6]; 93 unsigned char buf[6];
94 bool ok = true; 94 bool ok = true;
95 int index = 14; 95 int index = 14;
96 for ( int i = 5; i >= 0; --i ) 96 for ( int i = 5; i >= 0; --i )
97 { 97 {
98 buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); 98 buf[i] = addr.right( 2 ).toUShort( &ok, 16 );
99 if ( !ok ) return OMacAddress::unknown; 99 if ( !ok ) return OMacAddress::unknown;
100 addr.truncate( index ); 100 addr.truncate( index );
101 index -= 3; 101 index -= 3;
102 } 102 }
103 return (const unsigned char*) &buf; 103 return (const unsigned char*) &buf;
104} 104}
105 105
106 106
107QString OMacAddress::toString( bool substitute ) const 107QString OMacAddress::toString( bool substitute ) const
108{ 108{
109 QString manu; 109 QString manu;
110 manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); 110 manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff );
111 QString serial; 111 QString serial;
112 serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); 112 serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
113 if ( !substitute ) return manu+serial; 113 if ( !substitute ) return manu+serial;
114 // fallback - if no vendor is found, just use the number 114 // fallback - if no vendor is found, just use the number
115 QString textmanu = OManufacturerDB::instance()->lookup( manu ); 115 QString textmanu = OManufacturerDB::instance()->lookup( manu );
116 return textmanu.isNull() ? manu+serial : textmanu+serial; 116 return textmanu.isNull() ? manu+serial : textmanu+serial;
117} 117}
118 118
119 119
120QString OMacAddress::manufacturer() const 120QString OMacAddress::manufacturer() const
121{ 121{
122 return OManufacturerDB::instance()->lookupExt( toString() ); 122 return OManufacturerDB::instance()->lookupExt( toString() );
123} 123}
124 124
125 125
126bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) 126bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
127{ 127{
128 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; 128 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
129} 129}
130 130
131 131
132/*====================================================================================== 132/*======================================================================================
133 * OHostAddress 133 * OHostAddress
134 *======================================================================================*/ 134 *======================================================================================*/
135 135
136 136
137/*====================================================================================== 137/*======================================================================================
138 * OPrivateIOCTL 138 * OPrivateIOCTL
139 *======================================================================================*/ 139 *======================================================================================*/
140 140
141OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) 141OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
142 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) 142 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
143{ 143{
144} 144}
145 145
146 146
147OPrivateIOCTL::~OPrivateIOCTL() 147OPrivateIOCTL::~OPrivateIOCTL()
148{ 148{
149} 149}
150 150
151 151
152int OPrivateIOCTL::numberGetArgs() const 152int OPrivateIOCTL::numberGetArgs() const
153{ 153{
154 return _getargs & IW_PRIV_SIZE_MASK; 154 return _getargs & IW_PRIV_SIZE_MASK;
155} 155}
156 156
157 157
158int OPrivateIOCTL::typeGetArgs() const 158int OPrivateIOCTL::typeGetArgs() const
159{ 159{
160 return _getargs & IW_PRIV_TYPE_MASK >> 12; 160 return _getargs & IW_PRIV_TYPE_MASK >> 12;
161} 161}
162 162
163 163
164int OPrivateIOCTL::numberSetArgs() const 164int OPrivateIOCTL::numberSetArgs() const
165{ 165{
166 return _setargs & IW_PRIV_SIZE_MASK; 166 return _setargs & IW_PRIV_SIZE_MASK;
167} 167}
168 168
169 169
170int OPrivateIOCTL::typeSetArgs() const 170int OPrivateIOCTL::typeSetArgs() const
171{ 171{
172 return _setargs & IW_PRIV_TYPE_MASK >> 12; 172 return _setargs & IW_PRIV_TYPE_MASK >> 12;
173} 173}
174 174
175 175
176void OPrivateIOCTL::invoke() const 176void OPrivateIOCTL::invoke() const
177{ 177{
178 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); 178 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
179} 179}
180 180
181 181
182void OPrivateIOCTL::setParameter( int num, u_int32_t value ) 182void OPrivateIOCTL::setParameter( int num, u_int32_t value )
183{ 183{
184 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; 184 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
185 arglist[num] = value; 185 arglist[num] = value;
186} 186}
187 187
188/*====================================================================================== 188/*======================================================================================
189 * assorted functions 189 * assorted functions
190 *======================================================================================*/ 190 *======================================================================================*/
191 191
192void dumpBytes( const unsigned char* data, int num ) 192void dumpBytes( const unsigned char* data, int num )
193{ 193{
194 printf( "Dumping %d bytes @ %0x", num, data ); 194 printf( "Dumping %d bytes @ %0x", num, data );
195 printf( "-------------------------------------------\n" ); 195 printf( "-------------------------------------------\n" );
196 196
197 for ( int i = 0; i < num; ++i ) 197 for ( int i = 0; i < num; ++i )
198 { 198 {
199 printf( "%02x ", data[i] ); 199 printf( "%02x ", data[i] );
200 if ( !((i+1) % 32) ) printf( "\n" ); 200 if ( !((i+1) % 32) ) printf( "\n" );
201 } 201 }
202 printf( "\n\n" ); 202 printf( "\n\n" );
203} 203}
204 204
205 205
206int stringToMode( const QString& mode ) 206int stringToMode( const QString& mode )
207{ 207{
208 if ( mode == "auto" ) return IW_MODE_AUTO; 208 if ( mode == "auto" ) return IW_MODE_AUTO;
209 else if ( mode == "adhoc" ) return IW_MODE_ADHOC; 209 else if ( mode == "adhoc" ) return IW_MODE_ADHOC;
210 else if ( mode == "managed" ) return IW_MODE_INFRA; 210 else if ( mode == "managed" ) return IW_MODE_INFRA;
211 else if ( mode == "master" ) return IW_MODE_MASTER; 211 else if ( mode == "master" ) return IW_MODE_MASTER;
212 else if ( mode == "repeater" ) return IW_MODE_REPEAT; 212 else if ( mode == "repeater" ) return IW_MODE_REPEAT;
213 else if ( mode == "secondary" ) return IW_MODE_SECOND; 213 else if ( mode == "secondary" ) return IW_MODE_SECOND;
214 else if ( mode == "monitor" ) return IW_MODE_MONITOR; 214 else if ( mode == "monitor" ) return IW_MODE_MONITOR;
215 else assert( 0 ); 215 else assert( 0 );
216} 216}
217 217
218 218
219QString modeToString( int mode ) 219QString modeToString( int mode )
220{ 220{
221 switch ( mode ) 221 switch ( mode )
222 { 222 {
223 case IW_MODE_AUTO: return "auto"; 223 case IW_MODE_AUTO: return "auto";
224 case IW_MODE_ADHOC: return "adhoc"; 224 case IW_MODE_ADHOC: return "adhoc";
225 case IW_MODE_INFRA: return "managed"; 225 case IW_MODE_INFRA: return "managed";
226 case IW_MODE_MASTER: return "master"; 226 case IW_MODE_MASTER: return "master";
227 case IW_MODE_REPEAT: return "repeater"; 227 case IW_MODE_REPEAT: return "repeater";
228 case IW_MODE_SECOND: return "second"; 228 case IW_MODE_SECOND: return "second";
229 case IW_MODE_MONITOR: return "monitor"; 229 case IW_MODE_MONITOR: return "monitor";
230 default: assert( 0 ); 230 default: assert( 0 );
231 } 231 }
232} 232}
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 95c813f..6a9280f 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1,1190 +1,1188 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 4 =.
8 .=l. 5 .=l.
9           .>+-= 6           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 13    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 20++=   -.     .`     .: details.
24 :     =  ...= . :.=- 21 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
31 28
32*/ 29*/
33 30
34/* OPIE */ 31/* OPIE */
35 32
36#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
37#include <opie2/ostation.h> 34#include <opie2/ostation.h>
38 35
39/* QT */ 36/* QT */
40 37
41#include <qfile.h> 38#include <qfile.h>
42#include <qtextstream.h> 39#include <qtextstream.h>
43 40
44/* UNIX */ 41/* UNIX */
45 42
46#include <assert.h> 43#include <assert.h>
47#include <arpa/inet.h> 44#include <arpa/inet.h>
48#include <errno.h> 45#include <errno.h>
49#include <string.h> 46#include <string.h>
50#include <stdlib.h> 47#include <stdlib.h>
51#include <math.h> 48#include <math.h>
52#include <sys/ioctl.h> 49#include <sys/ioctl.h>
53#include <sys/socket.h> 50#include <sys/socket.h>
54#include <sys/types.h> 51#include <sys/types.h>
55#include <unistd.h> 52#include <unistd.h>
56#include <linux/sockios.h> 53#include <linux/sockios.h>
57#include <net/if_arp.h> 54#include <net/if_arp.h>
58#include <stdarg.h> 55#include <stdarg.h>
59 56
60#ifndef NODEBUG 57#ifndef NODEBUG
61#include <opie2/odebugmapper.h> 58#include <opie2/odebugmapper.h>
62DebugMapper* debugmapper = new DebugMapper(); 59DebugMapper* debugmapper = new DebugMapper();
63#endif 60#endif
64 61
65/*====================================================================================== 62/*======================================================================================
66 * ONetwork 63 * ONetwork
67 *======================================================================================*/ 64 *======================================================================================*/
68 65
69ONetwork* ONetwork::_instance = 0; 66ONetwork* ONetwork::_instance = 0;
70 67
71ONetwork::ONetwork() 68ONetwork::ONetwork()
72{ 69{
73 qDebug( "ONetwork::ONetwork()" ); 70 qDebug( "ONetwork::ONetwork()" );
74 qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT ); 71 qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT );
75 synchronize(); 72 synchronize();
76} 73}
77 74
78void ONetwork::synchronize() 75void ONetwork::synchronize()
79{ 76{
80 // gather available interfaces by inspecting /proc/net/dev 77 // gather available interfaces by inspecting /proc/net/dev
81 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 78 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
82 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 79 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
83 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev 80 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
84 81
85 _interfaces.clear(); 82 _interfaces.clear();
86 QString str; 83 QString str;
87 QFile f( "/proc/net/dev" ); 84 QFile f( "/proc/net/dev" );
88 bool hasFile = f.open( IO_ReadOnly ); 85 bool hasFile = f.open( IO_ReadOnly );
89 if ( !hasFile ) 86 if ( !hasFile )
90 { 87 {
91 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); 88 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" );
92 return; 89 return;
93 } 90 }
94 QTextStream s( &f ); 91 QTextStream s( &f );
95 s.readLine(); 92 s.readLine();
96 s.readLine(); 93 s.readLine();
97 while ( !s.atEnd() ) 94 while ( !s.atEnd() )
98 { 95 {
99 s >> str; 96 s >> str;
100 str.truncate( str.find( ':' ) ); 97 str.truncate( str.find( ':' ) );
101 qDebug( "ONetwork: found interface '%s'", (const char*) str ); 98 qDebug( "ONetwork: found interface '%s'", (const char*) str );
102 ONetworkInterface* iface; 99 ONetworkInterface* iface;
103 if ( isWirelessInterface( str ) ) 100 if ( isWirelessInterface( str ) )
104 { 101 {
105 iface = new OWirelessNetworkInterface( this, (const char*) str ); 102 iface = new OWirelessNetworkInterface( this, (const char*) str );
106 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); 103 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str );
107 } 104 }
108 else 105 else
109 { 106 {
110 iface = new ONetworkInterface( this, (const char*) str ); 107 iface = new ONetworkInterface( this, (const char*) str );
111 } 108 }
112 _interfaces.insert( str, iface ); 109 _interfaces.insert( str, iface );
113 s.readLine(); 110 s.readLine();
114 } 111 }
115} 112}
116 113
117 114
118short ONetwork::wirelessExtensionVersion() 115short ONetwork::wirelessExtensionVersion()
119{ 116{
120 return WIRELESS_EXT; 117 return WIRELESS_EXT;
121} 118}
122 119
123 120
124int ONetwork::count() const 121int ONetwork::count() const
125{ 122{
126 return _interfaces.count(); 123 return _interfaces.count();
127} 124}
128 125
129 126
130ONetworkInterface* ONetwork::interface( const QString& iface ) const 127ONetworkInterface* ONetwork::interface( const QString& iface ) const
131{ 128{
132 return _interfaces[iface]; 129 return _interfaces[iface];
133} 130}
134 131
135 132
136ONetwork* ONetwork::instance() 133ONetwork* ONetwork::instance()
137{ 134{
138 if ( !_instance ) _instance = new ONetwork(); 135 if ( !_instance ) _instance = new ONetwork();
139 return _instance; 136 return _instance;
140} 137}
141 138
142 139
143ONetwork::InterfaceIterator ONetwork::iterator() const 140ONetwork::InterfaceIterator ONetwork::iterator() const
144{ 141{
145 return ONetwork::InterfaceIterator( _interfaces ); 142 return ONetwork::InterfaceIterator( _interfaces );
146} 143}
147 144
148 145
149bool ONetwork::isWirelessInterface( const char* name ) const 146bool ONetwork::isWirelessInterface( const char* name ) const
150{ 147{
151 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 148 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
152 struct iwreq iwr; 149 struct iwreq iwr;
153 memset( &iwr, 0, sizeof( struct iwreq ) ); 150 memset( &iwr, 0, sizeof( struct iwreq ) );
154 strcpy( (char*) &iwr.ifr_name, name ); 151 strcpy( (char*) &iwr.ifr_name, name );
155 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); 152 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
156 return result != -1; 153 return result != -1;
157} 154}
158 155
159/*====================================================================================== 156/*======================================================================================
160 * ONetworkInterface 157 * ONetworkInterface
161 *======================================================================================*/ 158 *======================================================================================*/
162 159
163ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) 160ONetworkInterface::ONetworkInterface( QObject* parent, const char* name )
164 :QObject( parent, name ), 161 :QObject( parent, name ),
165 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) 162 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
166{ 163{
167 qDebug( "ONetworkInterface::ONetworkInterface()" ); 164 qDebug( "ONetworkInterface::ONetworkInterface()" );
168 init(); 165 init();
169} 166}
170 167
171 168
172struct ifreq& ONetworkInterface::ifr() const 169struct ifreq& ONetworkInterface::ifr() const
173{ 170{
174 return _ifr; 171 return _ifr;
175} 172}
176 173
177 174
178void ONetworkInterface::init() 175void ONetworkInterface::init()
179{ 176{
180 qDebug( "ONetworkInterface::init()" ); 177 qDebug( "ONetworkInterface::init()" );
181 178
182 memset( &_ifr, 0, sizeof( struct ifreq ) ); 179 memset( &_ifr, 0, sizeof( struct ifreq ) );
183 180
184 if ( _sfd == -1 ) 181 if ( _sfd == -1 )
185 { 182 {
186 qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); 183 qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() );
187 return; 184 return;
188 } 185 }
189} 186}
190 187
191 188
192bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const 189bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const
193{ 190{
194 #ifndef NODEBUG 191 #ifndef NODEBUG
195 int result = ::ioctl( _sfd, call, &ifreq ); 192 int result = ::ioctl( _sfd, call, &ifreq );
196 if ( result == -1 ) 193 if ( result == -1 )
197 qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) ); 194 qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) );
198 else 195 else
199 qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call ); 196 qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call );
200 return ( result != -1 ); 197 return ( result != -1 );
201 #else 198 #else
202 return ::ioctl( _sfd, call, &ifreq ) != -1; 199 return ::ioctl( _sfd, call, &ifreq ) != -1;
203 #endif 200 #endif
204} 201}
205 202
206 203
207bool ONetworkInterface::ioctl( int call ) const 204bool ONetworkInterface::ioctl( int call ) const
208{ 205{
209 strcpy( _ifr.ifr_name, name() ); 206 strcpy( _ifr.ifr_name, name() );
210 return ioctl( call, _ifr ); 207 return ioctl( call, _ifr );
211} 208}
212 209
213 210
214bool ONetworkInterface::isLoopback() const 211bool ONetworkInterface::isLoopback() const
215{ 212{
216 ioctl( SIOCGIFFLAGS ); 213 ioctl( SIOCGIFFLAGS );
217 return _ifr.ifr_flags & IFF_LOOPBACK; 214 return _ifr.ifr_flags & IFF_LOOPBACK;
218} 215}
219 216
220 217
221bool ONetworkInterface::setUp( bool b ) 218bool ONetworkInterface::setUp( bool b )
222{ 219{
223 ioctl( SIOCGIFFLAGS ); 220 ioctl( SIOCGIFFLAGS );
224 if ( b ) _ifr.ifr_flags |= IFF_UP; 221 if ( b ) _ifr.ifr_flags |= IFF_UP;
225 else _ifr.ifr_flags &= (~IFF_UP); 222 else _ifr.ifr_flags &= (~IFF_UP);
226 return ioctl( SIOCSIFFLAGS ); 223 return ioctl( SIOCSIFFLAGS );
227} 224}
228 225
229 226
230bool ONetworkInterface::isUp() const 227bool ONetworkInterface::isUp() const
231{ 228{
232 ioctl( SIOCGIFFLAGS ); 229 ioctl( SIOCGIFFLAGS );
233 return _ifr.ifr_flags & IFF_UP; 230 return _ifr.ifr_flags & IFF_UP;
234} 231}
235 232
236 233
237void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) 234void ONetworkInterface::setIPV4Address( const QHostAddress& addr )
238{ 235{
239 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; 236 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
240 sa->sin_family = AF_INET; 237 sa->sin_family = AF_INET;
241 sa->sin_port = 0; 238 sa->sin_port = 0;
242 sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); 239 sa->sin_addr.s_addr = htonl( addr.ip4Addr() );
243 ioctl( SIOCSIFADDR ); 240 ioctl( SIOCSIFADDR );
244} 241}
245 242
246 243
247QString ONetworkInterface::ipV4Address() const 244QString ONetworkInterface::ipV4Address() const
248{ 245{
249 if ( ioctl( SIOCGIFADDR ) ) 246 if ( ioctl( SIOCGIFADDR ) )
250 { 247 {
251 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; 248 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
252 //FIXME: Use QHostAddress here 249 //FIXME: Use QHostAddress here
253 return QString( inet_ntoa( sa->sin_addr ) ); 250 return QString( inet_ntoa( sa->sin_addr ) );
254 } 251 }
255 else 252 else
256 return "<unknown>"; 253 return "<unknown>";
257 254
258} 255}
259 256
260 257
261void ONetworkInterface::setMacAddress( const OMacAddress& addr ) 258void ONetworkInterface::setMacAddress( const OMacAddress& addr )
262{ 259{
263 _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; 260 _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
264 memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); 261 memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 );
265 ioctl( SIOCSIFHWADDR ); 262 ioctl( SIOCSIFHWADDR );
266} 263}
267 264
268 265
269OMacAddress ONetworkInterface::macAddress() const 266OMacAddress ONetworkInterface::macAddress() const
270{ 267{
271 if ( ioctl( SIOCGIFHWADDR ) ) 268 if ( ioctl( SIOCGIFHWADDR ) )
272 { 269 {
273 return OMacAddress( _ifr ); 270 return OMacAddress( _ifr );
274 } 271 }
275 else 272 else
276 { 273 {
277 return OMacAddress::unknown; 274 return OMacAddress::unknown;
278 } 275 }
279} 276}
280 277
281 278
282void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) 279void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr )
283{ 280{
284 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; 281 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
285 sa->sin_family = AF_INET; 282 sa->sin_family = AF_INET;
286 sa->sin_port = 0; 283 sa->sin_port = 0;
287 sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); 284 sa->sin_addr.s_addr = htonl( addr.ip4Addr() );
288 ioctl( SIOCSIFNETMASK ); 285 ioctl( SIOCSIFNETMASK );
289} 286}
290 287
291 288
292QString ONetworkInterface::ipV4Netmask() const 289QString ONetworkInterface::ipV4Netmask() const
293{ 290{
294 if ( ioctl( SIOCGIFNETMASK ) ) 291 if ( ioctl( SIOCGIFNETMASK ) )
295 { 292 {
296 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; 293 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
297 //FIXME: Use QHostAddress here 294 //FIXME: Use QHostAddress here
298 return QString( inet_ntoa( sa->sin_addr ) ); 295 return QString( inet_ntoa( sa->sin_addr ) );
299 } 296 }
300 else 297 else
301 return "<unknown>"; 298 return "<unknown>";
302} 299}
303 300
304 301
305int ONetworkInterface::dataLinkType() const 302int ONetworkInterface::dataLinkType() const
306{ 303{
307 if ( ioctl( SIOCGIFHWADDR ) ) 304 if ( ioctl( SIOCGIFHWADDR ) )
308 { 305 {
309 return _ifr.ifr_hwaddr.sa_family; 306 return _ifr.ifr_hwaddr.sa_family;
310 } 307 }
311 else 308 else
312 { 309 {
313 return -1; 310 return -1;
314 } 311 }
315} 312}
316 313
317 314
318void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) 315void ONetworkInterface::setMonitoring( OMonitoringInterface* m )
319{ 316{
320 _mon = m; 317 _mon = m;
321 qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); 318 qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() );
322} 319}
323 320
324 321
325OMonitoringInterface* ONetworkInterface::monitoring() const 322OMonitoringInterface* ONetworkInterface::monitoring() const
326{ 323{
327 return _mon; 324 return _mon;
328} 325}
329 326
330 327
331ONetworkInterface::~ONetworkInterface() 328ONetworkInterface::~ONetworkInterface()
332{ 329{
333 qDebug( "ONetworkInterface::~ONetworkInterface()" ); 330 qDebug( "ONetworkInterface::~ONetworkInterface()" );
334 if ( _sfd != -1 ) ::close( _sfd ); 331 if ( _sfd != -1 ) ::close( _sfd );
335} 332}
336 333
337 334
338bool ONetworkInterface::setPromiscuousMode( bool b ) 335bool ONetworkInterface::setPromiscuousMode( bool b )
339{ 336{
340 ioctl( SIOCGIFFLAGS ); 337 ioctl( SIOCGIFFLAGS );
341 if ( b ) _ifr.ifr_flags |= IFF_PROMISC; 338 if ( b ) _ifr.ifr_flags |= IFF_PROMISC;
342 else _ifr.ifr_flags &= (~IFF_PROMISC); 339 else _ifr.ifr_flags &= (~IFF_PROMISC);
343 return ioctl( SIOCSIFFLAGS ); 340 return ioctl( SIOCSIFFLAGS );
344} 341}
345 342
346 343
347bool ONetworkInterface::promiscuousMode() const 344bool ONetworkInterface::promiscuousMode() const
348{ 345{
349 ioctl( SIOCGIFFLAGS ); 346 ioctl( SIOCGIFFLAGS );
350 return _ifr.ifr_flags & IFF_PROMISC; 347 return _ifr.ifr_flags & IFF_PROMISC;
351} 348}
352 349
353 350
354bool ONetworkInterface::isWireless() const 351bool ONetworkInterface::isWireless() const
355{ 352{
356 return ioctl( SIOCGIWNAME ); 353 return ioctl( SIOCGIWNAME );
357} 354}
358 355
359 356
360/*====================================================================================== 357/*======================================================================================
361 * OChannelHopper 358 * OChannelHopper
362 *======================================================================================*/ 359 *======================================================================================*/
363 360
364OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) 361OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface )
365 :QObject( 0, "Mickey's funky hopper" ), 362 :QObject( 0, "Mickey's funky hopper" ),
366 _iface( iface ), _interval( 0 ), _tid( 0 ) 363 _iface( iface ), _interval( 0 ), _tid( 0 )
367{ 364{
368 int _maxChannel = iface->channels()+1; 365 int _maxChannel = iface->channels()+1;
369 // generate fancy hopping sequence honoring the device capabilities 366 // generate fancy hopping sequence honoring the device capabilities
370 if ( _maxChannel >= 1 ) _channels.append( 1 ); 367 if ( _maxChannel >= 1 ) _channels.append( 1 );
371 if ( _maxChannel >= 7 ) _channels.append( 7 ); 368 if ( _maxChannel >= 7 ) _channels.append( 7 );
372 if ( _maxChannel >= 13 ) _channels.append( 13 ); 369 if ( _maxChannel >= 13 ) _channels.append( 13 );
373 if ( _maxChannel >= 2 ) _channels.append( 2 ); 370 if ( _maxChannel >= 2 ) _channels.append( 2 );
374 if ( _maxChannel >= 8 ) _channels.append( 8 ); 371 if ( _maxChannel >= 8 ) _channels.append( 8 );
375 if ( _maxChannel >= 3 ) _channels.append( 3 ); 372 if ( _maxChannel >= 3 ) _channels.append( 3 );
376 if ( _maxChannel >= 14 ) _channels.append( 14 ); 373 if ( _maxChannel >= 14 ) _channels.append( 14 );
377 if ( _maxChannel >= 9 ) _channels.append( 9 ); 374 if ( _maxChannel >= 9 ) _channels.append( 9 );
378 if ( _maxChannel >= 4 ) _channels.append( 4 ); 375 if ( _maxChannel >= 4 ) _channels.append( 4 );
379 if ( _maxChannel >= 10 ) _channels.append( 10 ); 376 if ( _maxChannel >= 10 ) _channels.append( 10 );
380 if ( _maxChannel >= 5 ) _channels.append( 5 ); 377 if ( _maxChannel >= 5 ) _channels.append( 5 );
381 if ( _maxChannel >= 11 ) _channels.append( 11 ); 378 if ( _maxChannel >= 11 ) _channels.append( 11 );
382 if ( _maxChannel >= 6 ) _channels.append( 6 ); 379 if ( _maxChannel >= 6 ) _channels.append( 6 );
383 if ( _maxChannel >= 12 ) _channels.append( 12 ); 380 if ( _maxChannel >= 12 ) _channels.append( 12 );
384 _channel = _channels.begin(); 381 _channel = _channels.begin();
385 382
386} 383}
387 384
388 385
389OChannelHopper::~OChannelHopper() 386OChannelHopper::~OChannelHopper()
390{ 387{
391} 388}
392 389
393 390
394bool OChannelHopper::isActive() const 391bool OChannelHopper::isActive() const
395{ 392{
396 return _tid; 393 return _tid;
397} 394}
398 395
399 396
400int OChannelHopper::channel() const 397int OChannelHopper::channel() const
401{ 398{
402 return *_channel; 399 return *_channel;
403} 400}
404 401
405 402
406void OChannelHopper::timerEvent( QTimerEvent* ) 403void OChannelHopper::timerEvent( QTimerEvent* )
407{ 404{
408 _iface->setChannel( *_channel ); 405 _iface->setChannel( *_channel );
409 emit( hopped( *_channel ) ); 406 emit( hopped( *_channel ) );
410 qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", 407 qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'",
411 *_channel, (const char*) _iface->name() ); 408 *_channel, (const char*) _iface->name() );
412 if ( ++_channel == _channels.end() ) _channel = _channels.begin(); 409 if ( ++_channel == _channels.end() ) _channel = _channels.begin();
413} 410}
414 411
415 412
416void OChannelHopper::setInterval( int interval ) 413void OChannelHopper::setInterval( int interval )
417{ 414{
418 if ( interval == _interval ) 415 if ( interval == _interval )
419 return; 416 return;
420 417
421 if ( _interval ) 418 if ( _interval )
422 killTimer( _tid ); 419 killTimer( _tid );
423 420
424 _tid = 0; 421 _tid = 0;
425 _interval = interval; 422 _interval = interval;
426 423
427 if ( _interval ) 424 if ( _interval )
428 { 425 {
429 _tid = startTimer( interval ); 426 _tid = startTimer( interval );
430 } 427 }
431} 428}
432 429
433 430
434int OChannelHopper::interval() const 431int OChannelHopper::interval() const
435{ 432{
436 return _interval; 433 return _interval;
437} 434}
438 435
439 436
440/*====================================================================================== 437/*======================================================================================
441 * OWirelessNetworkInterface 438 * OWirelessNetworkInterface
442 *======================================================================================*/ 439 *======================================================================================*/
443 440
444OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) 441OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name )
445 :ONetworkInterface( parent, name ), _hopper( 0 ) 442 :ONetworkInterface( parent, name ), _hopper( 0 )
446{ 443{
447 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); 444 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" );
448 init(); 445 init();
449} 446}
450 447
451 448
452OWirelessNetworkInterface::~OWirelessNetworkInterface() 449OWirelessNetworkInterface::~OWirelessNetworkInterface()
453{ 450{
454} 451}
455 452
456 453
457struct iwreq& OWirelessNetworkInterface::iwr() const 454struct iwreq& OWirelessNetworkInterface::iwr() const
458{ 455{
459 return _iwr; 456 return _iwr;
460} 457}
461 458
462 459
463void OWirelessNetworkInterface::init() 460void OWirelessNetworkInterface::init()
464{ 461{
465 qDebug( "OWirelessNetworkInterface::init()" ); 462 qDebug( "OWirelessNetworkInterface::init()" );
466 memset( &_iwr, 0, sizeof( struct iwreq ) ); 463 memset( &_iwr, 0, sizeof( struct iwreq ) );
467 buildInformation(); 464 buildInformation();
468 buildPrivateList(); 465 buildPrivateList();
469 dumpInformation(); 466 dumpInformation();
470} 467}
471 468
472 469
473bool OWirelessNetworkInterface::isAssociated() const 470bool OWirelessNetworkInterface::isAssociated() const
474{ 471{
475 //FIXME: handle different modes 472 //FIXME: handle different modes
476 return !(associatedAP() == OMacAddress::unknown); 473 return !(associatedAP() == OMacAddress::unknown);
477} 474}
478 475
479 476
480OMacAddress OWirelessNetworkInterface::associatedAP() const 477OMacAddress OWirelessNetworkInterface::associatedAP() const
481{ 478{
482 if ( ioctl( SIOCGIWAP ) ) 479 if ( ioctl( SIOCGIWAP ) )
483 return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; 480 return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0];
484 else 481 else
485 return OMacAddress::unknown; 482 return OMacAddress::unknown;
486} 483}
487 484
488 485
489void OWirelessNetworkInterface::buildInformation() 486void OWirelessNetworkInterface::buildInformation()
490{ 487{
491 //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck 488 //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck
492 //ML: The HostAP drivers need more than sizeof struct_iw range to complete 489 //ML: The HostAP drivers need more than sizeof struct_iw range to complete
493 //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". 490 //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length".
494 //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate 491 //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate
495 //ML: _too much_ space. This is damn shitty crap *sigh* 492 //ML: _too much_ space. This is damn shitty crap *sigh*
496 //ML: We allocate a large memory region in RAM and check whether the 493 //ML: We allocate a large memory region in RAM and check whether the
497 //ML: driver pollutes this extra space. The complaint will be made on stdout, 494 //ML: driver pollutes this extra space. The complaint will be made on stdout,
498 //ML: so please forward this... 495 //ML: so please forward this...
499 496
500 struct iwreq wrq; 497 struct iwreq wrq;
501 int len = sizeof( struct iw_range )*2; 498 int len = sizeof( struct iw_range )*2;
502 char *buffer = (char*) malloc( len ); 499 char *buffer = (char*) malloc( len );
503 //FIXME: Validate if we actually got the memory block 500 //FIXME: Validate if we actually got the memory block
504 memset( buffer, 0, len ); 501 memset( buffer, 0, len );
505 memcpy( wrq.ifr_name, name(), IFNAMSIZ); 502 memcpy( wrq.ifr_name, name(), IFNAMSIZ);
506 wrq.u.data.pointer = (caddr_t) buffer; 503 wrq.u.data.pointer = (caddr_t) buffer;
507 wrq.u.data.length = sizeof( struct iw_range ); 504 wrq.u.data.length = sizeof( struct iw_range );
508 wrq.u.data.flags = 0; 505 wrq.u.data.flags = 0;
509 506
510 if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) 507 if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 )
511 { 508 {
512 qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) ); 509 qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) );
513 _channels.insert( 2412, 1 ); // 2.412 GHz 510 _channels.insert( 2412, 1 ); // 2.412 GHz
514 _channels.insert( 2417, 2 ); // 2.417 GHz 511 _channels.insert( 2417, 2 ); // 2.417 GHz
515 _channels.insert( 2422, 3 ); // 2.422 GHz 512 _channels.insert( 2422, 3 ); // 2.422 GHz
516 _channels.insert( 2427, 4 ); // 2.427 GHz 513 _channels.insert( 2427, 4 ); // 2.427 GHz
517 _channels.insert( 2432, 5 ); // 2.432 GHz 514 _channels.insert( 2432, 5 ); // 2.432 GHz
518 _channels.insert( 2437, 6 ); // 2.437 GHz 515 _channels.insert( 2437, 6 ); // 2.437 GHz
519 _channels.insert( 2442, 7 ); // 2.442 GHz 516 _channels.insert( 2442, 7 ); // 2.442 GHz
520 _channels.insert( 2447, 8 ); // 2.447 GHz 517 _channels.insert( 2447, 8 ); // 2.447 GHz
521 _channels.insert( 2452, 9 ); // 2.452 GHz 518 _channels.insert( 2452, 9 ); // 2.452 GHz
522 _channels.insert( 2457, 10 ); // 2.457 GHz 519 _channels.insert( 2457, 10 ); // 2.457 GHz
523 _channels.insert( 2462, 11 ); // 2.462 GHz 520 _channels.insert( 2462, 11 ); // 2.462 GHz
524 521
525 memset( &_range, 0, sizeof( struct iw_range ) ); 522 memset( &_range, 0, sizeof( struct iw_range ) );
526 } 523 }
527 else 524 else
528 { 525 {
529 // <check if the driver overwrites stuff> 526 // <check if the driver overwrites stuff>
530 int max = 0; 527 int max = 0;
531 for ( int r = sizeof( struct iw_range ); r < len; r++ ) 528 for ( int r = sizeof( struct iw_range ); r < len; r++ )
532 if (buffer[r] != 0) 529 if (buffer[r] != 0)
533 max = r; 530 max = r;
534 if (max > 0) 531 if (max > 0)
535 { 532 {
536 qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n" 533 qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n"
537 "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); 534 "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) );
538 } 535 }
539 // </check if the driver overwrites stuff> 536 // </check if the driver overwrites stuff>
540 537
541 struct iw_range range; 538 struct iw_range range;
542 memcpy( &range, buffer, sizeof range ); 539 memcpy( &range, buffer, sizeof range );
543 540
544 qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency ); 541 qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency );
545 for ( int i = 0; i < range.num_frequency; ++i ) 542 for ( int i = 0; i < range.num_frequency; ++i )
546 { 543 {
547 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); 544 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 );
548 _channels.insert( freq, i+1 ); 545 _channels.insert( freq, i+1 );
549 } 546 }
550 } 547 }
551 548
552 memcpy( &_range, buffer, sizeof( struct iw_range ) ); 549 memcpy( &_range, buffer, sizeof( struct iw_range ) );
553 qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." ); 550 qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." );
554 free(buffer); 551 free(buffer);
555} 552}
556 553
557 554
558void OWirelessNetworkInterface::buildPrivateList() 555void OWirelessNetworkInterface::buildPrivateList()
559{ 556{
560 qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); 557 qDebug( "OWirelessNetworkInterface::buildPrivateList()" );
561 558
562 struct iw_priv_args priv[IW_MAX_PRIV_DEF]; 559 struct iw_priv_args priv[IW_MAX_PRIV_DEF];
563 560
564 _iwr.u.data.pointer = (char*) &priv; 561 _iwr.u.data.pointer = (char*) &priv;
565 _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself 562 _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself
566 _iwr.u.data.flags = 0; 563 _iwr.u.data.flags = 0;
567 564
568 if ( !wioctl( SIOCGIWPRIV ) ) 565 if ( !wioctl( SIOCGIWPRIV ) )
569 { 566 {
570 qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); 567 qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) );
571 return; 568 return;
572 } 569 }
573 570
574 for ( int i = 0; i < _iwr.u.data.length; ++i ) 571 for ( int i = 0; i < _iwr.u.data.length; ++i )
575 { 572 {
576 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); 573 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args );
577 } 574 }
578 qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); 575 qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." );
579} 576}
580 577
581 578
582void OWirelessNetworkInterface::dumpInformation() const 579void OWirelessNetworkInterface::dumpInformation() const
583{ 580{
584 qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" ); 581 qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" );
585 582
586 qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ); 583 qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 );
587 qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source ); 584 qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source );
588 585
589 qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" ); 586 qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" );
590} 587}
591 588
592 589
593int OWirelessNetworkInterface::channel() const 590int OWirelessNetworkInterface::channel() const
594{ 591{
595 //FIXME: When monitoring enabled, then use it 592 //FIXME: When monitoring enabled, then use it
596 //FIXME: to gather the current RF channel 593 //FIXME: to gather the current RF channel
597 //FIXME: Until then, get active channel from hopper. 594 //FIXME: Until then, get active channel from hopper.
598 if ( _hopper && _hopper->isActive() ) 595 if ( _hopper && _hopper->isActive() )
599 return _hopper->channel(); 596 return _hopper->channel();
600 597
601 if ( !wioctl( SIOCGIWFREQ ) ) 598 if ( !wioctl( SIOCGIWFREQ ) )
602 { 599 {
603 return -1; 600 return -1;
604 } 601 }
605 else 602 else
606 { 603 {
607 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; 604 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ];
608 } 605 }
609} 606}
610 607
611 608
612void OWirelessNetworkInterface::setChannel( int c ) const 609void OWirelessNetworkInterface::setChannel( int c ) const
613{ 610{
614 if ( !c ) 611 if ( !c )
615 { 612 {
616 qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" ); 613 qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" );
617 return; 614 return;
618 } 615 }
619 616
620 if ( !_mon ) 617 if ( !_mon )
621 { 618 {
622 memset( &_iwr, 0, sizeof( struct iwreq ) ); 619 memset( &_iwr, 0, sizeof( struct iwreq ) );
623 _iwr.u.freq.m = c; 620 _iwr.u.freq.m = c;
624 _iwr.u.freq.e = 0; 621 _iwr.u.freq.e = 0;
625 wioctl( SIOCSIWFREQ ); 622 wioctl( SIOCSIWFREQ );
626 } 623 }
627 else 624 else
628 { 625 {
629 _mon->setChannel( c ); 626 _mon->setChannel( c );
630 } 627 }
631} 628}
632 629
633 630
634double OWirelessNetworkInterface::frequency() const 631double OWirelessNetworkInterface::frequency() const
635{ 632{
636 if ( !wioctl( SIOCGIWFREQ ) ) 633 if ( !wioctl( SIOCGIWFREQ ) )
637 { 634 {
638 return -1.0; 635 return -1.0;
639 } 636 }
640 else 637 else
641 { 638 {
642 return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; 639 return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0;
643 } 640 }
644} 641}
645 642
646 643
647int OWirelessNetworkInterface::channels() const 644int OWirelessNetworkInterface::channels() const
648{ 645{
649 return _channels.count(); 646 return _channels.count();
650} 647}
651 648
652 649
653void OWirelessNetworkInterface::setChannelHopping( int interval ) 650void OWirelessNetworkInterface::setChannelHopping( int interval )
654{ 651{
655 if ( !_hopper ) _hopper = new OChannelHopper( this ); 652 if ( !_hopper ) _hopper = new OChannelHopper( this );
656 _hopper->setInterval( interval ); 653 _hopper->setInterval( interval );
657 //FIXME: When and by whom will the channel hopper be deleted? 654 //FIXME: When and by whom will the channel hopper be deleted?
658 //TODO: rely on QObject hierarchy 655 //TODO: rely on QObject hierarchy
659} 656}
660 657
661 658
662int OWirelessNetworkInterface::channelHopping() const 659int OWirelessNetworkInterface::channelHopping() const
663{ 660{
664 return _hopper->interval(); 661 return _hopper->interval();
665} 662}
666 663
667 664
668OChannelHopper* OWirelessNetworkInterface::channelHopper() const 665OChannelHopper* OWirelessNetworkInterface::channelHopper() const
669{ 666{
670 return _hopper; 667 return _hopper;
671} 668}
672 669
673 670
674void OWirelessNetworkInterface::commit() const 671void OWirelessNetworkInterface::commit() const
675{ 672{
676 wioctl( SIOCSIWCOMMIT ); 673 wioctl( SIOCSIWCOMMIT );
677} 674}
678 675
679 676
680void OWirelessNetworkInterface::setMode( const QString& newMode ) 677void OWirelessNetworkInterface::setMode( const QString& newMode )
681{ 678{
682 #ifdef FINALIZE 679 #ifdef FINALIZE
683 QString currentMode = mode(); 680 QString currentMode = mode();
684 if ( currentMode == newMode ) return; 681 if ( currentMode == newMode ) return;
685 #endif 682 #endif
686 683
687 qDebug( "OWirelessNetworkInterface::setMode(): trying to set mode '%s' (%d)", (const char*) newMode, stringToMode( newMode ) ); 684 qDebug( "OWirelessNetworkInterface::setMode(): trying to set mode '%s' (%d)", (const char*) newMode, stringToMode( newMode ) );
688 685
689 _iwr.u.mode = stringToMode( newMode ); 686 _iwr.u.mode = stringToMode( newMode );
690 687
691 if ( _iwr.u.mode != IW_MODE_MONITOR ) 688 if ( _iwr.u.mode != IW_MODE_MONITOR )
692 { 689 {
693 // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! 690 // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP!
694 _iwr.u.mode = stringToMode( newMode ); 691 _iwr.u.mode = stringToMode( newMode );
695 wioctl( SIOCSIWMODE ); 692 wioctl( SIOCSIWMODE );
696 693
697 // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) 694 // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now)
698 695
699 if ( mode() == "monitor" ) 696 if ( mode() == "monitor" )
700 { 697 {
701 qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." ); 698 qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." );
702 if ( _mon ) 699 if ( _mon )
703 _mon->setEnabled( false ); 700 _mon->setEnabled( false );
704 else 701 else
705 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); 702 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" );
706 } 703 }
707 704
708 } 705 }
709 else // special iwpriv fallback for monitor mode 706 else // special iwpriv fallback for monitor mode
710 { 707 {
711 if ( wioctl( SIOCSIWMODE ) ) 708 if ( wioctl( SIOCSIWMODE ) )
712 { 709 {
713 qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" ); 710 qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" );
714 } 711 }
715 else 712 else
716 { 713 {
717 qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." ); 714 qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." );
718 715
719 if ( _mon ) 716 if ( _mon )
720 _mon->setEnabled( true ); 717 _mon->setEnabled( true );
721 else 718 else
722 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); 719 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" );
723 } 720 }
724 } 721 }
725} 722}
726 723
727 724
728QString OWirelessNetworkInterface::mode() const 725QString OWirelessNetworkInterface::mode() const
729{ 726{
730 memset( &_iwr, 0, sizeof( struct iwreq ) ); 727 memset( &_iwr, 0, sizeof( struct iwreq ) );
731 728
732 if ( !wioctl( SIOCGIWMODE ) ) 729 if ( !wioctl( SIOCGIWMODE ) )
733 { 730 {
734 return "<unknown>"; 731 return "<unknown>";
735 } 732 }
736 733
737 qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) ); 734 qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) );
738 735
739 // legacy compatible monitor mode check 736 // legacy compatible monitor mode check
740 737
741 if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) 738 if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 )
742 { 739 {
743 return "monitor"; 740 return "monitor";
744 } 741 }
745 else 742 else
746 { 743 {
747 return modeToString( _iwr.u.mode ); 744 return modeToString( _iwr.u.mode );
748 } 745 }
749} 746}
750 747
751void OWirelessNetworkInterface::setNickName( const QString& nickname ) 748void OWirelessNetworkInterface::setNickName( const QString& nickname )
752{ 749{
753 _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); 750 _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname );
754 _iwr.u.essid.length = nickname.length(); 751 _iwr.u.essid.length = nickname.length();
755 wioctl( SIOCSIWNICKN ); 752 wioctl( SIOCSIWNICKN );
756} 753}
757 754
758 755
759QString OWirelessNetworkInterface::nickName() const 756QString OWirelessNetworkInterface::nickName() const
760{ 757{
761 char str[IW_ESSID_MAX_SIZE]; 758 char str[IW_ESSID_MAX_SIZE];
762 _iwr.u.data.pointer = &str[0]; 759 _iwr.u.data.pointer = &str[0];
763 _iwr.u.data.length = IW_ESSID_MAX_SIZE; 760 _iwr.u.data.length = IW_ESSID_MAX_SIZE;
764 if ( !wioctl( SIOCGIWNICKN ) ) 761 if ( !wioctl( SIOCGIWNICKN ) )
765 { 762 {
766 return "<unknown>"; 763 return "<unknown>";
767 } 764 }
768 else 765 else
769 { 766 {
770 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string 767 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string
771 return str; 768 return str;
772 } 769 }
773} 770}
774 771
775 772
776void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) 773void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... )
777{ 774{
778 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); 775 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) );
779 if ( !priv ) 776 if ( !priv )
780 { 777 {
781 qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); 778 qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call );
782 return; 779 return;
783 } 780 }
784 if ( priv->numberSetArgs() != numargs ) 781 if ( priv->numberSetArgs() != numargs )
785 { 782 {
786 qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); 783 qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs );
787 return; 784 return;
788 } 785 }
789 786
790 qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); 787 qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() );
791 memset( &_iwr, 0, sizeof _iwr ); 788 memset( &_iwr, 0, sizeof _iwr );
792 va_list argp; 789 va_list argp;
793 va_start( argp, numargs ); 790 va_start( argp, numargs );
794 for ( int i = 0; i < numargs; ++i ) 791 for ( int i = 0; i < numargs; ++i )
795 { 792 {
796 priv->setParameter( i, va_arg( argp, int ) ); 793 priv->setParameter( i, va_arg( argp, int ) );
797 } 794 }
798 va_end( argp ); 795 va_end( argp );
799 priv->invoke(); 796 priv->invoke();
800} 797}
801 798
802 799
803void OWirelessNetworkInterface::getPrivate( const QString& call ) 800void OWirelessNetworkInterface::getPrivate( const QString& call )
804{ 801{
805 qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); 802 qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." );
806} 803}
807 804
808 805
809bool OWirelessNetworkInterface::hasPrivate( const QString& call ) 806bool OWirelessNetworkInterface::hasPrivate( const QString& call )
810{ 807{
811 return child( (const char*) call ); 808 return child( (const char*) call );
812} 809}
813 810
814 811
815QString OWirelessNetworkInterface::SSID() const 812QString OWirelessNetworkInterface::SSID() const
816{ 813{
817 char str[IW_ESSID_MAX_SIZE]; 814 char str[IW_ESSID_MAX_SIZE];
818 _iwr.u.essid.pointer = &str[0]; 815 _iwr.u.essid.pointer = &str[0];
819 _iwr.u.essid.length = IW_ESSID_MAX_SIZE; 816 _iwr.u.essid.length = IW_ESSID_MAX_SIZE;
820 if ( !wioctl( SIOCGIWESSID ) ) 817 if ( !wioctl( SIOCGIWESSID ) )
821 { 818 {
822 return "<unknown>"; 819 return "<unknown>";
823 } 820 }
824 else 821 else
825 { 822 {
826 return str; 823 return str;
827 } 824 }
828} 825}
829 826
830 827
831void OWirelessNetworkInterface::setSSID( const QString& ssid ) 828void OWirelessNetworkInterface::setSSID( const QString& ssid )
832{ 829{
833 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); 830 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid );
834 _iwr.u.essid.length = ssid.length(); 831 _iwr.u.essid.length = ssid.length();
835 wioctl( SIOCSIWESSID ); 832 wioctl( SIOCSIWESSID );
836} 833}
837 834
838 835
839OStationList* OWirelessNetworkInterface::scanNetwork() 836OStationList* OWirelessNetworkInterface::scanNetwork()
840{ 837{
841 _iwr.u.param.flags = IW_SCAN_DEFAULT; 838 _iwr.u.param.flags = IW_SCAN_DEFAULT;
842 _iwr.u.param.value = 0; 839 _iwr.u.param.value = 0;
843 if ( !wioctl( SIOCSIWSCAN ) ) 840 if ( !wioctl( SIOCSIWSCAN ) )
844 { 841 {
845 return 0; 842 return 0;
846 } 843 }
847 844
848 OStationList* stations = new OStationList(); 845 OStationList* stations = new OStationList();
849 846
850 int timeout = 1000000; 847 int timeout = 1000000;
851 848
852 qDebug( "ONetworkInterface::scanNetwork() - scan started." ); 849 qDebug( "ONetworkInterface::scanNetwork() - scan started." );
853 850
854 bool results = false; 851 bool results = false;
855 struct timeval tv; 852 struct timeval tv;
856 tv.tv_sec = 0; 853 tv.tv_sec = 0;
857 tv.tv_usec = 250000; // initial timeout ~ 250ms 854 tv.tv_usec = 250000; // initial timeout ~ 250ms
858 char buffer[IW_SCAN_MAX_DATA]; 855 char buffer[IW_SCAN_MAX_DATA];
859 856
860 while ( !results && timeout > 0 ) 857 while ( !results && timeout > 0 )
861 { 858 {
862 timeout -= tv.tv_usec; 859 timeout -= tv.tv_usec;
863 select( 0, 0, 0, 0, &tv ); 860 select( 0, 0, 0, 0, &tv );
864 861
865 _iwr.u.data.pointer = &buffer[0]; 862 _iwr.u.data.pointer = &buffer[0];
866 _iwr.u.data.flags = 0; 863 _iwr.u.data.flags = 0;
867 _iwr.u.data.length = sizeof buffer; 864 _iwr.u.data.length = sizeof buffer;
868 if ( wioctl( SIOCGIWSCAN ) ) 865 if ( wioctl( SIOCGIWSCAN ) )
869 { 866 {
870 results = true; 867 results = true;
871 continue; 868 continue;
872 } 869 }
873 else if ( errno == EAGAIN) 870 else if ( errno == EAGAIN)
874 { 871 {
875 qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); 872 qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." );
876 #if 0 873 #if 0
877 if ( qApp ) 874 if ( qApp )
878 { 875 {
879 qApp->processEvents( 100 ); 876 qApp->processEvents( 100 );
880 continue; 877 continue;
881 } 878 }
882 #endif 879 #endif
883 tv.tv_sec = 0; 880 tv.tv_sec = 0;
884 tv.tv_usec = 100000; 881 tv.tv_usec = 100000;
885 continue; 882 continue;
886 } 883 }
887 } 884 }
888 885
889 qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); 886 qDebug( "ONetworkInterface::scanNetwork() - scan finished." );
890 887
891 if ( results ) 888 if ( results )
892 { 889 {
893 qDebug( " - result length = %d", _iwr.u.data.length ); 890 qDebug( " - result length = %d", _iwr.u.data.length );
894 if ( !_iwr.u.data.length ) 891 if ( !_iwr.u.data.length )
895 { 892 {
896 qDebug( " - no results (empty neighbourhood)" ); 893 qDebug( " - no results (empty neighbourhood)" );
897 return stations; 894 return stations;
898 } 895 }
899 896
900 qDebug( " - results are in!" ); 897 qDebug( " - results are in!" );
901 dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); 898 dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length );
902 899
903 // parse results 900 // parse results
904 901
905 int offset = 0; 902 int offset = 0;
906 struct iw_event* we = (struct iw_event*) &buffer[0]; 903 struct iw_event* we = (struct iw_event*) &buffer[0];
907 904
908 while ( offset < _iwr.u.data.length ) 905 while ( offset < _iwr.u.data.length )
909 { 906 {
910 //const char* cmd = *(*_ioctlmap)[we->cmd]; 907 //const char* cmd = *(*_ioctlmap)[we->cmd];
911 //if ( !cmd ) cmd = "<unknown>"; 908 //if ( !cmd ) cmd = "<unknown>";
912 qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len ); 909 qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len );
913 switch (we->cmd) 910 switch (we->cmd)
914 { 911 {
915 case SIOCGIWAP: 912 case SIOCGIWAP:
916 { 913 {
917 qDebug( "SIOCGIWAP" ); 914 qDebug( "SIOCGIWAP" );
918 stations->append( new OStation() ); 915 stations->append( new OStation() );
919 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; 916 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0];
920 break; 917 break;
921 } 918 }
922 case SIOCGIWMODE: 919 case SIOCGIWMODE:
923 { 920 {
924 qDebug( "SIOCGIWMODE" ); 921 qDebug( "SIOCGIWMODE" );
925 stations->last()->type = modeToString( we->u.mode ); 922 stations->last()->type = modeToString( we->u.mode );
926 break; 923 break;
927 } 924 }
928 case SIOCGIWFREQ: 925 case SIOCGIWFREQ:
929 { 926 {
930 qDebug( "SIOCGIWFREQ" ); 927 qDebug( "SIOCGIWFREQ" );
931 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; 928 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ];
932 break; 929 break;
933 } 930 }
934 case SIOCGIWESSID: 931 case SIOCGIWESSID:
935 { 932 {
936 qDebug( "SIOCGIWESSID" ); 933 qDebug( "SIOCGIWESSID" );
937 stations->last()->ssid = we->u.essid.pointer; 934 stations->last()->ssid = we->u.essid.pointer;
938 break; 935 break;
939 } 936 }
940 case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break; 937 case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break;
941 case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break; 938 case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break;
942 case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */ 939 case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */
943 case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */ 940 case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */
944 case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */ 941 case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */
945 case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */ 942 case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */
946 case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */ 943 case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */
947 default: qDebug( "unhandled event" ); 944 default: qDebug( "unhandled event" );
948 } 945 }
949 946
950 offset += we->len; 947 offset += we->len;
951 we = (struct iw_event*) &buffer[offset]; 948 we = (struct iw_event*) &buffer[offset];
952 } 949 }
950 return stations;
953 951
954 return stations; 952 return stations;
955 953
956 } 954 }
957 else 955 else
958 { 956 {
959 qDebug( " - no results (timeout) :(" ); 957 qDebug( " - no results (timeout) :(" );
960 return stations; 958 return stations;
961 } 959 }
962} 960}
963 961
964 962
965bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const 963bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
966{ 964{
967 #ifndef NODEBUG 965 #ifndef NODEBUG
968 int result = ::ioctl( _sfd, call, &iwreq ); 966 int result = ::ioctl( _sfd, call, &iwreq );
969 if ( result == -1 ) 967 if ( result == -1 )
970 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) ); 968 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) );
971 else 969 else
972 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call ); 970 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call );
973 return ( result != -1 ); 971 return ( result != -1 );
974 #else 972 #else
975 return ::ioctl( _sfd, call, &iwreq ) != -1; 973 return ::ioctl( _sfd, call, &iwreq ) != -1;
976 #endif 974 #endif
977} 975}
978 976
979 977
980bool OWirelessNetworkInterface::wioctl( int call ) const 978bool OWirelessNetworkInterface::wioctl( int call ) const
981{ 979{
982 strcpy( _iwr.ifr_name, name() ); 980 strcpy( _iwr.ifr_name, name() );
983 return wioctl( call, _iwr ); 981 return wioctl( call, _iwr );
984} 982}
985 983
986 984
987/*====================================================================================== 985/*======================================================================================
988 * OMonitoringInterface 986 * OMonitoringInterface
989 *======================================================================================*/ 987 *======================================================================================*/
990 988
991OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 989OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
992 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) 990 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader )
993{ 991{
994} 992}
995 993
996 994
997OMonitoringInterface::~OMonitoringInterface() 995OMonitoringInterface::~OMonitoringInterface()
998{ 996{
999} 997}
1000 998
1001 999
1002void OMonitoringInterface::setChannel( int c ) 1000void OMonitoringInterface::setChannel( int c )
1003{ 1001{
1004 // use standard WE channel switching protocol 1002 // use standard WE channel switching protocol
1005 memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); 1003 memset( &_if->_iwr, 0, sizeof( struct iwreq ) );
1006 _if->_iwr.u.freq.m = c; 1004 _if->_iwr.u.freq.m = c;
1007 _if->_iwr.u.freq.e = 0; 1005 _if->_iwr.u.freq.e = 0;
1008 _if->wioctl( SIOCSIWFREQ ); 1006 _if->wioctl( SIOCSIWFREQ );
1009} 1007}
1010 1008
1011 1009
1012void OMonitoringInterface::setEnabled( bool b ) 1010void OMonitoringInterface::setEnabled( bool b )
1013{ 1011{
1014} 1012}
1015 1013
1016 1014
1017/*====================================================================================== 1015/*======================================================================================
1018 * OCiscoMonitoringInterface 1016 * OCiscoMonitoringInterface
1019 *======================================================================================*/ 1017 *======================================================================================*/
1020 1018
1021OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1019OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1022 :OMonitoringInterface( iface, prismHeader ) 1020 :OMonitoringInterface( iface, prismHeader )
1023{ 1021{
1024 iface->setMonitoring( this ); 1022 iface->setMonitoring( this );
1025} 1023}
1026 1024
1027 1025
1028OCiscoMonitoringInterface::~OCiscoMonitoringInterface() 1026OCiscoMonitoringInterface::~OCiscoMonitoringInterface()
1029{ 1027{
1030} 1028}
1031 1029
1032 1030
1033void OCiscoMonitoringInterface::setEnabled( bool b ) 1031void OCiscoMonitoringInterface::setEnabled( bool b )
1034{ 1032{
1035 QString fname; 1033 QString fname;
1036 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); 1034 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() );
1037 QFile f( fname ); 1035 QFile f( fname );
1038 if ( !f.exists() ) return; 1036 if ( !f.exists() ) return;
1039 1037
1040 if ( f.open( IO_WriteOnly ) ) 1038 if ( f.open( IO_WriteOnly ) )
1041 { 1039 {
1042 QTextStream s( &f ); 1040 QTextStream s( &f );
1043 s << "Mode: r"; 1041 s << "Mode: r";
1044 s << "Mode: y"; 1042 s << "Mode: y";
1045 s << "XmitPower: 1"; 1043 s << "XmitPower: 1";
1046 } 1044 }
1047 1045
1048 // flushing and closing will be done automatically when f goes out of scope 1046 // flushing and closing will be done automatically when f goes out of scope
1049} 1047}
1050 1048
1051 1049
1052QString OCiscoMonitoringInterface::name() const 1050QString OCiscoMonitoringInterface::name() const
1053{ 1051{
1054 return "cisco"; 1052 return "cisco";
1055} 1053}
1056 1054
1057 1055
1058void OCiscoMonitoringInterface::setChannel( int ) 1056void OCiscoMonitoringInterface::setChannel( int )
1059{ 1057{
1060 // cisco devices automatically switch channels when in monitor mode 1058 // cisco devices automatically switch channels when in monitor mode
1061} 1059}
1062 1060
1063 1061
1064/*====================================================================================== 1062/*======================================================================================
1065 * OWlanNGMonitoringInterface 1063 * OWlanNGMonitoringInterface
1066 *======================================================================================*/ 1064 *======================================================================================*/
1067 1065
1068 1066
1069OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1067OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1070 :OMonitoringInterface( iface, prismHeader ) 1068 :OMonitoringInterface( iface, prismHeader )
1071{ 1069{
1072 iface->setMonitoring( this ); 1070 iface->setMonitoring( this );
1073} 1071}
1074 1072
1075 1073
1076OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() 1074OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface()
1077{ 1075{
1078} 1076}
1079 1077
1080 1078
1081void OWlanNGMonitoringInterface::setEnabled( bool b ) 1079void OWlanNGMonitoringInterface::setEnabled( bool b )
1082{ 1080{
1083 //FIXME: do nothing if its already in the same mode 1081 //FIXME: do nothing if its already in the same mode
1084 1082
1085 QString enable = b ? "true" : "false"; 1083 QString enable = b ? "true" : "false";
1086 QString prism = _prismHeader ? "true" : "false"; 1084 QString prism = _prismHeader ? "true" : "false";
1087 QString cmd; 1085 QString cmd;
1088 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", 1086 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
1089 (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); 1087 (const char*) _if->name(), 1, (const char*) enable, (const char*) prism );
1090 system( cmd ); 1088 system( cmd );
1091} 1089}
1092 1090
1093 1091
1094QString OWlanNGMonitoringInterface::name() const 1092QString OWlanNGMonitoringInterface::name() const
1095{ 1093{
1096 return "wlan-ng"; 1094 return "wlan-ng";
1097} 1095}
1098 1096
1099 1097
1100void OWlanNGMonitoringInterface::setChannel( int c ) 1098void OWlanNGMonitoringInterface::setChannel( int c )
1101{ 1099{
1102 //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. 1100 //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't.
1103 1101
1104 QString enable = "true"; //_if->monitorMode() ? "true" : "false"; 1102 QString enable = "true"; //_if->monitorMode() ? "true" : "false";
1105 QString prism = _prismHeader ? "true" : "false"; 1103 QString prism = _prismHeader ? "true" : "false";
1106 QString cmd; 1104 QString cmd;
1107 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", 1105 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
1108 (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); 1106 (const char*) _if->name(), c, (const char*) enable, (const char*) prism );
1109 system( cmd ); 1107 system( cmd );
1110} 1108}
1111 1109
1112 1110
1113/*====================================================================================== 1111/*======================================================================================
1114 * OHostAPMonitoringInterface 1112 * OHostAPMonitoringInterface
1115 *======================================================================================*/ 1113 *======================================================================================*/
1116 1114
1117OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1115OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1118 :OMonitoringInterface( iface, prismHeader ) 1116 :OMonitoringInterface( iface, prismHeader )
1119{ 1117{
1120 iface->setMonitoring( this ); 1118 iface->setMonitoring( this );
1121} 1119}
1122 1120
1123OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 1121OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
1124{ 1122{
1125} 1123}
1126 1124
1127void OHostAPMonitoringInterface::setEnabled( bool b ) 1125void OHostAPMonitoringInterface::setEnabled( bool b )
1128{ 1126{
1129 int monitorCode = _prismHeader ? 1 : 2; 1127 int monitorCode = _prismHeader ? 1 : 2;
1130 if ( b ) 1128 if ( b )
1131 { 1129 {
1132 _if->setPrivate( "monitor", 1, monitorCode ); 1130 _if->setPrivate( "monitor", 1, monitorCode );
1133 } 1131 }
1134 else 1132 else
1135 { 1133 {
1136 _if->setPrivate( "monitor", 1, 0 ); 1134 _if->setPrivate( "monitor", 1, 0 );
1137 } 1135 }
1138} 1136}
1139 1137
1140 1138
1141QString OHostAPMonitoringInterface::name() const 1139QString OHostAPMonitoringInterface::name() const
1142{ 1140{
1143 return "hostap"; 1141 return "hostap";
1144} 1142}
1145 1143
1146 1144
1147/*====================================================================================== 1145/*======================================================================================
1148 * OOrinocoNetworkInterface 1146 * OOrinocoNetworkInterface
1149 *======================================================================================*/ 1147 *======================================================================================*/
1150 1148
1151OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1149OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1152 :OMonitoringInterface( iface, prismHeader ) 1150 :OMonitoringInterface( iface, prismHeader )
1153{ 1151{
1154 iface->setMonitoring( this ); 1152 iface->setMonitoring( this );
1155} 1153}
1156 1154
1157 1155
1158OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 1156OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
1159{ 1157{
1160} 1158}
1161 1159
1162 1160
1163void OOrinocoMonitoringInterface::setChannel( int c ) 1161void OOrinocoMonitoringInterface::setChannel( int c )
1164{ 1162{
1165 int monitorCode = _prismHeader ? 1 : 2; 1163 int monitorCode = _prismHeader ? 1 : 2;
1166 _if->setPrivate( "monitor", 2, monitorCode, c ); 1164 _if->setPrivate( "monitor", 2, monitorCode, c );
1167} 1165}
1168 1166
1169 1167
1170void OOrinocoMonitoringInterface::setEnabled( bool b ) 1168void OOrinocoMonitoringInterface::setEnabled( bool b )
1171{ 1169{
1172 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 1170 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
1173 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 1171 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
1174 // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported 1172 // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported
1175 1173
1176 if ( b ) 1174 if ( b )
1177 { 1175 {
1178 setChannel( 1 ); 1176 setChannel( 1 );
1179 } 1177 }
1180 else 1178 else
1181 { 1179 {
1182 _if->setPrivate( "monitor", 2, 0, 0 ); 1180 _if->setPrivate( "monitor", 2, 0, 0 );
1183 } 1181 }
1184} 1182}
1185 1183
1186 1184
1187QString OOrinocoMonitoringInterface::name() const 1185QString OOrinocoMonitoringInterface::name() const
1188{ 1186{
1189 return "orinoco"; 1187 return "orinoco";
1190} 1188}
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index eb6c86e..bc9e299 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -1,542 +1,539 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 4 =.
8 .=l. 5 .=l.
9           .>+-= 6           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 13    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 20++=   -.     .`     .: details.
24 :     =  ...= . :.=- 21 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
31 28
32*/ 29*/
33 30
34#ifndef ONETWORK_H 31#ifndef ONETWORK_H
35#define ONETWORK_H 32#define ONETWORK_H
36 33
37#include "wireless.h" 34#include "wireless.h"
38 35
39/* OPIE */ 36/* OPIE */
40 37
41#include <opie2/onetutils.h> 38#include <opie2/onetutils.h>
42#include <opie2/ostation.h> 39#include <opie2/ostation.h>
43 40
44/* QT */ 41/* QT */
45 42
46#include <qvaluelist.h> 43#include <qvaluelist.h>
47#include <qdict.h> 44#include <qdict.h>
48#include <qmap.h> 45#include <qmap.h>
49#include <qobject.h> 46#include <qobject.h>
50#include <qhostaddress.h> 47#include <qhostaddress.h>
51 48
52class ONetworkInterface; 49class ONetworkInterface;
53class OWirelessNetworkInterface; 50class OWirelessNetworkInterface;
54class OChannelHopper; 51class OChannelHopper;
55class OMonitoringInterface; 52class OMonitoringInterface;
56 53
57/*====================================================================================== 54/*======================================================================================
58 * ONetwork 55 * ONetwork
59 *======================================================================================*/ 56 *======================================================================================*/
60 57
61/** 58/**
62 * @brief A container class for all network interfaces 59 * @brief A container class for all network interfaces
63 * 60 *
64 * This class provides access to all available network interfaces of your computer. 61 * This class provides access to all available network interfaces of your computer.
65 * 62 *
66 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 63 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
67 */ 64 */
68class ONetwork : public QObject 65class ONetwork : public QObject
69{ 66{
70 Q_OBJECT 67 Q_OBJECT
71 68
72 public: 69 public:
73 typedef QDict<ONetworkInterface> InterfaceMap; 70 typedef QDict<ONetworkInterface> InterfaceMap;
74 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 71 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
75 72
76 public: 73 public:
77 /** 74 /**
78 * @returns the number of available interfaces 75 * @returns the number of available interfaces
79 */ 76 */
80 int count() const; 77 int count() const;
81 /** 78 /**
82 * @returns a pointer to the (one and only) @ref ONetwork instance. 79 * @returns a pointer to the (one and only) @ref ONetwork instance.
83 */ 80 */
84 static ONetwork* instance(); 81 static ONetwork* instance();
85 /** 82 /**
86 * @returns an iterator usable for iterating through all network interfaces. 83 * @returns an iterator usable for iterating through all network interfaces.
87 */ 84 */
88 InterfaceIterator iterator() const; 85 InterfaceIterator iterator() const;
89 /** 86 /**
90 * @returns true, if the @a interface supports the wireless extension protocol. 87 * @returns true, if the @a interface supports the wireless extension protocol.
91 */ 88 */
92 bool isWirelessInterface( const char* interface ) const; 89 bool isWirelessInterface( const char* interface ) const;
93 /** 90 /**
94 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. 91 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found.
95 * @see ONetworkInterface 92 * @see ONetworkInterface
96 */ 93 */
97 ONetworkInterface* interface( const QString& interface ) const; 94 ONetworkInterface* interface( const QString& interface ) const;
98 /** 95 /**
99 * @internal Rebuild the internal interface database 96 * @internal Rebuild the internal interface database
100 * @note Sometimes it might be useful to call this from client code, 97 * @note Sometimes it might be useful to call this from client code,
101 * e.g. after issuing a cardctl insert 98 * e.g. after issuing a cardctl insert
102 */ 99 */
103 void synchronize(); 100 void synchronize();
104 /** 101 /**
105 * @returns the wireless extension version used at compile time. 102 * @returns the wireless extension version used at compile time.
106 **/ 103 **/
107 static short wirelessExtensionVersion(); 104 static short wirelessExtensionVersion();
108 105
109 protected: 106 protected:
110 ONetwork(); 107 ONetwork();
111 108
112 private: 109 private:
113 static ONetwork* _instance; 110 static ONetwork* _instance;
114 InterfaceMap _interfaces; 111 InterfaceMap _interfaces;
115}; 112};
116 113
117 114
118/*====================================================================================== 115/*======================================================================================
119 * ONetworkInterface 116 * ONetworkInterface
120 *======================================================================================*/ 117 *======================================================================================*/
121 118
122/** 119/**
123 * @brief A network interface wrapper. 120 * @brief A network interface wrapper.
124 * 121 *
125 * This class provides a wrapper for a network interface. All the cumbersume details of 122 * This class provides a wrapper for a network interface. All the cumbersume details of
126 * Linux ioctls are hidden under a convenient high-level interface. 123 * Linux ioctls are hidden under a convenient high-level interface.
127 * @warning Most of the setting methods contained in this class require the appropriate 124 * @warning Most of the setting methods contained in this class require the appropriate
128 * process permissions to work. 125 * process permissions to work.
129 * 126 *
130 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 127 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
131 */ 128 */
132class ONetworkInterface : public QObject 129class ONetworkInterface : public QObject
133{ 130{
134 friend class OMonitoringInterface; 131 friend class OMonitoringInterface;
135 friend class OCiscoMonitoringInterface; 132 friend class OCiscoMonitoringInterface;
136 friend class OWlanNGMonitoringInterface; 133 friend class OWlanNGMonitoringInterface;
137 friend class OHostAPMonitoringInterface; 134 friend class OHostAPMonitoringInterface;
138 friend class OOrinocoMonitoringInterface; 135 friend class OOrinocoMonitoringInterface;
139 136
140 public: 137 public:
141 /** 138 /**
142 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, 139 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself,
143 * but access them via @ref ONetwork::interface(). 140 * but access them via @ref ONetwork::interface().
144 */ 141 */
145 ONetworkInterface( QObject* parent, const char* name ); 142 ONetworkInterface( QObject* parent, const char* name );
146 /** 143 /**
147 * Destructor. 144 * Destructor.
148 */ 145 */
149 virtual ~ONetworkInterface(); 146 virtual ~ONetworkInterface();
150 /** 147 /**
151 * Associates a @a monitoring interface with this network interface. 148 * Associates a @a monitoring interface with this network interface.
152 * @note This is currently only useful with @ref OWirelessNetworkInterface objects. 149 * @note This is currently only useful with @ref OWirelessNetworkInterface objects.
153 */ 150 */
154 void setMonitoring( OMonitoringInterface* monitoring ); 151 void setMonitoring( OMonitoringInterface* monitoring );
155 /** 152 /**
156 * @returns the currently associated monitoring interface or 0, if no monitoring is associated. 153 * @returns the currently associated monitoring interface or 0, if no monitoring is associated.
157 */ 154 */
158 OMonitoringInterface* monitoring() const; 155 OMonitoringInterface* monitoring() const;
159 /** 156 /**
160 * Setting an interface to promiscuous mode enables the device to receive 157 * Setting an interface to promiscuous mode enables the device to receive
161 * all packets on the shared medium - as opposed to packets which are addressed to this interface. 158 * all packets on the shared medium - as opposed to packets which are addressed to this interface.
162 */ 159 */
163 bool setPromiscuousMode( bool ); 160 bool setPromiscuousMode( bool );
164 /** 161 /**
165 * @returns true if the interface is set to promiscuous mode. 162 * @returns true if the interface is set to promiscuous mode.
166 */ 163 */
167 bool promiscuousMode() const; 164 bool promiscuousMode() const;
168 /** 165 /**
169 * Setting an interface to up enables it to receive packets. 166 * Setting an interface to up enables it to receive packets.
170 */ 167 */
171 bool setUp( bool ); 168 bool setUp( bool );
172 /** 169 /**
173 * @returns true if the interface is up. 170 * @returns true if the interface is up.
174 */ 171 */
175 bool isUp() const; 172 bool isUp() const;
176 /** 173 /**
177 * @returns true if the interface is a loopback interface. 174 * @returns true if the interface is a loopback interface.
178 */ 175 */
179 bool isLoopback() const; 176 bool isLoopback() const;
180 /** 177 /**
181 * @returns true if the interface is featuring supports the wireless extension protocol. 178 * @returns true if the interface is featuring supports the wireless extension protocol.
182 */ 179 */
183 bool isWireless() const; 180 bool isWireless() const;
184 /** 181 /**
185 * Associate the IP address @ addr with the interface. 182 * Associate the IP address @ addr with the interface.
186 */ 183 */
187 void setIPV4Address( const QHostAddress& addr ); 184 void setIPV4Address( const QHostAddress& addr );
188 /** 185 /**
189 * @returns the IPv4 address associated with the interface. 186 * @returns the IPv4 address associated with the interface.
190 */ 187 */
191 QString ipV4Address() const; //TODO: make this return an OHostAddress 188 QString ipV4Address() const; //TODO: make this return an OHostAddress
192 /** 189 /**
193 * Associate the MAC address @a addr with the interface. 190 * Associate the MAC address @a addr with the interface.
194 * @note It can be necessary to shut down the interface prior to calling this method. 191 * @note It can be necessary to shut down the interface prior to calling this method.
195 * @warning This is not supported by all drivers. 192 * @warning This is not supported by all drivers.
196 */ 193 */
197 void setMacAddress( const OMacAddress& addr ); 194 void setMacAddress( const OMacAddress& addr );
198 /** 195 /**
199 * @returns the MAC address associated with the interface. 196 * @returns the MAC address associated with the interface.
200 */ 197 */
201 OMacAddress macAddress() const; 198 OMacAddress macAddress() const;
202 /** 199 /**
203 * Associate the IPv4 @a netmask with the interface. 200 * Associate the IPv4 @a netmask with the interface.
204 */ 201 */
205 void setIPV4Netmask( const QHostAddress& netmask ); 202 void setIPV4Netmask( const QHostAddress& netmask );
206 /** 203 /**
207 * @returns the IPv4 netmask associated with the interface. 204 * @returns the IPv4 netmask associated with the interface.
208 */ 205 */
209 QString ipV4Netmask() const; //TODO: make this return an OHostAddress 206 QString ipV4Netmask() const; //TODO: make this return an OHostAddress
210 /** 207 /**
211 * @returns the data link type currently associated with the interface. 208 * @returns the data link type currently associated with the interface.
212 * @see #include <net/if_arp.h> for possible values. 209 * @see #include <net/if_arp.h> for possible values.
213 */ 210 */
214 int dataLinkType() const; 211 int dataLinkType() const;
215 212
216 protected: 213 protected:
217 const int _sfd; 214 const int _sfd;
218 mutable ifreq _ifr; 215 mutable ifreq _ifr;
219 OMonitoringInterface* _mon; 216 OMonitoringInterface* _mon;
220 217
221 protected: 218 protected:
222 struct ifreq& ifr() const; 219 struct ifreq& ifr() const;
223 virtual void init(); 220 virtual void init();
224 bool ioctl( int call ) const; 221 bool ioctl( int call ) const;
225 bool ioctl( int call, struct ifreq& ) const; 222 bool ioctl( int call, struct ifreq& ) const;
226}; 223};
227 224
228/*====================================================================================== 225/*======================================================================================
229 * OChannelHopper 226 * OChannelHopper
230 *======================================================================================*/ 227 *======================================================================================*/
231 228
232/** 229/**
233 * @brief A radio frequency channel hopper. 230 * @brief A radio frequency channel hopper.
234 * 231 *
235 * This class provides a channel hopper for radio frequencies. A channel hopper frequently 232 * This class provides a channel hopper for radio frequencies. A channel hopper frequently
236 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. 233 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface.
237 * This is necessary when in monitoring mode and scanning for other devices, because 234 * This is necessary when in monitoring mode and scanning for other devices, because
238 * the radio frequency hardware can only detect packets sent on the same frequency. 235 * the radio frequency hardware can only detect packets sent on the same frequency.
239 * 236 *
240 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 237 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
241 */ 238 */
242class OChannelHopper : public QObject 239class OChannelHopper : public QObject
243{ 240{
244 Q_OBJECT 241 Q_OBJECT
245 242
246 public: 243 public:
247 /** 244 /**
248 * Constructor. 245 * Constructor.
249 */ 246 */
250 OChannelHopper( OWirelessNetworkInterface* ); 247 OChannelHopper( OWirelessNetworkInterface* );
251 /** 248 /**
252 * Destructor. 249 * Destructor.
253 */ 250 */
254 virtual ~OChannelHopper(); 251 virtual ~OChannelHopper();
255 /** 252 /**
256 * @returns true, if the channel hopper is hopping channels 253 * @returns true, if the channel hopper is hopping channels
257 */ 254 */
258 bool isActive() const; 255 bool isActive() const;
259 /** 256 /**
260 * @returns the last hopped channel 257 * @returns the last hopped channel
261 */ 258 */
262 int channel() const; 259 int channel() const;
263 /** 260 /**
264 * Set the channel hopping @a interval. 261 * Set the channel hopping @a interval.
265 * An interval of 0 deactivates the channel hopper. 262 * An interval of 0 deactivates the channel hopper.
266 */ 263 */
267 void setInterval( int interval ); 264 void setInterval( int interval );
268 /** 265 /**
269 * @returns the channel hopping interval 266 * @returns the channel hopping interval
270 */ 267 */
271 int interval() const; 268 int interval() const;
272 269
273 signals: 270 signals:
274 /** 271 /**
275 * This signal is emitted right after the channel hopper performed a hop 272 * This signal is emitted right after the channel hopper performed a hop
276 */ 273 */
277 void hopped( int ); 274 void hopped( int );
278 275
279 protected: 276 protected:
280 virtual void timerEvent( QTimerEvent* ); 277 virtual void timerEvent( QTimerEvent* );
281 278
282 private: 279 private:
283 OWirelessNetworkInterface* _iface; 280 OWirelessNetworkInterface* _iface;
284 int _interval; 281 int _interval;
285 int _tid; 282 int _tid;
286 QValueList<int> _channels; 283 QValueList<int> _channels;
287 QValueList<int>::Iterator _channel; 284 QValueList<int>::Iterator _channel;
288}; 285};
289 286
290 287
291/*====================================================================================== 288/*======================================================================================
292 * OWirelessNetworkInterface 289 * OWirelessNetworkInterface
293 *======================================================================================*/ 290 *======================================================================================*/
294 291
295/** 292/**
296 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. 293 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol.
297 * 294 *
298 * This class provides a high-level encapsulation of the Linux wireless extension API. 295 * This class provides a high-level encapsulation of the Linux wireless extension API.
299 * 296 *
300 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 297 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
301 */ 298 */
302class OWirelessNetworkInterface : public ONetworkInterface 299class OWirelessNetworkInterface : public ONetworkInterface
303{ 300{
304 friend class OMonitoringInterface; 301 friend class OMonitoringInterface;
305 friend class OCiscoMonitoringInterface; 302 friend class OCiscoMonitoringInterface;
306 friend class OWlanNGMonitoringInterface; 303 friend class OWlanNGMonitoringInterface;
307 friend class OHostAPMonitoringInterface; 304 friend class OHostAPMonitoringInterface;
308 friend class OOrinocoMonitoringInterface; 305 friend class OOrinocoMonitoringInterface;
309 306
310 friend class OPrivateIOCTL; 307 friend class OPrivateIOCTL;
311 308
312 public: 309 public:
313 /** 310 /**
314 * Constructor. 311 * Constructor.
315 */ 312 */
316 OWirelessNetworkInterface( QObject* parent, const char* name ); 313 OWirelessNetworkInterface( QObject* parent, const char* name );
317 /** 314 /**
318 * Destructor. 315 * Destructor.
319 */ 316 */
320 virtual ~OWirelessNetworkInterface(); 317 virtual ~OWirelessNetworkInterface();
321 /** 318 /**
322 * Setting the @a channel of the interface changes the radio frequency (RF) 319 * Setting the @a channel of the interface changes the radio frequency (RF)
323 * of the corresponding wireless network device. 320 * of the corresponding wireless network device.
324 * @note Common channel range is within [1-14]. A value of 0 is not allowed. 321 * @note Common channel range is within [1-14]. A value of 0 is not allowed.
325 * @see channels() 322 * @see channels()
326 */ 323 */
327 virtual void setChannel( int channel ) const; 324 virtual void setChannel( int channel ) const;
328 /** 325 /**
329 * @returns the channel index of the current radio frequency. 326 * @returns the channel index of the current radio frequency.
330 */ 327 */
331 virtual int channel() const; 328 virtual int channel() const;
332 /** 329 /**
333 * @returns the current radio frequency (in MHz). 330 * @returns the current radio frequency (in MHz).
334 */ 331 */
335 virtual double frequency() const; 332 virtual double frequency() const;
336 /** 333 /**
337 * @returns the number of radio frequency channels for the 334 * @returns the number of radio frequency channels for the
338 * corresponding wireless network device. 335 * corresponding wireless network device.
339 * @note European devices usually have 14 channels, while American typically feature 11 channels. 336 * @note European devices usually have 14 channels, while American typically feature 11 channels.
340 */ 337 */
341 virtual int channels() const; 338 virtual int channels() const;
342 /** 339 /**
343 * Set the IEEE 802.11 operation @a mode. 340 * Set the IEEE 802.11 operation @a mode.
344 * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master 341 * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master
345 * @warning Not all drivers support the all modes. 342 * @warning Not all drivers support the all modes.
346 * @note You might have to change the SSID to get the operation mode change into effect. 343 * @note You might have to change the SSID to get the operation mode change into effect.
347 */ 344 */
348 virtual void setMode( const QString& mode ); 345 virtual void setMode( const QString& mode );
349 /** 346 /**
350 * @returns the current IEEE 802.11 operation mode. 347 * @returns the current IEEE 802.11 operation mode.
351 * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown 348 * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown
352 * 349 *
353 * @note: Important note concerning the 'monitor' mode: 350 * @note: Important note concerning the 'monitor' mode:
354 * Setting the monitor mode on a wireless network interface enables 351 * Setting the monitor mode on a wireless network interface enables
355 * listening to IEEE 802.11 data and management frames which normally 352 * listening to IEEE 802.11 data and management frames which normally
356 * are handled by the device firmware. This can be used to detect 353 * are handled by the device firmware. This can be used to detect
357 * other wireless network devices, e.g. Access Points or Ad-hoc stations. 354 * other wireless network devices, e.g. Access Points or Ad-hoc stations.
358 * @warning Standard wireless network drives don't support the monitor mode. 355 * @warning Standard wireless network drives don't support the monitor mode.
359 * @warning You need a patched driver for this to work. 356 * @warning You need a patched driver for this to work.
360 * @note Enabling the monitor mode is highly driver dependent and requires 357 * @note Enabling the monitor mode is highly driver dependent and requires
361 * the proper @ref OMonitoringInterface to be associated with the interface. 358 * the proper @ref OMonitoringInterface to be associated with the interface.
362 * @see OMonitoringInterface 359 * @see OMonitoringInterface
363 */ 360 */
364 virtual QString mode() const; 361 virtual QString mode() const;
365 /** 362 /**
366 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. 363 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping.
367 * @see OChannelHopper 364 * @see OChannelHopper
368 */ 365 */
369 virtual void setChannelHopping( int interval = 0 ); 366 virtual void setChannelHopping( int interval = 0 );
370 /** 367 /**
371 * @returns the channel hopping interval or 0, if channel hopping is disabled. 368 * @returns the channel hopping interval or 0, if channel hopping is disabled.
372 */ 369 */
373 virtual int channelHopping() const; 370 virtual int channelHopping() const;
374 /** 371 /**
375 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before 372 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before
376 */ 373 */
377 virtual OChannelHopper* channelHopper() const; 374 virtual OChannelHopper* channelHopper() const;
378 /** 375 /**
379 * Set the station @a nickname. 376 * Set the station @a nickname.
380 */ 377 */
381 virtual void setNickName( const QString& nickname ); 378 virtual void setNickName( const QString& nickname );
382 /** 379 /**
383 * @returns the current station nickname. 380 * @returns the current station nickname.
384 */ 381 */
385 virtual QString nickName() const; 382 virtual QString nickName() const;
386 /** 383 /**
387 * Invoke the private IOCTL @a command with a @number of parameters on the network interface. 384 * Invoke the private IOCTL @a command with a @number of parameters on the network interface.
388 * @see OPrivateIOCTL 385 * @see OPrivateIOCTL
389 */ 386 */
390 virtual void setPrivate( const QString& command, int number, ... ); 387 virtual void setPrivate( const QString& command, int number, ... );
391 /** 388 /**
392 * @returns true if the interface is featuring the private IOCTL @command. 389 * @returns true if the interface is featuring the private IOCTL @command.
393 */ 390 */
394 virtual bool hasPrivate( const QString& command ); 391 virtual bool hasPrivate( const QString& command );
395 virtual void getPrivate( const QString& command ); //FIXME: Implement and document this 392 virtual void getPrivate( const QString& command ); //FIXME: Implement and document this
396 /** 393 /**
397 * @returns true if the interface is associated to an access point 394 * @returns true if the interface is associated to an access point
398 * @note: This information is only valid if the interface is in managed mode. 395 * @note: This information is only valid if the interface is in managed mode.
399 */ 396 */
400 virtual bool isAssociated() const; 397 virtual bool isAssociated() const;
401 /** 398 /**
402 * @returns the MAC address of the Access Point if the device is in infrastructure mode. 399 * @returns the MAC address of the Access Point if the device is in infrastructure mode.
403 * @returns a (more or less random) cell ID address if the device is in adhoc mode. 400 * @returns a (more or less random) cell ID address if the device is in adhoc mode.
404 */ 401 */
405 virtual OMacAddress associatedAP() const; 402 virtual OMacAddress associatedAP() const;
406 /** 403 /**
407 * Set the @a ssid (Service Set ID) string. This is used to decide 404 * Set the @a ssid (Service Set ID) string. This is used to decide
408 * which network to associate with (use "any" to let the driver decide). 405 * which network to associate with (use "any" to let the driver decide).
409 */ 406 */
410 virtual void setSSID( const QString& ssid ); 407 virtual void setSSID( const QString& ssid );
411 /** 408 /**
412 * @returns the current SSID (Service Set ID). 409 * @returns the current SSID (Service Set ID).
413 */ 410 */
414 virtual QString SSID() const; 411 virtual QString SSID() const;
415 /** 412 /**
416 * Perform scanning the wireless network neighbourhood. 413 * Perform scanning the wireless network neighbourhood.
417 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! 414 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE!
418 */ 415 */
419 virtual OStationList* scanNetwork(); 416 virtual OStationList* scanNetwork();
420 /** @internal commit pending changes to the driver 417 /** @internal commit pending changes to the driver
421 * 418 *
422 */ 419 */
423 void commit() const; 420 void commit() const;
424 421
425 protected: 422 protected:
426 void buildInformation(); 423 void buildInformation();
427 void buildPrivateList(); 424 void buildPrivateList();
428 void dumpInformation() const; 425 void dumpInformation() const;
429 virtual void init(); 426 virtual void init();
430 struct iwreq& iwr() const; 427 struct iwreq& iwr() const;
431 bool wioctl( int call ) const; 428 bool wioctl( int call ) const;
432 bool wioctl( int call, struct iwreq& ) const; 429 bool wioctl( int call, struct iwreq& ) const;
433 430
434 protected: 431 protected:
435 mutable struct iwreq _iwr; 432 mutable struct iwreq _iwr;
436 QMap<int,int> _channels; 433 QMap<int,int> _channels;
437 struct iw_range _range; 434 struct iw_range _range;
438 435
439 private: 436 private:
440 OChannelHopper* _hopper; 437 OChannelHopper* _hopper;
441}; 438};
442 439
443 440
444/*====================================================================================== 441/*======================================================================================
445 * OMonitoringInterface 442 * OMonitoringInterface
446 *======================================================================================*/ 443 *======================================================================================*/
447 444
448 445
449class OMonitoringInterface 446class OMonitoringInterface
450{ 447{
451 public: 448 public:
452 OMonitoringInterface(); 449 OMonitoringInterface();
453 OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 450 OMonitoringInterface( ONetworkInterface*, bool _prismHeader );
454 virtual ~OMonitoringInterface(); 451 virtual ~OMonitoringInterface();
455 452
456 public: 453 public:
457 virtual void setEnabled( bool ); 454 virtual void setEnabled( bool );
458 virtual void setChannel( int ); 455 virtual void setChannel( int );
459 456
460 virtual QString name() const = 0; 457 virtual QString name() const = 0;
461 458
462 protected: 459 protected:
463 OWirelessNetworkInterface* _if; 460 OWirelessNetworkInterface* _if;
464 bool _prismHeader; 461 bool _prismHeader;
465 462
466}; 463};
467 464
468 465
469/*====================================================================================== 466/*======================================================================================
470 * OCiscoMonitoring 467 * OCiscoMonitoring
471 *======================================================================================*/ 468 *======================================================================================*/
472 469
473 470
474class OCiscoMonitoringInterface : public OMonitoringInterface 471class OCiscoMonitoringInterface : public OMonitoringInterface
475{ 472{
476 public: 473 public:
477 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 474 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
478 virtual ~OCiscoMonitoringInterface(); 475 virtual ~OCiscoMonitoringInterface();
479 476
480 virtual void setEnabled( bool ); 477 virtual void setEnabled( bool );
481 virtual QString name() const; 478 virtual QString name() const;
482 virtual void setChannel( int ); 479 virtual void setChannel( int );
483 480
484}; 481};
485 482
486 483
487/*====================================================================================== 484/*======================================================================================
488 * OWlanNGMonitoringInterface 485 * OWlanNGMonitoringInterface
489 *======================================================================================*/ 486 *======================================================================================*/
490 487
491 488
492class OWlanNGMonitoringInterface : public OMonitoringInterface 489class OWlanNGMonitoringInterface : public OMonitoringInterface
493{ 490{
494 public: 491 public:
495 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 492 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader );
496 virtual ~OWlanNGMonitoringInterface(); 493 virtual ~OWlanNGMonitoringInterface();
497 494
498 public: 495 public:
499 virtual void setEnabled( bool ); 496 virtual void setEnabled( bool );
500 virtual QString name() const; 497 virtual QString name() const;
501 virtual void setChannel( int ); 498 virtual void setChannel( int );
502 499
503}; 500};
504 501
505 502
506/*====================================================================================== 503/*======================================================================================
507 * OHostAPMonitoringInterface 504 * OHostAPMonitoringInterface
508 *======================================================================================*/ 505 *======================================================================================*/
509 506
510 507
511class OHostAPMonitoringInterface : public OMonitoringInterface 508class OHostAPMonitoringInterface : public OMonitoringInterface
512{ 509{
513 public: 510 public:
514 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 511 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader );
515 virtual ~OHostAPMonitoringInterface(); 512 virtual ~OHostAPMonitoringInterface();
516 513
517 public: 514 public:
518 virtual void setEnabled( bool ); 515 virtual void setEnabled( bool );
519 virtual QString name() const; 516 virtual QString name() const;
520 }; 517 };
521 518
522 519
523/*====================================================================================== 520/*======================================================================================
524 * OOrinocoMonitoringInterface 521 * OOrinocoMonitoringInterface
525 *======================================================================================*/ 522 *======================================================================================*/
526 523
527 524
528class OOrinocoMonitoringInterface : public OMonitoringInterface 525class OOrinocoMonitoringInterface : public OMonitoringInterface
529{ 526{
530 public: 527 public:
531 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 528 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
532 virtual ~OOrinocoMonitoringInterface(); 529 virtual ~OOrinocoMonitoringInterface();
533 530
534 public: 531 public:
535 virtual void setChannel( int ); 532 virtual void setChannel( int );
536 virtual void setEnabled( bool ); 533 virtual void setEnabled( bool );
537 virtual QString name() const; 534 virtual QString name() const;
538 535
539}; 536};
540 537
541#endif // ONETWORK_H 538#endif // ONETWORK_H
542 539
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 6331b2d..635224c 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -1,1323 +1,1320 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 4 =.
8 .=l. 5 .=l.
9           .>+-= 6           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 13    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 20++=   -.     .`     .: details.
24 :     =  ...= . :.=- 21 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
31 28
32*/ 29*/
33 30
34/* OPIE */ 31/* OPIE */
35#include <opie2/opcap.h> 32#include <opie2/opcap.h>
36 33
37/* QT */ 34/* QT */
38#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) 35#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
39#include <qsocketnotifier.h> 36#include <qsocketnotifier.h>
40#include <qobjectlist.h> 37#include <qobjectlist.h>
41 38
42/* SYSTEM */ 39/* SYSTEM */
43#include <sys/time.h> 40#include <sys/time.h>
44#include <sys/types.h> 41#include <sys/types.h>
45#include <unistd.h> 42#include <unistd.h>
46 43
47/* LOCAL */ 44/* LOCAL */
48#include "udp_ports.h" 45#include "udp_ports.h"
49 46
50/*====================================================================================== 47/*======================================================================================
51 * OPacket 48 * OPacket
52 *======================================================================================*/ 49 *======================================================================================*/
53 50
54OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) 51OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
55 :QObject( parent, "Generic" ), _hdr( header ), _data( data ) 52 :QObject( parent, "Generic" ), _hdr( header ), _data( data )
56{ 53{
57 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); 54 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
58 55
59 _end = (unsigned char*) data + header.len; 56 _end = (unsigned char*) data + header.len;
60 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); 57 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end );
61 58
62 switch ( datalink ) 59 switch ( datalink )
63 { 60 {
64 case DLT_EN10MB: 61 case DLT_EN10MB:
65 qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); 62 qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" );
66 new OEthernetPacket( _end, (const struct ether_header*) data, this ); 63 new OEthernetPacket( _end, (const struct ether_header*) data, this );
67 break; 64 break;
68 65
69 case DLT_IEEE802_11: 66 case DLT_IEEE802_11:
70 qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); 67 qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" );
71 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); 68 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this );
72 break; 69 break;
73 70
74 case DLT_PRISM_HEADER: 71 case DLT_PRISM_HEADER:
75 qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" ); 72 qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" );
76 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); 73 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this );
77 break; 74 break;
78 75
79 default: 76 default:
80 qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink ); 77 qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink );
81 } 78 }
82} 79}
83 80
84 81
85OPacket::~OPacket() 82OPacket::~OPacket()
86{ 83{
87} 84}
88 85
89 86
90timevalstruct OPacket::timeval() const 87timevalstruct OPacket::timeval() const
91{ 88{
92 return _hdr.ts; 89 return _hdr.ts;
93} 90}
94 91
95 92
96int OPacket::caplen() const 93int OPacket::caplen() const
97{ 94{
98 return _hdr.caplen; 95 return _hdr.caplen;
99} 96}
100 97
101 98
102void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) 99void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l )
103{ 100{
104 if (!l) return; 101 if (!l) return;
105 QObject* o = l->first(); 102 QObject* o = l->first();
106 while ( o ) 103 while ( o )
107 { 104 {
108 stats[o->name()]++; 105 stats[o->name()]++;
109 updateStats( stats, const_cast<QObjectList*>( o->children() ) ); 106 updateStats( stats, const_cast<QObjectList*>( o->children() ) );
110 o = l->next(); 107 o = l->next();
111 } 108 }
112} 109}
113 110
114 111
115void OPacket::dumpStructure( QObjectList* l ) 112void OPacket::dumpStructure( QObjectList* l )
116{ 113{
117 QString packetString( "[ |" + _dumpStructure( l ) + " ]" ); 114 QString packetString( "[ |" + _dumpStructure( l ) + " ]" );
118 qDebug( "OPacket::dumpStructure: %s", (const char*) packetString ); 115 qDebug( "OPacket::dumpStructure: %s", (const char*) packetString );
119} 116}
120 117
121 118
122QString OPacket::_dumpStructure( QObjectList* l ) 119QString OPacket::_dumpStructure( QObjectList* l )
123{ 120{
124 if (!l) return QString::null; 121 if (!l) return QString::null;
125 QObject* o = l->first(); 122 QObject* o = l->first();
126 QString str(" "); 123 QString str(" ");
127 124
128 while ( o ) 125 while ( o )
129 { 126 {
130 str.append( o->name() ); 127 str.append( o->name() );
131 str.append( " |" ); 128 str.append( " |" );
132 str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); 129 str += _dumpStructure( const_cast<QObjectList*>( o->children() ) );
133 o = l->next(); 130 o = l->next();
134 } 131 }
135 return str; 132 return str;
136} 133}
137 134
138QString OPacket::dump( int bpl ) const 135QString OPacket::dump( int bpl ) const
139{ 136{
140 static int index = 0; 137 static int index = 0;
141 index++; 138 index++;
142 int len = _hdr.caplen; 139 int len = _hdr.caplen;
143 QString str; 140 QString str;
144 str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); 141 str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len );
145 str.append( "0000: " ); 142 str.append( "0000: " );
146 QString tmp; 143 QString tmp;
147 QString bytes; 144 QString bytes;
148 QString chars; 145 QString chars;
149 146
150 for ( int i = 0; i < len; ++i ) 147 for ( int i = 0; i < len; ++i )
151 { 148 {
152 tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); 149 tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp );
153 if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); 150 if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] );
154 else chars.append( '.' ); 151 else chars.append( '.' );
155 152
156 if ( !((i+1) % bpl) ) 153 if ( !((i+1) % bpl) )
157 { 154 {
158 str.append( bytes ); 155 str.append( bytes );
159 str.append( ' ' ); 156 str.append( ' ' );
160 str.append( chars ); 157 str.append( chars );
161 str.append( '\n' ); 158 str.append( '\n' );
162 tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); 159 tmp.sprintf( "%04X: ", i+1 ); str.append( tmp );
163 bytes = ""; 160 bytes = "";
164 chars = ""; 161 chars = "";
165 } 162 }
166 163
167 } 164 }
168 if ( (len % bpl) ) 165 if ( (len % bpl) )
169 { 166 {
170 str.append( bytes.leftJustify( 1 + 3*bpl ) ); 167 str.append( bytes.leftJustify( 1 + 3*bpl ) );
171 str.append( chars ); 168 str.append( chars );
172 } 169 }
173 str.append( '\n' ); 170 str.append( '\n' );
174 return str; 171 return str;
175} 172}
176 173
177 174
178int OPacket::len() const 175int OPacket::len() const
179{ 176{
180 return _hdr.len; 177 return _hdr.len;
181} 178}
182 179
183 180
184/*====================================================================================== 181/*======================================================================================
185 * OEthernetPacket 182 * OEthernetPacket
186 *======================================================================================*/ 183 *======================================================================================*/
187 184
188OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) 185OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent )
189 :QObject( parent, "Ethernet" ), _ether( data ) 186 :QObject( parent, "Ethernet" ), _ether( data )
190{ 187{
191 188
192 qDebug( "Source = %s", (const char*) sourceAddress().toString() ); 189 qDebug( "Source = %s", (const char*) sourceAddress().toString() );
193 qDebug( "Destination = %s", (const char*) destinationAddress().toString() ); 190 qDebug( "Destination = %s", (const char*) destinationAddress().toString() );
194 191
195 if ( sourceAddress() == OMacAddress::broadcast ) 192 if ( sourceAddress() == OMacAddress::broadcast )
196 qDebug( "Source is broadcast address" ); 193 qDebug( "Source is broadcast address" );
197 if ( destinationAddress() == OMacAddress::broadcast ) 194 if ( destinationAddress() == OMacAddress::broadcast )
198 qDebug( "Destination is broadcast address" ); 195 qDebug( "Destination is broadcast address" );
199 196
200 switch ( type() ) 197 switch ( type() )
201 { 198 {
202 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 199 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
203 case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; 200 case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
204 case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; } 201 case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; }
205 default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" ); 202 default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" );
206 } 203 }
207 204
208} 205}
209 206
210 207
211OEthernetPacket::~OEthernetPacket() 208OEthernetPacket::~OEthernetPacket()
212{ 209{
213} 210}
214 211
215 212
216OMacAddress OEthernetPacket::sourceAddress() const 213OMacAddress OEthernetPacket::sourceAddress() const
217{ 214{
218 return OMacAddress( _ether->ether_shost ); 215 return OMacAddress( _ether->ether_shost );
219} 216}
220 217
221 218
222OMacAddress OEthernetPacket::destinationAddress() const 219OMacAddress OEthernetPacket::destinationAddress() const
223{ 220{
224 return OMacAddress( _ether->ether_dhost ); 221 return OMacAddress( _ether->ether_dhost );
225} 222}
226 223
227int OEthernetPacket::type() const 224int OEthernetPacket::type() const
228{ 225{
229 return ntohs( _ether->ether_type ); 226 return ntohs( _ether->ether_type );
230} 227}
231 228
232 229
233/*====================================================================================== 230/*======================================================================================
234 * OIPPacket 231 * OIPPacket
235 *======================================================================================*/ 232 *======================================================================================*/
236 233
237 234
238OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) 235OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent )
239 :QObject( parent, "IP" ), _iphdr( data ) 236 :QObject( parent, "IP" ), _iphdr( data )
240{ 237{
241 qDebug( "OIPPacket::OIPPacket(): decoding IP header..." ); 238 qDebug( "OIPPacket::OIPPacket(): decoding IP header..." );
242 239
243 //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) ); 240 //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) );
244 //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) ); 241 //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) );
245 242
246 qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() ); 243 qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() );
247 qDebug( " toAddress: %s", (const char*) toIPAddress().toString() ); 244 qDebug( " toAddress: %s", (const char*) toIPAddress().toString() );
248 245
249 switch ( protocol() ) 246 switch ( protocol() )
250 { 247 {
251 case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; 248 case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break;
252 case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; 249 case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break;
253 default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() ); 250 default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() );
254 } 251 }
255 252
256} 253}
257 254
258OIPPacket::~OIPPacket() 255OIPPacket::~OIPPacket()
259{ 256{
260} 257}
261 258
262 259
263QHostAddress OIPPacket::fromIPAddress() const 260QHostAddress OIPPacket::fromIPAddress() const
264{ 261{
265 return EXTRACT_32BITS( &_iphdr->saddr ); 262 return EXTRACT_32BITS( &_iphdr->saddr );
266} 263}
267 264
268 265
269QHostAddress OIPPacket::toIPAddress() const 266QHostAddress OIPPacket::toIPAddress() const
270{ 267{
271 return EXTRACT_32BITS( &_iphdr->saddr ); 268 return EXTRACT_32BITS( &_iphdr->saddr );
272} 269}
273 270
274 271
275int OIPPacket::tos() const 272int OIPPacket::tos() const
276{ 273{
277 return _iphdr->tos; 274 return _iphdr->tos;
278} 275}
279 276
280 277
281int OIPPacket::len() const 278int OIPPacket::len() const
282{ 279{
283 return EXTRACT_16BITS( &_iphdr->tot_len ); 280 return EXTRACT_16BITS( &_iphdr->tot_len );
284} 281}
285 282
286 283
287int OIPPacket::id() const 284int OIPPacket::id() const
288{ 285{
289 return EXTRACT_16BITS( &_iphdr->id ); 286 return EXTRACT_16BITS( &_iphdr->id );
290} 287}
291 288
292 289
293int OIPPacket::offset() const 290int OIPPacket::offset() const
294{ 291{
295 return EXTRACT_16BITS( &_iphdr->frag_off ); 292 return EXTRACT_16BITS( &_iphdr->frag_off );
296} 293}
297 294
298 295
299int OIPPacket::ttl() const 296int OIPPacket::ttl() const
300{ 297{
301 return _iphdr->ttl; 298 return _iphdr->ttl;
302} 299}
303 300
304 301
305int OIPPacket::protocol() const 302int OIPPacket::protocol() const
306{ 303{
307 return _iphdr->protocol; 304 return _iphdr->protocol;
308} 305}
309 306
310 307
311int OIPPacket::checksum() const 308int OIPPacket::checksum() const
312{ 309{
313 return EXTRACT_16BITS( &_iphdr->check ); 310 return EXTRACT_16BITS( &_iphdr->check );
314} 311}
315 312
316/*====================================================================================== 313/*======================================================================================
317 * OARPPacket 314 * OARPPacket
318 *======================================================================================*/ 315 *======================================================================================*/
319 316
320 317
321OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) 318OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent )
322 :QObject( parent, "ARP" ), _arphdr( data ) 319 :QObject( parent, "ARP" ), _arphdr( data )
323{ 320{
324 qDebug( "OARPPacket::OARPPacket(): decoding ARP header..." ); 321 qDebug( "OARPPacket::OARPPacket(): decoding ARP header..." );
325 qDebug( "ARP type seems to be %02d - '%s'", EXTRACT_16BITS( &_arphdr->ar_op ), (const char*) type() ); 322 qDebug( "ARP type seems to be %02d - '%s'", EXTRACT_16BITS( &_arphdr->ar_op ), (const char*) type() );
326 qDebug( "Sender: MAC %s = IP %s", (const char*) senderMacAddress().toString(), (const char*) senderIPV4Address().toString() ); 323 qDebug( "Sender: MAC %s = IP %s", (const char*) senderMacAddress().toString(), (const char*) senderIPV4Address().toString() );
327 qDebug( "Target: MAC %s = IP %s", (const char*) targetMacAddress().toString(), (const char*) targetIPV4Address().toString() ); 324 qDebug( "Target: MAC %s = IP %s", (const char*) targetMacAddress().toString(), (const char*) targetIPV4Address().toString() );
328} 325}
329 326
330 327
331OARPPacket::~OARPPacket() 328OARPPacket::~OARPPacket()
332{ 329{
333} 330}
334 331
335 332
336QString OARPPacket::type() const 333QString OARPPacket::type() const
337{ 334{
338 switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) 335 switch ( EXTRACT_16BITS( &_arphdr->ar_op ) )
339 { 336 {
340 case 1: return "REQUEST"; 337 case 1: return "REQUEST";
341 case 2: return "REPLY"; 338 case 2: return "REPLY";
342 case 3: return "RREQUEST"; 339 case 3: return "RREQUEST";
343 case 4: return "RREPLY"; 340 case 4: return "RREPLY";
344 case 8: return "InREQUEST"; 341 case 8: return "InREQUEST";
345 case 9: return "InREPLY"; 342 case 9: return "InREPLY";
346 case 10: return "NAK"; 343 case 10: return "NAK";
347 default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>"; 344 default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>";
348 } 345 }
349} 346}
350 347
351 348
352QHostAddress OARPPacket::senderIPV4Address() const 349QHostAddress OARPPacket::senderIPV4Address() const
353{ 350{
354 return EXTRACT_32BITS( &_arphdr->ar_sip ); 351 return EXTRACT_32BITS( &_arphdr->ar_sip );
355} 352}
356 353
357 354
358QHostAddress OARPPacket::targetIPV4Address() const 355QHostAddress OARPPacket::targetIPV4Address() const
359{ 356{
360 return EXTRACT_32BITS( &_arphdr->ar_tip ); 357 return EXTRACT_32BITS( &_arphdr->ar_tip );
361} 358}
362 359
363 360
364OMacAddress OARPPacket::senderMacAddress() const 361OMacAddress OARPPacket::senderMacAddress() const
365{ 362{
366 return OMacAddress( _arphdr->ar_sha ); 363 return OMacAddress( _arphdr->ar_sha );
367} 364}
368 365
369 366
370OMacAddress OARPPacket::targetMacAddress() const 367OMacAddress OARPPacket::targetMacAddress() const
371{ 368{
372 return OMacAddress( _arphdr->ar_tha ); 369 return OMacAddress( _arphdr->ar_tha );
373} 370}
374 371
375 372
376/*====================================================================================== 373/*======================================================================================
377 * OUDPPacket 374 * OUDPPacket
378 *======================================================================================*/ 375 *======================================================================================*/
379 376
380 377
381OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) 378OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent )
382 :QObject( parent, "UDP" ), _udphdr( data ) 379 :QObject( parent, "UDP" ), _udphdr( data )
383 380
384{ 381{
385 qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); 382 qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." );
386 qDebug( "fromPort = %d", fromPort() ); 383 qDebug( "fromPort = %d", fromPort() );
387 qDebug( " toPort = %d", toPort() ); 384 qDebug( " toPort = %d", toPort() );
388 385
389 // TODO: Make this a case or a hash if we know more udp protocols 386 // TODO: Make this a case or a hash if we know more udp protocols
390 387
391 if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC || 388 if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC ||
392 toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC ) 389 toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC )
393 { 390 {
394 qDebug( "seems to be part of a DHCP conversation => creating DHCP packet." ); 391 qDebug( "seems to be part of a DHCP conversation => creating DHCP packet." );
395 new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this ); 392 new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this );
396 } 393 }
397} 394}
398 395
399 396
400OUDPPacket::~OUDPPacket() 397OUDPPacket::~OUDPPacket()
401{ 398{
402} 399}
403 400
404 401
405int OUDPPacket::fromPort() const 402int OUDPPacket::fromPort() const
406{ 403{
407 return EXTRACT_16BITS( &_udphdr->source ); 404 return EXTRACT_16BITS( &_udphdr->source );
408} 405}
409 406
410 407
411int OUDPPacket::toPort() const 408int OUDPPacket::toPort() const
412{ 409{
413 return EXTRACT_16BITS( &_udphdr->dest ); 410 return EXTRACT_16BITS( &_udphdr->dest );
414} 411}
415 412
416 413
417int OUDPPacket::length() const 414int OUDPPacket::length() const
418{ 415{
419 return EXTRACT_16BITS( &_udphdr->len ); 416 return EXTRACT_16BITS( &_udphdr->len );
420} 417}
421 418
422 419
423int OUDPPacket::checksum() const 420int OUDPPacket::checksum() const
424{ 421{
425 return EXTRACT_16BITS( &_udphdr->check ); 422 return EXTRACT_16BITS( &_udphdr->check );
426} 423}
427 424
428 425
429/*====================================================================================== 426/*======================================================================================
430 * ODHCPPacket 427 * ODHCPPacket
431 *======================================================================================*/ 428 *======================================================================================*/
432 429
433 430
434ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent ) 431ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent )
435 :QObject( parent, "DHCP" ), _dhcphdr( data ) 432 :QObject( parent, "DHCP" ), _dhcphdr( data )
436 433
437{ 434{
438 qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." ); 435 qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." );
439 qDebug( "DHCP opcode seems to be %02d - '%s'", _dhcphdr->op, isRequest() ? "REQUEST" : "REPLY" ); 436 qDebug( "DHCP opcode seems to be %02d - '%s'", _dhcphdr->op, isRequest() ? "REQUEST" : "REPLY" );
440 qDebug( "clientAddress: %s", (const char*) clientAddress().toString() ); 437 qDebug( "clientAddress: %s", (const char*) clientAddress().toString() );
441 qDebug( " yourAddress: %s", (const char*) yourAddress().toString() ); 438 qDebug( " yourAddress: %s", (const char*) yourAddress().toString() );
442 qDebug( "serverAddress: %s", (const char*) serverAddress().toString() ); 439 qDebug( "serverAddress: %s", (const char*) serverAddress().toString() );
443 qDebug( " relayAddress: %s", (const char*) relayAddress().toString() ); 440 qDebug( " relayAddress: %s", (const char*) relayAddress().toString() );
444 qDebug( "parsing DHCP options..." ); 441 qDebug( "parsing DHCP options..." );
445 442
446 _type = 0; 443 _type = 0;
447 444
448 const unsigned char* option = &_dhcphdr->options[4]; 445 const unsigned char* option = &_dhcphdr->options[4];
449 char tag = -1; 446 char tag = -1;
450 char len = -1; 447 char len = -1;
451 448
452 while ( ( tag = *option++ ) != -1 /* end of option field */ ) 449 while ( ( tag = *option++ ) != -1 /* end of option field */ )
453 { 450 {
454 len = *option++; 451 len = *option++;
455 qDebug( "recognized DHCP option #%d, length %d", tag, len ); 452 qDebug( "recognized DHCP option #%d, length %d", tag, len );
456 453
457 if ( tag == DHO_DHCP_MESSAGE_TYPE ) 454 if ( tag == DHO_DHCP_MESSAGE_TYPE )
458 _type = *option; 455 _type = *option;
459 456
460 option += len; 457 option += len;
461 if ( option >= end ) 458 if ( option >= end )
462 { 459 {
463 qWarning( "DHCP parsing ERROR: sanity check says the packet is at its end!" ); 460 qWarning( "DHCP parsing ERROR: sanity check says the packet is at its end!" );
464 break; 461 break;
465 } 462 }
466 } 463 }
467 464
468 qDebug( "DHCP type seems to be '%s'", (const char*) type() ); 465 qDebug( "DHCP type seems to be '%s'", (const char*) type() );
469} 466}
470 467
471 468
472ODHCPPacket::~ODHCPPacket() 469ODHCPPacket::~ODHCPPacket()
473{ 470{
474} 471}
475 472
476 473
477bool ODHCPPacket::isRequest() const 474bool ODHCPPacket::isRequest() const
478{ 475{
479 return ( _dhcphdr->op == 01 ); 476 return ( _dhcphdr->op == 01 );
480} 477}
481 478
482 479
483bool ODHCPPacket::isReply() const 480bool ODHCPPacket::isReply() const
484{ 481{
485 return ( _dhcphdr->op == 02 ); 482 return ( _dhcphdr->op == 02 );
486} 483}
487 484
488 485
489QString ODHCPPacket::type() const 486QString ODHCPPacket::type() const
490{ 487{
491 switch ( _type ) 488 switch ( _type )
492 { 489 {
493 case 1: return "DISCOVER"; 490 case 1: return "DISCOVER";
494 case 2: return "OFFER"; 491 case 2: return "OFFER";
495 case 3: return "REQUEST"; 492 case 3: return "REQUEST";
496 case 4: return "DECLINE"; 493 case 4: return "DECLINE";
497 case 5: return "ACK"; 494 case 5: return "ACK";
498 case 6: return "NAK"; 495 case 6: return "NAK";
499 case 7: return "RELEASE"; 496 case 7: return "RELEASE";
500 case 8: return "INFORM"; 497 case 8: return "INFORM";
501 default: qWarning( "ODHCPPacket::type(): invalid DHCP type (%d) !", _dhcphdr->op ); return "<unknown>"; 498 default: qWarning( "ODHCPPacket::type(): invalid DHCP type (%d) !", _dhcphdr->op ); return "<unknown>";
502 } 499 }
503} 500}
504 501
505 502
506QHostAddress ODHCPPacket::clientAddress() const 503QHostAddress ODHCPPacket::clientAddress() const
507{ 504{
508 return EXTRACT_32BITS( &_dhcphdr->ciaddr ); 505 return EXTRACT_32BITS( &_dhcphdr->ciaddr );
509} 506}
510 507
511 508
512QHostAddress ODHCPPacket::yourAddress() const 509QHostAddress ODHCPPacket::yourAddress() const
513{ 510{
514 return EXTRACT_32BITS( &_dhcphdr->yiaddr ); 511 return EXTRACT_32BITS( &_dhcphdr->yiaddr );
515} 512}
516 513
517 514
518QHostAddress ODHCPPacket::serverAddress() const 515QHostAddress ODHCPPacket::serverAddress() const
519{ 516{
520 return EXTRACT_32BITS( &_dhcphdr->siaddr ); 517 return EXTRACT_32BITS( &_dhcphdr->siaddr );
521} 518}
522 519
523 520
524QHostAddress ODHCPPacket::relayAddress() const 521QHostAddress ODHCPPacket::relayAddress() const
525{ 522{
526 return EXTRACT_32BITS( &_dhcphdr->giaddr ); 523 return EXTRACT_32BITS( &_dhcphdr->giaddr );
527} 524}
528 525
529 526
530OMacAddress ODHCPPacket::clientMacAddress() const 527OMacAddress ODHCPPacket::clientMacAddress() const
531{ 528{
532 return OMacAddress( _dhcphdr->chaddr ); 529 return OMacAddress( _dhcphdr->chaddr );
533} 530}
534 531
535 532
536/*====================================================================================== 533/*======================================================================================
537 * OTCPPacket 534 * OTCPPacket
538 *======================================================================================*/ 535 *======================================================================================*/
539 536
540 537
541OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) 538OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent )
542 :QObject( parent, "TCP" ), _tcphdr( data ) 539 :QObject( parent, "TCP" ), _tcphdr( data )
543 540
544{ 541{
545 qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); 542 qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." );
546} 543}
547 544
548 545
549OTCPPacket::~OTCPPacket() 546OTCPPacket::~OTCPPacket()
550{ 547{
551} 548}
552 549
553 550
554int OTCPPacket::fromPort() const 551int OTCPPacket::fromPort() const
555{ 552{
556 return EXTRACT_16BITS( &_tcphdr->source ); 553 return EXTRACT_16BITS( &_tcphdr->source );
557} 554}
558 555
559 556
560int OTCPPacket::toPort() const 557int OTCPPacket::toPort() const
561{ 558{
562 return EXTRACT_16BITS( &_tcphdr->dest ); 559 return EXTRACT_16BITS( &_tcphdr->dest );
563} 560}
564 561
565 562
566int OTCPPacket::seq() const 563int OTCPPacket::seq() const
567{ 564{
568 return EXTRACT_16BITS( &_tcphdr->seq ); 565 return EXTRACT_16BITS( &_tcphdr->seq );
569} 566}
570 567
571 568
572int OTCPPacket::ack() const 569int OTCPPacket::ack() const
573{ 570{
574 return EXTRACT_16BITS( &_tcphdr->ack_seq ); 571 return EXTRACT_16BITS( &_tcphdr->ack_seq );
575} 572}
576 573
577 574
578int OTCPPacket::window() const 575int OTCPPacket::window() const
579{ 576{
580 return EXTRACT_16BITS( &_tcphdr->window ); 577 return EXTRACT_16BITS( &_tcphdr->window );
581} 578}
582 579
583 580
584int OTCPPacket::checksum() const 581int OTCPPacket::checksum() const
585{ 582{
586 return EXTRACT_16BITS( &_tcphdr->check ); 583 return EXTRACT_16BITS( &_tcphdr->check );
587} 584}
588 585
589/*====================================================================================== 586/*======================================================================================
590 * OPrismHeaderPacket 587 * OPrismHeaderPacket
591 *======================================================================================*/ 588 *======================================================================================*/
592 589
593 590
594OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent ) 591OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent )
595 :QObject( parent, "Prism" ), _header( data ) 592 :QObject( parent, "Prism" ), _header( data )
596 593
597{ 594{
598 qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." ); 595 qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." );
599 596
600 qDebug( "Signal Strength = %d", data->signal.data ); 597 qDebug( "Signal Strength = %d", data->signal.data );
601 598
602 new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this ); 599 new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this );
603} 600}
604 601
605OPrismHeaderPacket::~OPrismHeaderPacket() 602OPrismHeaderPacket::~OPrismHeaderPacket()
606{ 603{
607} 604}
608 605
609 606
610unsigned int OPrismHeaderPacket::signalStrength() const 607unsigned int OPrismHeaderPacket::signalStrength() const
611{ 608{
612 return _header->signal.data; 609 return _header->signal.data;
613} 610}
614 611
615/*====================================================================================== 612/*======================================================================================
616 * OWaveLanPacket 613 * OWaveLanPacket
617 *======================================================================================*/ 614 *======================================================================================*/
618 615
619 616
620OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) 617OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent )
621 :QObject( parent, "802.11" ), _wlanhdr( data ) 618 :QObject( parent, "802.11" ), _wlanhdr( data )
622 619
623{ 620{
624 qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); 621 qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." );
625 qDebug( "type: %0X", type() ); 622 qDebug( "type: %0X", type() );
626 qDebug( "subType: %0X", subType() ); 623 qDebug( "subType: %0X", subType() );
627 qDebug( "duration: %d", duration() ); 624 qDebug( "duration: %d", duration() );
628 qDebug( "powermanagement: %d", usesPowerManagement() ); 625 qDebug( "powermanagement: %d", usesPowerManagement() );
629 qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" ); 626 qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" );
630 qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); 627 qDebug( "MAC1: %s", (const char*) macAddress1().toString() );
631 qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); 628 qDebug( "MAC2: %s", (const char*) macAddress2().toString() );
632 qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); 629 qDebug( "MAC3: %s", (const char*) macAddress3().toString() );
633 qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); 630 qDebug( "MAC4: %s", (const char*) macAddress4().toString() );
634 631
635 switch ( type() ) 632 switch ( type() )
636 { 633 {
637 case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; 634 case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break;
638 case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; 635 case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break;
639 case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break; 636 case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break;
640 default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() ); 637 default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() );
641 } 638 }
642} 639}
643 640
644OWaveLanPacket::~OWaveLanPacket() 641OWaveLanPacket::~OWaveLanPacket()
645{ 642{
646} 643}
647 644
648 645
649int OWaveLanPacket::duration() const 646int OWaveLanPacket::duration() const
650{ 647{
651 return _wlanhdr->duration; 648 return _wlanhdr->duration;
652} 649}
653 650
654 651
655OMacAddress OWaveLanPacket::macAddress1() const 652OMacAddress OWaveLanPacket::macAddress1() const
656{ 653{
657 return OMacAddress( _wlanhdr->mac1 ); 654 return OMacAddress( _wlanhdr->mac1 );
658} 655}
659 656
660 657
661OMacAddress OWaveLanPacket::macAddress2() const 658OMacAddress OWaveLanPacket::macAddress2() const
662{ 659{
663 return OMacAddress( _wlanhdr->mac2 ); 660 return OMacAddress( _wlanhdr->mac2 );
664} 661}
665 662
666 663
667OMacAddress OWaveLanPacket::macAddress3() const 664OMacAddress OWaveLanPacket::macAddress3() const
668{ 665{
669 return OMacAddress( _wlanhdr->mac3 ); 666 return OMacAddress( _wlanhdr->mac3 );
670} 667}
671 668
672 669
673OMacAddress OWaveLanPacket::macAddress4() const 670OMacAddress OWaveLanPacket::macAddress4() const
674{ 671{
675 return OMacAddress( _wlanhdr->mac4 ); 672 return OMacAddress( _wlanhdr->mac4 );
676} 673}
677 674
678 675
679int OWaveLanPacket::subType() const 676int OWaveLanPacket::subType() const
680{ 677{
681 return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 678 return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
682} 679}
683 680
684 681
685int OWaveLanPacket::type() const 682int OWaveLanPacket::type() const
686{ 683{
687 return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 684 return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
688} 685}
689 686
690 687
691int OWaveLanPacket::version() const 688int OWaveLanPacket::version() const
692{ 689{
693 return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 690 return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
694} 691}
695 692
696 693
697bool OWaveLanPacket::fromDS() const 694bool OWaveLanPacket::fromDS() const
698{ 695{
699 return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 696 return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
700} 697}
701 698
702 699
703bool OWaveLanPacket::toDS() const 700bool OWaveLanPacket::toDS() const
704{ 701{
705 return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 702 return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
706} 703}
707 704
708 705
709bool OWaveLanPacket::usesPowerManagement() const 706bool OWaveLanPacket::usesPowerManagement() const
710{ 707{
711 return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 708 return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
712} 709}
713 710
714 711
715bool OWaveLanPacket::usesWep() const 712bool OWaveLanPacket::usesWep() const
716{ 713{
717 return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 714 return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
718} 715}
719 716
720 717
721/*====================================================================================== 718/*======================================================================================
722 * OWaveLanManagementPacket 719 * OWaveLanManagementPacket
723 *======================================================================================*/ 720 *======================================================================================*/
724 721
725OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) 722OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent )
726 :QObject( parent, "802.11 Management" ), _header( data ), 723 :QObject( parent, "802.11 Management" ), _header( data ),
727 _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) 724 _body( (const struct ieee_802_11_mgmt_body*) (data+1) )
728{ 725{
729 qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." ); 726 qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." );
730 qDebug( "Detected subtype is '%s'", (const char*) managementType() ); 727 qDebug( "Detected subtype is '%s'", (const char*) managementType() );
731 728
732 // grab tagged values 729 // grab tagged values
733 const unsigned char* ptr = (const unsigned char*) (_body+1); 730 const unsigned char* ptr = (const unsigned char*) (_body+1);
734 while (ptr < end) 731 while (ptr < end)
735 { 732 {
736 switch ( *ptr ) 733 switch ( *ptr )
737 { 734 {
738 case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break; 735 case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break;
739 case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break; 736 case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break;
740 case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break; 737 case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break;
741 case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break; 738 case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break;
742 case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break; 739 case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break;
743 case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break; 740 case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break;
744 case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break; 741 case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break;
745 case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break; 742 case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break;
746 } 743 }
747 ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value 744 ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value
748 ptr+= 2; // skip tag ID and length 745 ptr+= 2; // skip tag ID and length
749 } 746 }
750} 747}
751 748
752 749
753OWaveLanManagementPacket::~OWaveLanManagementPacket() 750OWaveLanManagementPacket::~OWaveLanManagementPacket()
754{ 751{
755} 752}
756 753
757 754
758QString OWaveLanManagementPacket::managementType() const 755QString OWaveLanManagementPacket::managementType() const
759{ 756{
760 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ) 757 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) )
761 { 758 {
762 case ST_ASSOC_REQUEST: return "AssociationRequest"; break; 759 case ST_ASSOC_REQUEST: return "AssociationRequest"; break;
763 case ST_ASSOC_RESPONSE: return "AssociationResponse"; break; 760 case ST_ASSOC_RESPONSE: return "AssociationResponse"; break;
764 case ST_REASSOC_REQUEST: return "ReassociationRequest"; break; 761 case ST_REASSOC_REQUEST: return "ReassociationRequest"; break;
765 case ST_REASSOC_RESPONSE: return "ReassociationResponse"; break; 762 case ST_REASSOC_RESPONSE: return "ReassociationResponse"; break;
766 case ST_PROBE_REQUEST: return "ProbeRequest"; break; 763 case ST_PROBE_REQUEST: return "ProbeRequest"; break;
767 case ST_PROBE_RESPONSE: return "ProbeResponse"; break; 764 case ST_PROBE_RESPONSE: return "ProbeResponse"; break;
768 case ST_BEACON: return "Beacon"; break; 765 case ST_BEACON: return "Beacon"; break;
769 case ST_ATIM: return "Atim"; break; 766 case ST_ATIM: return "Atim"; break;
770 case ST_DISASSOC: return "Disassociation"; break; 767 case ST_DISASSOC: return "Disassociation"; break;
771 case ST_AUTH: return "Authentication"; break; 768 case ST_AUTH: return "Authentication"; break;
772 case ST_DEAUTH: return "Deathentication"; break; 769 case ST_DEAUTH: return "Deathentication"; break;
773 default: 770 default:
774 qWarning( "OWaveLanManagementPacket::managementType(): unhandled subtype %d", FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ); 771 qWarning( "OWaveLanManagementPacket::managementType(): unhandled subtype %d", FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) );
775 return "Unknown"; 772 return "Unknown";
776 } 773 }
777} 774}
778 775
779 776
780int OWaveLanManagementPacket::beaconInterval() const 777int OWaveLanManagementPacket::beaconInterval() const
781{ 778{
782 return EXTRACT_LE_16BITS( &_body->beacon_interval ); 779 return EXTRACT_LE_16BITS( &_body->beacon_interval );
783} 780}
784 781
785 782
786int OWaveLanManagementPacket::capabilities() const 783int OWaveLanManagementPacket::capabilities() const
787{ 784{
788 return EXTRACT_LE_16BITS( &_body->capability_info ); 785 return EXTRACT_LE_16BITS( &_body->capability_info );
789} 786}
790 787
791 788
792bool OWaveLanManagementPacket::canESS() const 789bool OWaveLanManagementPacket::canESS() const
793{ 790{
794 return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) ); 791 return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) );
795} 792}
796 793
797 794
798bool OWaveLanManagementPacket::canIBSS() const 795bool OWaveLanManagementPacket::canIBSS() const
799{ 796{
800 return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) ); 797 return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) );
801} 798}
802 799
803 800
804bool OWaveLanManagementPacket::canCFP() const 801bool OWaveLanManagementPacket::canCFP() const
805{ 802{
806 return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) ); 803 return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) );
807} 804}
808 805
809 806
810bool OWaveLanManagementPacket::canCFP_REQ() const 807bool OWaveLanManagementPacket::canCFP_REQ() const
811{ 808{
812 return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) ); 809 return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) );
813} 810}
814 811
815 812
816bool OWaveLanManagementPacket::canPrivacy() const 813bool OWaveLanManagementPacket::canPrivacy() const
817{ 814{
818 return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) ); 815 return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) );
819} 816}
820 817
821 818
822/*====================================================================================== 819/*======================================================================================
823 * OWaveLanManagementSSID 820 * OWaveLanManagementSSID
824 *======================================================================================*/ 821 *======================================================================================*/
825 822
826OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent ) 823OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent )
827 :QObject( parent, "802.11 SSID" ), _data( data ) 824 :QObject( parent, "802.11 SSID" ), _data( data )
828{ 825{
829 qDebug( "OWaveLanManagementSSID()" ); 826 qDebug( "OWaveLanManagementSSID()" );
830} 827}
831 828
832 829
833OWaveLanManagementSSID::~OWaveLanManagementSSID() 830OWaveLanManagementSSID::~OWaveLanManagementSSID()
834{ 831{
835} 832}
836 833
837 834
838QString OWaveLanManagementSSID::ID() const 835QString OWaveLanManagementSSID::ID() const
839{ 836{
840 int length = _data->length; 837 int length = _data->length;
841 if ( length > 32 ) length = 32; 838 if ( length > 32 ) length = 32;
842 char essid[length+1]; 839 char essid[length+1];
843 memcpy( &essid, &_data->ssid, length ); 840 memcpy( &essid, &_data->ssid, length );
844 essid[length] = 0x0; 841 essid[length] = 0x0;
845 return essid; 842 return essid;
846} 843}
847 844
848 845
849/*====================================================================================== 846/*======================================================================================
850 * OWaveLanManagementRates 847 * OWaveLanManagementRates
851 *======================================================================================*/ 848 *======================================================================================*/
852 849
853OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent ) 850OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent )
854 :QObject( parent, "802.11 Rates" ), _data( data ) 851 :QObject( parent, "802.11 Rates" ), _data( data )
855{ 852{
856 qDebug( "OWaveLanManagementRates()" ); 853 qDebug( "OWaveLanManagementRates()" );
857} 854}
858 855
859 856
860OWaveLanManagementRates::~OWaveLanManagementRates() 857OWaveLanManagementRates::~OWaveLanManagementRates()
861{ 858{
862} 859}
863 860
864/*====================================================================================== 861/*======================================================================================
865 * OWaveLanManagementCF 862 * OWaveLanManagementCF
866 *======================================================================================*/ 863 *======================================================================================*/
867 864
868OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent ) 865OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent )
869 :QObject( parent, "802.11 CF" ), _data( data ) 866 :QObject( parent, "802.11 CF" ), _data( data )
870{ 867{
871 qDebug( "OWaveLanManagementCF()" ); 868 qDebug( "OWaveLanManagementCF()" );
872} 869}
873 870
874 871
875OWaveLanManagementCF::~OWaveLanManagementCF() 872OWaveLanManagementCF::~OWaveLanManagementCF()
876{ 873{
877} 874}
878 875
879/*====================================================================================== 876/*======================================================================================
880 * OWaveLanManagementFH 877 * OWaveLanManagementFH
881 *======================================================================================*/ 878 *======================================================================================*/
882 879
883OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent ) 880OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent )
884 :QObject( parent, "802.11 FH" ), _data( data ) 881 :QObject( parent, "802.11 FH" ), _data( data )
885{ 882{
886 qDebug( "OWaveLanManagementFH()" ); 883 qDebug( "OWaveLanManagementFH()" );
887} 884}
888 885
889 886
890OWaveLanManagementFH::~OWaveLanManagementFH() 887OWaveLanManagementFH::~OWaveLanManagementFH()
891{ 888{
892} 889}
893 890
894/*====================================================================================== 891/*======================================================================================
895 * OWaveLanManagementDS 892 * OWaveLanManagementDS
896 *======================================================================================*/ 893 *======================================================================================*/
897 894
898OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent ) 895OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent )
899 :QObject( parent, "802.11 DS" ), _data( data ) 896 :QObject( parent, "802.11 DS" ), _data( data )
900{ 897{
901 qDebug( "OWaveLanManagementDS()" ); 898 qDebug( "OWaveLanManagementDS()" );
902} 899}
903 900
904 901
905OWaveLanManagementDS::~OWaveLanManagementDS() 902OWaveLanManagementDS::~OWaveLanManagementDS()
906{ 903{
907} 904}
908 905
909 906
910int OWaveLanManagementDS::channel() const 907int OWaveLanManagementDS::channel() const
911{ 908{
912 return _data->channel; 909 return _data->channel;
913} 910}
914 911
915/*====================================================================================== 912/*======================================================================================
916 * OWaveLanManagementTim 913 * OWaveLanManagementTim
917 *======================================================================================*/ 914 *======================================================================================*/
918 915
919OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent ) 916OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent )
920 :QObject( parent, "802.11 Tim" ), _data( data ) 917 :QObject( parent, "802.11 Tim" ), _data( data )
921{ 918{
922 qDebug( "OWaveLanManagementTim()" ); 919 qDebug( "OWaveLanManagementTim()" );
923} 920}
924 921
925 922
926OWaveLanManagementTim::~OWaveLanManagementTim() 923OWaveLanManagementTim::~OWaveLanManagementTim()
927{ 924{
928} 925}
929 926
930/*====================================================================================== 927/*======================================================================================
931 * OWaveLanManagementIBSS 928 * OWaveLanManagementIBSS
932 *======================================================================================*/ 929 *======================================================================================*/
933 930
934OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent ) 931OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent )
935 :QObject( parent, "802.11 IBSS" ), _data( data ) 932 :QObject( parent, "802.11 IBSS" ), _data( data )
936{ 933{
937 qDebug( "OWaveLanManagementIBSS()" ); 934 qDebug( "OWaveLanManagementIBSS()" );
938} 935}
939 936
940 937
941OWaveLanManagementIBSS::~OWaveLanManagementIBSS() 938OWaveLanManagementIBSS::~OWaveLanManagementIBSS()
942{ 939{
943} 940}
944 941
945/*====================================================================================== 942/*======================================================================================
946 * OWaveLanManagementChallenge 943 * OWaveLanManagementChallenge
947 *======================================================================================*/ 944 *======================================================================================*/
948 945
949OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent ) 946OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent )
950 :QObject( parent, "802.11 Challenge" ), _data( data ) 947 :QObject( parent, "802.11 Challenge" ), _data( data )
951{ 948{
952 qDebug( "OWaveLanManagementChallenge()" ); 949 qDebug( "OWaveLanManagementChallenge()" );
953} 950}
954 951
955 952
956OWaveLanManagementChallenge::~OWaveLanManagementChallenge() 953OWaveLanManagementChallenge::~OWaveLanManagementChallenge()
957{ 954{
958} 955}
959 956
960/*====================================================================================== 957/*======================================================================================
961 * OWaveLanDataPacket 958 * OWaveLanDataPacket
962 *======================================================================================*/ 959 *======================================================================================*/
963 960
964OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) 961OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent )
965 :QObject( parent, "802.11 Data" ), _header( data ) 962 :QObject( parent, "802.11 Data" ), _header( data )
966{ 963{
967 qDebug( "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." ); 964 qDebug( "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." );
968 965
969 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); 966 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header );
970 967
971 #warning The next line works for most cases, but can not be correct generally! 968 #warning The next line works for most cases, but can not be correct generally!
972 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address 969 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address
973 970
974 new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); 971 new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this );
975} 972}
976 973
977 974
978OWaveLanDataPacket::~OWaveLanDataPacket() 975OWaveLanDataPacket::~OWaveLanDataPacket()
979{ 976{
980} 977}
981 978
982 979
983/*====================================================================================== 980/*======================================================================================
984 * OLLCPacket 981 * OLLCPacket
985 *======================================================================================*/ 982 *======================================================================================*/
986 983
987OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) 984OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent )
988 :QObject( parent, "802.11 LLC" ), _header( data ) 985 :QObject( parent, "802.11 LLC" ), _header( data )
989{ 986{
990 qDebug( "OLLCPacket::OLLCPacket(): decoding frame..." ); 987 qDebug( "OLLCPacket::OLLCPacket(): decoding frame..." );
991 988
992 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) 989 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) )
993 { 990 {
994 qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) ); 991 qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) );
995 992
996 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h 993 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h
997 { 994 {
998 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 995 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
999 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; 996 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
1000 default: qWarning( "OLLCPacket::OLLCPacket(): Unknown Encapsulation (type=%04X)", EXTRACT_16BITS( &_header->type ) ); 997 default: qWarning( "OLLCPacket::OLLCPacket(): Unknown Encapsulation (type=%04X)", EXTRACT_16BITS( &_header->type ) );
1001 } 998 }
1002 999
1003 } 1000 }
1004} 1001}
1005 1002
1006 1003
1007OLLCPacket::~OLLCPacket() 1004OLLCPacket::~OLLCPacket()
1008{ 1005{
1009} 1006}
1010 1007
1011 1008
1012/*====================================================================================== 1009/*======================================================================================
1013 * OWaveLanControlPacket 1010 * OWaveLanControlPacket
1014 *======================================================================================*/ 1011 *======================================================================================*/
1015 1012
1016OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent ) 1013OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent )
1017 :QObject( parent, "802.11 Control" ), _header( data ) 1014 :QObject( parent, "802.11 Control" ), _header( data )
1018{ 1015{
1019 qDebug( "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." ); 1016 qDebug( "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." );
1020 //TODO: Implement this 1017 //TODO: Implement this
1021} 1018}
1022 1019
1023 1020
1024OWaveLanControlPacket::~OWaveLanControlPacket() 1021OWaveLanControlPacket::~OWaveLanControlPacket()
1025{ 1022{
1026} 1023}
1027 1024
1028 1025
1029/*====================================================================================== 1026/*======================================================================================
1030 * OPacketCapturer 1027 * OPacketCapturer
1031 *======================================================================================*/ 1028 *======================================================================================*/
1032 1029
1033OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) 1030OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
1034 :QObject( parent, name ), _name( QString::null ), _open( false ), 1031 :QObject( parent, name ), _name( QString::null ), _open( false ),
1035 _pch( 0 ), _pcd( 0 ), _sn( 0 ) 1032 _pch( 0 ), _pcd( 0 ), _sn( 0 )
1036{ 1033{
1037} 1034}
1038 1035
1039 1036
1040OPacketCapturer::~OPacketCapturer() 1037OPacketCapturer::~OPacketCapturer()
1041{ 1038{
1042 if ( _open ) 1039 if ( _open )
1043 { 1040 {
1044 qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." ); 1041 qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." );
1045 close(); 1042 close();
1046 } 1043 }
1047} 1044}
1048 1045
1049 1046
1050void OPacketCapturer::setBlocking( bool b ) 1047void OPacketCapturer::setBlocking( bool b )
1051{ 1048{
1052 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) 1049 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 )
1053 { 1050 {
1054 qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." ); 1051 qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." );
1055 } 1052 }
1056 else 1053 else
1057 { 1054 {
1058 qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf ); 1055 qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf );
1059 } 1056 }
1060} 1057}
1061 1058
1062 1059
1063bool OPacketCapturer::blocking() const 1060bool OPacketCapturer::blocking() const
1064{ 1061{
1065 int b = pcap_getnonblock( _pch, _errbuf ); 1062 int b = pcap_getnonblock( _pch, _errbuf );
1066 if ( b == -1 ) 1063 if ( b == -1 )
1067 { 1064 {
1068 qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf ); 1065 qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf );
1069 return -1; 1066 return -1;
1070 } 1067 }
1071 return !b; 1068 return !b;
1072} 1069}
1073 1070
1074 1071
1075void OPacketCapturer::closeDumpFile() 1072void OPacketCapturer::closeDumpFile()
1076{ 1073{
1077 if ( _pcd ) 1074 if ( _pcd )
1078 { 1075 {
1079 pcap_dump_close( _pcd ); 1076 pcap_dump_close( _pcd );
1080 _pcd = 0; 1077 _pcd = 0;
1081 } 1078 }
1082 pcap_close( _pch ); 1079 pcap_close( _pch );
1083} 1080}
1084 1081
1085 1082
1086void OPacketCapturer::close() 1083void OPacketCapturer::close()
1087{ 1084{
1088 if ( _open ) 1085 if ( _open )
1089 { 1086 {
1090 if ( _sn ) 1087 if ( _sn )
1091 { 1088 {
1092 _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1089 _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
1093 delete _sn; 1090 delete _sn;
1094 } 1091 }
1095 closeDumpFile(); 1092 closeDumpFile();
1096 _open = false; 1093 _open = false;
1097 } 1094 }
1098 1095
1099 qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." ); 1096 qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." );
1100 qDebug( "--------------------------------------------------" ); 1097 qDebug( "--------------------------------------------------" );
1101 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it ) 1098 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it )
1102 qDebug( "%s : %d", (const char*) it.key(), it.data() ); 1099 qDebug( "%s : %d", (const char*) it.key(), it.data() );
1103 qDebug( "--------------------------------------------------" ); 1100 qDebug( "--------------------------------------------------" );
1104 1101
1105} 1102}
1106 1103
1107 1104
1108int OPacketCapturer::dataLink() const 1105int OPacketCapturer::dataLink() const
1109{ 1106{
1110 return pcap_datalink( _pch ); 1107 return pcap_datalink( _pch );
1111} 1108}
1112 1109
1113 1110
1114void OPacketCapturer::dump( OPacket* p ) 1111void OPacketCapturer::dump( OPacket* p )
1115{ 1112{
1116 if ( !_pcd ) 1113 if ( !_pcd )
1117 { 1114 {
1118 qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" ); 1115 qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" );
1119 return; 1116 return;
1120 } 1117 }
1121 pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data ); 1118 pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data );
1122} 1119}
1123 1120
1124 1121
1125int OPacketCapturer::fileno() const 1122int OPacketCapturer::fileno() const
1126{ 1123{
1127 if ( _open ) 1124 if ( _open )
1128 { 1125 {
1129 return pcap_fileno( _pch ); 1126 return pcap_fileno( _pch );
1130 } 1127 }
1131 else 1128 else
1132 { 1129 {
1133 return -1; 1130 return -1;
1134 } 1131 }
1135} 1132}
1136 1133
1137 1134
1138OPacket* OPacketCapturer::next( int time ) 1135OPacket* OPacketCapturer::next( int time )
1139{ 1136{
1140 fd_set fds; 1137 fd_set fds;
1141 struct timeval tv; 1138 struct timeval tv;
1142 FD_ZERO( &fds ); 1139 FD_ZERO( &fds );
1143 FD_SET( pcap_fileno( _pch ), &fds ); 1140 FD_SET( pcap_fileno( _pch ), &fds );
1144 tv.tv_sec = time / 1000; 1141 tv.tv_sec = time / 1000;
1145 tv.tv_usec = time % 1000; 1142 tv.tv_usec = time % 1000;
1146 int retval = select( pcap_fileno( _pch )+1, &fds, NULL, NULL, &tv); 1143 int retval = select( pcap_fileno( _pch )+1, &fds, NULL, NULL, &tv);
1147 if ( retval > 0 ) // clear to read! 1144 if ( retval > 0 ) // clear to read!
1148 return next(); 1145 return next();
1149 else 1146 else
1150 return 0; 1147 return 0;
1151} 1148}
1152 1149
1153 1150
1154OPacket* OPacketCapturer::next() 1151OPacket* OPacketCapturer::next()
1155{ 1152{
1156 packetheaderstruct header; 1153 packetheaderstruct header;
1157 qDebug( "==> OPacketCapturer::next()" ); 1154 qDebug( "==> OPacketCapturer::next()" );
1158 const unsigned char* pdata = pcap_next( _pch, &header ); 1155 const unsigned char* pdata = pcap_next( _pch, &header );
1159 qDebug( "<== OPacketCapturer::next()" ); 1156 qDebug( "<== OPacketCapturer::next()" );
1160 1157
1161 if ( pdata && header.len ) 1158 if ( pdata && header.len )
1162 { 1159 {
1163 OPacket* p = new OPacket( dataLink(), header, pdata, 0 ); 1160 OPacket* p = new OPacket( dataLink(), header, pdata, 0 );
1164 // packets shouldn't be inserted in the QObject child-parent hierarchy, 1161 // packets shouldn't be inserted in the QObject child-parent hierarchy,
1165 // because due to memory constraints they will be deleted as soon 1162 // because due to memory constraints they will be deleted as soon
1166 // as possible - that is right after they have been processed 1163 // as possible - that is right after they have been processed
1167 // by emit() [ see below ] 1164 // by emit() [ see below ]
1168 //TODO: make gathering statistics optional, because it takes time 1165 //TODO: make gathering statistics optional, because it takes time
1169 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); 1166 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) );
1170 #ifndef NODEBUG 1167 #ifndef NODEBUG
1171 p->dumpStructure( const_cast<QObjectList*>( p->children() ) ); 1168 p->dumpStructure( const_cast<QObjectList*>( p->children() ) );
1172 #endif 1169 #endif
1173 return p; 1170 return p;
1174 } 1171 }
1175 else 1172 else
1176 { 1173 {
1177 qWarning( "OPacketCapturer::next() - no packet received!" ); 1174 qWarning( "OPacketCapturer::next() - no packet received!" );
1178 return 0; 1175 return 0;
1179 } 1176 }
1180} 1177}
1181 1178
1182 1179
1183bool OPacketCapturer::open( const QString& name ) 1180bool OPacketCapturer::open( const QString& name )
1184{ 1181{
1185 if ( _open ) 1182 if ( _open )
1186 { 1183 {
1187 if ( name == _name ) // ignore opening an already openend device 1184 if ( name == _name ) // ignore opening an already openend device
1188 { 1185 {
1189 return true; 1186 return true;
1190 } 1187 }
1191 else // close the last opened device 1188 else // close the last opened device
1192 { 1189 {
1193 close(); 1190 close();
1194 } 1191 }
1195 } 1192 }
1196 1193
1197 _name = name; 1194 _name = name;
1198 1195
1199 // open libpcap 1196 // open libpcap
1200 pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] ); 1197 pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] );
1201 1198
1202 if ( !handle ) 1199 if ( !handle )
1203 { 1200 {
1204 qWarning( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); 1201 qWarning( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf );
1205 return false; 1202 return false;
1206 } 1203 }
1207 1204
1208 qDebug( "OPacketCapturer::open(): libpcap [%s] opened successfully.", (const char*) name ); 1205 qDebug( "OPacketCapturer::open(): libpcap [%s] opened successfully.", (const char*) name );
1209 _pch = handle; 1206 _pch = handle;
1210 _open = true; 1207 _open = true;
1211 _stats.clear(); 1208 _stats.clear();
1212 1209
1213 // in case we have an application object, create a socket notifier 1210 // in case we have an application object, create a socket notifier
1214 if ( qApp ) //TODO: I don't like this here... 1211 if ( qApp ) //TODO: I don't like this here...
1215 { 1212 {
1216 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); 1213 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
1217 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1214 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
1218 } 1215 }
1219 1216
1220 return true; 1217 return true;
1221} 1218}
1222 1219
1223 1220
1224bool OPacketCapturer::openDumpFile( const QString& filename ) 1221bool OPacketCapturer::openDumpFile( const QString& filename )
1225{ 1222{
1226 pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); 1223 pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) );
1227 if ( !dump ) 1224 if ( !dump )
1228 { 1225 {
1229 qWarning( "OPacketCapturer::open(): can't open dump with '%s': %s", (const char*) filename, _errbuf ); 1226 qWarning( "OPacketCapturer::open(): can't open dump with '%s': %s", (const char*) filename, _errbuf );
1230 return false; 1227 return false;
1231 } 1228 }
1232 qDebug( "OPacketCapturer::open(): dump [%s] opened successfully.", (const char*) filename ); 1229 qDebug( "OPacketCapturer::open(): dump [%s] opened successfully.", (const char*) filename );
1233 _pcd = dump; 1230 _pcd = dump;
1234 1231
1235 return true; 1232 return true;
1236} 1233}
1237 1234
1238 1235
1239bool OPacketCapturer::open( const QFile& file ) 1236bool OPacketCapturer::open( const QFile& file )
1240{ 1237{
1241 QString name = file.name(); 1238 QString name = file.name();
1242 1239
1243 if ( _open ) 1240 if ( _open )
1244 { 1241 {
1245 close(); 1242 close();
1246 if ( name == _name ) // ignore opening an already openend device 1243 if ( name == _name ) // ignore opening an already openend device
1247 { 1244 {
1248 return true; 1245 return true;
1249 } 1246 }
1250 else // close the last opened device 1247 else // close the last opened device
1251 { 1248 {
1252 close(); 1249 close();
1253 } 1250 }
1254 } 1251 }
1255 1252
1256 _name = name; 1253 _name = name;
1257 1254
1258 pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] ); 1255 pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] );
1259 1256
1260 if ( handle ) 1257 if ( handle )
1261 { 1258 {
1262 qDebug( "OPacketCapturer::open(): libpcap opened successfully." ); 1259 qDebug( "OPacketCapturer::open(): libpcap opened successfully." );
1263 _pch = handle; 1260 _pch = handle;
1264 _open = true; 1261 _open = true;
1265 1262
1266 // in case we have an application object, create a socket notifier 1263 // in case we have an application object, create a socket notifier
1267 if ( qApp ) 1264 if ( qApp )
1268 { 1265 {
1269 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); 1266 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
1270 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1267 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
1271 } 1268 }
1272 1269
1273 return true; 1270 return true;
1274 } 1271 }
1275 else 1272 else
1276 { 1273 {
1277 qDebug( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); 1274 qDebug( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf );
1278 return false; 1275 return false;
1279 } 1276 }
1280 1277
1281} 1278}
1282 1279
1283 1280
1284bool OPacketCapturer::isOpen() const 1281bool OPacketCapturer::isOpen() const
1285{ 1282{
1286 return _open; 1283 return _open;
1287} 1284}
1288 1285
1289 1286
1290void OPacketCapturer::readyToReceive() 1287void OPacketCapturer::readyToReceive()
1291{ 1288{
1292 qDebug( "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" ); 1289 qDebug( "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" );
1293 OPacket* p = next(); 1290 OPacket* p = next();
1294 emit receivedPacket( p ); 1291 emit receivedPacket( p );
1295 // emit is synchronous - packet has been dealt with, now it's safe to delete 1292 // emit is synchronous - packet has been dealt with, now it's safe to delete
1296 delete p; 1293 delete p;
1297} 1294}
1298 1295
1299 1296
1300const QMap<QString,int>& OPacketCapturer::statistics() const 1297const QMap<QString,int>& OPacketCapturer::statistics() const
1301{ 1298{
1302 return _stats; 1299 return _stats;
1303} 1300}
1304 1301
1305 1302
1306int OPacketCapturer::snapShot() const 1303int OPacketCapturer::snapShot() const
1307{ 1304{
1308 return pcap_snapshot( _pch ); 1305 return pcap_snapshot( _pch );
1309} 1306}
1310 1307
1311 1308
1312bool OPacketCapturer::swapped() const 1309bool OPacketCapturer::swapped() const
1313{ 1310{
1314 return pcap_is_swapped( _pch ); 1311 return pcap_is_swapped( _pch );
1315} 1312}
1316 1313
1317 1314
1318QString OPacketCapturer::version() const 1315QString OPacketCapturer::version() const
1319{ 1316{
1320 return QString().sprintf( "%s.%s", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); 1317 return QString().sprintf( "%s.%s", pcap_major_version( _pch ), pcap_minor_version( _pch ) );
1321} 1318}
1322 1319
1323 1320
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 54b256b..497fd6b 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -1,667 +1,664 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 4 =.
8 .=l. 5 .=l.
9           .>+-= 6           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 13    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 20++=   -.     .`     .: details.
24 :     =  ...= . :.=- 21 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
31 28
32*/ 29*/
33 30
34#ifndef OPCAP_H 31#ifndef OPCAP_H
35#define OPCAP_H 32#define OPCAP_H
36 33
37/* LINUX */ 34/* LINUX */
38extern "C" // work around a bpf/pcap conflict in recent headers 35extern "C" // work around a bpf/pcap conflict in recent headers
39{ 36{
40 #include <pcap.h> 37 #include <pcap.h>
41} 38}
42#include <netinet/ether.h> 39#include <netinet/ether.h>
43#include <netinet/ip.h> 40#include <netinet/ip.h>
44#include <netinet/udp.h> 41#include <netinet/udp.h>
45#include <netinet/tcp.h> 42#include <netinet/tcp.h>
46#include <time.h> 43#include <time.h>
47 44
48/* QT */ 45/* QT */
49#include <qevent.h> 46#include <qevent.h>
50#include <qfile.h> 47#include <qfile.h>
51#include <qhostaddress.h> 48#include <qhostaddress.h>
52#include <qobject.h> 49#include <qobject.h>
53#include <qstring.h> 50#include <qstring.h>
54#include <qmap.h> 51#include <qmap.h>
55 52
56/* OPIE */ 53/* OPIE */
57#include <opie2/onetutils.h> 54#include <opie2/onetutils.h>
58 55
59/* Custom Network Includes */ 56/* Custom Network Includes */
60#include "802_11_user.h" 57#include "802_11_user.h"
61#include "dhcp.h" 58#include "dhcp.h"
62 59
63/* TYPEDEFS */ 60/* TYPEDEFS */
64typedef struct timeval timevalstruct; 61typedef struct timeval timevalstruct;
65typedef struct pcap_pkthdr packetheaderstruct; 62typedef struct pcap_pkthdr packetheaderstruct;
66 63
67/* FORWARDS */ 64/* FORWARDS */
68class OPacketCapturer; 65class OPacketCapturer;
69class QSocketNotifier; 66class QSocketNotifier;
70 67
71/*====================================================================================== 68/*======================================================================================
72 * OPacket - A frame on the wire 69 * OPacket - A frame on the wire
73 *======================================================================================*/ 70 *======================================================================================*/
74 71
75/** @brief A class representing a data frame on the wire. 72/** @brief A class representing a data frame on the wire.
76 * 73 *
77 * The whole family of the packet classes are used when capturing frames from a network. 74 * The whole family of the packet classes are used when capturing frames from a network.
78 * Most standard network protocols in use share a common architecture, which mostly is 75 * Most standard network protocols in use share a common architecture, which mostly is
79 * a packet header and then the packet payload. In layered architectures, each lower layer 76 * a packet header and then the packet payload. In layered architectures, each lower layer
80 * encapsulates data from its upper layer - that is it 77 * encapsulates data from its upper layer - that is it
81 * treats the data from its upper layer as payload and prepends an own header to the packet, 78 * treats the data from its upper layer as payload and prepends an own header to the packet,
82 * which - again - is treated as the payload for the layer below. The figure below is an 79 * which - again - is treated as the payload for the layer below. The figure below is an
83 * example for how such a data frame is composed out of packets, e.g. when sending a mail. 80 * example for how such a data frame is composed out of packets, e.g. when sending a mail.
84 * 81 *
85 * <pre> 82 * <pre>
86 * | User Data | == Mail Data 83 * | User Data | == Mail Data
87 * | SMTP Header | User Data | == SMTP 84 * | SMTP Header | User Data | == SMTP
88 * | TCP Header | SMTP Header | User Data | == TCP 85 * | TCP Header | SMTP Header | User Data | == TCP
89 * | IP Header | TCP Header | SMTP Header | User Data | == IP 86 * | IP Header | TCP Header | SMTP Header | User Data | == IP
90 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC 87 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC
91 * 88 *
92 * </pre> 89 * </pre>
93 * 90 *
94 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer 91 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer
95 * also contains a few more levels of encapsulation. 92 * also contains a few more levels of encapsulation.
96 * Since the type of the payload is more or less independent from the encapsulating protocol, 93 * Since the type of the payload is more or less independent from the encapsulating protocol,
97 * the header must be inspected before attempting to decode the payload. Hence, the 94 * the header must be inspected before attempting to decode the payload. Hence, the
98 * encapsulation level varies and can't be deduced without actually looking into the packets. 95 * encapsulation level varies and can't be deduced without actually looking into the packets.
99 * 96 *
100 * For actually working with captured frames, it's useful to identify the packets via names and 97 * For actually working with captured frames, it's useful to identify the packets via names and
101 * insert them into a parent/child - relationship based on the encapsulation. This is why 98 * insert them into a parent/child - relationship based on the encapsulation. This is why
102 * all packet classes derive from QObject. The amount of overhead caused by the QObject is 99 * all packet classes derive from QObject. The amount of overhead caused by the QObject is
103 * not a problem in this case, because we're talking about a theoratical maximum of about 100 * not a problem in this case, because we're talking about a theoratical maximum of about
104 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the 101 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the
105 * QObject also cares about destroying the sub-, (child-) packets. 102 * QObject also cares about destroying the sub-, (child-) packets.
106 * 103 *
107 * This enables us to perform a simple look for packets of a certain type: 104 * This enables us to perform a simple look for packets of a certain type:
108 * @code 105 * @code
109 * OPacketCapturer* pcap = new OPacketCapturer(); 106 * OPacketCapturer* pcap = new OPacketCapturer();
110 * pcap->open( "eth0" ); 107 * pcap->open( "eth0" );
111 * OPacket* p = pcap->next(); 108 * OPacket* p = pcap->next();
112 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists 109 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists
113 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; 110 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl;
114 * 111 *
115 */ 112 */
116 113
117class OPacket : public QObject 114class OPacket : public QObject
118{ 115{
119 Q_OBJECT 116 Q_OBJECT
120 117
121 friend class OPacketCapturer; 118 friend class OPacketCapturer;
122 119
123 public: 120 public:
124 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); 121 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent );
125 virtual ~OPacket(); 122 virtual ~OPacket();
126 123
127 timevalstruct timeval() const; 124 timevalstruct timeval() const;
128 125
129 int caplen() const; 126 int caplen() const;
130 int len() const; 127 int len() const;
131 QString dump( int = 32 ) const; 128 QString dump( int = 32 ) const;
132 129
133 void updateStats( QMap<QString,int>&, QObjectList* ); 130 void updateStats( QMap<QString,int>&, QObjectList* );
134 131
135 private: 132 private:
136 133
137 void dumpStructure( QObjectList* ); 134 void dumpStructure( QObjectList* );
138 QString _dumpStructure( QObjectList* ); 135 QString _dumpStructure( QObjectList* );
139 136
140 private: 137 private:
141 const packetheaderstruct _hdr; // pcap packet header 138 const packetheaderstruct _hdr; // pcap packet header
142 const unsigned char* _data; // pcap packet data 139 const unsigned char* _data; // pcap packet data
143 const unsigned char* _end; // end of pcap packet data 140 const unsigned char* _end; // end of pcap packet data
144}; 141};
145 142
146/*====================================================================================== 143/*======================================================================================
147 * OEthernetPacket - DLT_EN10MB frame 144 * OEthernetPacket - DLT_EN10MB frame
148 *======================================================================================*/ 145 *======================================================================================*/
149 146
150class OEthernetPacket : public QObject 147class OEthernetPacket : public QObject
151{ 148{
152 Q_OBJECT 149 Q_OBJECT
153 150
154 public: 151 public:
155 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); 152 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 );
156 virtual ~OEthernetPacket(); 153 virtual ~OEthernetPacket();
157 154
158 OMacAddress sourceAddress() const; 155 OMacAddress sourceAddress() const;
159 OMacAddress destinationAddress() const; 156 OMacAddress destinationAddress() const;
160 int type() const; 157 int type() const;
161 158
162 private: 159 private:
163 const struct ether_header* _ether; 160 const struct ether_header* _ether;
164}; 161};
165 162
166/*====================================================================================== 163/*======================================================================================
167 * OPrismHeaderPacket - DLT_PRISM_HEADER frame 164 * OPrismHeaderPacket - DLT_PRISM_HEADER frame
168 *======================================================================================*/ 165 *======================================================================================*/
169 166
170class OPrismHeaderPacket : public QObject 167class OPrismHeaderPacket : public QObject
171{ 168{
172 Q_OBJECT 169 Q_OBJECT
173 170
174 public: 171 public:
175 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); 172 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 );
176 virtual ~OPrismHeaderPacket(); 173 virtual ~OPrismHeaderPacket();
177 174
178 unsigned int signalStrength() const; 175 unsigned int signalStrength() const;
179 176
180 private: 177 private:
181 const struct prism_hdr* _header; 178 const struct prism_hdr* _header;
182}; 179};
183 180
184/*====================================================================================== 181/*======================================================================================
185 * OWaveLanPacket - DLT_IEEE802_11 frame 182 * OWaveLanPacket - DLT_IEEE802_11 frame
186 *======================================================================================*/ 183 *======================================================================================*/
187 184
188class OWaveLanPacket : public QObject 185class OWaveLanPacket : public QObject
189{ 186{
190 Q_OBJECT 187 Q_OBJECT
191 188
192 public: 189 public:
193 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); 190 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 );
194 virtual ~OWaveLanPacket(); 191 virtual ~OWaveLanPacket();
195 192
196 int duration() const; 193 int duration() const;
197 bool fromDS() const; 194 bool fromDS() const;
198 bool toDS() const; 195 bool toDS() const;
199 virtual OMacAddress macAddress1() const; 196 virtual OMacAddress macAddress1() const;
200 virtual OMacAddress macAddress2() const; 197 virtual OMacAddress macAddress2() const;
201 virtual OMacAddress macAddress3() const; 198 virtual OMacAddress macAddress3() const;
202 virtual OMacAddress macAddress4() const; 199 virtual OMacAddress macAddress4() const;
203 bool usesPowerManagement() const; 200 bool usesPowerManagement() const;
204 int type() const; 201 int type() const;
205 int subType() const; 202 int subType() const;
206 int version() const; 203 int version() const;
207 bool usesWep() const; 204 bool usesWep() const;
208 205
209 private: 206 private:
210 const struct ieee_802_11_header* _wlanhdr; 207 const struct ieee_802_11_header* _wlanhdr;
211}; 208};
212 209
213 210
214/*====================================================================================== 211/*======================================================================================
215 * OWaveLanManagementPacket - type: management (T_MGMT) 212 * OWaveLanManagementPacket - type: management (T_MGMT)
216 *======================================================================================*/ 213 *======================================================================================*/
217 214
218class OWaveLanManagementPacket : public QObject 215class OWaveLanManagementPacket : public QObject
219{ 216{
220 Q_OBJECT 217 Q_OBJECT
221 218
222 public: 219 public:
223 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); 220 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 );
224 virtual ~OWaveLanManagementPacket(); 221 virtual ~OWaveLanManagementPacket();
225 222
226 QString managementType() const; 223 QString managementType() const;
227 224
228 int beaconInterval() const; 225 int beaconInterval() const;
229 int capabilities() const; // generic 226 int capabilities() const; // generic
230 227
231 bool canESS() const; 228 bool canESS() const;
232 bool canIBSS() const; 229 bool canIBSS() const;
233 bool canCFP() const; 230 bool canCFP() const;
234 bool canCFP_REQ() const; 231 bool canCFP_REQ() const;
235 bool canPrivacy() const; 232 bool canPrivacy() const;
236 233
237 private: 234 private:
238 const struct ieee_802_11_mgmt_header* _header; 235 const struct ieee_802_11_mgmt_header* _header;
239 const struct ieee_802_11_mgmt_body* _body; 236 const struct ieee_802_11_mgmt_body* _body;
240}; 237};
241 238
242 239
243/*====================================================================================== 240/*======================================================================================
244 * OWaveLanManagementSSID 241 * OWaveLanManagementSSID
245 *======================================================================================*/ 242 *======================================================================================*/
246 243
247class OWaveLanManagementSSID : public QObject 244class OWaveLanManagementSSID : public QObject
248{ 245{
249 Q_OBJECT 246 Q_OBJECT
250 247
251 public: 248 public:
252 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); 249 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 );
253 virtual ~OWaveLanManagementSSID(); 250 virtual ~OWaveLanManagementSSID();
254 251
255 QString ID() const; 252 QString ID() const;
256 253
257 private: 254 private:
258 const struct ssid_t* _data; 255 const struct ssid_t* _data;
259}; 256};
260 257
261/*====================================================================================== 258/*======================================================================================
262 * OWaveLanManagementRates 259 * OWaveLanManagementRates
263 *======================================================================================*/ 260 *======================================================================================*/
264 261
265class OWaveLanManagementRates : public QObject 262class OWaveLanManagementRates : public QObject
266{ 263{
267 Q_OBJECT 264 Q_OBJECT
268 265
269 public: 266 public:
270 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); 267 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 );
271 virtual ~OWaveLanManagementRates(); 268 virtual ~OWaveLanManagementRates();
272 269
273 private: 270 private:
274 const struct rates_t* _data; 271 const struct rates_t* _data;
275}; 272};
276 273
277/*====================================================================================== 274/*======================================================================================
278 * OWaveLanManagementCF 275 * OWaveLanManagementCF
279 *======================================================================================*/ 276 *======================================================================================*/
280 277
281class OWaveLanManagementCF : public QObject 278class OWaveLanManagementCF : public QObject
282{ 279{
283 Q_OBJECT 280 Q_OBJECT
284 281
285 public: 282 public:
286 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); 283 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 );
287 virtual ~OWaveLanManagementCF(); 284 virtual ~OWaveLanManagementCF();
288 285
289 private: 286 private:
290 const struct cf_t* _data; 287 const struct cf_t* _data;
291}; 288};
292 289
293/*====================================================================================== 290/*======================================================================================
294 * OWaveLanManagementFH 291 * OWaveLanManagementFH
295 *======================================================================================*/ 292 *======================================================================================*/
296 293
297class OWaveLanManagementFH : public QObject 294class OWaveLanManagementFH : public QObject
298{ 295{
299 Q_OBJECT 296 Q_OBJECT
300 297
301 public: 298 public:
302 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); 299 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 );
303 virtual ~OWaveLanManagementFH(); 300 virtual ~OWaveLanManagementFH();
304 301
305 private: 302 private:
306 const struct fh_t* _data; 303 const struct fh_t* _data;
307}; 304};
308 305
309/*====================================================================================== 306/*======================================================================================
310 * OWaveLanManagementDS 307 * OWaveLanManagementDS
311 *======================================================================================*/ 308 *======================================================================================*/
312 309
313class OWaveLanManagementDS : public QObject 310class OWaveLanManagementDS : public QObject
314{ 311{
315 Q_OBJECT 312 Q_OBJECT
316 313
317 public: 314 public:
318 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); 315 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 );
319 virtual ~OWaveLanManagementDS(); 316 virtual ~OWaveLanManagementDS();
320 317
321 int channel() const; 318 int channel() const;
322 319
323 private: 320 private:
324 const struct ds_t* _data; 321 const struct ds_t* _data;
325}; 322};
326 323
327/*====================================================================================== 324/*======================================================================================
328 * OWaveLanManagementTim 325 * OWaveLanManagementTim
329 *======================================================================================*/ 326 *======================================================================================*/
330 327
331class OWaveLanManagementTim : public QObject 328class OWaveLanManagementTim : public QObject
332{ 329{
333 Q_OBJECT 330 Q_OBJECT
334 331
335 public: 332 public:
336 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); 333 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 );
337 virtual ~OWaveLanManagementTim(); 334 virtual ~OWaveLanManagementTim();
338 335
339 private: 336 private:
340 const struct tim_t* _data; 337 const struct tim_t* _data;
341}; 338};
342 339
343/*====================================================================================== 340/*======================================================================================
344 * OWaveLanManagementIBSS 341 * OWaveLanManagementIBSS
345 *======================================================================================*/ 342 *======================================================================================*/
346 343
347class OWaveLanManagementIBSS : public QObject 344class OWaveLanManagementIBSS : public QObject
348{ 345{
349 Q_OBJECT 346 Q_OBJECT
350 347
351 public: 348 public:
352 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); 349 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 );
353 virtual ~OWaveLanManagementIBSS(); 350 virtual ~OWaveLanManagementIBSS();
354 351
355 private: 352 private:
356 const struct ibss_t* _data; 353 const struct ibss_t* _data;
357}; 354};
358 355
359/*====================================================================================== 356/*======================================================================================
360 * OWaveLanManagementChallenge 357 * OWaveLanManagementChallenge
361 *======================================================================================*/ 358 *======================================================================================*/
362 359
363class OWaveLanManagementChallenge : public QObject 360class OWaveLanManagementChallenge : public QObject
364{ 361{
365 Q_OBJECT 362 Q_OBJECT
366 363
367 public: 364 public:
368 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); 365 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 );
369 virtual ~OWaveLanManagementChallenge(); 366 virtual ~OWaveLanManagementChallenge();
370 367
371 private: 368 private:
372 const struct challenge_t* _data; 369 const struct challenge_t* _data;
373}; 370};
374 371
375/*====================================================================================== 372/*======================================================================================
376 * OWaveLanDataPacket - type: data (T_DATA) 373 * OWaveLanDataPacket - type: data (T_DATA)
377 *======================================================================================*/ 374 *======================================================================================*/
378 375
379class OWaveLanDataPacket : public QObject 376class OWaveLanDataPacket : public QObject
380{ 377{
381 Q_OBJECT 378 Q_OBJECT
382 379
383 public: 380 public:
384 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); 381 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 );
385 virtual ~OWaveLanDataPacket(); 382 virtual ~OWaveLanDataPacket();
386 383
387 private: 384 private:
388 const struct ieee_802_11_data_header* _header; 385 const struct ieee_802_11_data_header* _header;
389}; 386};
390 387
391/*====================================================================================== 388/*======================================================================================
392 * OWaveLanControlPacket - type: control (T_CTRL) 389 * OWaveLanControlPacket - type: control (T_CTRL)
393 *======================================================================================*/ 390 *======================================================================================*/
394 391
395class OWaveLanControlPacket : public QObject 392class OWaveLanControlPacket : public QObject
396{ 393{
397 Q_OBJECT 394 Q_OBJECT
398 395
399 public: 396 public:
400 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); 397 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 );
401 virtual ~OWaveLanControlPacket(); 398 virtual ~OWaveLanControlPacket();
402 399
403 private: 400 private:
404 const struct ieee_802_11_control_header* _header; 401 const struct ieee_802_11_control_header* _header;
405}; 402};
406 403
407/*====================================================================================== 404/*======================================================================================
408 * OLLCPacket - IEEE 802.2 Link Level Control 405 * OLLCPacket - IEEE 802.2 Link Level Control
409 *======================================================================================*/ 406 *======================================================================================*/
410 407
411class OLLCPacket : public QObject 408class OLLCPacket : public QObject
412{ 409{
413 Q_OBJECT 410 Q_OBJECT
414 411
415 public: 412 public:
416 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); 413 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 );
417 virtual ~OLLCPacket(); 414 virtual ~OLLCPacket();
418 415
419 private: 416 private:
420 const struct ieee_802_11_802_2_header* _header; 417 const struct ieee_802_11_802_2_header* _header;
421}; 418};
422 419
423/*====================================================================================== 420/*======================================================================================
424 * OIPPacket 421 * OIPPacket
425 *======================================================================================*/ 422 *======================================================================================*/
426 423
427class OIPPacket : public QObject 424class OIPPacket : public QObject
428{ 425{
429 Q_OBJECT 426 Q_OBJECT
430 427
431 public: 428 public:
432 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); 429 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 );
433 virtual ~OIPPacket(); 430 virtual ~OIPPacket();
434 431
435 QHostAddress fromIPAddress() const; 432 QHostAddress fromIPAddress() const;
436 QHostAddress toIPAddress() const; 433 QHostAddress toIPAddress() const;
437 434
438 int tos() const; 435 int tos() const;
439 int len() const; 436 int len() const;
440 int id() const; 437 int id() const;
441 int offset() const; 438 int offset() const;
442 int ttl() const; 439 int ttl() const;
443 int protocol() const; 440 int protocol() const;
444 int checksum() const; 441 int checksum() const;
445 442
446 private: 443 private:
447 const struct iphdr* _iphdr; 444 const struct iphdr* _iphdr;
448}; 445};
449 446
450/*====================================================================================== 447/*======================================================================================
451 * OARPPacket 448 * OARPPacket
452 *======================================================================================*/ 449 *======================================================================================*/
453 450
454class OARPPacket : public QObject 451class OARPPacket : public QObject
455{ 452{
456 Q_OBJECT 453 Q_OBJECT
457 454
458 public: 455 public:
459 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); 456 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 );
460 virtual ~OARPPacket(); 457 virtual ~OARPPacket();
461 458
462 QHostAddress senderIPV4Address() const; 459 QHostAddress senderIPV4Address() const;
463 OMacAddress senderMacAddress() const; 460 OMacAddress senderMacAddress() const;
464 QHostAddress targetIPV4Address() const; 461 QHostAddress targetIPV4Address() const;
465 OMacAddress targetMacAddress() const; 462 OMacAddress targetMacAddress() const;
466 463
467 //int type() const; 464 //int type() const;
468 QString type() const; 465 QString type() const;
469 466
470 private: 467 private:
471 const struct myarphdr* _arphdr; 468 const struct myarphdr* _arphdr;
472}; 469};
473 470
474/*====================================================================================== 471/*======================================================================================
475 * OUDPPacket 472 * OUDPPacket
476 *======================================================================================*/ 473 *======================================================================================*/
477 474
478class OUDPPacket : public QObject 475class OUDPPacket : public QObject
479{ 476{
480 Q_OBJECT 477 Q_OBJECT
481 478
482 public: 479 public:
483 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); 480 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
484 virtual ~OUDPPacket(); 481 virtual ~OUDPPacket();
485 482
486 int fromPort() const; 483 int fromPort() const;
487 int toPort() const; 484 int toPort() const;
488 int length() const; 485 int length() const;
489 int checksum() const; 486 int checksum() const;
490 487
491 private: 488 private:
492 const struct udphdr* _udphdr; 489 const struct udphdr* _udphdr;
493}; 490};
494 491
495/*====================================================================================== 492/*======================================================================================
496 * ODHCPPacket 493 * ODHCPPacket
497 *======================================================================================*/ 494 *======================================================================================*/
498 495
499class ODHCPPacket : public QObject 496class ODHCPPacket : public QObject
500{ 497{
501 Q_OBJECT 498 Q_OBJECT
502 499
503 public: 500 public:
504 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); 501 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 );
505 virtual ~ODHCPPacket(); 502 virtual ~ODHCPPacket();
506 503
507 QHostAddress clientAddress() const; 504 QHostAddress clientAddress() const;
508 QHostAddress yourAddress() const; 505 QHostAddress yourAddress() const;
509 QHostAddress serverAddress() const; 506 QHostAddress serverAddress() const;
510 QHostAddress relayAddress() const; 507 QHostAddress relayAddress() const;
511 508
512 OMacAddress clientMacAddress() const; 509 OMacAddress clientMacAddress() const;
513 510
514 bool isRequest() const; 511 bool isRequest() const;
515 bool isReply() const; 512 bool isReply() const;
516 QString type() const; 513 QString type() const;
517 514
518 private: 515 private:
519 const struct dhcp_packet* _dhcphdr; 516 const struct dhcp_packet* _dhcphdr;
520 unsigned char _type; 517 unsigned char _type;
521}; 518};
522 519
523/*====================================================================================== 520/*======================================================================================
524 * OTCPPacket 521 * OTCPPacket
525 *======================================================================================*/ 522 *======================================================================================*/
526 523
527class OTCPPacket : public QObject 524class OTCPPacket : public QObject
528{ 525{
529 Q_OBJECT 526 Q_OBJECT
530 527
531 public: 528 public:
532 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); 529 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
533 virtual ~OTCPPacket(); 530 virtual ~OTCPPacket();
534 531
535 int fromPort() const; 532 int fromPort() const;
536 int toPort() const; 533 int toPort() const;
537 int seq() const; 534 int seq() const;
538 int ack() const; 535 int ack() const;
539 int window() const; 536 int window() const;
540 int checksum() const; 537 int checksum() const;
541 538
542 private: 539 private:
543 const struct tcphdr* _tcphdr; 540 const struct tcphdr* _tcphdr;
544}; 541};
545 542
546 543
547/*====================================================================================== 544/*======================================================================================
548 * OPacketCapturer 545 * OPacketCapturer
549 *======================================================================================*/ 546 *======================================================================================*/
550 547
551/** 548/**
552 * @brief A class based wrapper for network packet capturing. 549 * @brief A class based wrapper for network packet capturing.
553 * 550 *
554 * This class is the base of a high-level interface to the well known packet capturing 551 * This class is the base of a high-level interface to the well known packet capturing
555 * library libpcap. 552 * library libpcap.
556 * @see http://tcpdump.org 553 * @see http://tcpdump.org
557 */ 554 */
558class OPacketCapturer : public QObject 555class OPacketCapturer : public QObject
559{ 556{
560 Q_OBJECT 557 Q_OBJECT
561 558
562 public: 559 public:
563 /** 560 /**
564 * Constructor. 561 * Constructor.
565 */ 562 */
566 OPacketCapturer( QObject* parent = 0, const char* name = 0 ); 563 OPacketCapturer( QObject* parent = 0, const char* name = 0 );
567 /** 564 /**
568 * Destructor. 565 * Destructor.
569 */ 566 */
570 ~OPacketCapturer(); 567 ~OPacketCapturer();
571 /** 568 /**
572 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when 569 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when
573 * not using the socket notifier, e.g. without an application object. 570 * not using the socket notifier, e.g. without an application object.
574 */ 571 */
575 void setBlocking( bool ); 572 void setBlocking( bool );
576 /** 573 /**
577 * @returns true if the packet capturer uses blocking IO calls. 574 * @returns true if the packet capturer uses blocking IO calls.
578 */ 575 */
579 bool blocking() const; 576 bool blocking() const;
580 /** 577 /**
581 * Close the packet capturer. This is automatically done in the destructor. 578 * Close the packet capturer. This is automatically done in the destructor.
582 */ 579 */
583 void close(); 580 void close();
584 /** 581 /**
585 * Close the output capture file. 582 * Close the output capture file.
586 */ 583 */
587 void closeDumpFile(); 584 void closeDumpFile();
588 /** 585 /**
589 * @returns the data link type. 586 * @returns the data link type.
590 * @see <pcap.h> for possible values. 587 * @see <pcap.h> for possible values.
591 */ 588 */
592 int dataLink() const; 589 int dataLink() const;
593 /** 590 /**
594 * Dump a packet to the output capture file. 591 * Dump a packet to the output capture file.
595 */ 592 */
596 void dump( OPacket* ); 593 void dump( OPacket* );
597 /** 594 /**
598 * @returns the file descriptor of the packet capturer. This is only useful, if 595 * @returns the file descriptor of the packet capturer. This is only useful, if
599 * not using the socket notifier, e.g. without an application object. 596 * not using the socket notifier, e.g. without an application object.
600 */ 597 */
601 int fileno() const; 598 int fileno() const;
602 /** 599 /**
603 * @returns the next @ref OPacket from the packet capturer. 600 * @returns the next @ref OPacket from the packet capturer.
604 * @note If blocking mode is true then this call might block. 601 * @note If blocking mode is true then this call might block.
605 */ 602 */
606 OPacket* next(); 603 OPacket* next();
607 /** 604 /**
608 * @returns the next @ref OPacket from the packet capturer, if 605 * @returns the next @ref OPacket from the packet capturer, if
609 * one arrives within @a time milliseconds. 606 * one arrives within @a time milliseconds.
610 */ 607 */
611 OPacket* next( int time ); 608 OPacket* next( int time );
612 /** 609 /**
613 * Open the packet capturer to capture packets in live-mode from @a interface. 610 * Open the packet capturer to capture packets in live-mode from @a interface.
614 */ 611 */
615 bool open( const QString& interface ); 612 bool open( const QString& interface );
616 /** 613 /**
617 * Open the packet capturer to capture packets in offline-mode from @a file. 614 * Open the packet capturer to capture packets in offline-mode from @a file.
618 */ 615 */
619 bool open( const QFile& file ); 616 bool open( const QFile& file );
620 /** 617 /**
621 * Open a prerecorded tcpdump compatible capture file for use with @ref dump() 618 * Open a prerecorded tcpdump compatible capture file for use with @ref dump()
622 */ 619 */
623 bool openDumpFile( const QString& filename ); 620 bool openDumpFile( const QString& filename );
624 /** 621 /**
625 * @returns true if the packet capturer is open 622 * @returns true if the packet capturer is open
626 */ 623 */
627 bool isOpen() const; 624 bool isOpen() const;
628 /** 625 /**
629 * @returns the snapshot length of this packet capturer 626 * @returns the snapshot length of this packet capturer
630 */ 627 */
631 int snapShot() const; 628 int snapShot() const;
632 /** 629 /**
633 * @returns true if the input capture file has a different byte-order 630 * @returns true if the input capture file has a different byte-order
634 * than the byte-order of the running system. 631 * than the byte-order of the running system.
635 */ 632 */
636 bool swapped() const; 633 bool swapped() const;
637 /** 634 /**
638 * @returns the libpcap version string used to write the input capture file. 635 * @returns the libpcap version string used to write the input capture file.
639 */ 636 */
640 QString version() const; 637 QString version() const;
641 /** 638 /**
642 * @returns the packet statistic database. 639 * @returns the packet statistic database.
643 * @see QMap 640 * @see QMap
644 */ 641 */
645 const QMap<QString,int>& statistics() const; 642 const QMap<QString,int>& statistics() const;
646 643
647 signals: 644 signals:
648 /** 645 /**
649 * This signal is emitted, when a packet has been received. 646 * This signal is emitted, when a packet has been received.
650 */ 647 */
651 void receivedPacket( OPacket* ); 648 void receivedPacket( OPacket* );
652 649
653 protected slots: 650 protected slots:
654 void readyToReceive(); 651 void readyToReceive();
655 652
656 protected: 653 protected:
657 QString _name; // devicename 654 QString _name; // devicename
658 bool _open; // check this before doing pcap calls 655 bool _open; // check this before doing pcap calls
659 pcap_t* _pch; // pcap library handle 656 pcap_t* _pch; // pcap library handle
660 pcap_dumper_t* _pcd; // pcap dumper handle 657 pcap_dumper_t* _pcd; // pcap dumper handle
661 QSocketNotifier* _sn; // socket notifier for main loop 658 QSocketNotifier* _sn; // socket notifier for main loop
662 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap 659 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap
663 QMap<QString, int> _stats; // statistics; 660 QMap<QString, int> _stats; // statistics;
664}; 661};
665 662
666#endif // OPCAP_H 663#endif // OPCAP_H
667 664
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro
index 386c2db..2027481 100644
--- a/libopie2/opienet/opienet.pro
+++ b/libopie2/opienet/opienet.pro
@@ -1,34 +1,34 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = 802_11_user.h \ 4HEADERS = 802_11_user.h \
5 dhcp.h \ 5 dhcp.h \
6 udp_ports.h \ 6 udp_ports.h \
7 wireless.h \ 7 wireless.h \
8 odebugmapper.h \ 8 odebugmapper.h \
9 omanufacturerdb.h \ 9 omanufacturerdb.h \
10 onetutils.h \ 10 onetutils.h \
11 onetwork.h \ 11 onetwork.h \
12 opcap.h \ 12 opcap.h \
13 ostation.h 13 ostation.h
14SOURCES = odebugmapper.cpp \ 14SOURCES = odebugmapper.cpp \
15 omanufacturerdb.cpp \ 15 omanufacturerdb.cpp \
16 onetutils.cpp \ 16 onetutils.cpp \
17 onetwork.cpp \ 17 onetwork.cpp \
18 opcap.cpp \ 18 opcap.cpp \
19 ostation.cpp 19 ostation.cpp
20INTERFACES = 20INTERFACES =
21TARGET = opienet2 21TARGET = opienet2
22VERSION = 1.8.1 22VERSION = 1.8.2
23INCLUDEPATH += $(OPIEDIR)/include 23INCLUDEPATH += $(OPIEDIR)/include
24DEPENDPATH += $(OPIEDIR)/include 24DEPENDPATH += $(OPIEDIR)/include
25LIBS += -lpcap 25LIBS += -lpcap
26 26
27 27
28!contains( platform, x11 ) { 28!contains( platform, x11 ) {
29 include ( $(OPIEDIR)/include.pro ) 29 include ( $(OPIEDIR)/include.pro )
30} 30}
31 31
32contains( platform, x11 ) { 32contains( platform, x11 ) {
33 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 33 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
34} 34}
diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp
index ba1e4f6..c363f0c 100644
--- a/libopie2/opienet/ostation.cpp
+++ b/libopie2/opienet/ostation.cpp
@@ -1,64 +1,63 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 4 =.
6 .=l. 5 .=l.
7           .>+-= 6           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 13    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 20++=   -.     .`     .: details.
22 :     =  ...= . :.=- 21 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
29 28
30*/ 29*/
31 30
32#include <opie2/ostation.h> 31#include <opie2/ostation.h>
33 32
34/*====================================================================================== 33/*======================================================================================
35 * OStation 34 * OStation
36 *======================================================================================*/ 35 *======================================================================================*/
37 36
38OStation::OStation() 37OStation::OStation()
39{ 38{
40 qDebug( "OStation::OStation()" ); 39 qDebug( "OStation::OStation()" );
41 40
42 type = "<unknown>"; 41 type = "<unknown>";
43 macAddress = OMacAddress::unknown; 42 macAddress = OMacAddress::unknown;
44 ssid = "<unknown>"; 43 ssid = "<unknown>";
45 channel = 0; 44 channel = 0;
46 apAddress = OMacAddress::unknown; 45 apAddress = OMacAddress::unknown;
47 46
48} 47}
49 48
50 49
51OStation::~OStation() 50OStation::~OStation()
52{ 51{
53 qDebug( "OStation::~OStation()" ); 52 qDebug( "OStation::~OStation()" );
54} 53}
55 54
56 55
57void OStation::dump() 56void OStation::dump()
58{ 57{
59 qDebug( "------- OStation::dump() ------------" ); 58 qDebug( "------- OStation::dump() ------------" );
60 qDebug( "type: %s", (const char*) type ); 59 qDebug( "type: %s", (const char*) type );
61 qDebug( "mac: %s", (const char*) macAddress.toString() ); 60 qDebug( "mac: %s", (const char*) macAddress.toString() );
62 qDebug( "ap: %s", (const char*) apAddress.toString() ); 61 qDebug( "ap: %s", (const char*) apAddress.toString() );
63 qDebug( "ip: %s", (const char*) ipAddress.toString() ); 62 qDebug( "ip: %s", (const char*) ipAddress.toString() );
64} 63}
diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h
index a6956c9..1e7366d 100644
--- a/libopie2/opienet/ostation.h
+++ b/libopie2/opienet/ostation.h
@@ -1,74 +1,73 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 4 =.
6 .=l. 5 .=l.
7           .>+-= 6           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 13    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 20++=   -.     .`     .: details.
22 :     =  ...= . :.=- 21 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
29 28
30*/ 29*/
31 30
32#ifndef OSTATION_H 31#ifndef OSTATION_H
33#define OSTATION_H 32#define OSTATION_H
34 33
35#include <opie2/onetutils.h> 34#include <opie2/onetutils.h>
36 35
37#include <qlist.h> 36#include <qlist.h>
38#include <qstring.h> 37#include <qstring.h>
39#include <qhostaddress.h> 38#include <qhostaddress.h>
40#include <qobject.h> 39#include <qobject.h>
41 40
42#include <sys/types.h> 41#include <sys/types.h>
43 42
44class OStation; 43class OStation;
45 44
46typedef QList<OStation> OStationList; 45typedef QList<OStation> OStationList;
47 46
48/*====================================================================================== 47/*======================================================================================
49 * OStation 48 * OStation
50 *======================================================================================*/ 49 *======================================================================================*/
51 50
52class OStation 51class OStation
53{ 52{
54 public: 53 public:
55 OStation(); 54 OStation();
56 ~OStation(); 55 ~OStation();
57 56
58 void dump(); 57 void dump();
59 58
60 /* Ethernet */ 59 /* Ethernet */
61 QString type; 60 QString type;
62 OMacAddress macAddress; 61 OMacAddress macAddress;
63 QHostAddress ipAddress; 62 QHostAddress ipAddress;
64 63
65 /* WaveLan */ 64 /* WaveLan */
66 QString ssid; 65 QString ssid;
67 OMacAddress apAddress; 66 OMacAddress apAddress;
68 int channel; 67 int channel;
69 bool encrypted; 68 bool encrypted;
70}; 69};
71 70
72 71
73#endif // OSTATION_H 72#endif // OSTATION_H
74 73
diff --git a/libopie2/opienet/udp_ports.h b/libopie2/opienet/udp_ports.h
index 5e92497..3fb1c85 100644
--- a/libopie2/opienet/udp_ports.h
+++ b/libopie2/opienet/udp_ports.h
@@ -1,89 +1,89 @@
1/* 1/*
2 * This file has been generated by doing 2 * This file has been generated by doing
3 * find . -name "*"|xargs grep -h '#define UDP_PORT' > udp_ports.h 3 * find . -name "*"|xargs grep -h '#define UDP_PORT' > udp_ports.h
4 * in the root directory of Ethereal 0.9.15. Cudos to the Ethereal Team. 4 * in the root directory of Ethereal 0.9.15. Cudos to the Ethereal Team.
5 * -- Michael 'Mickey' Lauer <mickeyl@handhelds.org> 5 * -- Michael 'Mickey' Lauer <mickey@Vanille.de>
6 */ 6 */
7 7
8 #define UDP_PORT_AODV654 8 #define UDP_PORT_AODV654
9#define UDP_PORT_LENGTH 2 9#define UDP_PORT_LENGTH 2
10#define UDP_PORT_OFFSET PARAMETER_VALUE_OFFSET 10#define UDP_PORT_OFFSET PARAMETER_VALUE_OFFSET
11#define UDP_PORT_RAS1 1718 11#define UDP_PORT_RAS1 1718
12#define UDP_PORT_RAS2 1719 12#define UDP_PORT_RAS2 1719
13 #define UDP_PORT_CPHA8116 13 #define UDP_PORT_CPHA8116
14 #define UDP_PORT_DDTP1052 14 #define UDP_PORT_DDTP1052
15 #define UDP_PORT_CUPS631 15 #define UDP_PORT_CUPS631
16 #define UDP_PORT_DLSW 2067 16 #define UDP_PORT_DLSW 2067
17 #define UDP_PORT_ISAKMP500 17 #define UDP_PORT_ISAKMP500
18#define UDP_PORT_L2TP 1701 18#define UDP_PORT_L2TP 1701
19#define UDP_PORT_IAPP 2313 19#define UDP_PORT_IAPP 2313
20#define UDP_PORT_HSRP 1985 20#define UDP_PORT_HSRP 1985
21 #define UDP_PORT_SSDP 1900 21 #define UDP_PORT_SSDP 1900
22 #define UDP_PORT_TACACS49 22 #define UDP_PORT_TACACS49
23 #define UDP_PORT_CLDAP 389 23 #define UDP_PORT_CLDAP 389
24 #define UDP_PORT_VINES573 24 #define UDP_PORT_VINES573
25 #define UDP_PORT_NBNS137 25 #define UDP_PORT_NBNS137
26 #define UDP_PORT_NBDGM138 26 #define UDP_PORT_NBDGM138
27#define UDP_PORT_XYPLEX 173 27#define UDP_PORT_XYPLEX 173
28#define UDP_PORT_PIM_RP_DISC 496 28#define UDP_PORT_PIM_RP_DISC 496
29#define UDP_PORT_SLIMP3_V1 1069 29#define UDP_PORT_SLIMP3_V1 1069
30#define UDP_PORT_SLIMP3_V2 3483 30#define UDP_PORT_SLIMP3_V2 3483
31 #define UDP_PORT_RMCP 623 31 #define UDP_PORT_RMCP 623
32 #define UDP_PORT_RMCP_SECURE664 32 #define UDP_PORT_RMCP_SECURE664
33#define UDP_PORT_SYSLOG 514 33#define UDP_PORT_SYSLOG 514
34 #define UDP_PORT_SNMP 161 34 #define UDP_PORT_SNMP 161
35 #define UDP_PORT_SNMP_TRAP162 35 #define UDP_PORT_SNMP_TRAP162
36#define UDP_PORT_TFTP 69 36#define UDP_PORT_TFTP 69
37#define UDP_PORT_TIME 37 37#define UDP_PORT_TIME 37
38 #define UDP_PORT_STUN 3478 38 #define UDP_PORT_STUN 3478
39 #define UDP_PORT_SRVLOC427 39 #define UDP_PORT_SRVLOC427
40 #define UDP_PORT_TZSP0x9090 40 #define UDP_PORT_TZSP0x9090
41 #define UDP_PORT_WCCP2048 41 #define UDP_PORT_WCCP2048
42#define UDP_PORT_MSPROXY 1745 42#define UDP_PORT_MSPROXY 1745
43#define UDP_PORT_BOOTPS 67 43#define UDP_PORT_BOOTPS 67
44#define UDP_PORT_BOOTPC 68 44#define UDP_PORT_BOOTPC 68
45#define UDP_PORT_XDMCP 177 45#define UDP_PORT_XDMCP 177
46 #define UDP_PORT_DHCPV6_DOWNSTREAM546 46 #define UDP_PORT_DHCPV6_DOWNSTREAM546
47 #define UDP_PORT_DHCPV6_UPSTREAM547 47 #define UDP_PORT_DHCPV6_UPSTREAM547
48#define UDP_PORT_DNS 53 48#define UDP_PORT_DNS 53
49#define UDP_PORT_MDNS 5353 49#define UDP_PORT_MDNS 5353
50#define UDP_PORT_ICP 3130 50#define UDP_PORT_ICP 3130
51 #define UDP_PORT_ICQ4000 51 #define UDP_PORT_ICQ4000
52 #define UDP_PORT_IPX 213 /* RFC 1234 */ 52 #define UDP_PORT_IPX 213 /* RFC 1234 */
53#define UDP_PORT_LDP 646 53#define UDP_PORT_LDP 646
54#define UDP_PORT_LLC1 12000 54#define UDP_PORT_LLC1 12000
55#define UDP_PORT_LLC2 12001 55#define UDP_PORT_LLC2 12001
56#define UDP_PORT_LLC3 12002 56#define UDP_PORT_LLC3 12002
57#define UDP_PORT_LLC4 12003 57#define UDP_PORT_LLC4 12003
58#define UDP_PORT_LLC5 12004 58#define UDP_PORT_LLC5 12004
59#define UDP_PORT_MIP 434 59#define UDP_PORT_MIP 434
60 #define UDP_PORT_NCP 524 60 #define UDP_PORT_NCP 524
61 #define UDP_PORT_NTP123 61 #define UDP_PORT_NTP123
62#define UDP_PORT_RIP 520 62#define UDP_PORT_RIP 520
63 #define UDP_PORT_SAP9875 63 #define UDP_PORT_SAP9875
64#define UDP_PORT_SIP 5060 64#define UDP_PORT_SIP 5060
65 #define UDP_PORT_TIMED525 65 #define UDP_PORT_TIMED525
66#define UDP_PORT_RIPNG 521 66#define UDP_PORT_RIPNG 521
67 #define UDP_PORT_WSP 9200 /* wap-wsp */ 67 #define UDP_PORT_WSP 9200 /* wap-wsp */
68 #define UDP_PORT_WTP_WSP 9201 /* wap-wsp-wtp */ 68 #define UDP_PORT_WTP_WSP 9201 /* wap-wsp-wtp */
69 #define UDP_PORT_WTLS_WSP 9202 /* wap-wsp-s */ 69 #define UDP_PORT_WTLS_WSP 9202 /* wap-wsp-s */
70 #define UDP_PORT_WTLS_WTP_WSP 9203 /* wap-wsp-wtp-s*/ 70 #define UDP_PORT_WTLS_WTP_WSP 9203 /* wap-wsp-wtp-s*/
71 #define UDP_PORT_WSP_PUSH 2948 /* wap-wsp */ 71 #define UDP_PORT_WSP_PUSH 2948 /* wap-wsp */
72 #define UDP_PORT_WTLS_WSP_PUSH 2949 /* wap-wsp-s */ 72 #define UDP_PORT_WTLS_WSP_PUSH 2949 /* wap-wsp-s */
73#define UDP_PORT_WHO 513 73#define UDP_PORT_WHO 513
74 #define UDP_PORT_KERBEROS 88 74 #define UDP_PORT_KERBEROS 88
75#define UDP_PORT_SFLOW 6343 75#define UDP_PORT_SFLOW 6343
76#define UDP_PORT_LAPLINK 1547 76#define UDP_PORT_LAPLINK 1547
77 #define UDP_PORT_NETFLOW2055 77 #define UDP_PORT_NETFLOW2055
78 #define UDP_PORT_RX_LOW 7000 78 #define UDP_PORT_RX_LOW 7000
79 #define UDP_PORT_RX_HIGH7009 79 #define UDP_PORT_RX_HIGH7009
80 #define UDP_PORT_RX_AFS_BACKUPS7021 80 #define UDP_PORT_RX_AFS_BACKUPS7021
81#define UDP_PORT_MGCP_GATEWAY 2427 81#define UDP_PORT_MGCP_GATEWAY 2427
82#define UDP_PORT_MGCP_CALLAGENT 2727 82#define UDP_PORT_MGCP_CALLAGENT 2727
83#define UDP_PORT_PCLI 9000 83#define UDP_PORT_PCLI 9000
84#define UDP_PORT_ARTNET 0x1936 84#define UDP_PORT_ARTNET 0x1936
85#define UDP_PORT_TERREDO 3544 85#define UDP_PORT_TERREDO 3544
86 #define UDP_PORT_RADIUS 1645 86 #define UDP_PORT_RADIUS 1645
87 #define UDP_PORT_RADIUS_NEW1812 87 #define UDP_PORT_RADIUS_NEW1812
88 #define UDP_PORT_RADACCT1646 88 #define UDP_PORT_RADACCT1646
89 #define UDP_PORT_RADACCT_NEW1813 89 #define UDP_PORT_RADACCT_NEW1813