summaryrefslogtreecommitdiff
path: root/libopie2/opienet
authorzecke <zecke>2004-03-14 17:00:46 (UTC)
committer zecke <zecke>2004-03-14 17:00:46 (UTC)
commit52169e2469a1edcca986e9f0404c3ca815d5833b (patch) (unidiff)
tree9c6651125f29fe63df33fe56b352d3288b2ea8df /libopie2/opienet
parent59106c8ffcf25181925281c519a2b49d6835ef9e (diff)
downloadopie-52169e2469a1edcca986e9f0404c3ca815d5833b.zip
opie-52169e2469a1edcca986e9f0404c3ca815d5833b.tar.gz
opie-52169e2469a1edcca986e9f0404c3ca815d5833b.tar.bz2
Change Signature of Signals to obey namespace
Make example compile
Diffstat (limited to 'libopie2/opienet') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index dc609a3..72a78de 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -1,721 +1,721 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef OPCAP_H 31#ifndef OPCAP_H
32#define OPCAP_H 32#define OPCAP_H
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/onetutils.h> 35#include <opie2/onetutils.h>
36 36
37/* QT */ 37/* QT */
38#include <qevent.h> 38#include <qevent.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qhostaddress.h> 40#include <qhostaddress.h>
41#include <qobject.h> 41#include <qobject.h>
42#include <qstring.h> 42#include <qstring.h>
43#include <qtextstream.h> 43#include <qtextstream.h>
44#include <qmap.h> 44#include <qmap.h>
45 45
46/* STD */ 46/* STD */
47extern "C" // work around a bpf/pcap conflict in recent headers 47extern "C" // work around a bpf/pcap conflict in recent headers
48{ 48{
49 #include <pcap.h> 49 #include <pcap.h>
50} 50}
51#include <netinet/ether.h> 51#include <netinet/ether.h>
52#include <netinet/ip.h> 52#include <netinet/ip.h>
53#include <netinet/udp.h> 53#include <netinet/udp.h>
54#include <netinet/tcp.h> 54#include <netinet/tcp.h>
55#include <time.h> 55#include <time.h>
56 56
57/* Custom Network Includes (must go here, don't reorder!) */ 57/* Custom Network Includes (must go here, don't reorder!) */
58#include "802_11_user.h" 58#include "802_11_user.h"
59#include "dhcp.h" 59#include "dhcp.h"
60 60
61 61
62/* TYPEDEFS */ 62/* TYPEDEFS */
63typedef struct timeval timevalstruct; 63typedef struct timeval timevalstruct;
64typedef struct pcap_pkthdr packetheaderstruct; 64typedef struct pcap_pkthdr packetheaderstruct;
65 65
66/* FORWARDS */ 66/* FORWARDS */
67class QSocketNotifier; 67class QSocketNotifier;
68namespace Opie { 68namespace Opie {
69namespace Net { 69namespace Net {
70class OPacketCapturer; 70class OPacketCapturer;
71 71
72/*====================================================================================== 72/*======================================================================================
73 * OPacket - A frame on the wire 73 * OPacket - A frame on the wire
74 *======================================================================================*/ 74 *======================================================================================*/
75 75
76/** @brief A class representing a data frame on the wire. 76/** @brief A class representing a data frame on the wire.
77 * 77 *
78 * The whole family of the packet classes are used when capturing frames from a network. 78 * The whole family of the packet classes are used when capturing frames from a network.
79 * Most standard network protocols in use share a common architecture, which mostly is 79 * Most standard network protocols in use share a common architecture, which mostly is
80 * a packet header and then the packet payload. In layered architectures, each lower layer 80 * a packet header and then the packet payload. In layered architectures, each lower layer
81 * encapsulates data from its upper layer - that is it 81 * encapsulates data from its upper layer - that is it
82 * treats the data from its upper layer as payload and prepends an own header to the packet, 82 * treats the data from its upper layer as payload and prepends an own header to the packet,
83 * which - again - is treated as the payload for the layer below. The figure below is an 83 * which - again - is treated as the payload for the layer below. The figure below is an
84 * example for how such a data frame is composed out of packets, e.g. when sending a mail. 84 * example for how such a data frame is composed out of packets, e.g. when sending a mail.
85 * 85 *
86 * <pre> 86 * <pre>
87 * | User Data | == Mail Data 87 * | User Data | == Mail Data
88 * | SMTP Header | User Data | == SMTP 88 * | SMTP Header | User Data | == SMTP
89 * | TCP Header | SMTP Header | User Data | == TCP 89 * | TCP Header | SMTP Header | User Data | == TCP
90 * | IP Header | TCP Header | SMTP Header | User Data | == IP 90 * | IP Header | TCP Header | SMTP Header | User Data | == IP
91 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC 91 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC
92 * 92 *
93 * </pre> 93 * </pre>
94 * 94 *
95 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer 95 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer
96 * also contains a few more levels of encapsulation. 96 * also contains a few more levels of encapsulation.
97 * Since the type of the payload is more or less independent from the encapsulating protocol, 97 * Since the type of the payload is more or less independent from the encapsulating protocol,
98 * the header must be inspected before attempting to decode the payload. Hence, the 98 * the header must be inspected before attempting to decode the payload. Hence, the
99 * encapsulation level varies and can't be deduced without actually looking into the packets. 99 * encapsulation level varies and can't be deduced without actually looking into the packets.
100 * 100 *
101 * For actually working with captured frames, it's useful to identify the packets via names and 101 * For actually working with captured frames, it's useful to identify the packets via names and
102 * insert them into a parent/child - relationship based on the encapsulation. This is why 102 * insert them into a parent/child - relationship based on the encapsulation. This is why
103 * all packet classes derive from QObject. The amount of overhead caused by the QObject is 103 * all packet classes derive from QObject. The amount of overhead caused by the QObject is
104 * not a problem in this case, because we're talking about a theoratical maximum of about 104 * not a problem in this case, because we're talking about a theoratical maximum of about
105 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the 105 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the
106 * QObject also cares about destroying the sub-, (child-) packets. 106 * QObject also cares about destroying the sub-, (child-) packets.
107 * 107 *
108 * This enables us to perform a simple look for packets of a certain type: 108 * This enables us to perform a simple look for packets of a certain type:
109 * @code 109 * @code
110 * OPacketCapturer* pcap = new OPacketCapturer(); 110 * OPacketCapturer* pcap = new OPacketCapturer();
111 * pcap->open( "eth0" ); 111 * pcap->open( "eth0" );
112 * OPacket* p = pcap->next(); 112 * OPacket* p = pcap->next();
113 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists 113 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists
114 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; 114 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl;
115 * 115 *
116 */ 116 */
117 117
118class OPacket : public QObject 118class OPacket : public QObject
119{ 119{
120 Q_OBJECT 120 Q_OBJECT
121 121
122 friend class OPacketCapturer; 122 friend class OPacketCapturer;
123 friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); 123 friend QTextStream& operator<<( QTextStream& s, const OPacket& p );
124 124
125 public: 125 public:
126 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); 126 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent );
127 virtual ~OPacket(); 127 virtual ~OPacket();
128 128
129 timevalstruct timeval() const; 129 timevalstruct timeval() const;
130 130
131 int caplen() const; 131 int caplen() const;
132 int len() const; 132 int len() const;
133 QString dump( int = 32 ) const; 133 QString dump( int = 32 ) const;
134 134
135 void updateStats( QMap<QString,int>&, QObjectList* ); 135 void updateStats( QMap<QString,int>&, QObjectList* );
136 136
137 private: 137 private:
138 138
139 QString dumpStructure() const; 139 QString dumpStructure() const;
140 QString _dumpStructure( QObjectList* ) const; 140 QString _dumpStructure( QObjectList* ) const;
141 141
142 private: 142 private:
143 const packetheaderstruct _hdr; // pcap packet header 143 const packetheaderstruct _hdr; // pcap packet header
144 const unsigned char* _data; // pcap packet data 144 const unsigned char* _data; // pcap packet data
145 const unsigned char* _end; // end of pcap packet data 145 const unsigned char* _end; // end of pcap packet data
146 private: 146 private:
147 class Private; 147 class Private;
148 Private *d; 148 Private *d;
149}; 149};
150 150
151QTextStream& operator<<( QTextStream& s, const OPacket& p ); 151QTextStream& operator<<( QTextStream& s, const OPacket& p );
152 152
153/*====================================================================================== 153/*======================================================================================
154 * OEthernetPacket - DLT_EN10MB frame 154 * OEthernetPacket - DLT_EN10MB frame
155 *======================================================================================*/ 155 *======================================================================================*/
156 156
157class OEthernetPacket : public QObject 157class OEthernetPacket : public QObject
158{ 158{
159 Q_OBJECT 159 Q_OBJECT
160 160
161 public: 161 public:
162 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); 162 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 );
163 virtual ~OEthernetPacket(); 163 virtual ~OEthernetPacket();
164 164
165 OMacAddress sourceAddress() const; 165 OMacAddress sourceAddress() const;
166 OMacAddress destinationAddress() const; 166 OMacAddress destinationAddress() const;
167 int type() const; 167 int type() const;
168 168
169 private: 169 private:
170 const struct ether_header* _ether; 170 const struct ether_header* _ether;
171 private: 171 private:
172 class Private; 172 class Private;
173 Private *d; 173 Private *d;
174}; 174};
175 175
176/*====================================================================================== 176/*======================================================================================
177 * OPrismHeaderPacket - DLT_PRISM_HEADER frame 177 * OPrismHeaderPacket - DLT_PRISM_HEADER frame
178 *======================================================================================*/ 178 *======================================================================================*/
179 179
180class OPrismHeaderPacket : public QObject 180class OPrismHeaderPacket : public QObject
181{ 181{
182 Q_OBJECT 182 Q_OBJECT
183 183
184 public: 184 public:
185 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); 185 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 );
186 virtual ~OPrismHeaderPacket(); 186 virtual ~OPrismHeaderPacket();
187 187
188 unsigned int signalStrength() const; 188 unsigned int signalStrength() const;
189 189
190 private: 190 private:
191 const struct prism_hdr* _header; 191 const struct prism_hdr* _header;
192 class Private; 192 class Private;
193 Private *d; 193 Private *d;
194}; 194};
195 195
196/*====================================================================================== 196/*======================================================================================
197 * OWaveLanPacket - DLT_IEEE802_11 frame 197 * OWaveLanPacket - DLT_IEEE802_11 frame
198 *======================================================================================*/ 198 *======================================================================================*/
199 199
200class OWaveLanPacket : public QObject 200class OWaveLanPacket : public QObject
201{ 201{
202 Q_OBJECT 202 Q_OBJECT
203 203
204 public: 204 public:
205 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); 205 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 );
206 virtual ~OWaveLanPacket(); 206 virtual ~OWaveLanPacket();
207 207
208 int duration() const; 208 int duration() const;
209 bool fromDS() const; 209 bool fromDS() const;
210 bool toDS() const; 210 bool toDS() const;
211 virtual OMacAddress macAddress1() const; 211 virtual OMacAddress macAddress1() const;
212 virtual OMacAddress macAddress2() const; 212 virtual OMacAddress macAddress2() const;
213 virtual OMacAddress macAddress3() const; 213 virtual OMacAddress macAddress3() const;
214 virtual OMacAddress macAddress4() const; 214 virtual OMacAddress macAddress4() const;
215 bool usesPowerManagement() const; 215 bool usesPowerManagement() const;
216 int type() const; 216 int type() const;
217 int subType() const; 217 int subType() const;
218 int version() const; 218 int version() const;
219 bool usesWep() const; 219 bool usesWep() const;
220 220
221 private: 221 private:
222 const struct ieee_802_11_header* _wlanhdr; 222 const struct ieee_802_11_header* _wlanhdr;
223 class Private; 223 class Private;
224 Private *d; 224 Private *d;
225}; 225};
226 226
227 227
228/*====================================================================================== 228/*======================================================================================
229 * OWaveLanManagementPacket - type: management (T_MGMT) 229 * OWaveLanManagementPacket - type: management (T_MGMT)
230 *======================================================================================*/ 230 *======================================================================================*/
231 231
232class OWaveLanManagementPacket : public QObject 232class OWaveLanManagementPacket : public QObject
233{ 233{
234 Q_OBJECT 234 Q_OBJECT
235 235
236 public: 236 public:
237 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); 237 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 );
238 virtual ~OWaveLanManagementPacket(); 238 virtual ~OWaveLanManagementPacket();
239 239
240 QString managementType() const; 240 QString managementType() const;
241 241
242 int beaconInterval() const; 242 int beaconInterval() const;
243 int capabilities() const; // generic 243 int capabilities() const; // generic
244 244
245 bool canESS() const; 245 bool canESS() const;
246 bool canIBSS() const; 246 bool canIBSS() const;
247 bool canCFP() const; 247 bool canCFP() const;
248 bool canCFP_REQ() const; 248 bool canCFP_REQ() const;
249 bool canPrivacy() const; 249 bool canPrivacy() const;
250 250
251 private: 251 private:
252 const struct ieee_802_11_mgmt_header* _header; 252 const struct ieee_802_11_mgmt_header* _header;
253 const struct ieee_802_11_mgmt_body* _body; 253 const struct ieee_802_11_mgmt_body* _body;
254 class Private; 254 class Private;
255 Private *d; 255 Private *d;
256}; 256};
257 257
258 258
259/*====================================================================================== 259/*======================================================================================
260 * OWaveLanManagementSSID 260 * OWaveLanManagementSSID
261 *======================================================================================*/ 261 *======================================================================================*/
262 262
263class OWaveLanManagementSSID : public QObject 263class OWaveLanManagementSSID : public QObject
264{ 264{
265 Q_OBJECT 265 Q_OBJECT
266 266
267 public: 267 public:
268 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); 268 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 );
269 virtual ~OWaveLanManagementSSID(); 269 virtual ~OWaveLanManagementSSID();
270 270
271 QString ID( bool decloak = false ) const; 271 QString ID( bool decloak = false ) const;
272 272
273 private: 273 private:
274 const struct ssid_t* _data; 274 const struct ssid_t* _data;
275 class Private; 275 class Private;
276 Private *d; 276 Private *d;
277}; 277};
278 278
279/*====================================================================================== 279/*======================================================================================
280 * OWaveLanManagementRates 280 * OWaveLanManagementRates
281 *======================================================================================*/ 281 *======================================================================================*/
282 282
283class OWaveLanManagementRates : public QObject 283class OWaveLanManagementRates : public QObject
284{ 284{
285 Q_OBJECT 285 Q_OBJECT
286 286
287 public: 287 public:
288 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); 288 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 );
289 virtual ~OWaveLanManagementRates(); 289 virtual ~OWaveLanManagementRates();
290 290
291 private: 291 private:
292 const struct rates_t* _data; 292 const struct rates_t* _data;
293 class Private; 293 class Private;
294 Private *d; 294 Private *d;
295}; 295};
296 296
297/*====================================================================================== 297/*======================================================================================
298 * OWaveLanManagementCF 298 * OWaveLanManagementCF
299 *======================================================================================*/ 299 *======================================================================================*/
300 300
301class OWaveLanManagementCF : public QObject 301class OWaveLanManagementCF : public QObject
302{ 302{
303 Q_OBJECT 303 Q_OBJECT
304 304
305 public: 305 public:
306 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); 306 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 );
307 virtual ~OWaveLanManagementCF(); 307 virtual ~OWaveLanManagementCF();
308 308
309 private: 309 private:
310 const struct cf_t* _data; 310 const struct cf_t* _data;
311 class Private; 311 class Private;
312 Private *d; 312 Private *d;
313}; 313};
314 314
315/*====================================================================================== 315/*======================================================================================
316 * OWaveLanManagementFH 316 * OWaveLanManagementFH
317 *======================================================================================*/ 317 *======================================================================================*/
318 318
319class OWaveLanManagementFH : public QObject 319class OWaveLanManagementFH : public QObject
320{ 320{
321 Q_OBJECT 321 Q_OBJECT
322 322
323 public: 323 public:
324 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); 324 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 );
325 virtual ~OWaveLanManagementFH(); 325 virtual ~OWaveLanManagementFH();
326 326
327 private: 327 private:
328 const struct fh_t* _data; 328 const struct fh_t* _data;
329 class Private; 329 class Private;
330 Private *d; 330 Private *d;
331}; 331};
332 332
333/*====================================================================================== 333/*======================================================================================
334 * OWaveLanManagementDS 334 * OWaveLanManagementDS
335 *======================================================================================*/ 335 *======================================================================================*/
336 336
337class OWaveLanManagementDS : public QObject 337class OWaveLanManagementDS : public QObject
338{ 338{
339 Q_OBJECT 339 Q_OBJECT
340 340
341 public: 341 public:
342 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); 342 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 );
343 virtual ~OWaveLanManagementDS(); 343 virtual ~OWaveLanManagementDS();
344 344
345 int channel() const; 345 int channel() const;
346 346
347 private: 347 private:
348 const struct ds_t* _data; 348 const struct ds_t* _data;
349 class Private; 349 class Private;
350 Private *d; 350 Private *d;
351}; 351};
352 352
353/*====================================================================================== 353/*======================================================================================
354 * OWaveLanManagementTim 354 * OWaveLanManagementTim
355 *======================================================================================*/ 355 *======================================================================================*/
356 356
357class OWaveLanManagementTim : public QObject 357class OWaveLanManagementTim : public QObject
358{ 358{
359 Q_OBJECT 359 Q_OBJECT
360 360
361 public: 361 public:
362 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); 362 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 );
363 virtual ~OWaveLanManagementTim(); 363 virtual ~OWaveLanManagementTim();
364 364
365 private: 365 private:
366 const struct tim_t* _data; 366 const struct tim_t* _data;
367 class Private; 367 class Private;
368 Private *d; 368 Private *d;
369}; 369};
370 370
371/*====================================================================================== 371/*======================================================================================
372 * OWaveLanManagementIBSS 372 * OWaveLanManagementIBSS
373 *======================================================================================*/ 373 *======================================================================================*/
374 374
375class OWaveLanManagementIBSS : public QObject 375class OWaveLanManagementIBSS : public QObject
376{ 376{
377 Q_OBJECT 377 Q_OBJECT
378 378
379 public: 379 public:
380 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); 380 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 );
381 virtual ~OWaveLanManagementIBSS(); 381 virtual ~OWaveLanManagementIBSS();
382 382
383 private: 383 private:
384 const struct ibss_t* _data; 384 const struct ibss_t* _data;
385 class Private; 385 class Private;
386 Private *d; 386 Private *d;
387}; 387};
388 388
389/*====================================================================================== 389/*======================================================================================
390 * OWaveLanManagementChallenge 390 * OWaveLanManagementChallenge
391 *======================================================================================*/ 391 *======================================================================================*/
392 392
393class OWaveLanManagementChallenge : public QObject 393class OWaveLanManagementChallenge : public QObject
394{ 394{
395 Q_OBJECT 395 Q_OBJECT
396 396
397 public: 397 public:
398 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); 398 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 );
399 virtual ~OWaveLanManagementChallenge(); 399 virtual ~OWaveLanManagementChallenge();
400 400
401 private: 401 private:
402 const struct challenge_t* _data; 402 const struct challenge_t* _data;
403 class Private; 403 class Private;
404 Private *d; 404 Private *d;
405}; 405};
406 406
407/*====================================================================================== 407/*======================================================================================
408 * OWaveLanDataPacket - type: data (T_DATA) 408 * OWaveLanDataPacket - type: data (T_DATA)
409 *======================================================================================*/ 409 *======================================================================================*/
410 410
411class OWaveLanDataPacket : public QObject 411class OWaveLanDataPacket : public QObject
412{ 412{
413 Q_OBJECT 413 Q_OBJECT
414 414
415 public: 415 public:
416 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); 416 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 );
417 virtual ~OWaveLanDataPacket(); 417 virtual ~OWaveLanDataPacket();
418 418
419 private: 419 private:
420 const struct ieee_802_11_data_header* _header; 420 const struct ieee_802_11_data_header* _header;
421 class Private; 421 class Private;
422 Private *d; 422 Private *d;
423}; 423};
424 424
425/*====================================================================================== 425/*======================================================================================
426 * OWaveLanControlPacket - type: control (T_CTRL) 426 * OWaveLanControlPacket - type: control (T_CTRL)
427 *======================================================================================*/ 427 *======================================================================================*/
428 428
429class OWaveLanControlPacket : public QObject 429class OWaveLanControlPacket : public QObject
430{ 430{
431 Q_OBJECT 431 Q_OBJECT
432 432
433 public: 433 public:
434 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); 434 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 );
435 virtual ~OWaveLanControlPacket(); 435 virtual ~OWaveLanControlPacket();
436 436
437 QString controlType() const; 437 QString controlType() const;
438 438
439 private: 439 private:
440 const struct ieee_802_11_control_header* _header; 440 const struct ieee_802_11_control_header* _header;
441 class Private; 441 class Private;
442 Private *d; 442 Private *d;
443}; 443};
444 444
445/*====================================================================================== 445/*======================================================================================
446 * OLLCPacket - IEEE 802.2 Link Level Control 446 * OLLCPacket - IEEE 802.2 Link Level Control
447 *======================================================================================*/ 447 *======================================================================================*/
448 448
449class OLLCPacket : public QObject 449class OLLCPacket : public QObject
450{ 450{
451 Q_OBJECT 451 Q_OBJECT
452 452
453 public: 453 public:
454 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); 454 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 );
455 virtual ~OLLCPacket(); 455 virtual ~OLLCPacket();
456 456
457 private: 457 private:
458 const struct ieee_802_11_802_2_header* _header; 458 const struct ieee_802_11_802_2_header* _header;
459 class Private; 459 class Private;
460 Private *d; 460 Private *d;
461}; 461};
462 462
463/*====================================================================================== 463/*======================================================================================
464 * OIPPacket 464 * OIPPacket
465 *======================================================================================*/ 465 *======================================================================================*/
466 466
467class OIPPacket : public QObject 467class OIPPacket : public QObject
468{ 468{
469 Q_OBJECT 469 Q_OBJECT
470 470
471 public: 471 public:
472 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); 472 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 );
473 virtual ~OIPPacket(); 473 virtual ~OIPPacket();
474 474
475 QHostAddress fromIPAddress() const; 475 QHostAddress fromIPAddress() const;
476 QHostAddress toIPAddress() const; 476 QHostAddress toIPAddress() const;
477 477
478 int tos() const; 478 int tos() const;
479 int len() const; 479 int len() const;
480 int id() const; 480 int id() const;
481 int offset() const; 481 int offset() const;
482 int ttl() const; 482 int ttl() const;
483 int protocol() const; 483 int protocol() const;
484 int checksum() const; 484 int checksum() const;
485 485
486 private: 486 private:
487 const struct iphdr* _iphdr; 487 const struct iphdr* _iphdr;
488 class Private; 488 class Private;
489 Private *d; 489 Private *d;
490}; 490};
491 491
492/*====================================================================================== 492/*======================================================================================
493 * OARPPacket 493 * OARPPacket
494 *======================================================================================*/ 494 *======================================================================================*/
495 495
496class OARPPacket : public QObject 496class OARPPacket : public QObject
497{ 497{
498 Q_OBJECT 498 Q_OBJECT
499 499
500 public: 500 public:
501 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); 501 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 );
502 virtual ~OARPPacket(); 502 virtual ~OARPPacket();
503 503
504 QHostAddress senderIPV4Address() const; 504 QHostAddress senderIPV4Address() const;
505 OMacAddress senderMacAddress() const; 505 OMacAddress senderMacAddress() const;
506 QHostAddress targetIPV4Address() const; 506 QHostAddress targetIPV4Address() const;
507 OMacAddress targetMacAddress() const; 507 OMacAddress targetMacAddress() const;
508 508
509 //int type() const; 509 //int type() const;
510 QString type() const; 510 QString type() const;
511 511
512 private: 512 private:
513 const struct myarphdr* _arphdr; 513 const struct myarphdr* _arphdr;
514 class Private; 514 class Private;
515 Private *d; 515 Private *d;
516}; 516};
517 517
518/*====================================================================================== 518/*======================================================================================
519 * OUDPPacket 519 * OUDPPacket
520 *======================================================================================*/ 520 *======================================================================================*/
521 521
522class OUDPPacket : public QObject 522class OUDPPacket : public QObject
523{ 523{
524 Q_OBJECT 524 Q_OBJECT
525 525
526 public: 526 public:
527 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); 527 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
528 virtual ~OUDPPacket(); 528 virtual ~OUDPPacket();
529 529
530 int fromPort() const; 530 int fromPort() const;
531 int toPort() const; 531 int toPort() const;
532 int length() const; 532 int length() const;
533 int checksum() const; 533 int checksum() const;
534 534
535 private: 535 private:
536 const struct udphdr* _udphdr; 536 const struct udphdr* _udphdr;
537 class Private; 537 class Private;
538 Private *d; 538 Private *d;
539}; 539};
540 540
541/*====================================================================================== 541/*======================================================================================
542 * ODHCPPacket 542 * ODHCPPacket
543 *======================================================================================*/ 543 *======================================================================================*/
544 544
545class ODHCPPacket : public QObject 545class ODHCPPacket : public QObject
546{ 546{
547 Q_OBJECT 547 Q_OBJECT
548 548
549 public: 549 public:
550 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); 550 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 );
551 virtual ~ODHCPPacket(); 551 virtual ~ODHCPPacket();
552 552
553 QHostAddress clientAddress() const; 553 QHostAddress clientAddress() const;
554 QHostAddress yourAddress() const; 554 QHostAddress yourAddress() const;
555 QHostAddress serverAddress() const; 555 QHostAddress serverAddress() const;
556 QHostAddress relayAddress() const; 556 QHostAddress relayAddress() const;
557 557
558 OMacAddress clientMacAddress() const; 558 OMacAddress clientMacAddress() const;
559 559
560 bool isRequest() const; 560 bool isRequest() const;
561 bool isReply() const; 561 bool isReply() const;
562 QString type() const; 562 QString type() const;
563 563
564 private: 564 private:
565 const struct dhcp_packet* _dhcphdr; 565 const struct dhcp_packet* _dhcphdr;
566 unsigned char _type; 566 unsigned char _type;
567 class Private; 567 class Private;
568 Private *d; 568 Private *d;
569}; 569};
570 570
571/*====================================================================================== 571/*======================================================================================
572 * OTCPPacket 572 * OTCPPacket
573 *======================================================================================*/ 573 *======================================================================================*/
574 574
575class OTCPPacket : public QObject 575class OTCPPacket : public QObject
576{ 576{
577 Q_OBJECT 577 Q_OBJECT
578 578
579 public: 579 public:
580 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); 580 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
581 virtual ~OTCPPacket(); 581 virtual ~OTCPPacket();
582 582
583 int fromPort() const; 583 int fromPort() const;
584 int toPort() const; 584 int toPort() const;
585 int seq() const; 585 int seq() const;
586 int ack() const; 586 int ack() const;
587 int window() const; 587 int window() const;
588 int checksum() const; 588 int checksum() const;
589 589
590 private: 590 private:
591 const struct tcphdr* _tcphdr; 591 const struct tcphdr* _tcphdr;
592 class Private; 592 class Private;
593 Private *d; 593 Private *d;
594}; 594};
595 595
596 596
597/*====================================================================================== 597/*======================================================================================
598 * OPacketCapturer 598 * OPacketCapturer
599 *======================================================================================*/ 599 *======================================================================================*/
600 600
601/** 601/**
602 * @brief A class based wrapper for network packet capturing. 602 * @brief A class based wrapper for network packet capturing.
603 * 603 *
604 * This class is the base of a high-level interface to the well known packet capturing 604 * This class is the base of a high-level interface to the well known packet capturing
605 * library libpcap. 605 * library libpcap.
606 * @see http://tcpdump.org 606 * @see http://tcpdump.org
607 */ 607 */
608class OPacketCapturer : public QObject 608class OPacketCapturer : public QObject
609{ 609{
610 Q_OBJECT 610 Q_OBJECT
611 611
612 public: 612 public:
613 /** 613 /**
614 * Constructor. 614 * Constructor.
615 */ 615 */
616 OPacketCapturer( QObject* parent = 0, const char* name = 0 ); 616 OPacketCapturer( QObject* parent = 0, const char* name = 0 );
617 /** 617 /**
618 * Destructor. 618 * Destructor.
619 */ 619 */
620 ~OPacketCapturer(); 620 ~OPacketCapturer();
621 /** 621 /**
622 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when 622 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when
623 * not using the socket notifier, e.g. without an application object. 623 * not using the socket notifier, e.g. without an application object.
624 */ 624 */
625 void setBlocking( bool ); 625 void setBlocking( bool );
626 /** 626 /**
627 * @returns true if the packet capturer uses blocking IO calls. 627 * @returns true if the packet capturer uses blocking IO calls.
628 */ 628 */
629 bool blocking() const; 629 bool blocking() const;
630 /** 630 /**
631 * Close the packet capturer. This is automatically done in the destructor. 631 * Close the packet capturer. This is automatically done in the destructor.
632 */ 632 */
633 void close(); 633 void close();
634 /** 634 /**
635 * Close the output capture file. 635 * Close the output capture file.
636 */ 636 */
637 void closeDumpFile(); 637 void closeDumpFile();
638 /** 638 /**
639 * @returns the data link type. 639 * @returns the data link type.
640 * @see <pcap.h> for possible values. 640 * @see <pcap.h> for possible values.
641 */ 641 */
642 int dataLink() const; 642 int dataLink() const;
643 /** 643 /**
644 * Dump a packet to the output capture file. 644 * Dump a packet to the output capture file.
645 */ 645 */
646 void dump( OPacket* ); 646 void dump( OPacket* );
647 /** 647 /**
648 * @returns the file descriptor of the packet capturer. This is only useful, if 648 * @returns the file descriptor of the packet capturer. This is only useful, if
649 * not using the socket notifier, e.g. without an application object. 649 * not using the socket notifier, e.g. without an application object.
650 */ 650 */
651 int fileno() const; 651 int fileno() const;
652 /** 652 /**
653 * @returns the next @ref OPacket from the packet capturer. 653 * @returns the next @ref OPacket from the packet capturer.
654 * @note If blocking mode is true then this call might block. 654 * @note If blocking mode is true then this call might block.
655 */ 655 */
656 OPacket* next(); 656 OPacket* next();
657 /** 657 /**
658 * @returns the next @ref OPacket from the packet capturer, if 658 * @returns the next @ref OPacket from the packet capturer, if
659 * one arrives within @a time milliseconds. 659 * one arrives within @a time milliseconds.
660 */ 660 */
661 OPacket* next( int time ); 661 OPacket* next( int time );
662 /** 662 /**
663 * Open the packet capturer to capture packets in live-mode from @a interface. 663 * Open the packet capturer to capture packets in live-mode from @a interface.
664 */ 664 */
665 bool open( const QString& interface ); 665 bool open( const QString& interface );
666 /** 666 /**
667 * Open the packet capturer to capture packets in offline-mode from @a file. 667 * Open the packet capturer to capture packets in offline-mode from @a file.
668 */ 668 */
669 bool open( const QFile& file ); 669 bool open( const QFile& file );
670 /** 670 /**
671 * Open a prerecorded tcpdump compatible capture file for use with @ref dump() 671 * Open a prerecorded tcpdump compatible capture file for use with @ref dump()
672 */ 672 */
673 bool openDumpFile( const QString& filename ); 673 bool openDumpFile( const QString& filename );
674 /** 674 /**
675 * @returns true if the packet capturer is open 675 * @returns true if the packet capturer is open
676 */ 676 */
677 bool isOpen() const; 677 bool isOpen() const;
678 /** 678 /**
679 * @returns the snapshot length of this packet capturer 679 * @returns the snapshot length of this packet capturer
680 */ 680 */
681 int snapShot() const; 681 int snapShot() const;
682 /** 682 /**
683 * @returns true if the input capture file has a different byte-order 683 * @returns true if the input capture file has a different byte-order
684 * than the byte-order of the running system. 684 * than the byte-order of the running system.
685 */ 685 */
686 bool swapped() const; 686 bool swapped() const;
687 /** 687 /**
688 * @returns the libpcap version string used to write the input capture file. 688 * @returns the libpcap version string used to write the input capture file.
689 */ 689 */
690 QString version() const; 690 QString version() const;
691 /** 691 /**
692 * @returns the packet statistic database. 692 * @returns the packet statistic database.
693 * @see QMap 693 * @see QMap
694 */ 694 */
695 const QMap<QString,int>& statistics() const; 695 const QMap<QString,int>& statistics() const;
696 696
697 signals: 697 signals:
698 /** 698 /**
699 * This signal is emitted, when a packet has been received. 699 * This signal is emitted, when a packet has been received.
700 */ 700 */
701 void receivedPacket( OPacket* ); 701 void receivedPacket( Opie::Net::OPacket* );
702 702
703 protected slots: 703 protected slots:
704 void readyToReceive(); 704 void readyToReceive();
705 705
706 protected: 706 protected:
707 QString _name; // devicename 707 QString _name; // devicename
708 bool _open; // check this before doing pcap calls 708 bool _open; // check this before doing pcap calls
709 pcap_t* _pch; // pcap library handle 709 pcap_t* _pch; // pcap library handle
710 pcap_dumper_t* _pcd; // pcap dumper handle 710 pcap_dumper_t* _pcd; // pcap dumper handle
711 QSocketNotifier* _sn; // socket notifier for main loop 711 QSocketNotifier* _sn; // socket notifier for main loop
712 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap 712 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap
713 QMap<QString, int> _stats; // statistics; 713 QMap<QString, int> _stats; // statistics;
714 class Private; // Private Forward declaration 714 class Private; // Private Forward declaration
715 Private *d; // if we need to add data 715 Private *d; // if we need to add data
716}; 716};
717} 717}
718} 718}
719 719
720#endif // OPCAP_H 720#endif // OPCAP_H
721 721