summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-03-30 01:41:56 (UTC)
committer mickeyl <mickeyl>2003-03-30 01:41:56 (UTC)
commit99899abc80a8aa05044eeecd8a061b0a8efaa713 (patch) (unidiff)
tree45db7a60f17d00ae72d0e8d6b986d5be10232c6c
parent340cb7e64fb898966996b00b93c03ca05a347aa5 (diff)
downloadopie-99899abc80a8aa05044eeecd8a061b0a8efaa713.zip
opie-99899abc80a8aa05044eeecd8a061b0a8efaa713.tar.gz
opie-99899abc80a8aa05044eeecd8a061b0a8efaa713.tar.bz2
- add classes for 802.11 tagged values
- adjust miniwellenreiter accordingly
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp11
-rw-r--r--libopie2/opiecore/oapplication.cpp14
-rw-r--r--libopie2/opiecore/oapplication.h16
-rw-r--r--libopie2/opienet/802_11_user.h54
-rw-r--r--libopie2/opienet/onetwork.cpp40
-rw-r--r--libopie2/opienet/onetwork.h7
-rw-r--r--libopie2/opienet/opcap.cpp253
-rw-r--r--libopie2/opienet/opcap.h166
8 files changed, 481 insertions, 80 deletions
diff --git a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
index aec9cc7..7581888 100644
--- a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
+++ b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
@@ -173,10 +173,13 @@ public slots:
173 if ( beacon ) 173 if ( beacon )
174 { 174 {
175 if ( stations.find( beacon->SSID() ) ) 175 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
176 stations[beacon->SSID()]->beacons++; 176 QString essid = ssid ? ssid->ID() : "<unknown>";
177
178 if ( stations.find( essid ) )
179 stations[essid]->beacons++;
177 else 180 else
178 { 181 {
179 printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) beacon->SSID() ); 182 printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) essid );
180 stations.insert( beacon->SSID(), new Station( "unknown", wiface->channel(), 183 stations.insert( essid, new Station( "unknown", wiface->channel(),
181 ((OWaveLanPacket*) beacon->parent())->usesWep() ) ); 184 ((OWaveLanPacket*) beacon->parent())->usesWep() ) );
182 } 185 }
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp
index a0abcc2..12418d5 100644
--- a/libopie2/opiecore/oapplication.cpp
+++ b/libopie2/opiecore/oapplication.cpp
@@ -93,4 +93,5 @@ void OApplication::init()
93} 93}
94 94
95
95void OApplication::setMainWidget( QWidget* widget ) 96void OApplication::setMainWidget( QWidget* widget )
96{ 97{
@@ -98,4 +99,5 @@ void OApplication::setMainWidget( QWidget* widget )
98} 99}
99 100
101
100void OApplication::showMainWidget( QWidget* widget, bool nomax ) 102void OApplication::showMainWidget( QWidget* widget, bool nomax )
101{ 103{
@@ -107,4 +109,16 @@ void OApplication::showMainWidget( QWidget* widget, bool nomax )
107 #endif 109 #endif
108 widget->setCaption( _appname ); 110 widget->setCaption( _appname );
111}
112
109 113
114void OApplication::setTitle( QString title ) const
115{
116 if ( mainWidget() )
117 {
118 if ( !title.isNull() )
119 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title );
120 else
121 mainWidget()->setCaption( _appname );
122 }
110} 123}
124
diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h
index 736e786..4d25202 100644
--- a/libopie2/opiecore/oapplication.h
+++ b/libopie2/opiecore/oapplication.h
@@ -70,4 +70,5 @@ class OApplication: public OApplicationBaseClass
70 * saves you the trouble of having to pass the pointer explicitly 70 * saves you the trouble of having to pass the pointer explicitly
71 * to every function that may require it. 71 * to every function that may require it.
72 *
72 * @return the current application object 73 * @return the current application object
73 */ 74 */
@@ -93,4 +94,7 @@ class OApplication: public OApplicationBaseClass
93 * Sets the main widget - reimplemented to call showMainWidget() 94 * Sets the main widget - reimplemented to call showMainWidget()
94 * on Qt/Embedded. 95 * on Qt/Embedded.
96 *
97 * @param mainWidget the widget to become the main widget
98 * @see QWidget object
95 */ 99 */
96 virtual void setMainWidget( QWidget *mainWidget ); 100 virtual void setMainWidget( QWidget *mainWidget );
@@ -99,7 +103,19 @@ class OApplication: public OApplicationBaseClass
99 * Shows the main widget - reimplemented to call setMainWidget() 103 * Shows the main widget - reimplemented to call setMainWidget()
100 * on platforms other than Qt/Embedded. 104 * on platforms other than Qt/Embedded.
105 *
106 * @param mainWidget the widget to become the main widget
107 * @see QWidget object
101 */ 108 */
102 virtual void showMainWidget( QWidget* widget, bool nomax = false ); 109 virtual void showMainWidget( QWidget* widget, bool nomax = false );
103 110
111 /**
112 * Set the application title. The application title will be concatenated
113 * to the application name given in the constructor.
114 *
115 * @param title the title. If not given, resets caption to appname
116 */
117 virtual void setTitle( QString title = QString::null ) const;
118 //virtual void setTitle() const;
119
104 protected: 120 protected:
105 void init(); 121 void init();
diff --git a/libopie2/opienet/802_11_user.h b/libopie2/opienet/802_11_user.h
index 0b3f198..ffdcb93 100644
--- a/libopie2/opienet/802_11_user.h
+++ b/libopie2/opienet/802_11_user.h
@@ -256,9 +256,9 @@ struct ieee_802_11_data_header {
256}; 256};
257 257
258 #define CAPABILITY_ESS(cap)((cap) & 0x0001) 258#define CAPABILITY_ESS(cap) ((cap) & 0x0001)
259 #define CAPABILITY_IBSS(cap)((cap) & 0x0002) 259#define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
260 #define CAPABILITY_CFP(cap)((cap) & 0x0004) 260#define CAPABILITY_CFP(cap) ((cap) & 0x0004)
261 #define CAPABILITY_CFP_REQ(cap)((cap) & 0x0008) 261#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
262 #define CAPABILITY_PRIVACY(cap)((cap) & 0x0010) 262#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
263 263
264struct ssid_t { 264struct ssid_t {
@@ -319,18 +319,26 @@ struct tim_t {
319}; 319};
320 320
321 #define E_SSID 0 321
322 #define E_RATES 1 322struct ibss_t {
323 #define E_FH 2 323 u_int8_telement_id;
324 #define E_DS 3 324 u_int8_tlength;
325 #define E_CF 4 325 u_int16_tatim_window;
326 #define E_TIM 5 326};
327 #define E_IBSS 6 327
328 #define E_CHALLENGE 16 328
329 #define E_CISCO 133 329#define E_SSID 0
330#define E_RATES 1
331#define E_FH 2
332#define E_DS 3
333#define E_CF 4
334#define E_TIM 5
335#define E_IBSS 6
336#define E_CHALLENGE 16
337#define E_CISCO 133
330 338
331 339
332struct ieee_802_11_mgmt_body { 340struct ieee_802_11_mgmt_body {
333 u_int8_t timestamp[8]; 341 u_int8_t timestamp[8];
334 u_int16_t beacon_interval; 342 u_int16_t beacon_interval;
335 // u_int16_t listen_interval; 343 // u_int16_t listen_interval;
336 // u_int16_t status_code; 344 // u_int16_t status_code;
@@ -341,11 +349,11 @@ struct ieee_802_11_mgmt_body {
341 // u_int16_tauth_trans_seq_num; 349 // u_int16_tauth_trans_seq_num;
342// struct challenge_t challenge; 350// struct challenge_t challenge;
343 u_int16_tcapability_info; 351 u_int16_t capability_info;
344 struct ssid_tssid; 352 // struct ssid_tssid;
345 struct rates_t rates; 353 // struct rates_t rates;
346 struct ds_tds; 354 // struct ds_tds;
347 struct cf_tcf; 355 // struct cf_tcf;
348 struct fh_tfh; 356 // struct fh_tfh;
349 struct tim_ttim; 357 // struct tim_ttim;
350}; 358};
351 359
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 1d3b9fe..25c70e0 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -292,5 +292,6 @@ bool ONetworkInterface::isWireless() const
292OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) 292OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface )
293 :QObject( 0, "Mickey's funky hopper" ), 293 :QObject( 0, "Mickey's funky hopper" ),
294 _iface( iface ), _interval( 0 ), _channel( 0 ), _tid( 0 ) 294 _iface( iface ), _interval( 0 ), _channel( 1 ), _tid( 0 ),
295 _maxChannel( iface->channels()+1 )
295{ 296{
296} 297}
@@ -302,8 +303,19 @@ OChannelHopper::~OChannelHopper()
302 303
303 304
305bool OChannelHopper::isActive() const
306{
307 return _tid;
308}
309
310
311int OChannelHopper::channel() const
312{
313 return _channel;
314}
315
316
304void OChannelHopper::timerEvent( QTimerEvent* ) 317void OChannelHopper::timerEvent( QTimerEvent* )
305{ 318{
306 //FIXME: Get available channels from OWirelessNetworkInterface 319 if ( !--_channel ) _channel = _maxChannel;
307 if ( --_channel < 0 ) _channel = 13;
308 _iface->setChannel( _channel ); 320 _iface->setChannel( _channel );
309 qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", 321 qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'",
@@ -320,4 +332,5 @@ void OChannelHopper::setInterval( int interval )
320 killTimer( _tid ); 332 killTimer( _tid );
321 333
334 _tid = 0;
322 _interval = interval; 335 _interval = interval;
323 336
@@ -340,5 +353,5 @@ int OChannelHopper::interval() const
340 353
341OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name ) 354OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name )
342 :ONetworkInterface( name ), _hopper( this ) 355 :ONetworkInterface( name ), _hopper( 0 )
343{ 356{
344 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); 357 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" );
@@ -377,11 +390,8 @@ void OWirelessNetworkInterface::init()
377 } 390 }
378 391
379 //TODO: Find out what the difference between num_channel and
380 // num_frequency is about.
381
382 for ( int i = 0; i < range.num_frequency; ++i ) 392 for ( int i = 0; i < range.num_frequency; ++i )
383 { 393 {
384 int freq = (int) ( double( range.freq[i].m ) * pow( 10, range.freq[i].e ) / 1000000.0 ); 394 int freq = (int) ( double( range.freq[i].m ) * pow( 10, range.freq[i].e ) / 1000000.0 );
385 _channels.insert( freq, i ); 395 _channels.insert( freq, i+1 );
386 } 396 }
387} 397}
@@ -413,4 +423,10 @@ QString OWirelessNetworkInterface::associatedAP() const
413int OWirelessNetworkInterface::channel() const 423int OWirelessNetworkInterface::channel() const
414{ 424{
425 //FIXME: When monitoring enabled, then use it
426 //FIXME: to gather the current RF channel
427 //FIXME: Until then, get active channel from hopper.
428 if ( _hopper && _hopper->isActive() )
429 return _hopper->channel();
430
415 if ( !wioctl( SIOCGIWFREQ ) ) 431 if ( !wioctl( SIOCGIWFREQ ) )
416 { 432 {
@@ -419,5 +435,4 @@ int OWirelessNetworkInterface::channel() const
419 else 435 else
420 { 436 {
421 //FIXME: This is off-by-one !? Why?
422 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000) ]; 437 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000) ];
423 } 438 }
@@ -462,5 +477,7 @@ int OWirelessNetworkInterface::channels() const
462void OWirelessNetworkInterface::setChannelHopping( int interval ) 477void OWirelessNetworkInterface::setChannelHopping( int interval )
463{ 478{
464 _hopper.setInterval( interval ); 479 if ( !_hopper ) _hopper = new OChannelHopper( this );
480 _hopper->setInterval( interval );
481 //FIXME: When and by whom will the channel hopper be deleted?
465} 482}
466 483
@@ -468,5 +485,5 @@ void OWirelessNetworkInterface::setChannelHopping( int interval )
468int OWirelessNetworkInterface::channelHopping() const 485int OWirelessNetworkInterface::channelHopping() const
469{ 486{
470 return _hopper.interval(); 487 return _hopper->interval();
471} 488}
472 489
@@ -480,4 +497,5 @@ void OWirelessNetworkInterface::setMonitorMode( bool b )
480} 497}
481 498
499
482bool OWirelessNetworkInterface::monitorMode() const 500bool OWirelessNetworkInterface::monitorMode() const
483{ 501{
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 9a68a74..936ac85 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -143,4 +143,6 @@ class OChannelHopper : public QObject
143 OChannelHopper( OWirelessNetworkInterface* ); 143 OChannelHopper( OWirelessNetworkInterface* );
144 virtual ~OChannelHopper(); 144 virtual ~OChannelHopper();
145 bool isActive() const;
146 int channel() const;
145 virtual void timerEvent( QTimerEvent* ); 147 virtual void timerEvent( QTimerEvent* );
146 void setInterval( int ); 148 void setInterval( int );
@@ -152,4 +154,5 @@ class OChannelHopper : public QObject
152 int _channel; 154 int _channel;
153 int _tid; 155 int _tid;
156 int _maxChannel;
154}; 157};
155 158
@@ -185,5 +188,5 @@ class OWirelessNetworkInterface : public ONetworkInterface
185 virtual bool monitorMode() const; 188 virtual bool monitorMode() const;
186 189
187 virtual void setChannelHopping( int interval ); 190 virtual void setChannelHopping( int interval = 0 );
188 virtual int channelHopping() const; 191 virtual int channelHopping() const;
189 192
@@ -208,5 +211,5 @@ class OWirelessNetworkInterface : public ONetworkInterface
208 211
209 private: 212 private:
210 OChannelHopper _hopper; 213 OChannelHopper* _hopper;
211}; 214};
212 215
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 48f874f..913d42e 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -50,13 +50,16 @@ OPacket::OPacket( packetheaderstruct header, const unsigned char* data, QObject*
50 qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); 50 qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
51 51
52 _end = (unsigned char*) data + header.len;
53 qDebug( "OPacket::data @ %0x, end @ %0x", data, _end );
54
52 if ( packetCapturer()->dataLink() == DLT_EN10MB ) 55 if ( packetCapturer()->dataLink() == DLT_EN10MB )
53 { 56 {
54 qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); 57 qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" );
55 new OEthernetPacket( (const struct ether_header*) data, this ); 58 new OEthernetPacket( _end, (const struct ether_header*) data, this );
56 } 59 }
57 else 60 else
58 { 61 {
59 qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); 62 qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" );
60 new OWaveLanPacket( (const struct ieee_802_11_header*) data, this ); 63 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this );
61 } 64 }
62} 65}
@@ -110,5 +113,5 @@ int OPacket::len() const
110 *======================================================================================*/ 113 *======================================================================================*/
111 114
112OEthernetPacket::OEthernetPacket( const struct ether_header* data, QObject* parent ) 115OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent )
113 :QObject( parent, "Ethernet" ), _ether( data ) 116 :QObject( parent, "Ethernet" ), _ether( data )
114 117
@@ -125,5 +128,5 @@ OEthernetPacket::OEthernetPacket( const struct ether_header* data, QObject* pare
125 switch ( type() ) 128 switch ( type() )
126 { 129 {
127 case ETHERTYPE_IP: new OIPPacket( (const struct iphdr*) (data+1), this ); break; 130 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
128 case ETHERTYPE_ARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = ARP" ); break; } 131 case ETHERTYPE_ARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = ARP" ); break; }
129 case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; } 132 case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; }
@@ -161,5 +164,5 @@ int OEthernetPacket::type() const
161 164
162 165
163OIPPacket::OIPPacket( const struct iphdr* data, QObject* parent ) 166OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent )
164 :QObject( parent, "IP" ), _iphdr( data ) 167 :QObject( parent, "IP" ), _iphdr( data )
165 168
@@ -175,6 +178,6 @@ OIPPacket::OIPPacket( const struct iphdr* data, QObject* parent )
175 switch ( protocol() ) 178 switch ( protocol() )
176 { 179 {
177 case IPPROTO_UDP: new OUDPPacket( (const struct udphdr*) (data+1), this ); break; 180 case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break;
178 case IPPROTO_TCP: new OTCPPacket( (const struct tcphdr*) (data+1), this ); break; 181 case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break;
179 default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() ); 182 default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() );
180 } 183 }
@@ -245,5 +248,5 @@ int OIPPacket::checksum() const
245 248
246 249
247OUDPPacket::OUDPPacket( const struct udphdr* data, QObject* parent ) 250OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent )
248 :QObject( parent, "UDP" ), _udphdr( data ) 251 :QObject( parent, "UDP" ), _udphdr( data )
249 252
@@ -262,5 +265,5 @@ OUDPPacket::~OUDPPacket()
262 265
263 266
264OTCPPacket::OTCPPacket( const struct tcphdr* data, QObject* parent ) 267OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent )
265 :QObject( parent, "TCP" ), _tcphdr( data ) 268 :QObject( parent, "TCP" ), _tcphdr( data )
266 269
@@ -279,5 +282,5 @@ OTCPPacket::~OTCPPacket()
279 282
280 283
281OWaveLanPacket::OWaveLanPacket( const struct ieee_802_11_header* data, QObject* parent ) 284OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent )
282 :QObject( parent, "802.11" ), _wlanhdr( data ) 285 :QObject( parent, "802.11" ), _wlanhdr( data )
283 286
@@ -296,7 +299,7 @@ OWaveLanPacket::OWaveLanPacket( const struct ieee_802_11_header* data, QObject*
296 switch ( type() ) 299 switch ( type() )
297 { 300 {
298 case T_MGMT: new OWaveLanManagementPacket( (const struct ieee_802_11_mgmt_header*) data, this ); break; 301 case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break;
299 case T_DATA: new OWaveLanDataPacket( (const struct ieee_802_11_data_header*) data, this ); break; 302 case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break;
300 //case T_CTRL: new OWaveLanControlPacket( (const struct ieee_802_11_ctrl_header*) data, this ); break; 303 //case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_ctrl_header*) data, this ); break;
301 default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown type!" ); 304 default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown type!" );
302 } 305 }
@@ -384,5 +387,5 @@ bool OWaveLanPacket::usesWep() const
384 *======================================================================================*/ 387 *======================================================================================*/
385 388
386OWaveLanManagementPacket::OWaveLanManagementPacket( const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) 389OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent )
387 :QObject( parent, "802.11 Management" ), _header( data ), 390 :QObject( parent, "802.11 Management" ), _header( data ),
388 _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) 391 _body( (const struct ieee_802_11_mgmt_body*) (data+1) )
@@ -394,8 +397,25 @@ OWaveLanManagementPacket::OWaveLanManagementPacket( const struct ieee_802_11_mgm
394 case ST_BEACON: 397 case ST_BEACON:
395 { 398 {
396 qDebug( "TYPE: BEACON FRAME" ); 399 // nice, received a beacon...
397 qDebug( "ESSID: %s", (const char*) SSID() ); 400 }
398 break; 401 }
402
403 // grab tagged values
404 const unsigned char* ptr = (const unsigned char*) (_body+1);
405 while (ptr < end)
406 {
407 switch ( *ptr )
408 {
409 case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break;
410 case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break;
411 case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break;
412 case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break;
413 case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break;
414 case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break;
415 case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break;
416 case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break;
399 } 417 }
418 ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value
419 ptr+= 2; // skip tag ID and length
400 } 420 }
401} 421}
@@ -407,10 +427,68 @@ OWaveLanManagementPacket::~OWaveLanManagementPacket()
407 427
408 428
409QString OWaveLanManagementPacket::SSID() const 429int OWaveLanManagementPacket::beaconInterval() const
430{
431 return EXTRACT_LE_16BITS( &_body->beacon_interval );
432}
433
434
435int OWaveLanManagementPacket::capabilities() const
436{
437 return EXTRACT_LE_16BITS( &_body->capability_info );
438}
439
440
441bool OWaveLanManagementPacket::canESS() const
410{ 442{
411 int length = _body->ssid.length; 443 return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) );
444}
445
446
447bool OWaveLanManagementPacket::canIBSS() const
448{
449 return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) );
450}
451
452
453bool OWaveLanManagementPacket::canCFP() const
454{
455 return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) );
456}
457
458
459bool OWaveLanManagementPacket::canCFP_REQ() const
460{
461 return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) );
462}
463
464
465bool OWaveLanManagementPacket::canPrivacy() const
466{
467 return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) );
468}
469
470
471/*======================================================================================
472 * OWaveLanManagementSSID
473 *======================================================================================*/
474
475OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent )
476 :QObject( parent, "802.11 SSID" ), _data( data )
477{
478 qDebug( "OWaveLanManagementSSID()" );
479}
480
481
482OWaveLanManagementSSID::~OWaveLanManagementSSID()
483{
484}
485
486
487QString OWaveLanManagementSSID::ID() const
488{
489 int length = _data->length;
412 if ( length > 32 ) length = 32; 490 if ( length > 32 ) length = 32;
413 char essid[length+1]; 491 char essid[length+1];
414 memcpy( &essid, _body->ssid.ssid, length ); 492 memcpy( &essid, &_data->ssid, length );
415 essid[length] = 0x0; 493 essid[length] = 0x0;
416 return essid; 494 return essid;
@@ -419,8 +497,119 @@ QString OWaveLanManagementPacket::SSID() const
419 497
420/*====================================================================================== 498/*======================================================================================
499 * OWaveLanManagementRates
500 *======================================================================================*/
501
502OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent )
503 :QObject( parent, "802.11 Rates" ), _data( data )
504{
505 qDebug( "OWaveLanManagementRates()" );
506}
507
508
509OWaveLanManagementRates::~OWaveLanManagementRates()
510{
511}
512
513/*======================================================================================
514 * OWaveLanManagementCF
515 *======================================================================================*/
516
517OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent )
518 :QObject( parent, "802.11 CF" ), _data( data )
519{
520 qDebug( "OWaveLanManagementCF()" );
521}
522
523
524OWaveLanManagementCF::~OWaveLanManagementCF()
525{
526}
527
528/*======================================================================================
529 * OWaveLanManagementFH
530 *======================================================================================*/
531
532OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent )
533 :QObject( parent, "802.11 FH" ), _data( data )
534{
535 qDebug( "OWaveLanManagementFH()" );
536}
537
538
539OWaveLanManagementFH::~OWaveLanManagementFH()
540{
541}
542
543/*======================================================================================
544 * OWaveLanManagementDS
545 *======================================================================================*/
546
547OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent )
548 :QObject( parent, "802.11 DS" ), _data( data )
549{
550 qDebug( "OWaveLanManagementDS()" );
551}
552
553
554OWaveLanManagementDS::~OWaveLanManagementDS()
555{
556}
557
558
559int OWaveLanManagementDS::channel() const
560{
561 return _data->channel;
562}
563
564/*======================================================================================
565 * OWaveLanManagementTim
566 *======================================================================================*/
567
568OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent )
569 :QObject( parent, "802.11 Tim" ), _data( data )
570{
571 qDebug( "OWaveLanManagementTim()" );
572}
573
574
575OWaveLanManagementTim::~OWaveLanManagementTim()
576{
577}
578
579/*======================================================================================
580 * OWaveLanManagementIBSS
581 *======================================================================================*/
582
583OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent )
584 :QObject( parent, "802.11 IBSS" ), _data( data )
585{
586 qDebug( "OWaveLanManagementIBSS()" );
587}
588
589
590OWaveLanManagementIBSS::~OWaveLanManagementIBSS()
591{
592}
593
594/*======================================================================================
595 * OWaveLanManagementChallenge
596 *======================================================================================*/
597
598OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent )
599 :QObject( parent, "802.11 Challenge" ), _data( data )
600{
601 qDebug( "OWaveLanManagementChallenge()" );
602}
603
604
605OWaveLanManagementChallenge::~OWaveLanManagementChallenge()
606{
607}
608
609/*======================================================================================
421 * OWaveLanDataPacket 610 * OWaveLanDataPacket
422 *======================================================================================*/ 611 *======================================================================================*/
423 612
424OWaveLanDataPacket::OWaveLanDataPacket( const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) 613OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent )
425 :QObject( parent, "802.11 Data" ), _header( data ) 614 :QObject( parent, "802.11 Data" ), _header( data )
426{ 615{
@@ -432,5 +621,5 @@ OWaveLanDataPacket::OWaveLanDataPacket( const struct ieee_802_11_data_header* da
432 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address 621 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address
433 622
434 new OLLCPacket( (const struct ieee_802_11_802_2_header*) payload, this ); 623 new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this );
435} 624}
436 625
@@ -445,5 +634,5 @@ OWaveLanDataPacket::~OWaveLanDataPacket()
445 *======================================================================================*/ 634 *======================================================================================*/
446 635
447OLLCPacket::OLLCPacket( const struct ieee_802_11_802_2_header* data, QObject* parent ) 636OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent )
448 :QObject( parent, "802.11 802_2" ), _header( data ) 637 :QObject( parent, "802.11 802_2" ), _header( data )
449{ 638{
@@ -456,5 +645,5 @@ OLLCPacket::OLLCPacket( const struct ieee_802_11_802_2_header* data, QObject* pa
456 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h 645 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h
457 { 646 {
458 case ETH_P_IP: new OIPPacket( (const struct iphdr*) (data+1), this ); break; 647 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
459 default: qDebug( "OLLCPacket::OLLCPacket(): Unknown Encapsulation Type" ); 648 default: qDebug( "OLLCPacket::OLLCPacket(): Unknown Encapsulation Type" );
460 } 649 }
@@ -474,5 +663,5 @@ OLLCPacket::~OLLCPacket()
474OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) 663OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
475 :QObject( parent, name ), _name( QString::null ), _open( false ), 664 :QObject( parent, name ), _name( QString::null ), _open( false ),
476 _pch( 0 ) 665 _pch( 0 ), _sn( 0 )
477{ 666{
478} 667}
@@ -518,4 +707,9 @@ void OPacketCapturer::close()
518 if ( _open ) 707 if ( _open )
519 { 708 {
709 if ( _sn )
710 {
711 _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
712 delete _sn;
713 }
520 pcap_close( _pch ); 714 pcap_close( _pch );
521 _open = false; 715 _open = false;
@@ -546,5 +740,8 @@ OPacket* OPacketCapturer::next()
546{ 740{
547 packetheaderstruct header; 741 packetheaderstruct header;
742 qDebug( "==> OPacketCapturer::next()" );
548 const unsigned char* pdata = pcap_next( _pch, &header ); 743 const unsigned char* pdata = pcap_next( _pch, &header );
744 qDebug( "<== OPacketCapturer::next()" );
745
549 if ( header.len ) 746 if ( header.len )
550 return new OPacket( header, pdata, this ); 747 return new OPacket( header, pdata, this );
@@ -578,9 +775,9 @@ bool OPacketCapturer::open( const QString& name )
578 _open = true; 775 _open = true;
579 776
580 // in case we have a qapp, create a socket notifier 777 // in case we have an application object, create a socket notifier
581 if ( qApp ) 778 if ( qApp )
582 { 779 {
583 QSocketNotifier* sn = new QSocketNotifier( fileno(), QSocketNotifier::Read, this ); 780 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
584 connect( sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 781 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
585 } 782 }
586 783
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 65c550c..0b06572 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -61,4 +61,5 @@ typedef struct pcap_pkthdr packetheaderstruct;
61/* FORWARDS */ 61/* FORWARDS */
62class OPacketCapturer; 62class OPacketCapturer;
63class QSocketNotifier;
63 64
64/*====================================================================================== 65/*======================================================================================
@@ -85,4 +86,5 @@ class OPacket : public QObject
85 const packetheaderstruct _hdr; // pcap packet header 86 const packetheaderstruct _hdr; // pcap packet header
86 const unsigned char* _data; // pcap packet data 87 const unsigned char* _data; // pcap packet data
88 const unsigned char* _end; // end of pcap packet data
87}; 89};
88 90
@@ -96,5 +98,5 @@ class OEthernetPacket : public QObject
96 98
97 public: 99 public:
98 OEthernetPacket( const struct ether_header*, QObject* parent = 0 ); 100 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 );
99 virtual ~OEthernetPacket(); 101 virtual ~OEthernetPacket();
100 102
@@ -117,5 +119,5 @@ class OWaveLanPacket : public QObject
117 119
118 public: 120 public:
119 OWaveLanPacket( const struct ieee_802_11_header*, QObject* parent = 0 ); 121 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 );
120 virtual ~OWaveLanPacket(); 122 virtual ~OWaveLanPacket();
121 123
@@ -147,8 +149,15 @@ class OWaveLanManagementPacket : public QObject
147 149
148 public: 150 public:
149 OWaveLanManagementPacket( const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); 151 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 );
150 virtual ~OWaveLanManagementPacket(); 152 virtual ~OWaveLanManagementPacket();
151 153
152 QString SSID() const; 154 int beaconInterval() const;
155 int capabilities() const; // generic
156
157 bool canESS() const;
158 bool canIBSS() const;
159 bool canCFP() const;
160 bool canCFP_REQ() const;
161 bool canPrivacy() const;
153 162
154 private: 163 private:
@@ -159,4 +168,136 @@ class OWaveLanManagementPacket : public QObject
159 168
160/*====================================================================================== 169/*======================================================================================
170 * OWaveLanManagementSSID
171 *======================================================================================*/
172
173class OWaveLanManagementSSID : public QObject
174{
175 Q_OBJECT
176
177 public:
178 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 );
179 virtual ~OWaveLanManagementSSID();
180
181 QString ID() const;
182
183 private:
184 const struct ssid_t* _data;
185};
186
187/*======================================================================================
188 * OWaveLanManagementRates
189 *======================================================================================*/
190
191class OWaveLanManagementRates : public QObject
192{
193 Q_OBJECT
194
195 public:
196 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 );
197 virtual ~OWaveLanManagementRates();
198
199 private:
200 const struct rates_t* _data;
201};
202
203/*======================================================================================
204 * OWaveLanManagementCF
205 *======================================================================================*/
206
207class OWaveLanManagementCF : public QObject
208{
209 Q_OBJECT
210
211 public:
212 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 );
213 virtual ~OWaveLanManagementCF();
214
215 private:
216 const struct cf_t* _data;
217};
218
219/*======================================================================================
220 * OWaveLanManagementFH
221 *======================================================================================*/
222
223class OWaveLanManagementFH : public QObject
224{
225 Q_OBJECT
226
227 public:
228 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 );
229 virtual ~OWaveLanManagementFH();
230
231 private:
232 const struct fh_t* _data;
233};
234
235/*======================================================================================
236 * OWaveLanManagementDS
237 *======================================================================================*/
238
239class OWaveLanManagementDS : public QObject
240{
241 Q_OBJECT
242
243 public:
244 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 );
245 virtual ~OWaveLanManagementDS();
246
247 int channel() const;
248
249 private:
250 const struct ds_t* _data;
251};
252
253/*======================================================================================
254 * OWaveLanManagementTim
255 *======================================================================================*/
256
257class OWaveLanManagementTim : public QObject
258{
259 Q_OBJECT
260
261 public:
262 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 );
263 virtual ~OWaveLanManagementTim();
264
265 private:
266 const struct tim_t* _data;
267};
268
269/*======================================================================================
270 * OWaveLanManagementIBSS
271 *======================================================================================*/
272
273class OWaveLanManagementIBSS : public QObject
274{
275 Q_OBJECT
276
277 public:
278 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 );
279 virtual ~OWaveLanManagementIBSS();
280
281 private:
282 const struct ibss_t* _data;
283};
284
285/*======================================================================================
286 * OWaveLanManagementChallenge
287 *======================================================================================*/
288
289class OWaveLanManagementChallenge : public QObject
290{
291 Q_OBJECT
292
293 public:
294 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 );
295 virtual ~OWaveLanManagementChallenge();
296
297 private:
298 const struct challenge_t* _data;
299};
300
301/*======================================================================================
161 * OWaveLanDataPacket - type: data (T_DATA) 302 * OWaveLanDataPacket - type: data (T_DATA)
162 *======================================================================================*/ 303 *======================================================================================*/
@@ -167,5 +308,5 @@ class OWaveLanDataPacket : public QObject
167 308
168 public: 309 public:
169 OWaveLanDataPacket( const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); 310 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 );
170 virtual ~OWaveLanDataPacket(); 311 virtual ~OWaveLanDataPacket();
171 312
@@ -183,5 +324,5 @@ class OLLCPacket : public QObject
183 324
184 public: 325 public:
185 OLLCPacket( const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); 326 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 );
186 virtual ~OLLCPacket(); 327 virtual ~OLLCPacket();
187 328
@@ -199,5 +340,5 @@ class OIPPacket : public QObject
199 340
200 public: 341 public:
201 OIPPacket( const struct iphdr*, QObject* parent = 0 ); 342 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 );
202 virtual ~OIPPacket(); 343 virtual ~OIPPacket();
203 344
@@ -226,5 +367,5 @@ class OUDPPacket : public QObject
226 367
227 public: 368 public:
228 OUDPPacket( const struct udphdr*, QObject* parent = 0 ); 369 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
229 virtual ~OUDPPacket(); 370 virtual ~OUDPPacket();
230 371
@@ -245,5 +386,5 @@ class OTCPPacket : public QObject
245 386
246 public: 387 public:
247 OTCPPacket( const struct tcphdr*, QObject* parent = 0 ); 388 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
248 virtual ~OTCPPacket(); 389 virtual ~OTCPPacket();
249 390
@@ -285,7 +426,8 @@ class OPacketCapturer : public QObject
285 426
286 protected: 427 protected:
287 QString _name; // devicename 428 QString _name; // devicename
288 bool _open; // check this before doing pcap calls 429 bool _open; // check this before doing pcap calls
289 pcap_t* _pch; // pcap library handle 430 pcap_t* _pch; // pcap library handle
431 QSocketNotifier* _sn; // socket notifier for main loop
290 mutable char _errbuf[PCAP_ERRBUF_SIZE]; 432 mutable char _errbuf[PCAP_ERRBUF_SIZE];
291}; 433};