summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2003-10-02 20:53:58 (UTC)
committer mickeyl <mickeyl>2003-10-02 20:53:58 (UTC)
commit78b29c765dbe70faec614796a4d1421eaf0ec773 (patch) (unidiff)
tree2db88636d14a462d8538003bcd282f3140b1d5f6 /libopie2
parente4fc6c395dd0a7400ed2cf76b3148dd7f535c2ea (diff)
downloadopie-78b29c765dbe70faec614796a4d1421eaf0ec773.zip
opie-78b29c765dbe70faec614796a4d1421eaf0ec773.tar.gz
opie-78b29c765dbe70faec614796a4d1421eaf0ec773.tar.bz2
prepare dhcp decoding
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/dhcp.h200
-rw-r--r--libopie2/opienet/opcap.cpp79
-rw-r--r--libopie2/opienet/opcap.h28
-rw-r--r--libopie2/opienet/opienet.pro4
4 files changed, 309 insertions, 2 deletions
diff --git a/libopie2/opienet/dhcp.h b/libopie2/opienet/dhcp.h
new file mode 100644
index 0000000..3f2f775
--- a/dev/null
+++ b/libopie2/opienet/dhcp.h
@@ -0,0 +1,200 @@
1/* dhcp.h
2
3 Protocol structures... */
4
5/*
6 * Copyright (c) 1995-2001 The Internet Software Consortium.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of The Internet Software Consortium nor the names
19 * of its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * This software has been written for the Internet Software Consortium
37 * by Ted Lemon in cooperation with Vixie Enterprises. To learn more
38 * about the Internet Software Consortium, see ``http://www.isc.org''.
39 * To learn more about Vixie Enterprises, see ``http://www.vix.com''.
40 */
41
42#ifndef DHCP_H
43#define DHCP_H
44
45 #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \
46 20 + /* IP header */ \
47 8) /* UDP header */
48 #define DHCP_SNAME_LEN 64
49 #define DHCP_FILE_LEN 128
50 #define DHCP_FIXED_NON_UDP236
51 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
52 /* Everything but options. */
53 #define DHCP_MTU_MAX 1500
54 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
55
56 #define BOOTP_MIN_LEN 300
57#define DHCP_MIN_LEN 548
58
59struct dhcp_packet {
60 u_int8_t op; /* 0: Message opcode/type */
61 u_int8_t htype;/* 1: Hardware addr type (net/if_types.h) */
62 u_int8_t hlen; /* 2: Hardware addr length */
63 u_int8_t hops; /* 3: Number of relay agent hops from client */
64 u_int32_t xid; /* 4: Transaction ID */
65 u_int16_t secs; /* 8: Seconds since client started looking */
66 u_int16_t flags;/* 10: Flag bits */
67 struct in_addr ciaddr;/* 12: Client IP address (if already in use) */
68 struct in_addr yiaddr;/* 16: Client IP address */
69 struct in_addr siaddr;/* 18: IP address of next server to talk to */
70 struct in_addr giaddr;/* 20: DHCP relay agent IP address */
71 unsigned char chaddr [16];/* 24: Client hardware address */
72 char sname [DHCP_SNAME_LEN];/* 40: Server name */
73 char file [DHCP_FILE_LEN];/* 104: Boot filename */
74 unsigned char options [DHCP_OPTION_LEN];
75 /* 212: Optional parameters
76 (actual length dependent on MTU). */
77};
78
79/* BOOTP (rfc951) message types */
80 #define BOOTREQUEST1
81 #define BOOTREPLY2
82
83/* Possible values for flags field... */
84#define BOOTP_BROADCAST 32768L
85
86/* Possible values for hardware type (htype) field... */
87 #define HTYPE_ETHER1 /* Ethernet 10Mbps */
88 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/
89 #define HTYPE_FDDI 8 /* FDDI... */
90
91/* Magic cookie validating dhcp options field (and bootp vendor
92 extensions field). */
93 #define DHCP_OPTIONS_COOKIE"\143\202\123\143"
94
95/* DHCP Option codes: */
96
97 #define DHO_PAD 0
98 #define DHO_SUBNET_MASK 1
99 #define DHO_TIME_OFFSET 2
100 #define DHO_ROUTERS 3
101 #define DHO_TIME_SERVERS 4
102 #define DHO_NAME_SERVERS 5
103 #define DHO_DOMAIN_NAME_SERVERS 6
104 #define DHO_LOG_SERVERS 7
105 #define DHO_COOKIE_SERVERS 8
106 #define DHO_LPR_SERVERS 9
107 #define DHO_IMPRESS_SERVERS 10
108 #define DHO_RESOURCE_LOCATION_SERVERS11
109 #define DHO_HOST_NAME 12
110 #define DHO_BOOT_SIZE 13
111 #define DHO_MERIT_DUMP 14
112 #define DHO_DOMAIN_NAME 15
113 #define DHO_SWAP_SERVER 16
114 #define DHO_ROOT_PATH 17
115 #define DHO_EXTENSIONS_PATH 18
116 #define DHO_IP_FORWARDING 19
117 #define DHO_NON_LOCAL_SOURCE_ROUTING20
118 #define DHO_POLICY_FILTER 21
119 #define DHO_MAX_DGRAM_REASSEMBLY22
120 #define DHO_DEFAULT_IP_TTL 23
121 #define DHO_PATH_MTU_AGING_TIMEOUT24
122 #define DHO_PATH_MTU_PLATEAU_TABLE25
123 #define DHO_INTERFACE_MTU 26
124 #define DHO_ALL_SUBNETS_LOCAL 27
125 #define DHO_BROADCAST_ADDRESS 28
126 #define DHO_PERFORM_MASK_DISCOVERY29
127 #define DHO_MASK_SUPPLIER 30
128 #define DHO_ROUTER_DISCOVERY 31
129 #define DHO_ROUTER_SOLICITATION_ADDRESS32
130 #define DHO_STATIC_ROUTES 33
131 #define DHO_TRAILER_ENCAPSULATION34
132 #define DHO_ARP_CACHE_TIMEOUT 35
133 #define DHO_IEEE802_3_ENCAPSULATION36
134 #define DHO_DEFAULT_TCP_TTL 37
135 #define DHO_TCP_KEEPALIVE_INTERVAL38
136 #define DHO_TCP_KEEPALIVE_GARBAGE39
137 #define DHO_NIS_DOMAIN 40
138 #define DHO_NIS_SERVERS 41
139 #define DHO_NTP_SERVERS 42
140 #define DHO_VENDOR_ENCAPSULATED_OPTIONS43
141 #define DHO_NETBIOS_NAME_SERVERS44
142 #define DHO_NETBIOS_DD_SERVER 45
143 #define DHO_NETBIOS_NODE_TYPE 46
144 #define DHO_NETBIOS_SCOPE 47
145 #define DHO_FONT_SERVERS 48
146 #define DHO_X_DISPLAY_MANAGER 49
147 #define DHO_DHCP_REQUESTED_ADDRESS50
148 #define DHO_DHCP_LEASE_TIME 51
149 #define DHO_DHCP_OPTION_OVERLOAD52
150 #define DHO_DHCP_MESSAGE_TYPE 53
151 #define DHO_DHCP_SERVER_IDENTIFIER54
152 #define DHO_DHCP_PARAMETER_REQUEST_LIST55
153 #define DHO_DHCP_MESSAGE 56
154 #define DHO_DHCP_MAX_MESSAGE_SIZE57
155 #define DHO_DHCP_RENEWAL_TIME 58
156 #define DHO_DHCP_REBINDING_TIME 59
157 #define DHO_VENDOR_CLASS_IDENTIFIER60
158 #define DHO_DHCP_CLIENT_IDENTIFIER61
159 #define DHO_NWIP_DOMAIN_NAME 62
160 #define DHO_NWIP_SUBOPTIONS 63
161 #define DHO_USER_CLASS 77
162 #define DHO_FQDN 81
163 #define DHO_DHCP_AGENT_OPTIONS 82
164 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */
165/* The DHO_AUTHENTICATE option is not a standard yet, so I've
166 allocated an option out of the "local" option space for it on a
167 temporary basis. Once an option code number is assigned, I will
168 immediately and shamelessly break this, so don't count on it
169 continuing to work. */
170 #define DHO_AUTHENTICATE 210
171
172 #define DHO_END 255
173
174/* DHCP message types. */
175 #define DHCPDISCOVER1
176 #define DHCPOFFER2
177 #define DHCPREQUEST3
178 #define DHCPDECLINE4
179 #define DHCPACK 5
180 #define DHCPNAK 6
181 #define DHCPRELEASE7
182 #define DHCPINFORM8
183
184/* Relay Agent Information option subtypes: */
185 #define RAI_CIRCUIT_ID1
186 #define RAI_REMOTE_ID2
187 #define RAI_AGENT_ID3
188
189/* FQDN suboptions: */
190 #define FQDN_NO_CLIENT_UPDATE 1
191 #define FQDN_SERVER_UPDATE 2
192 #define FQDN_ENCODED 3
193 #define FQDN_RCODE1 4
194 #define FQDN_RCODE2 5
195 #define FQDN_HOSTNAME 6
196 #define FQDN_DOMAINNAME 7
197 #define FQDN_FQDN 8
198 #define FQDN_SUBOPTION_COUNT 8
199
200#endif \ No newline at end of file
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 1de7124..cc8ce7f 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -1,1096 +1,1175 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34/* OPIE */ 34/* OPIE */
35 35
36#include <opie2/opcap.h> 36#include <opie2/opcap.h>
37 37
38/* QT */ 38/* QT */
39 39
40#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) 40#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
41#include <qsocketnotifier.h> 41#include <qsocketnotifier.h>
42#include <qobjectlist.h> 42#include <qobjectlist.h>
43 43
44/*====================================================================================== 44/*======================================================================================
45 * OPacket 45 * OPacket
46 *======================================================================================*/ 46 *======================================================================================*/
47 47
48OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) 48OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
49 :QObject( parent, "Generic" ), _hdr( header ), _data( data ) 49 :QObject( parent, "Generic" ), _hdr( header ), _data( data )
50{ 50{
51 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); 51 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
52 52
53 _end = (unsigned char*) data + header.len; 53 _end = (unsigned char*) data + header.len;
54 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); 54 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end );
55 55
56 switch ( datalink ) 56 switch ( datalink )
57 { 57 {
58 case DLT_EN10MB: 58 case DLT_EN10MB:
59 qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); 59 qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" );
60 new OEthernetPacket( _end, (const struct ether_header*) data, this ); 60 new OEthernetPacket( _end, (const struct ether_header*) data, this );
61 break; 61 break;
62 62
63 case DLT_IEEE802_11: 63 case DLT_IEEE802_11:
64 qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); 64 qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" );
65 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); 65 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this );
66 break; 66 break;
67 67
68 case DLT_PRISM_HEADER: 68 case DLT_PRISM_HEADER:
69 qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" ); 69 qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" );
70 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); 70 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this );
71 break; 71 break;
72 72
73 default: 73 default:
74 qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink ); 74 qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink );
75 } 75 }
76} 76}
77 77
78 78
79OPacket::~OPacket() 79OPacket::~OPacket()
80{ 80{
81} 81}
82 82
83 83
84timevalstruct OPacket::timeval() const 84timevalstruct OPacket::timeval() const
85{ 85{
86 return _hdr.ts; 86 return _hdr.ts;
87} 87}
88 88
89 89
90int OPacket::caplen() const 90int OPacket::caplen() const
91{ 91{
92 return _hdr.caplen; 92 return _hdr.caplen;
93} 93}
94 94
95 95
96void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) 96void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l )
97{ 97{
98 if (!l) return; 98 if (!l) return;
99 QObject* o = l->first(); 99 QObject* o = l->first();
100 while ( o ) 100 while ( o )
101 { 101 {
102 stats[o->name()]++; 102 stats[o->name()]++;
103 updateStats( stats, const_cast<QObjectList*>( o->children() ) ); 103 updateStats( stats, const_cast<QObjectList*>( o->children() ) );
104 o = l->next(); 104 o = l->next();
105 } 105 }
106} 106}
107 107
108 108
109QString OPacket::dump( int bpl ) const 109QString OPacket::dump( int bpl ) const
110{ 110{
111 static int index = 0; 111 static int index = 0;
112 index++; 112 index++;
113 int len = _hdr.caplen; 113 int len = _hdr.caplen;
114 QString str; 114 QString str;
115 str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); 115 str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len );
116 str.append( "0000: " ); 116 str.append( "0000: " );
117 QString tmp; 117 QString tmp;
118 QString bytes; 118 QString bytes;
119 QString chars; 119 QString chars;
120 120
121 for ( int i = 0; i < len; ++i ) 121 for ( int i = 0; i < len; ++i )
122 { 122 {
123 tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); 123 tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp );
124 if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); 124 if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] );
125 else chars.append( '.' ); 125 else chars.append( '.' );
126 126
127 if ( !((i+1) % bpl) ) 127 if ( !((i+1) % bpl) )
128 { 128 {
129 str.append( bytes ); 129 str.append( bytes );
130 str.append( ' ' ); 130 str.append( ' ' );
131 str.append( chars ); 131 str.append( chars );
132 str.append( '\n' ); 132 str.append( '\n' );
133 tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); 133 tmp.sprintf( "%04X: ", i+1 ); str.append( tmp );
134 bytes = ""; 134 bytes = "";
135 chars = ""; 135 chars = "";
136 } 136 }
137 137
138 } 138 }
139 if ( (len % bpl) ) 139 if ( (len % bpl) )
140 { 140 {
141 str.append( bytes.leftJustify( 1 + 3*bpl ) ); 141 str.append( bytes.leftJustify( 1 + 3*bpl ) );
142 str.append( chars ); 142 str.append( chars );
143 } 143 }
144 str.append( '\n' ); 144 str.append( '\n' );
145 return str; 145 return str;
146} 146}
147 147
148 148
149int OPacket::len() const 149int OPacket::len() const
150{ 150{
151 return _hdr.len; 151 return _hdr.len;
152} 152}
153 153
154 154
155/*====================================================================================== 155/*======================================================================================
156 * OEthernetPacket 156 * OEthernetPacket
157 *======================================================================================*/ 157 *======================================================================================*/
158 158
159OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) 159OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent )
160 :QObject( parent, "Ethernet" ), _ether( data ) 160 :QObject( parent, "Ethernet" ), _ether( data )
161{ 161{
162 162
163 qDebug( "Source = %s", (const char*) sourceAddress().toString() ); 163 qDebug( "Source = %s", (const char*) sourceAddress().toString() );
164 qDebug( "Destination = %s", (const char*) destinationAddress().toString() ); 164 qDebug( "Destination = %s", (const char*) destinationAddress().toString() );
165 165
166 if ( sourceAddress() == OMacAddress::broadcast ) 166 if ( sourceAddress() == OMacAddress::broadcast )
167 qDebug( "Source is broadcast address" ); 167 qDebug( "Source is broadcast address" );
168 if ( destinationAddress() == OMacAddress::broadcast ) 168 if ( destinationAddress() == OMacAddress::broadcast )
169 qDebug( "Destination is broadcast address" ); 169 qDebug( "Destination is broadcast address" );
170 170
171 switch ( type() ) 171 switch ( type() )
172 { 172 {
173 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 173 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
174 case ETHERTYPE_ARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = ARP" ); break; } 174 case ETHERTYPE_ARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = ARP" ); break; }
175 case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; } 175 case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; }
176 default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" ); 176 default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" );
177 } 177 }
178 178
179} 179}
180 180
181 181
182OEthernetPacket::~OEthernetPacket() 182OEthernetPacket::~OEthernetPacket()
183{ 183{
184} 184}
185 185
186 186
187OMacAddress OEthernetPacket::sourceAddress() const 187OMacAddress OEthernetPacket::sourceAddress() const
188{ 188{
189 return OMacAddress( _ether->ether_shost ); 189 return OMacAddress( _ether->ether_shost );
190} 190}
191 191
192 192
193OMacAddress OEthernetPacket::destinationAddress() const 193OMacAddress OEthernetPacket::destinationAddress() const
194{ 194{
195 return OMacAddress( _ether->ether_dhost ); 195 return OMacAddress( _ether->ether_dhost );
196} 196}
197 197
198int OEthernetPacket::type() const 198int OEthernetPacket::type() const
199{ 199{
200 return ntohs( _ether->ether_type ); 200 return ntohs( _ether->ether_type );
201} 201}
202 202
203 203
204/*====================================================================================== 204/*======================================================================================
205 * OIPPacket 205 * OIPPacket
206 *======================================================================================*/ 206 *======================================================================================*/
207 207
208 208
209OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) 209OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent )
210 :QObject( parent, "IP" ), _iphdr( data ) 210 :QObject( parent, "IP" ), _iphdr( data )
211{ 211{
212 qDebug( "OIPPacket::OIPPacket(): decoding IP header..." ); 212 qDebug( "OIPPacket::OIPPacket(): decoding IP header..." );
213 213
214 //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) ); 214 //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) );
215 //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) ); 215 //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) );
216 216
217 qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() ); 217 qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() );
218 qDebug( " toAddress: %s", (const char*) toIPAddress().toString() ); 218 qDebug( " toAddress: %s", (const char*) toIPAddress().toString() );
219 219
220 switch ( protocol() ) 220 switch ( protocol() )
221 { 221 {
222 case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; 222 case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break;
223 case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; 223 case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break;
224 default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() ); 224 default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() );
225 } 225 }
226 226
227} 227}
228 228
229OIPPacket::~OIPPacket() 229OIPPacket::~OIPPacket()
230{ 230{
231} 231}
232 232
233 233
234QHostAddress OIPPacket::fromIPAddress() const 234QHostAddress OIPPacket::fromIPAddress() const
235{ 235{
236 return EXTRACT_32BITS( &_iphdr->saddr ); 236 return EXTRACT_32BITS( &_iphdr->saddr );
237} 237}
238 238
239 239
240QHostAddress OIPPacket::toIPAddress() const 240QHostAddress OIPPacket::toIPAddress() const
241{ 241{
242 return EXTRACT_32BITS( &_iphdr->saddr ); 242 return EXTRACT_32BITS( &_iphdr->saddr );
243} 243}
244 244
245 245
246int OIPPacket::tos() const 246int OIPPacket::tos() const
247{ 247{
248 return _iphdr->tos; 248 return _iphdr->tos;
249} 249}
250 250
251 251
252int OIPPacket::len() const 252int OIPPacket::len() const
253{ 253{
254 return EXTRACT_16BITS( &_iphdr->tot_len ); 254 return EXTRACT_16BITS( &_iphdr->tot_len );
255} 255}
256 256
257 257
258int OIPPacket::id() const 258int OIPPacket::id() const
259{ 259{
260 return EXTRACT_16BITS( &_iphdr->id ); 260 return EXTRACT_16BITS( &_iphdr->id );
261} 261}
262 262
263 263
264int OIPPacket::offset() const 264int OIPPacket::offset() const
265{ 265{
266 return EXTRACT_16BITS( &_iphdr->frag_off ); 266 return EXTRACT_16BITS( &_iphdr->frag_off );
267} 267}
268 268
269 269
270int OIPPacket::ttl() const 270int OIPPacket::ttl() const
271{ 271{
272 return _iphdr->ttl; 272 return _iphdr->ttl;
273} 273}
274 274
275 275
276int OIPPacket::protocol() const 276int OIPPacket::protocol() const
277{ 277{
278 return _iphdr->protocol; 278 return _iphdr->protocol;
279} 279}
280 280
281 281
282int OIPPacket::checksum() const 282int OIPPacket::checksum() const
283{ 283{
284 return EXTRACT_16BITS( &_iphdr->check ); 284 return EXTRACT_16BITS( &_iphdr->check );
285} 285}
286 286
287/*====================================================================================== 287/*======================================================================================
288 * OARPPacket 288 * OARPPacket
289 *======================================================================================*/ 289 *======================================================================================*/
290 290
291 291
292OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) 292OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent )
293 :QObject( parent, "ARP" ), _arphdr( data ) 293 :QObject( parent, "ARP" ), _arphdr( data )
294{ 294{
295 qDebug( "OARPPacket::OARPPacket(): decoding ARP header..." ); 295 qDebug( "OARPPacket::OARPPacket(): decoding ARP header..." );
296 qDebug( "ARP type seems to be %02d - '%s'", EXTRACT_16BITS( &_arphdr->ar_op ), (const char*) type() ); 296 qDebug( "ARP type seems to be %02d - '%s'", EXTRACT_16BITS( &_arphdr->ar_op ), (const char*) type() );
297 qDebug( "Sender: MAC %s = IP %s", (const char*) senderMacAddress().toString(), (const char*) senderIPV4Address().toString() ); 297 qDebug( "Sender: MAC %s = IP %s", (const char*) senderMacAddress().toString(), (const char*) senderIPV4Address().toString() );
298 qDebug( "Target: MAC %s = IP %s", (const char*) targetMacAddress().toString(), (const char*) targetIPV4Address().toString() ); 298 qDebug( "Target: MAC %s = IP %s", (const char*) targetMacAddress().toString(), (const char*) targetIPV4Address().toString() );
299} 299}
300 300
301 301
302OARPPacket::~OARPPacket() 302OARPPacket::~OARPPacket()
303{ 303{
304} 304}
305 305
306 306
307QString OARPPacket::type() const 307QString OARPPacket::type() const
308{ 308{
309 switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) 309 switch ( EXTRACT_16BITS( &_arphdr->ar_op ) )
310 { 310 {
311 case 1: return "REQUEST"; 311 case 1: return "REQUEST";
312 case 2: return "REPLY"; 312 case 2: return "REPLY";
313 case 3: return "RREQUEST"; 313 case 3: return "RREQUEST";
314 case 4: return "RREPLY"; 314 case 4: return "RREPLY";
315 case 8: return "InREQUEST"; 315 case 8: return "InREQUEST";
316 case 9: return "InREPLY"; 316 case 9: return "InREPLY";
317 case 10: return "NAK"; 317 case 10: return "NAK";
318 default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>"; 318 default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>";
319 } 319 }
320} 320}
321 321
322 322
323QHostAddress OARPPacket::senderIPV4Address() const 323QHostAddress OARPPacket::senderIPV4Address() const
324{ 324{
325 return EXTRACT_32BITS( &_arphdr->ar_sip ); 325 return EXTRACT_32BITS( &_arphdr->ar_sip );
326} 326}
327 327
328 328
329QHostAddress OARPPacket::targetIPV4Address() const 329QHostAddress OARPPacket::targetIPV4Address() const
330{ 330{
331 return EXTRACT_32BITS( &_arphdr->ar_tip ); 331 return EXTRACT_32BITS( &_arphdr->ar_tip );
332} 332}
333 333
334 334
335OMacAddress OARPPacket::senderMacAddress() const 335OMacAddress OARPPacket::senderMacAddress() const
336{ 336{
337 return OMacAddress( _arphdr->ar_sha ); 337 return OMacAddress( _arphdr->ar_sha );
338} 338}
339 339
340 340
341OMacAddress OARPPacket::targetMacAddress() const 341OMacAddress OARPPacket::targetMacAddress() const
342{ 342{
343 return OMacAddress( _arphdr->ar_tha ); 343 return OMacAddress( _arphdr->ar_tha );
344} 344}
345 345
346 346
347/*====================================================================================== 347/*======================================================================================
348 * OUDPPacket 348 * OUDPPacket
349 *======================================================================================*/ 349 *======================================================================================*/
350 350
351 351
352OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) 352OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent )
353 :QObject( parent, "UDP" ), _udphdr( data ) 353 :QObject( parent, "UDP" ), _udphdr( data )
354 354
355{ 355{
356 qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); 356 qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." );
357} 357}
358 358
359
359OUDPPacket::~OUDPPacket() 360OUDPPacket::~OUDPPacket()
360{ 361{
361} 362}
362 363
363 364
365int OUDPPacket::fromPort() const
366{
367 return _udphdr->source;
368}
369
370
371int OUDPPacket::toPort() const
372{
373 return _udphdr->dest;
374}
375
376
377int OUDPPacket::length() const
378{
379 return _udphdr->len;
380}
381
382
383int OUDPPacket::checksum() const
384{
385 return _udphdr->check;
386}
387
388
389/*======================================================================================
390 * ODHCPPacket
391 *======================================================================================*/
392
393
394ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent )
395 :QObject( parent, "DHCP" ), _dhcphdr( data )
396
397{
398 qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." );
399}
400
401
402ODHCPPacket::~ODHCPPacket()
403{
404}
405
406
364/*====================================================================================== 407/*======================================================================================
365 * OTCPPacket 408 * OTCPPacket
366 *======================================================================================*/ 409 *======================================================================================*/
367 410
368 411
369OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) 412OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent )
370 :QObject( parent, "TCP" ), _tcphdr( data ) 413 :QObject( parent, "TCP" ), _tcphdr( data )
371 414
372{ 415{
373 qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); 416 qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." );
374} 417}
375 418
419
376OTCPPacket::~OTCPPacket() 420OTCPPacket::~OTCPPacket()
377{ 421{
378} 422}
379 423
380 424
425int OTCPPacket::fromPort() const
426{
427 return _tcphdr->source;
428}
429
430
431int OTCPPacket::toPort() const
432{
433 return _tcphdr->dest;
434}
435
436
437int OTCPPacket::seq() const
438{
439 return _tcphdr->seq;
440}
441
442
443int OTCPPacket::ack() const
444{
445 return _tcphdr->ack_seq;
446}
447
448
449int OTCPPacket::window() const
450{
451 return _tcphdr->window;
452}
453
454
455int OTCPPacket::checksum() const
456{
457 return _tcphdr->check;
458}
459
381/*====================================================================================== 460/*======================================================================================
382 * OPrismHeaderPacket 461 * OPrismHeaderPacket
383 *======================================================================================*/ 462 *======================================================================================*/
384 463
385 464
386OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent ) 465OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent )
387 :QObject( parent, "Prism" ), _header( data ) 466 :QObject( parent, "Prism" ), _header( data )
388 467
389{ 468{
390 qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." ); 469 qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." );
391 470
392 qDebug( "Signal Strength = %d", data->signal.data ); 471 qDebug( "Signal Strength = %d", data->signal.data );
393 472
394 new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this ); 473 new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this );
395} 474}
396 475
397OPrismHeaderPacket::~OPrismHeaderPacket() 476OPrismHeaderPacket::~OPrismHeaderPacket()
398{ 477{
399} 478}
400 479
401 480
402unsigned int OPrismHeaderPacket::signalStrength() const 481unsigned int OPrismHeaderPacket::signalStrength() const
403{ 482{
404 return _header->signal.data; 483 return _header->signal.data;
405} 484}
406 485
407/*====================================================================================== 486/*======================================================================================
408 * OWaveLanPacket 487 * OWaveLanPacket
409 *======================================================================================*/ 488 *======================================================================================*/
410 489
411 490
412OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) 491OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent )
413 :QObject( parent, "802.11" ), _wlanhdr( data ) 492 :QObject( parent, "802.11" ), _wlanhdr( data )
414 493
415{ 494{
416 qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); 495 qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." );
417 qDebug( "type: %0X", type() ); 496 qDebug( "type: %0X", type() );
418 qDebug( "subType: %0X", subType() ); 497 qDebug( "subType: %0X", subType() );
419 qDebug( "duration: %d", duration() ); 498 qDebug( "duration: %d", duration() );
420 qDebug( "powermanagement: %d", usesPowerManagement() ); 499 qDebug( "powermanagement: %d", usesPowerManagement() );
421 qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" ); 500 qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" );
422 qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); 501 qDebug( "MAC1: %s", (const char*) macAddress1().toString() );
423 qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); 502 qDebug( "MAC2: %s", (const char*) macAddress2().toString() );
424 qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); 503 qDebug( "MAC3: %s", (const char*) macAddress3().toString() );
425 qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); 504 qDebug( "MAC4: %s", (const char*) macAddress4().toString() );
426 505
427 switch ( type() ) 506 switch ( type() )
428 { 507 {
429 case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; 508 case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break;
430 case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; 509 case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break;
431 case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break; 510 case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break;
432 default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() ); 511 default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() );
433 } 512 }
434} 513}
435 514
436OWaveLanPacket::~OWaveLanPacket() 515OWaveLanPacket::~OWaveLanPacket()
437{ 516{
438} 517}
439 518
440 519
441int OWaveLanPacket::duration() const 520int OWaveLanPacket::duration() const
442{ 521{
443 return _wlanhdr->duration; 522 return _wlanhdr->duration;
444} 523}
445 524
446 525
447OMacAddress OWaveLanPacket::macAddress1() const 526OMacAddress OWaveLanPacket::macAddress1() const
448{ 527{
449 return OMacAddress( _wlanhdr->mac1 ); 528 return OMacAddress( _wlanhdr->mac1 );
450} 529}
451 530
452 531
453OMacAddress OWaveLanPacket::macAddress2() const 532OMacAddress OWaveLanPacket::macAddress2() const
454{ 533{
455 return OMacAddress( _wlanhdr->mac2 ); 534 return OMacAddress( _wlanhdr->mac2 );
456} 535}
457 536
458 537
459OMacAddress OWaveLanPacket::macAddress3() const 538OMacAddress OWaveLanPacket::macAddress3() const
460{ 539{
461 return OMacAddress( _wlanhdr->mac3 ); 540 return OMacAddress( _wlanhdr->mac3 );
462} 541}
463 542
464 543
465OMacAddress OWaveLanPacket::macAddress4() const 544OMacAddress OWaveLanPacket::macAddress4() const
466{ 545{
467 return OMacAddress( _wlanhdr->mac4 ); 546 return OMacAddress( _wlanhdr->mac4 );
468} 547}
469 548
470 549
471int OWaveLanPacket::subType() const 550int OWaveLanPacket::subType() const
472{ 551{
473 return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 552 return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
474} 553}
475 554
476 555
477int OWaveLanPacket::type() const 556int OWaveLanPacket::type() const
478{ 557{
479 return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 558 return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
480} 559}
481 560
482 561
483int OWaveLanPacket::version() const 562int OWaveLanPacket::version() const
484{ 563{
485 return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 564 return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
486} 565}
487 566
488 567
489bool OWaveLanPacket::fromDS() const 568bool OWaveLanPacket::fromDS() const
490{ 569{
491 return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 570 return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
492} 571}
493 572
494 573
495bool OWaveLanPacket::toDS() const 574bool OWaveLanPacket::toDS() const
496{ 575{
497 return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 576 return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
498} 577}
499 578
500 579
501bool OWaveLanPacket::usesPowerManagement() const 580bool OWaveLanPacket::usesPowerManagement() const
502{ 581{
503 return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 582 return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
504} 583}
505 584
506 585
507bool OWaveLanPacket::usesWep() const 586bool OWaveLanPacket::usesWep() const
508{ 587{
509 return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 588 return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
510} 589}
511 590
512 591
513/*====================================================================================== 592/*======================================================================================
514 * OWaveLanManagementPacket 593 * OWaveLanManagementPacket
515 *======================================================================================*/ 594 *======================================================================================*/
516 595
517OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) 596OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent )
518 :QObject( parent, "802.11 Management" ), _header( data ), 597 :QObject( parent, "802.11 Management" ), _header( data ),
519 _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) 598 _body( (const struct ieee_802_11_mgmt_body*) (data+1) )
520{ 599{
521 qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." ); 600 qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." );
522 qDebug( "Detected subtype is '%s'", (const char*) managementType() ); 601 qDebug( "Detected subtype is '%s'", (const char*) managementType() );
523 602
524 // grab tagged values 603 // grab tagged values
525 const unsigned char* ptr = (const unsigned char*) (_body+1); 604 const unsigned char* ptr = (const unsigned char*) (_body+1);
526 while (ptr < end) 605 while (ptr < end)
527 { 606 {
528 switch ( *ptr ) 607 switch ( *ptr )
529 { 608 {
530 case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break; 609 case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break;
531 case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break; 610 case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break;
532 case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break; 611 case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break;
533 case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break; 612 case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break;
534 case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break; 613 case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break;
535 case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break; 614 case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break;
536 case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break; 615 case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break;
537 case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break; 616 case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break;
538 } 617 }
539 ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value 618 ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value
540 ptr+= 2; // skip tag ID and length 619 ptr+= 2; // skip tag ID and length
541 } 620 }
542} 621}
543 622
544 623
545OWaveLanManagementPacket::~OWaveLanManagementPacket() 624OWaveLanManagementPacket::~OWaveLanManagementPacket()
546{ 625{
547} 626}
548 627
549 628
550QString OWaveLanManagementPacket::managementType() const 629QString OWaveLanManagementPacket::managementType() const
551{ 630{
552 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ) 631 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) )
553 { 632 {
554 case ST_ASSOC_REQUEST: return "AssociationRequest"; break; 633 case ST_ASSOC_REQUEST: return "AssociationRequest"; break;
555 case ST_ASSOC_RESPONSE: return "AssociationResponse"; break; 634 case ST_ASSOC_RESPONSE: return "AssociationResponse"; break;
556 case ST_REASSOC_REQUEST: return "ReassociationRequest"; break; 635 case ST_REASSOC_REQUEST: return "ReassociationRequest"; break;
557 case ST_REASSOC_RESPONSE: return "ReassociationResponse"; break; 636 case ST_REASSOC_RESPONSE: return "ReassociationResponse"; break;
558 case ST_PROBE_REQUEST: return "ProbeRequest"; break; 637 case ST_PROBE_REQUEST: return "ProbeRequest"; break;
559 case ST_PROBE_RESPONSE: return "ProbeResponse"; break; 638 case ST_PROBE_RESPONSE: return "ProbeResponse"; break;
560 case ST_BEACON: return "Beacon"; break; 639 case ST_BEACON: return "Beacon"; break;
561 case ST_ATIM: return "Atim"; break; 640 case ST_ATIM: return "Atim"; break;
562 case ST_DISASSOC: return "Disassociation"; break; 641 case ST_DISASSOC: return "Disassociation"; break;
563 case ST_AUTH: return "Authentication"; break; 642 case ST_AUTH: return "Authentication"; break;
564 case ST_DEAUTH: return "Deathentication"; break; 643 case ST_DEAUTH: return "Deathentication"; break;
565 default: 644 default:
566 qWarning( "OWaveLanManagementPacket::managementType(): unhandled subtype %d", FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ); 645 qWarning( "OWaveLanManagementPacket::managementType(): unhandled subtype %d", FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) );
567 return "Unknown"; 646 return "Unknown";
568 } 647 }
569} 648}
570 649
571 650
572int OWaveLanManagementPacket::beaconInterval() const 651int OWaveLanManagementPacket::beaconInterval() const
573{ 652{
574 return EXTRACT_LE_16BITS( &_body->beacon_interval ); 653 return EXTRACT_LE_16BITS( &_body->beacon_interval );
575} 654}
576 655
577 656
578int OWaveLanManagementPacket::capabilities() const 657int OWaveLanManagementPacket::capabilities() const
579{ 658{
580 return EXTRACT_LE_16BITS( &_body->capability_info ); 659 return EXTRACT_LE_16BITS( &_body->capability_info );
581} 660}
582 661
583 662
584bool OWaveLanManagementPacket::canESS() const 663bool OWaveLanManagementPacket::canESS() const
585{ 664{
586 return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) ); 665 return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) );
587} 666}
588 667
589 668
590bool OWaveLanManagementPacket::canIBSS() const 669bool OWaveLanManagementPacket::canIBSS() const
591{ 670{
592 return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) ); 671 return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) );
593} 672}
594 673
595 674
596bool OWaveLanManagementPacket::canCFP() const 675bool OWaveLanManagementPacket::canCFP() const
597{ 676{
598 return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) ); 677 return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) );
599} 678}
600 679
601 680
602bool OWaveLanManagementPacket::canCFP_REQ() const 681bool OWaveLanManagementPacket::canCFP_REQ() const
603{ 682{
604 return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) ); 683 return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) );
605} 684}
606 685
607 686
608bool OWaveLanManagementPacket::canPrivacy() const 687bool OWaveLanManagementPacket::canPrivacy() const
609{ 688{
610 return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) ); 689 return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) );
611} 690}
612 691
613 692
614/*====================================================================================== 693/*======================================================================================
615 * OWaveLanManagementSSID 694 * OWaveLanManagementSSID
616 *======================================================================================*/ 695 *======================================================================================*/
617 696
618OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent ) 697OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent )
619 :QObject( parent, "802.11 SSID" ), _data( data ) 698 :QObject( parent, "802.11 SSID" ), _data( data )
620{ 699{
621 qDebug( "OWaveLanManagementSSID()" ); 700 qDebug( "OWaveLanManagementSSID()" );
622} 701}
623 702
624 703
625OWaveLanManagementSSID::~OWaveLanManagementSSID() 704OWaveLanManagementSSID::~OWaveLanManagementSSID()
626{ 705{
627} 706}
628 707
629 708
630QString OWaveLanManagementSSID::ID() const 709QString OWaveLanManagementSSID::ID() const
631{ 710{
632 int length = _data->length; 711 int length = _data->length;
633 if ( length > 32 ) length = 32; 712 if ( length > 32 ) length = 32;
634 char essid[length+1]; 713 char essid[length+1];
635 memcpy( &essid, &_data->ssid, length ); 714 memcpy( &essid, &_data->ssid, length );
636 essid[length] = 0x0; 715 essid[length] = 0x0;
637 return essid; 716 return essid;
638} 717}
639 718
640 719
641/*====================================================================================== 720/*======================================================================================
642 * OWaveLanManagementRates 721 * OWaveLanManagementRates
643 *======================================================================================*/ 722 *======================================================================================*/
644 723
645OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent ) 724OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent )
646 :QObject( parent, "802.11 Rates" ), _data( data ) 725 :QObject( parent, "802.11 Rates" ), _data( data )
647{ 726{
648 qDebug( "OWaveLanManagementRates()" ); 727 qDebug( "OWaveLanManagementRates()" );
649} 728}
650 729
651 730
652OWaveLanManagementRates::~OWaveLanManagementRates() 731OWaveLanManagementRates::~OWaveLanManagementRates()
653{ 732{
654} 733}
655 734
656/*====================================================================================== 735/*======================================================================================
657 * OWaveLanManagementCF 736 * OWaveLanManagementCF
658 *======================================================================================*/ 737 *======================================================================================*/
659 738
660OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent ) 739OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent )
661 :QObject( parent, "802.11 CF" ), _data( data ) 740 :QObject( parent, "802.11 CF" ), _data( data )
662{ 741{
663 qDebug( "OWaveLanManagementCF()" ); 742 qDebug( "OWaveLanManagementCF()" );
664} 743}
665 744
666 745
667OWaveLanManagementCF::~OWaveLanManagementCF() 746OWaveLanManagementCF::~OWaveLanManagementCF()
668{ 747{
669} 748}
670 749
671/*====================================================================================== 750/*======================================================================================
672 * OWaveLanManagementFH 751 * OWaveLanManagementFH
673 *======================================================================================*/ 752 *======================================================================================*/
674 753
675OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent ) 754OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent )
676 :QObject( parent, "802.11 FH" ), _data( data ) 755 :QObject( parent, "802.11 FH" ), _data( data )
677{ 756{
678 qDebug( "OWaveLanManagementFH()" ); 757 qDebug( "OWaveLanManagementFH()" );
679} 758}
680 759
681 760
682OWaveLanManagementFH::~OWaveLanManagementFH() 761OWaveLanManagementFH::~OWaveLanManagementFH()
683{ 762{
684} 763}
685 764
686/*====================================================================================== 765/*======================================================================================
687 * OWaveLanManagementDS 766 * OWaveLanManagementDS
688 *======================================================================================*/ 767 *======================================================================================*/
689 768
690OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent ) 769OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent )
691 :QObject( parent, "802.11 DS" ), _data( data ) 770 :QObject( parent, "802.11 DS" ), _data( data )
692{ 771{
693 qDebug( "OWaveLanManagementDS()" ); 772 qDebug( "OWaveLanManagementDS()" );
694} 773}
695 774
696 775
697OWaveLanManagementDS::~OWaveLanManagementDS() 776OWaveLanManagementDS::~OWaveLanManagementDS()
698{ 777{
699} 778}
700 779
701 780
702int OWaveLanManagementDS::channel() const 781int OWaveLanManagementDS::channel() const
703{ 782{
704 return _data->channel; 783 return _data->channel;
705} 784}
706 785
707/*====================================================================================== 786/*======================================================================================
708 * OWaveLanManagementTim 787 * OWaveLanManagementTim
709 *======================================================================================*/ 788 *======================================================================================*/
710 789
711OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent ) 790OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent )
712 :QObject( parent, "802.11 Tim" ), _data( data ) 791 :QObject( parent, "802.11 Tim" ), _data( data )
713{ 792{
714 qDebug( "OWaveLanManagementTim()" ); 793 qDebug( "OWaveLanManagementTim()" );
715} 794}
716 795
717 796
718OWaveLanManagementTim::~OWaveLanManagementTim() 797OWaveLanManagementTim::~OWaveLanManagementTim()
719{ 798{
720} 799}
721 800
722/*====================================================================================== 801/*======================================================================================
723 * OWaveLanManagementIBSS 802 * OWaveLanManagementIBSS
724 *======================================================================================*/ 803 *======================================================================================*/
725 804
726OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent ) 805OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent )
727 :QObject( parent, "802.11 IBSS" ), _data( data ) 806 :QObject( parent, "802.11 IBSS" ), _data( data )
728{ 807{
729 qDebug( "OWaveLanManagementIBSS()" ); 808 qDebug( "OWaveLanManagementIBSS()" );
730} 809}
731 810
732 811
733OWaveLanManagementIBSS::~OWaveLanManagementIBSS() 812OWaveLanManagementIBSS::~OWaveLanManagementIBSS()
734{ 813{
735} 814}
736 815
737/*====================================================================================== 816/*======================================================================================
738 * OWaveLanManagementChallenge 817 * OWaveLanManagementChallenge
739 *======================================================================================*/ 818 *======================================================================================*/
740 819
741OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent ) 820OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent )
742 :QObject( parent, "802.11 Challenge" ), _data( data ) 821 :QObject( parent, "802.11 Challenge" ), _data( data )
743{ 822{
744 qDebug( "OWaveLanManagementChallenge()" ); 823 qDebug( "OWaveLanManagementChallenge()" );
745} 824}
746 825
747 826
748OWaveLanManagementChallenge::~OWaveLanManagementChallenge() 827OWaveLanManagementChallenge::~OWaveLanManagementChallenge()
749{ 828{
750} 829}
751 830
752/*====================================================================================== 831/*======================================================================================
753 * OWaveLanDataPacket 832 * OWaveLanDataPacket
754 *======================================================================================*/ 833 *======================================================================================*/
755 834
756OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) 835OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent )
757 :QObject( parent, "802.11 Data" ), _header( data ) 836 :QObject( parent, "802.11 Data" ), _header( data )
758{ 837{
759 qDebug( "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." ); 838 qDebug( "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." );
760 839
761 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); 840 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header );
762 841
763 #warning The next line works for most cases, but can not be correct generally! 842 #warning The next line works for most cases, but can not be correct generally!
764 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address 843 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address
765 844
766 new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); 845 new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this );
767} 846}
768 847
769 848
770OWaveLanDataPacket::~OWaveLanDataPacket() 849OWaveLanDataPacket::~OWaveLanDataPacket()
771{ 850{
772} 851}
773 852
774 853
775/*====================================================================================== 854/*======================================================================================
776 * OLLCPacket 855 * OLLCPacket
777 *======================================================================================*/ 856 *======================================================================================*/
778 857
779OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) 858OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent )
780 :QObject( parent, "802.11 LLC" ), _header( data ) 859 :QObject( parent, "802.11 LLC" ), _header( data )
781{ 860{
782 qDebug( "OLLCPacket::OLLCPacket(): decoding frame..." ); 861 qDebug( "OLLCPacket::OLLCPacket(): decoding frame..." );
783 862
784 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) 863 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) )
785 { 864 {
786 qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) ); 865 qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) );
787 866
788 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h 867 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h
789 { 868 {
790 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 869 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
791 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; 870 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
792 default: qWarning( "OLLCPacket::OLLCPacket(): Unknown Encapsulation (type=%04X)", EXTRACT_16BITS( &_header->type ) ); 871 default: qWarning( "OLLCPacket::OLLCPacket(): Unknown Encapsulation (type=%04X)", EXTRACT_16BITS( &_header->type ) );
793 } 872 }
794 873
795 } 874 }
796} 875}
797 876
798 877
799OLLCPacket::~OLLCPacket() 878OLLCPacket::~OLLCPacket()
800{ 879{
801} 880}
802 881
803 882
804/*====================================================================================== 883/*======================================================================================
805 * OWaveLanControlPacket 884 * OWaveLanControlPacket
806 *======================================================================================*/ 885 *======================================================================================*/
807 886
808OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent ) 887OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent )
809 :QObject( parent, "802.11 Control" ), _header( data ) 888 :QObject( parent, "802.11 Control" ), _header( data )
810{ 889{
811 qDebug( "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." ); 890 qDebug( "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." );
812 //TODO: Implement this 891 //TODO: Implement this
813} 892}
814 893
815 894
816OWaveLanControlPacket::~OWaveLanControlPacket() 895OWaveLanControlPacket::~OWaveLanControlPacket()
817{ 896{
818} 897}
819 898
820 899
821/*====================================================================================== 900/*======================================================================================
822 * OPacketCapturer 901 * OPacketCapturer
823 *======================================================================================*/ 902 *======================================================================================*/
824 903
825OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) 904OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
826 :QObject( parent, name ), _name( QString::null ), _open( false ), 905 :QObject( parent, name ), _name( QString::null ), _open( false ),
827 _pch( 0 ), _pcd( 0 ), _sn( 0 ) 906 _pch( 0 ), _pcd( 0 ), _sn( 0 )
828{ 907{
829} 908}
830 909
831 910
832OPacketCapturer::~OPacketCapturer() 911OPacketCapturer::~OPacketCapturer()
833{ 912{
834 if ( _open ) 913 if ( _open )
835 { 914 {
836 qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." ); 915 qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." );
837 close(); 916 close();
838 } 917 }
839} 918}
840 919
841 920
842void OPacketCapturer::setBlocking( bool b ) 921void OPacketCapturer::setBlocking( bool b )
843{ 922{
844 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) 923 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 )
845 { 924 {
846 qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." ); 925 qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." );
847 } 926 }
848 else 927 else
849 { 928 {
850 qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf ); 929 qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf );
851 } 930 }
852} 931}
853 932
854 933
855bool OPacketCapturer::blocking() const 934bool OPacketCapturer::blocking() const
856{ 935{
857 int b = pcap_getnonblock( _pch, _errbuf ); 936 int b = pcap_getnonblock( _pch, _errbuf );
858 if ( b == -1 ) 937 if ( b == -1 )
859 { 938 {
860 qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf ); 939 qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf );
861 return -1; 940 return -1;
862 } 941 }
863 return !b; 942 return !b;
864} 943}
865 944
866 945
867void OPacketCapturer::closeDumpFile() 946void OPacketCapturer::closeDumpFile()
868{ 947{
869 if ( _pcd ) 948 if ( _pcd )
870 { 949 {
871 pcap_dump_close( _pcd ); 950 pcap_dump_close( _pcd );
872 _pcd = 0; 951 _pcd = 0;
873 } 952 }
874 pcap_close( _pch ); 953 pcap_close( _pch );
875} 954}
876 955
877 956
878void OPacketCapturer::close() 957void OPacketCapturer::close()
879{ 958{
880 if ( _open ) 959 if ( _open )
881 { 960 {
882 if ( _sn ) 961 if ( _sn )
883 { 962 {
884 _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 963 _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
885 delete _sn; 964 delete _sn;
886 } 965 }
887 closeDumpFile(); 966 closeDumpFile();
888 _open = false; 967 _open = false;
889 } 968 }
890 969
891 qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." ); 970 qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." );
892 qDebug( "--------------------------------------------------" ); 971 qDebug( "--------------------------------------------------" );
893 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it ) 972 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it )
894 qDebug( "%s : %d", (const char*) it.key(), it.data() ); 973 qDebug( "%s : %d", (const char*) it.key(), it.data() );
895 qDebug( "--------------------------------------------------" ); 974 qDebug( "--------------------------------------------------" );
896 975
897} 976}
898 977
899 978
900int OPacketCapturer::dataLink() const 979int OPacketCapturer::dataLink() const
901{ 980{
902 return pcap_datalink( _pch ); 981 return pcap_datalink( _pch );
903} 982}
904 983
905 984
906void OPacketCapturer::dump( OPacket* p ) 985void OPacketCapturer::dump( OPacket* p )
907{ 986{
908 if ( !_pcd ) 987 if ( !_pcd )
909 { 988 {
910 qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" ); 989 qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" );
911 return; 990 return;
912 } 991 }
913 pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data ); 992 pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data );
914} 993}
915 994
916 995
917int OPacketCapturer::fileno() const 996int OPacketCapturer::fileno() const
918{ 997{
919 if ( _open ) 998 if ( _open )
920 { 999 {
921 return pcap_fileno( _pch ); 1000 return pcap_fileno( _pch );
922 } 1001 }
923 else 1002 else
924 { 1003 {
925 return -1; 1004 return -1;
926 } 1005 }
927} 1006}
928 1007
929OPacket* OPacketCapturer::next() 1008OPacket* OPacketCapturer::next()
930{ 1009{
931 packetheaderstruct header; 1010 packetheaderstruct header;
932 qDebug( "==> OPacketCapturer::next()" ); 1011 qDebug( "==> OPacketCapturer::next()" );
933 const unsigned char* pdata = pcap_next( _pch, &header ); 1012 const unsigned char* pdata = pcap_next( _pch, &header );
934 qDebug( "<== OPacketCapturer::next()" ); 1013 qDebug( "<== OPacketCapturer::next()" );
935 1014
936 if ( pdata && header.len ) 1015 if ( pdata && header.len )
937 { 1016 {
938 OPacket* p = new OPacket( dataLink(), header, pdata, 0 ); 1017 OPacket* p = new OPacket( dataLink(), header, pdata, 0 );
939 // packets shouldn't be inserted in the QObject child-parent hierarchy, 1018 // packets shouldn't be inserted in the QObject child-parent hierarchy,
940 // because due to memory constraints they will be deleted as soon 1019 // because due to memory constraints they will be deleted as soon
941 // as possible - that is right after they have been processed 1020 // as possible - that is right after they have been processed
942 // by emit() [ see below ] 1021 // by emit() [ see below ]
943 //TODO: make gathering statistics optional, because it takes time 1022 //TODO: make gathering statistics optional, because it takes time
944 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); 1023 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) );
945 1024
946 return p; 1025 return p;
947 } 1026 }
948 else 1027 else
949 { 1028 {
950 qWarning( "OPacketCapturer::next() - no packet received!" ); 1029 qWarning( "OPacketCapturer::next() - no packet received!" );
951 return 0; 1030 return 0;
952 } 1031 }
953} 1032}
954 1033
955 1034
956bool OPacketCapturer::open( const QString& name ) 1035bool OPacketCapturer::open( const QString& name )
957{ 1036{
958 if ( _open ) 1037 if ( _open )
959 { 1038 {
960 if ( name == _name ) // ignore opening an already openend device 1039 if ( name == _name ) // ignore opening an already openend device
961 { 1040 {
962 return true; 1041 return true;
963 } 1042 }
964 else // close the last opened device 1043 else // close the last opened device
965 { 1044 {
966 close(); 1045 close();
967 } 1046 }
968 } 1047 }
969 1048
970 _name = name; 1049 _name = name;
971 1050
972 // open libpcap 1051 // open libpcap
973 pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] ); 1052 pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] );
974 1053
975 if ( !handle ) 1054 if ( !handle )
976 { 1055 {
977 qWarning( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); 1056 qWarning( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf );
978 return false; 1057 return false;
979 } 1058 }
980 1059
981 qDebug( "OPacketCapturer::open(): libpcap [%s] opened successfully.", (const char*) name ); 1060 qDebug( "OPacketCapturer::open(): libpcap [%s] opened successfully.", (const char*) name );
982 _pch = handle; 1061 _pch = handle;
983 _open = true; 1062 _open = true;
984 _stats.clear(); 1063 _stats.clear();
985 1064
986 // in case we have an application object, create a socket notifier 1065 // in case we have an application object, create a socket notifier
987 if ( qApp ) //TODO: I don't like this here... 1066 if ( qApp ) //TODO: I don't like this here...
988 { 1067 {
989 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); 1068 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
990 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1069 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
991 } 1070 }
992 1071
993 return true; 1072 return true;
994} 1073}
995 1074
996 1075
997bool OPacketCapturer::openDumpFile( const QString& filename ) 1076bool OPacketCapturer::openDumpFile( const QString& filename )
998{ 1077{
999 pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); 1078 pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) );
1000 if ( !dump ) 1079 if ( !dump )
1001 { 1080 {
1002 qWarning( "OPacketCapturer::open(): can't open dump with '%s': %s", (const char*) filename, _errbuf ); 1081 qWarning( "OPacketCapturer::open(): can't open dump with '%s': %s", (const char*) filename, _errbuf );
1003 return false; 1082 return false;
1004 } 1083 }
1005 qDebug( "OPacketCapturer::open(): dump [%s] opened successfully.", (const char*) filename ); 1084 qDebug( "OPacketCapturer::open(): dump [%s] opened successfully.", (const char*) filename );
1006 _pcd = dump; 1085 _pcd = dump;
1007 1086
1008 return true; 1087 return true;
1009} 1088}
1010 1089
1011 1090
1012bool OPacketCapturer::open( const QFile& file ) 1091bool OPacketCapturer::open( const QFile& file )
1013{ 1092{
1014 QString name = file.name(); 1093 QString name = file.name();
1015 1094
1016 if ( _open ) 1095 if ( _open )
1017 { 1096 {
1018 close(); 1097 close();
1019 if ( name == _name ) // ignore opening an already openend device 1098 if ( name == _name ) // ignore opening an already openend device
1020 { 1099 {
1021 return true; 1100 return true;
1022 } 1101 }
1023 else // close the last opened device 1102 else // close the last opened device
1024 { 1103 {
1025 close(); 1104 close();
1026 } 1105 }
1027 } 1106 }
1028 1107
1029 _name = name; 1108 _name = name;
1030 1109
1031 pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] ); 1110 pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] );
1032 1111
1033 if ( handle ) 1112 if ( handle )
1034 { 1113 {
1035 qDebug( "OPacketCapturer::open(): libpcap opened successfully." ); 1114 qDebug( "OPacketCapturer::open(): libpcap opened successfully." );
1036 _pch = handle; 1115 _pch = handle;
1037 _open = true; 1116 _open = true;
1038 1117
1039 // in case we have an application object, create a socket notifier 1118 // in case we have an application object, create a socket notifier
1040 if ( qApp ) 1119 if ( qApp )
1041 { 1120 {
1042 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); 1121 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
1043 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1122 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
1044 } 1123 }
1045 1124
1046 return true; 1125 return true;
1047 } 1126 }
1048 else 1127 else
1049 { 1128 {
1050 qDebug( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); 1129 qDebug( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf );
1051 return false; 1130 return false;
1052 } 1131 }
1053 1132
1054} 1133}
1055 1134
1056 1135
1057bool OPacketCapturer::isOpen() const 1136bool OPacketCapturer::isOpen() const
1058{ 1137{
1059 return _open; 1138 return _open;
1060} 1139}
1061 1140
1062 1141
1063void OPacketCapturer::readyToReceive() 1142void OPacketCapturer::readyToReceive()
1064{ 1143{
1065 qDebug( "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" ); 1144 qDebug( "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" );
1066 OPacket* p = next(); 1145 OPacket* p = next();
1067 emit receivedPacket( p ); 1146 emit receivedPacket( p );
1068 // emit is synchronous - packet has been dealt with, now it's safe to delete 1147 // emit is synchronous - packet has been dealt with, now it's safe to delete
1069 delete p; 1148 delete p;
1070} 1149}
1071 1150
1072 1151
1073const QMap<QString,int>& OPacketCapturer::statistics() const 1152const QMap<QString,int>& OPacketCapturer::statistics() const
1074{ 1153{
1075 return _stats; 1154 return _stats;
1076} 1155}
1077 1156
1078 1157
1079int OPacketCapturer::snapShot() const 1158int OPacketCapturer::snapShot() const
1080{ 1159{
1081 return pcap_snapshot( _pch ); 1160 return pcap_snapshot( _pch );
1082} 1161}
1083 1162
1084 1163
1085bool OPacketCapturer::swapped() const 1164bool OPacketCapturer::swapped() const
1086{ 1165{
1087 return pcap_is_swapped( _pch ); 1166 return pcap_is_swapped( _pch );
1088} 1167}
1089 1168
1090 1169
1091QString OPacketCapturer::version() const 1170QString OPacketCapturer::version() const
1092{ 1171{
1093 return QString().sprintf( "%s.%s", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); 1172 return QString().sprintf( "%s.%s", pcap_major_version( _pch ), pcap_minor_version( _pch ) );
1094} 1173}
1095 1174
1096 1175
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 9119972..0c9e7da 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -1,619 +1,645 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef OPCAP_H 34#ifndef OPCAP_H
35#define OPCAP_H 35#define OPCAP_H
36 36
37/* LINUX */ 37/* LINUX */
38extern "C" // work around a bpf/pcap conflict in recent headers 38extern "C" // work around a bpf/pcap conflict in recent headers
39{ 39{
40 #include <pcap.h> 40 #include <pcap.h>
41} 41}
42#include <netinet/ether.h> 42#include <netinet/ether.h>
43#include <netinet/ip.h> 43#include <netinet/ip.h>
44#include <netinet/udp.h> 44#include <netinet/udp.h>
45#include <netinet/tcp.h> 45#include <netinet/tcp.h>
46#include <time.h> 46#include <time.h>
47 47
48/* QT */ 48/* QT */
49#include <qevent.h> 49#include <qevent.h>
50#include <qfile.h> 50#include <qfile.h>
51#include <qhostaddress.h> 51#include <qhostaddress.h>
52#include <qobject.h> 52#include <qobject.h>
53#include <qstring.h> 53#include <qstring.h>
54#include <qmap.h> 54#include <qmap.h>
55 55
56/* OPIE */ 56/* OPIE */
57#include <opie2/onetutils.h> 57#include <opie2/onetutils.h>
58
59/* Custom Network Includes */
58#include "802_11_user.h" 60#include "802_11_user.h"
61#include "dhcp.h"
59 62
60/* TYPEDEFS */ 63/* TYPEDEFS */
61typedef struct timeval timevalstruct; 64typedef struct timeval timevalstruct;
62typedef struct pcap_pkthdr packetheaderstruct; 65typedef struct pcap_pkthdr packetheaderstruct;
63 66
64/* FORWARDS */ 67/* FORWARDS */
65class OPacketCapturer; 68class OPacketCapturer;
66class QSocketNotifier; 69class QSocketNotifier;
67 70
68/*====================================================================================== 71/*======================================================================================
69 * OPacket - A frame on the wire 72 * OPacket - A frame on the wire
70 *======================================================================================*/ 73 *======================================================================================*/
71 74
72/** @brief A class representing a data frame on the wire. 75/** @brief A class representing a data frame on the wire.
73 * 76 *
74 * The whole family of the packet classes are used when capturing frames from a network. 77 * The whole family of the packet classes are used when capturing frames from a network.
75 * Most standard network protocols in use share a common architecture, which mostly is 78 * Most standard network protocols in use share a common architecture, which mostly is
76 * a packet header and then the packet payload. In layered architectures, each lower layer 79 * a packet header and then the packet payload. In layered architectures, each lower layer
77 * encapsulates data from its upper layer - that is it 80 * encapsulates data from its upper layer - that is it
78 * treats the data from its upper layer as payload and prepends an own header to the packet, 81 * treats the data from its upper layer as payload and prepends an own header to the packet,
79 * which - again - is treated as the payload for the layer below. The figure below is an 82 * which - again - is treated as the payload for the layer below. The figure below is an
80 * example for how such a data frame is composed out of packets, e.g. when sending a mail. 83 * example for how such a data frame is composed out of packets, e.g. when sending a mail.
81 * 84 *
82 * <pre> 85 * <pre>
83 * | User Data | == Mail Data 86 * | User Data | == Mail Data
84 * | SMTP Header | User Data | == SMTP 87 * | SMTP Header | User Data | == SMTP
85 * | TCP Header | SMTP Header | User Data | == TCP 88 * | TCP Header | SMTP Header | User Data | == TCP
86 * | IP Header | TCP Header | SMTP Header | User Data | == IP 89 * | IP Header | TCP Header | SMTP Header | User Data | == IP
87 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC 90 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC
88 * 91 *
89 * </pre> 92 * </pre>
90 * 93 *
91 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer 94 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer
92 * also contains a few more levels of encapsulation. 95 * also contains a few more levels of encapsulation.
93 * Since the type of the payload is more or less independent from the encapsulating protocol, 96 * Since the type of the payload is more or less independent from the encapsulating protocol,
94 * the header must be inspected before attempting to decode the payload. Hence, the 97 * the header must be inspected before attempting to decode the payload. Hence, the
95 * encapsulation level varies and can't be deduced without actually looking into the packets. 98 * encapsulation level varies and can't be deduced without actually looking into the packets.
96 * 99 *
97 * For actually working with captured frames, it's useful to identify the packets via names and 100 * For actually working with captured frames, it's useful to identify the packets via names and
98 * insert them into a parent/child - relationship based on the encapsulation. This is why 101 * insert them into a parent/child - relationship based on the encapsulation. This is why
99 * all packet classes derive from QObject. The amount of overhead caused by the QObject is 102 * all packet classes derive from QObject. The amount of overhead caused by the QObject is
100 * not a problem in this case, because we're talking about a theoratical maximum of about 103 * not a problem in this case, because we're talking about a theoratical maximum of about
101 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the 104 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the
102 * QObject also cares about destroying the sub-, (child-) packets. 105 * QObject also cares about destroying the sub-, (child-) packets.
103 * 106 *
104 * This enables us to perform a simple look for packets of a certain type: 107 * This enables us to perform a simple look for packets of a certain type:
105 * @code 108 * @code
106 * OPacketCapturer* pcap = new OPacketCapturer(); 109 * OPacketCapturer* pcap = new OPacketCapturer();
107 * pcap->open( "eth0" ); 110 * pcap->open( "eth0" );
108 * OPacket* p = pcap->next(); 111 * OPacket* p = pcap->next();
109 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists 112 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists
110 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; 113 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl;
111 * 114 *
112 */ 115 */
113 116
114class OPacket : public QObject 117class OPacket : public QObject
115{ 118{
116 Q_OBJECT 119 Q_OBJECT
117 120
118 friend class OPacketCapturer; 121 friend class OPacketCapturer;
119 122
120 public: 123 public:
121 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); 124 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent );
122 virtual ~OPacket(); 125 virtual ~OPacket();
123 126
124 timevalstruct timeval() const; 127 timevalstruct timeval() const;
125 128
126 int caplen() const; 129 int caplen() const;
127 int len() const; 130 int len() const;
128 QString dump( int = 32 ) const; 131 QString dump( int = 32 ) const;
129 132
130 void updateStats( QMap<QString,int>&, QObjectList* ); 133 void updateStats( QMap<QString,int>&, QObjectList* );
131 134
132 private: 135 private:
133 const packetheaderstruct _hdr; // pcap packet header 136 const packetheaderstruct _hdr; // pcap packet header
134 const unsigned char* _data; // pcap packet data 137 const unsigned char* _data; // pcap packet data
135 const unsigned char* _end; // end of pcap packet data 138 const unsigned char* _end; // end of pcap packet data
136}; 139};
137 140
138/*====================================================================================== 141/*======================================================================================
139 * OEthernetPacket - DLT_EN10MB frame 142 * OEthernetPacket - DLT_EN10MB frame
140 *======================================================================================*/ 143 *======================================================================================*/
141 144
142class OEthernetPacket : public QObject 145class OEthernetPacket : public QObject
143{ 146{
144 Q_OBJECT 147 Q_OBJECT
145 148
146 public: 149 public:
147 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); 150 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 );
148 virtual ~OEthernetPacket(); 151 virtual ~OEthernetPacket();
149 152
150 OMacAddress sourceAddress() const; 153 OMacAddress sourceAddress() const;
151 OMacAddress destinationAddress() const; 154 OMacAddress destinationAddress() const;
152 int type() const; 155 int type() const;
153 156
154 private: 157 private:
155 const struct ether_header* _ether; 158 const struct ether_header* _ether;
156}; 159};
157 160
158/*====================================================================================== 161/*======================================================================================
159 * OPrismHeaderPacket - DLT_PRISM_HEADER frame 162 * OPrismHeaderPacket - DLT_PRISM_HEADER frame
160 *======================================================================================*/ 163 *======================================================================================*/
161 164
162class OPrismHeaderPacket : public QObject 165class OPrismHeaderPacket : public QObject
163{ 166{
164 Q_OBJECT 167 Q_OBJECT
165 168
166 public: 169 public:
167 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); 170 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 );
168 virtual ~OPrismHeaderPacket(); 171 virtual ~OPrismHeaderPacket();
169 172
170 unsigned int signalStrength() const; 173 unsigned int signalStrength() const;
171 174
172 private: 175 private:
173 const struct prism_hdr* _header; 176 const struct prism_hdr* _header;
174}; 177};
175 178
176/*====================================================================================== 179/*======================================================================================
177 * OWaveLanPacket - DLT_IEEE802_11 frame 180 * OWaveLanPacket - DLT_IEEE802_11 frame
178 *======================================================================================*/ 181 *======================================================================================*/
179 182
180class OWaveLanPacket : public QObject 183class OWaveLanPacket : public QObject
181{ 184{
182 Q_OBJECT 185 Q_OBJECT
183 186
184 public: 187 public:
185 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); 188 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 );
186 virtual ~OWaveLanPacket(); 189 virtual ~OWaveLanPacket();
187 190
188 int duration() const; 191 int duration() const;
189 bool fromDS() const; 192 bool fromDS() const;
190 bool toDS() const; 193 bool toDS() const;
191 virtual OMacAddress macAddress1() const; 194 virtual OMacAddress macAddress1() const;
192 virtual OMacAddress macAddress2() const; 195 virtual OMacAddress macAddress2() const;
193 virtual OMacAddress macAddress3() const; 196 virtual OMacAddress macAddress3() const;
194 virtual OMacAddress macAddress4() const; 197 virtual OMacAddress macAddress4() const;
195 bool usesPowerManagement() const; 198 bool usesPowerManagement() const;
196 int type() const; 199 int type() const;
197 int subType() const; 200 int subType() const;
198 int version() const; 201 int version() const;
199 bool usesWep() const; 202 bool usesWep() const;
200 203
201 private: 204 private:
202 const struct ieee_802_11_header* _wlanhdr; 205 const struct ieee_802_11_header* _wlanhdr;
203}; 206};
204 207
205 208
206/*====================================================================================== 209/*======================================================================================
207 * OWaveLanManagementPacket - type: management (T_MGMT) 210 * OWaveLanManagementPacket - type: management (T_MGMT)
208 *======================================================================================*/ 211 *======================================================================================*/
209 212
210class OWaveLanManagementPacket : public QObject 213class OWaveLanManagementPacket : public QObject
211{ 214{
212 Q_OBJECT 215 Q_OBJECT
213 216
214 public: 217 public:
215 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); 218 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 );
216 virtual ~OWaveLanManagementPacket(); 219 virtual ~OWaveLanManagementPacket();
217 220
218 QString managementType() const; 221 QString managementType() const;
219 222
220 int beaconInterval() const; 223 int beaconInterval() const;
221 int capabilities() const; // generic 224 int capabilities() const; // generic
222 225
223 bool canESS() const; 226 bool canESS() const;
224 bool canIBSS() const; 227 bool canIBSS() const;
225 bool canCFP() const; 228 bool canCFP() const;
226 bool canCFP_REQ() const; 229 bool canCFP_REQ() const;
227 bool canPrivacy() const; 230 bool canPrivacy() const;
228 231
229 private: 232 private:
230 const struct ieee_802_11_mgmt_header* _header; 233 const struct ieee_802_11_mgmt_header* _header;
231 const struct ieee_802_11_mgmt_body* _body; 234 const struct ieee_802_11_mgmt_body* _body;
232}; 235};
233 236
234 237
235/*====================================================================================== 238/*======================================================================================
236 * OWaveLanManagementSSID 239 * OWaveLanManagementSSID
237 *======================================================================================*/ 240 *======================================================================================*/
238 241
239class OWaveLanManagementSSID : public QObject 242class OWaveLanManagementSSID : public QObject
240{ 243{
241 Q_OBJECT 244 Q_OBJECT
242 245
243 public: 246 public:
244 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); 247 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 );
245 virtual ~OWaveLanManagementSSID(); 248 virtual ~OWaveLanManagementSSID();
246 249
247 QString ID() const; 250 QString ID() const;
248 251
249 private: 252 private:
250 const struct ssid_t* _data; 253 const struct ssid_t* _data;
251}; 254};
252 255
253/*====================================================================================== 256/*======================================================================================
254 * OWaveLanManagementRates 257 * OWaveLanManagementRates
255 *======================================================================================*/ 258 *======================================================================================*/
256 259
257class OWaveLanManagementRates : public QObject 260class OWaveLanManagementRates : public QObject
258{ 261{
259 Q_OBJECT 262 Q_OBJECT
260 263
261 public: 264 public:
262 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); 265 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 );
263 virtual ~OWaveLanManagementRates(); 266 virtual ~OWaveLanManagementRates();
264 267
265 private: 268 private:
266 const struct rates_t* _data; 269 const struct rates_t* _data;
267}; 270};
268 271
269/*====================================================================================== 272/*======================================================================================
270 * OWaveLanManagementCF 273 * OWaveLanManagementCF
271 *======================================================================================*/ 274 *======================================================================================*/
272 275
273class OWaveLanManagementCF : public QObject 276class OWaveLanManagementCF : public QObject
274{ 277{
275 Q_OBJECT 278 Q_OBJECT
276 279
277 public: 280 public:
278 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); 281 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 );
279 virtual ~OWaveLanManagementCF(); 282 virtual ~OWaveLanManagementCF();
280 283
281 private: 284 private:
282 const struct cf_t* _data; 285 const struct cf_t* _data;
283}; 286};
284 287
285/*====================================================================================== 288/*======================================================================================
286 * OWaveLanManagementFH 289 * OWaveLanManagementFH
287 *======================================================================================*/ 290 *======================================================================================*/
288 291
289class OWaveLanManagementFH : public QObject 292class OWaveLanManagementFH : public QObject
290{ 293{
291 Q_OBJECT 294 Q_OBJECT
292 295
293 public: 296 public:
294 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); 297 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 );
295 virtual ~OWaveLanManagementFH(); 298 virtual ~OWaveLanManagementFH();
296 299
297 private: 300 private:
298 const struct fh_t* _data; 301 const struct fh_t* _data;
299}; 302};
300 303
301/*====================================================================================== 304/*======================================================================================
302 * OWaveLanManagementDS 305 * OWaveLanManagementDS
303 *======================================================================================*/ 306 *======================================================================================*/
304 307
305class OWaveLanManagementDS : public QObject 308class OWaveLanManagementDS : public QObject
306{ 309{
307 Q_OBJECT 310 Q_OBJECT
308 311
309 public: 312 public:
310 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); 313 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 );
311 virtual ~OWaveLanManagementDS(); 314 virtual ~OWaveLanManagementDS();
312 315
313 int channel() const; 316 int channel() const;
314 317
315 private: 318 private:
316 const struct ds_t* _data; 319 const struct ds_t* _data;
317}; 320};
318 321
319/*====================================================================================== 322/*======================================================================================
320 * OWaveLanManagementTim 323 * OWaveLanManagementTim
321 *======================================================================================*/ 324 *======================================================================================*/
322 325
323class OWaveLanManagementTim : public QObject 326class OWaveLanManagementTim : public QObject
324{ 327{
325 Q_OBJECT 328 Q_OBJECT
326 329
327 public: 330 public:
328 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); 331 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 );
329 virtual ~OWaveLanManagementTim(); 332 virtual ~OWaveLanManagementTim();
330 333
331 private: 334 private:
332 const struct tim_t* _data; 335 const struct tim_t* _data;
333}; 336};
334 337
335/*====================================================================================== 338/*======================================================================================
336 * OWaveLanManagementIBSS 339 * OWaveLanManagementIBSS
337 *======================================================================================*/ 340 *======================================================================================*/
338 341
339class OWaveLanManagementIBSS : public QObject 342class OWaveLanManagementIBSS : public QObject
340{ 343{
341 Q_OBJECT 344 Q_OBJECT
342 345
343 public: 346 public:
344 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); 347 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 );
345 virtual ~OWaveLanManagementIBSS(); 348 virtual ~OWaveLanManagementIBSS();
346 349
347 private: 350 private:
348 const struct ibss_t* _data; 351 const struct ibss_t* _data;
349}; 352};
350 353
351/*====================================================================================== 354/*======================================================================================
352 * OWaveLanManagementChallenge 355 * OWaveLanManagementChallenge
353 *======================================================================================*/ 356 *======================================================================================*/
354 357
355class OWaveLanManagementChallenge : public QObject 358class OWaveLanManagementChallenge : public QObject
356{ 359{
357 Q_OBJECT 360 Q_OBJECT
358 361
359 public: 362 public:
360 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); 363 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 );
361 virtual ~OWaveLanManagementChallenge(); 364 virtual ~OWaveLanManagementChallenge();
362 365
363 private: 366 private:
364 const struct challenge_t* _data; 367 const struct challenge_t* _data;
365}; 368};
366 369
367/*====================================================================================== 370/*======================================================================================
368 * OWaveLanDataPacket - type: data (T_DATA) 371 * OWaveLanDataPacket - type: data (T_DATA)
369 *======================================================================================*/ 372 *======================================================================================*/
370 373
371class OWaveLanDataPacket : public QObject 374class OWaveLanDataPacket : public QObject
372{ 375{
373 Q_OBJECT 376 Q_OBJECT
374 377
375 public: 378 public:
376 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); 379 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 );
377 virtual ~OWaveLanDataPacket(); 380 virtual ~OWaveLanDataPacket();
378 381
379 private: 382 private:
380 const struct ieee_802_11_data_header* _header; 383 const struct ieee_802_11_data_header* _header;
381}; 384};
382 385
383/*====================================================================================== 386/*======================================================================================
384 * OWaveLanControlPacket - type: control (T_CTRL) 387 * OWaveLanControlPacket - type: control (T_CTRL)
385 *======================================================================================*/ 388 *======================================================================================*/
386 389
387class OWaveLanControlPacket : public QObject 390class OWaveLanControlPacket : public QObject
388{ 391{
389 Q_OBJECT 392 Q_OBJECT
390 393
391 public: 394 public:
392 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); 395 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 );
393 virtual ~OWaveLanControlPacket(); 396 virtual ~OWaveLanControlPacket();
394 397
395 private: 398 private:
396 const struct ieee_802_11_control_header* _header; 399 const struct ieee_802_11_control_header* _header;
397}; 400};
398 401
399/*====================================================================================== 402/*======================================================================================
400 * OLLCPacket - IEEE 802.2 Link Level Control 403 * OLLCPacket - IEEE 802.2 Link Level Control
401 *======================================================================================*/ 404 *======================================================================================*/
402 405
403class OLLCPacket : public QObject 406class OLLCPacket : public QObject
404{ 407{
405 Q_OBJECT 408 Q_OBJECT
406 409
407 public: 410 public:
408 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); 411 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 );
409 virtual ~OLLCPacket(); 412 virtual ~OLLCPacket();
410 413
411 private: 414 private:
412 const struct ieee_802_11_802_2_header* _header; 415 const struct ieee_802_11_802_2_header* _header;
413}; 416};
414 417
415/*====================================================================================== 418/*======================================================================================
416 * OIPPacket 419 * OIPPacket
417 *======================================================================================*/ 420 *======================================================================================*/
418 421
419class OIPPacket : public QObject 422class OIPPacket : public QObject
420{ 423{
421 Q_OBJECT 424 Q_OBJECT
422 425
423 public: 426 public:
424 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); 427 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 );
425 virtual ~OIPPacket(); 428 virtual ~OIPPacket();
426 429
427 QHostAddress fromIPAddress() const; 430 QHostAddress fromIPAddress() const;
428 QHostAddress toIPAddress() const; 431 QHostAddress toIPAddress() const;
429 432
430 int tos() const; 433 int tos() const;
431 int len() const; 434 int len() const;
432 int id() const; 435 int id() const;
433 int offset() const; 436 int offset() const;
434 int ttl() const; 437 int ttl() const;
435 int protocol() const; 438 int protocol() const;
436 int checksum() const; 439 int checksum() const;
437 440
438 private: 441 private:
439 const struct iphdr* _iphdr; 442 const struct iphdr* _iphdr;
440}; 443};
441 444
442/*====================================================================================== 445/*======================================================================================
443 * OARPPacket 446 * OARPPacket
444 *======================================================================================*/ 447 *======================================================================================*/
445 448
446class OARPPacket : public QObject 449class OARPPacket : public QObject
447{ 450{
448 Q_OBJECT 451 Q_OBJECT
449 452
450 public: 453 public:
451 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); 454 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 );
452 virtual ~OARPPacket(); 455 virtual ~OARPPacket();
453 456
454 QHostAddress senderIPV4Address() const; 457 QHostAddress senderIPV4Address() const;
455 OMacAddress senderMacAddress() const; 458 OMacAddress senderMacAddress() const;
456 QHostAddress targetIPV4Address() const; 459 QHostAddress targetIPV4Address() const;
457 OMacAddress targetMacAddress() const; 460 OMacAddress targetMacAddress() const;
458 461
459 //int type() const; 462 //int type() const;
460 QString type() const; 463 QString type() const;
461 464
462 private: 465 private:
463 const struct myarphdr* _arphdr; 466 const struct myarphdr* _arphdr;
464}; 467};
465 468
466/*====================================================================================== 469/*======================================================================================
467 * OUDPPacket 470 * OUDPPacket
468 *======================================================================================*/ 471 *======================================================================================*/
469 472
470class OUDPPacket : public QObject 473class OUDPPacket : public QObject
471{ 474{
472 Q_OBJECT 475 Q_OBJECT
473 476
474 public: 477 public:
475 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); 478 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
476 virtual ~OUDPPacket(); 479 virtual ~OUDPPacket();
477 480
478 int fromPort() const; 481 int fromPort() const;
479 int toPort() const; 482 int toPort() const;
483 int length() const;
484 int checksum() const;
480 485
481 private: 486 private:
482 const struct udphdr* _udphdr; 487 const struct udphdr* _udphdr;
483}; 488};
484 489
485/*====================================================================================== 490/*======================================================================================
491 * ODHCPPacket
492 *======================================================================================*/
493
494class ODHCPPacket : public QObject
495{
496 Q_OBJECT
497
498 public:
499 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 );
500 virtual ~ODHCPPacket();
501
502 private:
503 const struct dhcp_packet* _dhcphdr;
504};
505
506/*======================================================================================
486 * OTCPPacket 507 * OTCPPacket
487 *======================================================================================*/ 508 *======================================================================================*/
488 509
489class OTCPPacket : public QObject 510class OTCPPacket : public QObject
490{ 511{
491 Q_OBJECT 512 Q_OBJECT
492 513
493 public: 514 public:
494 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); 515 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
495 virtual ~OTCPPacket(); 516 virtual ~OTCPPacket();
496 517
497 int fromPort() const; 518 int fromPort() const;
498 int toPort() const; 519 int toPort() const;
520 int seq() const;
521 int ack() const;
522 int window() const;
523 int checksum() const;
499 524
500 private: 525 private:
501 const struct tcphdr* _tcphdr; 526 const struct tcphdr* _tcphdr;
502}; 527};
503 528
504 529
505/*====================================================================================== 530/*======================================================================================
506 * OPacketCapturer 531 * OPacketCapturer
507 *======================================================================================*/ 532 *======================================================================================*/
508 533
509/** 534/**
510 * @brief A class based wrapper for network packet capturing. 535 * @brief A class based wrapper for network packet capturing.
511 * 536 *
512 * This class is the base of a high-level interface to the well known packet capturing 537 * This class is the base of a high-level interface to the well known packet capturing
513 * library libpcap. ... 538 * library libpcap.
539 * @see http://tcpdump.org
514 */ 540 */
515class OPacketCapturer : public QObject 541class OPacketCapturer : public QObject
516{ 542{
517 Q_OBJECT 543 Q_OBJECT
518 544
519 public: 545 public:
520 /** 546 /**
521 * Constructor. 547 * Constructor.
522 */ 548 */
523 OPacketCapturer( QObject* parent = 0, const char* name = 0 ); 549 OPacketCapturer( QObject* parent = 0, const char* name = 0 );
524 /** 550 /**
525 * Destructor. 551 * Destructor.
526 */ 552 */
527 ~OPacketCapturer(); 553 ~OPacketCapturer();
528 /** 554 /**
529 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when 555 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when
530 * not using the socket notifier, e.g. without an application object. 556 * not using the socket notifier, e.g. without an application object.
531 */ 557 */
532 void setBlocking( bool ); 558 void setBlocking( bool );
533 /** 559 /**
534 * @returns true if the packet capturer uses blocking IO calls. 560 * @returns true if the packet capturer uses blocking IO calls.
535 */ 561 */
536 bool blocking() const; 562 bool blocking() const;
537 /** 563 /**
538 * Close the packet capturer. This is automatically done in the destructor. 564 * Close the packet capturer. This is automatically done in the destructor.
539 */ 565 */
540 void close(); 566 void close();
541 /** 567 /**
542 * Close the output capture file. 568 * Close the output capture file.
543 */ 569 */
544 void closeDumpFile(); 570 void closeDumpFile();
545 /** 571 /**
546 * @returns the data link type. 572 * @returns the data link type.
547 * @see <pcap.h> for possible values. 573 * @see <pcap.h> for possible values.
548 */ 574 */
549 int dataLink() const; 575 int dataLink() const;
550 /** 576 /**
551 * Dump a packet to the output capture file. 577 * Dump a packet to the output capture file.
552 */ 578 */
553 void dump( OPacket* ); 579 void dump( OPacket* );
554 /** 580 /**
555 * @returns the file descriptor of the packet capturer. This is only useful, if 581 * @returns the file descriptor of the packet capturer. This is only useful, if
556 * not using the socket notifier, e.g. without an application object. 582 * not using the socket notifier, e.g. without an application object.
557 */ 583 */
558 int fileno() const; 584 int fileno() const;
559 /** 585 /**
560 * @returns the next @ref OPacket from the packet capturer. 586 * @returns the next @ref OPacket from the packet capturer.
561 * @note If blocking mode is true then this call might block. 587 * @note If blocking mode is true then this call might block.
562 */ 588 */
563 OPacket* next(); 589 OPacket* next();
564 /** 590 /**
565 * Open the packet capturer to capture packets in live-mode from @a interface. 591 * Open the packet capturer to capture packets in live-mode from @a interface.
566 */ 592 */
567 bool open( const QString& interface ); 593 bool open( const QString& interface );
568 /** 594 /**
569 * Open the packet capturer to capture packets in offline-mode from @a file. 595 * Open the packet capturer to capture packets in offline-mode from @a file.
570 */ 596 */
571 bool open( const QFile& file ); 597 bool open( const QFile& file );
572 /** 598 /**
573 * Open a prerecorded tcpdump compatible capture file for use with @ref dump() 599 * Open a prerecorded tcpdump compatible capture file for use with @ref dump()
574 */ 600 */
575 bool openDumpFile( const QString& filename ); 601 bool openDumpFile( const QString& filename );
576 /** 602 /**
577 * @returns true if the packet capturer is open 603 * @returns true if the packet capturer is open
578 */ 604 */
579 bool isOpen() const; 605 bool isOpen() const;
580 /** 606 /**
581 * @returns the snapshot length of this packet capturer 607 * @returns the snapshot length of this packet capturer
582 */ 608 */
583 int snapShot() const; 609 int snapShot() const;
584 /** 610 /**
585 * @returns true if the input capture file has a different byte-order 611 * @returns true if the input capture file has a different byte-order
586 * than the byte-order of the running system. 612 * than the byte-order of the running system.
587 */ 613 */
588 bool swapped() const; 614 bool swapped() const;
589 /** 615 /**
590 * @returns the libpcap version string used to write the input capture file. 616 * @returns the libpcap version string used to write the input capture file.
591 */ 617 */
592 QString version() const; 618 QString version() const;
593 /** 619 /**
594 * @returns the packet statistic database. 620 * @returns the packet statistic database.
595 * @see QMap 621 * @see QMap
596 */ 622 */
597 const QMap<QString,int>& statistics() const; 623 const QMap<QString,int>& statistics() const;
598 624
599 signals: 625 signals:
600 /** 626 /**
601 * This signal is emitted, when a packet has been received. 627 * This signal is emitted, when a packet has been received.
602 */ 628 */
603 void receivedPacket( OPacket* ); 629 void receivedPacket( OPacket* );
604 630
605 protected slots: 631 protected slots:
606 void readyToReceive(); 632 void readyToReceive();
607 633
608 protected: 634 protected:
609 QString _name; // devicename 635 QString _name; // devicename
610 bool _open; // check this before doing pcap calls 636 bool _open; // check this before doing pcap calls
611 pcap_t* _pch; // pcap library handle 637 pcap_t* _pch; // pcap library handle
612 pcap_dumper_t* _pcd; // pcap dumper handle 638 pcap_dumper_t* _pcd; // pcap dumper handle
613 QSocketNotifier* _sn; // socket notifier for main loop 639 QSocketNotifier* _sn; // socket notifier for main loop
614 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap 640 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap
615 QMap<QString, int> _stats; // statistics; 641 QMap<QString, int> _stats; // statistics;
616}; 642};
617 643
618#endif // OPCAP_H 644#endif // OPCAP_H
619 645
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro
index 93389db..7a7adde 100644
--- a/libopie2/opienet/opienet.pro
+++ b/libopie2/opienet/opienet.pro
@@ -1,28 +1,30 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = omanufacturerdb.cpp \ 4HEADERS = 802_11_user.h \
5 dhcp.h \
6 omanufacturerdb.cpp \
5 onetutils.cpp \ 7 onetutils.cpp \
6 onetwork.h \ 8 onetwork.h \
7 opcap.h 9 opcap.h
8SOURCES = omanufacturerdb.cpp \ 10SOURCES = omanufacturerdb.cpp \
9 onetutils.cpp \ 11 onetutils.cpp \
10 onetwork.cpp \ 12 onetwork.cpp \
11 opcap.cpp 13 opcap.cpp
12INTERFACES = 14INTERFACES =
13TARGET = opienet2 15TARGET = opienet2
14VERSION = 1.8.1 16VERSION = 1.8.1
15INCLUDEPATH += $(OPIEDIR)/include 17INCLUDEPATH += $(OPIEDIR)/include
16DEPENDPATH += $(OPIEDIR)/include 18DEPENDPATH += $(OPIEDIR)/include
17LIBS += -lpcap 19LIBS += -lpcap
18MOC_DIR = moc 20MOC_DIR = moc
19OBJECTS_DIR = obj 21OBJECTS_DIR = obj
20 22
21 23
22!contains( platform, x11 ) { 24!contains( platform, x11 ) {
23 include ( $(OPIEDIR)/include.pro ) 25 include ( $(OPIEDIR)/include.pro )
24} 26}
25 27
26contains( platform, x11 ) { 28contains( platform, x11 ) {
27 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 29 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
28} 30}