Diffstat (limited to 'noncore/net/wellenreiter/gui') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 20 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 7 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 39 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 5 |
4 files changed, 57 insertions, 14 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index aea7eb6..fd88b63 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -99,49 +99,50 @@ OListViewItem* MScanListView::childFactory() | |||
99 | return new MScanListItem( this ); | 99 | return new MScanListItem( this ); |
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | void MScanListView::serializeTo( QDataStream& s) const | 103 | void MScanListView::serializeTo( QDataStream& s) const |
104 | { | 104 | { |
105 | qDebug( "serializing MScanListView" ); | 105 | qDebug( "serializing MScanListView" ); |
106 | OListView::serializeTo( s ); | 106 | OListView::serializeTo( s ); |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | void MScanListView::serializeFrom( QDataStream& s) | 110 | void MScanListView::serializeFrom( QDataStream& s) |
111 | { | 111 | { |
112 | qDebug( "serializing MScanListView" ); | 112 | qDebug( "serializing MScanListView" ); |
113 | OListView::serializeFrom( s ); | 113 | OListView::serializeFrom( s ); |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void MScanListView::addNewItem( const QString& type, | 117 | void MScanListView::addNewItem( const QString& type, |
118 | const QString& essid, | 118 | const QString& essid, |
119 | const OMacAddress& mac, | 119 | const OMacAddress& mac, |
120 | bool wep, | 120 | bool wep, |
121 | int channel, | 121 | int channel, |
122 | int signal, | 122 | int signal, |
123 | const GpsLocation& loc ) | 123 | const GpsLocation& loc, |
124 | bool probe ) | ||
124 | { | 125 | { |
125 | QString macaddr = mac.toString(true); | 126 | QString macaddr = mac.toString(true); |
126 | 127 | ||
127 | #ifdef DEBUG | 128 | #ifdef DEBUG |
128 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, | 129 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, |
129 | (const char*) essid, (const char*) macaddr, channel ); | 130 | (const char*) essid, (const char*) macaddr, channel ); |
130 | #endif | 131 | #endif |
131 | 132 | ||
132 | // search, if we already have seen this net | 133 | // search, if we already have seen this net |
133 | 134 | ||
134 | QString s; | 135 | QString s; |
135 | MScanListItem* network; | 136 | MScanListItem* network; |
136 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 137 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
137 | 138 | ||
138 | while ( item && ( item->text( col_essid ) != essid ) ) | 139 | while ( item && ( item->text( col_essid ) != essid ) ) |
139 | { | 140 | { |
140 | #ifdef DEBUG | 141 | #ifdef DEBUG |
141 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); | 142 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); |
142 | #endif | 143 | #endif |
143 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 144 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
144 | } | 145 | } |
145 | if ( item ) | 146 | if ( item ) |
146 | { | 147 | { |
147 | // we have already seen this net, check all childs if MAC exists | 148 | // we have already seen this net, check all childs if MAC exists |
@@ -152,73 +153,72 @@ void MScanListView::addNewItem( const QString& type, | |||
152 | assert( item ); // this shouldn't fail | 153 | assert( item ); // this shouldn't fail |
153 | 154 | ||
154 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 155 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
155 | { | 156 | { |
156 | #ifdef DEBUG | 157 | #ifdef DEBUG |
157 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 158 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); |
158 | #endif | 159 | #endif |
159 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 160 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
160 | } | 161 | } |
161 | 162 | ||
162 | if ( item ) | 163 | if ( item ) |
163 | { | 164 | { |
164 | // we have already seen this item, it's a dupe | 165 | // we have already seen this item, it's a dupe |
165 | #ifdef DEBUG | 166 | #ifdef DEBUG |
166 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 167 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
167 | #endif | 168 | #endif |
168 | item->receivedBeacon(); | 169 | item->receivedBeacon(); |
169 | return; | 170 | return; |
170 | } | 171 | } |
171 | } | 172 | } |
172 | else | 173 | else |
173 | { | 174 | { |
174 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 175 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); |
175 | MLogWindow::logwindow()->log( s ); | 176 | MLogWindow::logwindow()->log( s ); |
176 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); | 177 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); |
177 | } | 178 | } |
178 | 179 | ||
179 | 180 | ||
180 | // insert new station as child from network | 181 | // insert new station as child from network |
181 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 182 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
182 | 183 | ||
183 | #ifdef DEBUG | 184 | #ifdef DEBUG |
184 | qDebug( "inserting new station %s", (const char*) macaddr ); | 185 | qDebug( "inserting new station %s", (const char*) macaddr ); |
185 | #endif | 186 | #endif |
186 | 187 | ||
187 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 188 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
188 | station->setManufacturer( mac.manufacturer() ); | 189 | station->setManufacturer( mac.manufacturer() ); |
189 | station->setLocation( loc.dmsPosition() ); | 190 | station->setLocation( loc.dmsPosition() ); |
190 | 191 | ||
191 | if ( type == "managed" ) | 192 | if ( type == "managed" ) |
192 | { | 193 | { |
193 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 194 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
194 | } | 195 | } |
195 | else | 196 | else |
196 | { | 197 | { |
197 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); | 198 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); |
198 | } | 199 | } |
199 | MLogWindow::logwindow()->log( s ); | 200 | MLogWindow::logwindow()->log( s ); |
200 | |||
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 204 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
205 | { | 205 | { |
206 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 206 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
207 | 207 | ||
208 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 208 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
209 | { | 209 | { |
210 | #ifdef DEBUG | 210 | #ifdef DEBUG |
211 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 211 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
212 | #endif | 212 | #endif |
213 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 213 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
214 | } | 214 | } |
215 | 215 | ||
216 | if ( subitem ) | 216 | if ( subitem ) |
217 | { | 217 | { |
218 | // we have already seen this item, it's a dupe | 218 | // we have already seen this item, it's a dupe |
219 | #ifdef DEBUG | 219 | #ifdef DEBUG |
220 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); | 220 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); |
221 | #endif | 221 | #endif |
222 | subitem->receivedBeacon(); //FIXME: sent data bit | 222 | subitem->receivedBeacon(); //FIXME: sent data bit |
223 | return; | 223 | return; |
224 | } | 224 | } |
@@ -389,132 +389,138 @@ void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, in | |||
389 | if ( !item ) return; | 389 | if ( !item ) return; |
390 | 390 | ||
391 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 391 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
392 | 392 | ||
393 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 393 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
394 | (const char*) itm->text(0), (const char*) itm->type, col ); | 394 | (const char*) itm->text(0), (const char*) itm->type, col ); |
395 | 395 | ||
396 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 396 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
397 | { | 397 | { |
398 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | 398 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); |
399 | 399 | ||
400 | QPopupMenu m( this ); | 400 | QPopupMenu m( this ); |
401 | m.insertItem( entry, 37773, 0 ); | 401 | m.insertItem( entry, 37773, 0 ); |
402 | int result = m.exec( QCursor::pos() ); | 402 | int result = m.exec( QCursor::pos() ); |
403 | if ( result == 37773 ) | 403 | if ( result == 37773 ) |
404 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 404 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | //============================================================ | 408 | //============================================================ |
409 | // MScanListItem | 409 | // MScanListItem |
410 | //============================================================ | 410 | //============================================================ |
411 | 411 | ||
412 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, | 412 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, |
413 | bool wep, int channel, int signal ) | 413 | bool wep, int channel, int signal, bool probed ) |
414 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 414 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
415 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 415 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
416 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 416 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
417 | { | 417 | { |
418 | #ifdef DEBUG | 418 | #ifdef DEBUG |
419 | qDebug( "creating scanlist item" ); | 419 | qDebug( "creating scanlist item" ); |
420 | #endif | 420 | #endif |
421 | 421 | ||
422 | if ( WellenreiterConfigWindow::instance() ) | 422 | if ( WellenreiterConfigWindow::instance() ) |
423 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 423 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
424 | 424 | ||
425 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 425 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); |
426 | } | 426 | } |
427 | 427 | ||
428 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, | 428 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, |
429 | bool wep, int channel, int signal ) | 429 | bool wep, int channel, int signal ) |
430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
431 | { | 431 | { |
432 | #ifdef DEBUG | 432 | #ifdef DEBUG |
433 | qDebug( "creating scanlist item" ); | 433 | qDebug( "creating scanlist item" ); |
434 | #endif | 434 | #endif |
435 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 435 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); |
436 | } | 436 | } |
437 | 437 | ||
438 | const QString& MScanListItem::essid() const | 438 | const QString& MScanListItem::essid() const |
439 | { | 439 | { |
440 | if ( type == "network" ) | 440 | if ( type == "network" ) |
441 | return _essid; | 441 | return _essid; |
442 | else | 442 | else |
443 | return ( (MScanListItem*) parent() )->essid(); | 443 | return ( (MScanListItem*) parent() )->essid(); |
444 | } | 444 | } |
445 | 445 | ||
446 | OListViewItem* MScanListItem::childFactory() | 446 | OListViewItem* MScanListItem::childFactory() |
447 | { | 447 | { |
448 | return new MScanListItem( this ); | 448 | return new MScanListItem( this ); |
449 | } | 449 | } |
450 | 450 | ||
451 | void MScanListItem::serializeTo( QDataStream& s ) const | 451 | void MScanListItem::serializeTo( QDataStream& s ) const |
452 | { | 452 | { |
453 | #ifdef DEBUG | 453 | #ifdef DEBUG |
454 | qDebug( "serializing MScanListItem" ); | 454 | qDebug( "serializing MScanListItem" ); |
455 | #endif | 455 | #endif |
456 | OListViewItem::serializeTo( s ); | 456 | OListViewItem::serializeTo( s ); |
457 | 457 | ||
458 | s << _type; | 458 | s << _type; |
459 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 459 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
460 | } | 460 | } |
461 | 461 | ||
462 | void MScanListItem::serializeFrom( QDataStream& s ) | 462 | void MScanListItem::serializeFrom( QDataStream& s ) |
463 | { | 463 | { |
464 | #ifdef DEBUG | 464 | #ifdef DEBUG |
465 | qDebug( "serializing MScanListItem" ); | 465 | qDebug( "serializing MScanListItem" ); |
466 | #endif | 466 | #endif |
467 | OListViewItem::serializeFrom( s ); | 467 | OListViewItem::serializeFrom( s ); |
468 | 468 | ||
469 | char wep; | 469 | char wep; |
470 | s >> _type; | 470 | s >> _type; |
471 | s >> (Q_UINT8) wep; | 471 | s >> (Q_UINT8) wep; |
472 | _wep = (wep == 'y'); | 472 | _wep = (wep == 'y'); |
473 | 473 | ||
474 | QString name; | 474 | QString name; |
475 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 475 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
476 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 476 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
477 | if ( _wep ) | 477 | if ( _wep ) |
478 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 478 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
479 | listView()->triggerUpdate(); | 479 | listView()->triggerUpdate(); |
480 | } | 480 | } |
481 | 481 | ||
482 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 482 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) |
483 | { | 483 | { |
484 | #ifdef DEBUG | 484 | #ifdef DEBUG |
485 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 485 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
486 | (const char*) type, | 486 | (const char*) type, |
487 | (const char*) essid, | 487 | (const char*) essid, |
488 | (const char*) macaddr, | 488 | (const char*) macaddr, |
489 | channel ); | 489 | channel ); |
490 | #endif | 490 | #endif |
491 | 491 | ||
492 | // set icon for managed or adhoc mode | 492 | // set icon for managed or adhoc mode |
493 | QString name; | 493 | QString name; |
494 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 494 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
495 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 495 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
496 | 496 | ||
497 | // special case for probed networks FIXME: This is ugly at present | ||
498 | if ( type == "network" && probed ) | ||
499 | { | ||
500 | setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); | ||
501 | } | ||
502 | |||
497 | // set icon for wep (wireless encryption protocol) | 503 | // set icon for wep (wireless encryption protocol) |
498 | if ( wep ) | 504 | if ( wep ) |
499 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 505 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
500 | 506 | ||
501 | // set channel and signal text | 507 | // set channel and signal text |
502 | 508 | ||
503 | if ( signal != -1 ) | 509 | if ( signal != -1 ) |
504 | setText( col_sig, QString::number( signal ) ); | 510 | setText( col_sig, QString::number( signal ) ); |
505 | if ( channel != -1 ) | 511 | if ( channel != -1 ) |
506 | setText( col_channel, QString::number( channel ) ); | 512 | setText( col_channel, QString::number( channel ) ); |
507 | 513 | ||
508 | setText( col_firstseen, QTime::currentTime().toString() ); | 514 | setText( col_firstseen, QTime::currentTime().toString() ); |
509 | //setText( col_lastseen, QTime::currentTime().toString() ); | 515 | //setText( col_lastseen, QTime::currentTime().toString() ); |
510 | 516 | ||
511 | listView()->triggerUpdate(); | 517 | listView()->triggerUpdate(); |
512 | 518 | ||
513 | this->type = type; | 519 | this->type = type; |
514 | _type = type; | 520 | _type = type; |
515 | _essid = essid; | 521 | _essid = essid; |
516 | _macaddr = macaddr; | 522 | _macaddr = macaddr; |
517 | _channel = channel; | 523 | _channel = channel; |
518 | _beacons = 1; | 524 | _beacons = 1; |
519 | _signal = 0; | 525 | _signal = 0; |
520 | 526 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index e8d48c3..cbacdee 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h | |||
@@ -20,93 +20,94 @@ | |||
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <opie2/olistview.h> | 22 | #include <opie2/olistview.h> |
23 | #include <opie2/onetutils.h> | 23 | #include <opie2/onetutils.h> |
24 | 24 | ||
25 | /* QT */ | 25 | /* QT */ |
26 | #include <qtextstream.h> | 26 | #include <qtextstream.h> |
27 | 27 | ||
28 | class QString; | 28 | class QString; |
29 | class MScanListItem; | 29 | class MScanListItem; |
30 | 30 | ||
31 | class MScanListView: public OListView | 31 | class MScanListView: public OListView |
32 | { | 32 | { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | 34 | ||
35 | public: | 35 | public: |
36 | MScanListView( QWidget* parent = 0, const char* name = 0 ); | 36 | MScanListView( QWidget* parent = 0, const char* name = 0 ); |
37 | virtual ~MScanListView(); | 37 | virtual ~MScanListView(); |
38 | 38 | ||
39 | virtual OListViewItem* childFactory(); | 39 | virtual OListViewItem* childFactory(); |
40 | virtual void serializeTo( QDataStream& s ) const; | 40 | virtual void serializeTo( QDataStream& s ) const; |
41 | virtual void serializeFrom( QDataStream& s ); | 41 | virtual void serializeFrom( QDataStream& s ); |
42 | 42 | ||
43 | public slots: | 43 | public slots: |
44 | void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location ); | 44 | void addNewItem( const QString& type, const QString&, const OMacAddress&, bool, int, int, const GpsLocation&, bool = false ); |
45 | void addService( const QString& name, const OMacAddress& macaddr, const QString& ip ); | 45 | void addService( const QString& name, const OMacAddress& macaddr, const QString& ip ); |
46 | 46 | ||
47 | void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); | 47 | void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); |
48 | void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); | 48 | void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); |
49 | void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); | 49 | void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); |
50 | void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); | 50 | void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); |
51 | 51 | ||
52 | void identify( const OMacAddress&, const QString& ipaddr ); | 52 | void identify( const OMacAddress&, const QString& ipaddr ); |
53 | 53 | ||
54 | void contextMenuRequested( QListViewItem* item, const QPoint&, int ); | 54 | void contextMenuRequested( QListViewItem* item, const QPoint&, int ); |
55 | 55 | ||
56 | signals: | 56 | signals: |
57 | void rightButtonClicked(QListViewItem*,const QPoint&,int); | 57 | void rightButtonClicked(QListViewItem*,const QPoint&,int); |
58 | void joinNetwork( const QString&, const QString&, int, const QString& ); | 58 | void joinNetwork( const QString&, const QString&, int, const QString& ); |
59 | 59 | ||
60 | protected: | 60 | protected: |
61 | void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); | 61 | void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); |
62 | 62 | ||
63 | }; | 63 | }; |
64 | 64 | ||
65 | //****************************** MScanListItem **************************************************************** | 65 | //****************************** MScanListItem **************************************************************** |
66 | 66 | ||
67 | class MScanListItem: public OListViewItem | 67 | class MScanListItem: public OListViewItem |
68 | { | 68 | { |
69 | public: | 69 | public: |
70 | MScanListItem::MScanListItem( QListView* parent, | 70 | MScanListItem::MScanListItem( QListView* parent, |
71 | const QString& type = "unknown", | 71 | const QString& type = "unknown", |
72 | const QString& essid = "unknown", | 72 | const QString& essid = "unknown", |
73 | const QString& macaddr = "unknown", | 73 | const QString& macaddr = "unknown", |
74 | bool wep = false, | 74 | bool wep = false, |
75 | int channel = 0, | 75 | int channel = 0, |
76 | int signal = 0 ); | 76 | int signal = 0, |
77 | bool probed = false ); | ||
77 | 78 | ||
78 | MScanListItem::MScanListItem( QListViewItem* parent, | 79 | MScanListItem::MScanListItem( QListViewItem* parent, |
79 | const QString& type = "unknown", | 80 | const QString& type = "unknown", |
80 | const QString& essid = "unknown", | 81 | const QString& essid = "unknown", |
81 | const QString& macaddr = "unknown", | 82 | const QString& macaddr = "unknown", |
82 | bool wep = false, | 83 | bool wep = false, |
83 | int channel = 0, | 84 | int channel = 0, |
84 | int signal = 0 ); | 85 | int signal = 0 ); |
85 | 86 | ||
86 | 87 | ||
87 | protected: | 88 | protected: |
88 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); | 89 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ); |
89 | 90 | ||
90 | public: | 91 | public: |
91 | QString type; | 92 | QString type; |
92 | 93 | ||
93 | public: | 94 | public: |
94 | //const QString& type() { return _type; }; | 95 | //const QString& type() { return _type; }; |
95 | const QString& essid() const; | 96 | const QString& essid() const; |
96 | const QString& macaddr() { return _macaddr; }; | 97 | const QString& macaddr() { return _macaddr; }; |
97 | bool wep() { return _wep; }; | 98 | bool wep() { return _wep; }; |
98 | int channel() { return _channel; }; | 99 | int channel() { return _channel; }; |
99 | int signal() { return _signal; }; | 100 | int signal() { return _signal; }; |
100 | int beacons() { return _beacons; }; | 101 | int beacons() { return _beacons; }; |
101 | 102 | ||
102 | void setSignal( int signal ) { /* TODO */ }; | 103 | void setSignal( int signal ) { /* TODO */ }; |
103 | void receivedBeacon(); | 104 | void receivedBeacon(); |
104 | 105 | ||
105 | void setManufacturer( const QString& manufacturer ); | 106 | void setManufacturer( const QString& manufacturer ); |
106 | void setLocation( const QString& location ); | 107 | void setLocation( const QString& location ); |
107 | 108 | ||
108 | virtual OListViewItem* childFactory(); | 109 | virtual OListViewItem* childFactory(); |
109 | virtual void serializeTo( QDataStream& s ) const; | 110 | virtual void serializeTo( QDataStream& s ) const; |
110 | virtual void serializeFrom( QDataStream& s ); | 111 | virtual void serializeFrom( QDataStream& s ); |
111 | 112 | ||
112 | private: | 113 | private: |
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 25632f3..cd74bed 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -140,52 +140,85 @@ void Wellenreiter::handleNotification( OPacket* p ) | |||
140 | QObjectList* l = p->queryList(); | 140 | QObjectList* l = p->queryList(); |
141 | QObjectListIt it( *l ); | 141 | QObjectListIt it( *l ); |
142 | QObject* o; | 142 | QObject* o; |
143 | 143 | ||
144 | while ( (o = it.current()) != 0 ) | 144 | while ( (o = it.current()) != 0 ) |
145 | { | 145 | { |
146 | QString name = it.current()->name(); | 146 | QString name = it.current()->name(); |
147 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) | 147 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) |
148 | { | 148 | { |
149 | QString action = configwindow->parsePackets->protocolAction( name ); | 149 | QString action = configwindow->parsePackets->protocolAction( name ); |
150 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 150 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
151 | doAction( action, name, p ); | 151 | doAction( action, name, p ); |
152 | } | 152 | } |
153 | else | 153 | else |
154 | { | 154 | { |
155 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); | 155 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); |
156 | } | 156 | } |
157 | ++it; | 157 | ++it; |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) | 162 | void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) |
163 | { | 163 | { |
164 | if ( manage->managementType() != "Beacon" ) return; // only handling beacons at that time | 164 | if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); |
165 | else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); | ||
166 | else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); | ||
167 | else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() ); | ||
168 | } | ||
165 | 169 | ||
166 | OWaveLanManagementPacket* beacon = manage; | ||
167 | 170 | ||
171 | void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) | ||
172 | { | ||
173 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | ||
174 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); | ||
175 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | ||
176 | int channel = ds ? ds->channel() : -1; | ||
177 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | ||
178 | |||
179 | GpsLocation loc( -111, -111 ); | ||
180 | if ( configwindow->enableGPS->isChecked() ) | ||
181 | { | ||
182 | // TODO: add check if GPS is working!? | ||
183 | qDebug( "Wellenreiter::gathering GPS data..." ); | ||
184 | loc = gps->position(); | ||
185 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); | ||
186 | } | ||
187 | |||
188 | if ( essid.length() ) | ||
189 | netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); | ||
190 | qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" ); | ||
191 | } | ||
192 | |||
193 | |||
194 | void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) | ||
195 | { | ||
196 | } | ||
197 | |||
198 | |||
199 | void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | ||
200 | { | ||
168 | QString type; | 201 | QString type; |
169 | if ( beacon->canIBSS() ) | 202 | if ( beacon->canIBSS() ) |
170 | { | 203 | { |
171 | type = "adhoc"; | 204 | type = "adhoc"; |
172 | } | 205 | } |
173 | else if ( beacon->canESS() ) | 206 | else if ( beacon->canESS() ) |
174 | { | 207 | { |
175 | type = "managed"; | 208 | type = "managed"; |
176 | } | 209 | } |
177 | else | 210 | else |
178 | { | 211 | { |
179 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); | 212 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); |
180 | return; | 213 | return; |
181 | } | 214 | } |
182 | 215 | ||
183 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 216 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
184 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); | 217 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); |
185 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 218 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
186 | int channel = ds ? ds->channel() : -1; | 219 | int channel = ds ? ds->channel() : -1; |
187 | 220 | ||
188 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 221 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
189 | 222 | ||
190 | GpsLocation loc( -111, -111 ); | 223 | GpsLocation loc( -111, -111 ); |
191 | if ( configwindow->enableGPS->isChecked() ) | 224 | if ( configwindow->enableGPS->isChecked() ) |
@@ -195,49 +228,49 @@ void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* | |||
195 | loc = gps->position(); | 228 | loc = gps->position(); |
196 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); | 229 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); |
197 | } | 230 | } |
198 | 231 | ||
199 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); | 232 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); |
200 | 233 | ||
201 | // update graph window | 234 | // update graph window |
202 | if ( ds ) | 235 | if ( ds ) |
203 | { | 236 | { |
204 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); | 237 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); |
205 | if ( prism ) | 238 | if ( prism ) |
206 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); | 239 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); |
207 | else | 240 | else |
208 | graphwindow->traffic( ds->channel(), 95 ); | 241 | graphwindow->traffic( ds->channel(), 95 ); |
209 | } | 242 | } |
210 | } | 243 | } |
211 | 244 | ||
212 | 245 | ||
213 | void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) | 246 | void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) |
214 | { | 247 | { |
215 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 248 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
216 | 249 | ||
217 | if ( control->controlType() == "Acknowledge" ) | 250 | if ( control->controlType() == "Acknowledge" ) |
218 | { | 251 | { |
219 | netView()->addNewItem( "adhoc", "???", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); | 252 | netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); |
220 | } | 253 | } |
221 | else | 254 | else |
222 | { | 255 | { |
223 | qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() ); | 256 | qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() ); |
224 | } | 257 | } |
225 | } | 258 | } |
226 | 259 | ||
227 | 260 | ||
228 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) | 261 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) |
229 | { | 262 | { |
230 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 263 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
231 | if ( wlan->fromDS() && !wlan->toDS() ) | 264 | if ( wlan->fromDS() && !wlan->toDS() ) |
232 | { | 265 | { |
233 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 266 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
234 | from = wlan->macAddress3(); | 267 | from = wlan->macAddress3(); |
235 | to = wlan->macAddress2(); | 268 | to = wlan->macAddress2(); |
236 | } | 269 | } |
237 | else if ( !wlan->fromDS() && wlan->toDS() ) | 270 | else if ( !wlan->fromDS() && wlan->toDS() ) |
238 | { | 271 | { |
239 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); | 272 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); |
240 | from = wlan->macAddress2(); | 273 | from = wlan->macAddress2(); |
241 | to = wlan->macAddress3(); | 274 | to = wlan->macAddress3(); |
242 | } | 275 | } |
243 | else if ( wlan->fromDS() && wlan->toDS() ) | 276 | else if ( wlan->fromDS() && wlan->toDS() ) |
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index 5414fda..a28740b 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h | |||
@@ -54,49 +54,52 @@ class Wellenreiter : public WellenreiterBase { | |||
54 | bool isDaemonRunning() const { return sniffing; }; | 54 | bool isDaemonRunning() const { return sniffing; }; |
55 | QString captureFileName() const { return dumpname; }; | 55 | QString captureFileName() const { return dumpname; }; |
56 | 56 | ||
57 | public: | 57 | public: |
58 | bool sniffing; | 58 | bool sniffing; |
59 | 59 | ||
60 | protected: | 60 | protected: |
61 | virtual void timerEvent( QTimerEvent* ); | 61 | virtual void timerEvent( QTimerEvent* ); |
62 | 62 | ||
63 | public slots: | 63 | public slots: |
64 | void initialTimer(); | 64 | void initialTimer(); |
65 | 65 | ||
66 | void channelHopped(int); | 66 | void channelHopped(int); |
67 | void receivePacket(OPacket*); | 67 | void receivePacket(OPacket*); |
68 | void startClicked(); | 68 | void startClicked(); |
69 | void stopClicked(); | 69 | void stopClicked(); |
70 | 70 | ||
71 | void joinNetwork(const QString&,const QString&,int,const QString&); | 71 | void joinNetwork(const QString&,const QString&,int,const QString&); |
72 | 72 | ||
73 | signals: | 73 | signals: |
74 | void startedSniffing(); | 74 | void startedSniffing(); |
75 | void stoppedSniffing(); | 75 | void stoppedSniffing(); |
76 | 76 | ||
77 | private: | 77 | private: |
78 | void handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ); | 78 | void handleManagementFrame( OPacket* p, OWaveLanManagementPacket* ); |
79 | void handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* ); | ||
80 | void handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* ); | ||
81 | void handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* ); | ||
79 | void handleControlFrame( OPacket* p, OWaveLanControlPacket* control ); | 82 | void handleControlFrame( OPacket* p, OWaveLanControlPacket* control ); |
80 | void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ); | 83 | void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ); |
81 | void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ); | 84 | void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ); |
82 | void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to ); | 85 | void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to ); |
83 | void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to ); | 86 | void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to ); |
84 | void handleNotification( OPacket* p ); | 87 | void handleNotification( OPacket* p ); |
85 | void doAction( const QString& action, const QString& protocol, OPacket* p ); | 88 | void doAction( const QString& action, const QString& protocol, OPacket* p ); |
86 | QObject* childIfToParse( OPacket* p, const QString& protocol ); | 89 | QObject* childIfToParse( OPacket* p, const QString& protocol ); |
87 | bool checkDumpPacket( OPacket* p ); | 90 | bool checkDumpPacket( OPacket* p ); |
88 | 91 | ||
89 | private: | 92 | private: |
90 | #ifdef QWS | 93 | #ifdef QWS |
91 | OSystem _system; // Opie Operating System identifier | 94 | OSystem _system; // Opie Operating System identifier |
92 | #endif | 95 | #endif |
93 | 96 | ||
94 | QString dumpname; | 97 | QString dumpname; |
95 | OWirelessNetworkInterface* iface; | 98 | OWirelessNetworkInterface* iface; |
96 | OPacketCapturer* pcap; | 99 | OPacketCapturer* pcap; |
97 | WellenreiterConfigWindow* configwindow; | 100 | WellenreiterConfigWindow* configwindow; |
98 | GPS* gps; | 101 | GPS* gps; |
99 | 102 | ||
100 | //void readConfig(); | 103 | //void readConfig(); |
101 | //void writeConfig(); | 104 | //void writeConfig(); |
102 | }; | 105 | }; |