author | mickeyl <mickeyl> | 2003-05-04 20:40:28 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-04 20:40:28 (UTC) |
commit | 7372d0271b19bc6ead8e796a949746ae45fe13fa (patch) (side-by-side diff) | |
tree | 35f2e418dfc4184ae335f24a487bce5a6787f129 | |
parent | 09dceae91b14a4b2d936ebfc6c7c276686c2b98c (diff) | |
download | opie-7372d0271b19bc6ead8e796a949746ae45fe13fa.zip opie-7372d0271b19bc6ead8e796a949746ae45fe13fa.tar.gz opie-7372d0271b19bc6ead8e796a949746ae45fe13fa.tar.bz2 |
- cleanup and code refactoring towards 1.0
- match IP addresses to MAC addresses by looking @ ARP packets
- show IP addresses
- reduce debug output
-rw-r--r-- | noncore/net/wellenreiter/gui/gui.pro | 18 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/logwindow.cpp | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/logwindow.h | 5 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 98 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 186 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 7 |
8 files changed, 222 insertions, 106 deletions
diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index 927f4b7..62e1d9a 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro @@ -47 +47,19 @@ contains( platform, x11 ) { +TRANSLATIONS = ../../../../i18n/de/wellenreiter.ts \ + ../../../../i18n/nl/wellenreiter.ts \ + ../../../../i18n/da/wellenreiter.ts \ + ../../../../i18n/xx/wellenreiter.ts \ + ../../../../i18n/en/wellenreiter.ts \ + ../../../../i18n/es/wellenreiter.ts \ + ../../../../i18n/fr/wellenreiter.ts \ + ../../../../i18n/hu/wellenreiter.ts \ + ../../../../i18n/ja/wellenreiter.ts \ + ../../../../i18n/ko/wellenreiter.ts \ + ../../../../i18n/no/wellenreiter.ts \ + ../../../../i18n/pl/wellenreiter.ts \ + ../../../../i18n/pt/wellenreiter.ts \ + ../../../../i18n/pt_BR/wellenreiter.ts \ + ../../../../i18n/sl/wellenreiter.ts \ + ../../../../i18n/zh_CN/wellenreiter.ts \ + ../../../../i18n/zh_TW/wellenreiter.ts + diff --git a/noncore/net/wellenreiter/gui/logwindow.cpp b/noncore/net/wellenreiter/gui/logwindow.cpp index 12f74fd..6078fa2 100644 --- a/noncore/net/wellenreiter/gui/logwindow.cpp +++ b/noncore/net/wellenreiter/gui/logwindow.cpp @@ -19,2 +19,4 @@ +MLogWindow* MLogWindow::_instance; + MLogWindow::MLogWindow( QWidget * parent, const char * name, WFlags f ) @@ -24,2 +26,4 @@ MLogWindow::MLogWindow( QWidget * parent, const char * name, WFlags f ) ledit->setReadOnly( true ); + + MLogWindow::_instance = this; } diff --git a/noncore/net/wellenreiter/gui/logwindow.h b/noncore/net/wellenreiter/gui/logwindow.h index 6e0fe50..da8c274 100644 --- a/noncore/net/wellenreiter/gui/logwindow.h +++ b/noncore/net/wellenreiter/gui/logwindow.h @@ -33,2 +33,4 @@ class MLogWindow: public QVBox + static MLogWindow* logwindow() { return MLogWindow::_instance; }; + protected: @@ -36,2 +38,5 @@ class MLogWindow: public QVBox + private: + static MLogWindow* _instance; + }; diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index c4a8fbc..773d825 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -134,7 +134,7 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n id = mb->insertItem( tr( "&File" ), file ); - id = mb->insertItem( tr( "&View" ), view ); - mb->setItemEnabled( id, false ); + //id = mb->insertItem( tr( "&View" ), view ); + //mb->setItemEnabled( id, false ); id = mb->insertItem( tr( "&Sniffer" ), sniffer ); - id = mb->insertItem( tr( "&Demo" ), demo ); - mb->setItemEnabled( id, true ); + //id = mb->insertItem( tr( "&Demo" ), demo ); + //mb->setItemEnabled( id, true ); diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 3a6aa15..d5665b4 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp @@ -17,2 +17,3 @@ #include "configwindow.h" +#include "logwindow.h" @@ -42,5 +43,6 @@ const int col_wep = 4; const int col_traffic = 5; -const int col_manuf = 6; -const int col_firstseen = 7; -const int col_lastseen = 8; +const int col_ip = 6; +const int col_manuf = 7; +const int col_firstseen = 8; +const int col_lastseen = 9; @@ -54,19 +56,21 @@ MScanListView::MScanListView( QWidget* parent, const char* name ) addColumn( tr( "Net/Station" ) ); - setColumnAlignment( 0, AlignLeft || AlignVCenter ); + setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); addColumn( tr( "#" ) ); - setColumnAlignment( 1, AlignCenter ); + setColumnAlignment( col_sig, AlignCenter ); addColumn( tr( "MAC" ) ); - setColumnAlignment( 2, AlignCenter ); + setColumnAlignment( col_ap, AlignCenter ); addColumn( tr( "Chn" ) ); - setColumnAlignment( 3, AlignCenter ); + setColumnAlignment( col_channel, AlignCenter ); addColumn( tr( "W" ) ); - setColumnAlignment( 4, AlignCenter ); + setColumnAlignment( col_wep, AlignCenter ); addColumn( tr( "T" ) ); - setColumnAlignment( 5, AlignCenter ); + setColumnAlignment( col_traffic, AlignCenter ); + addColumn( tr( "IP" ) ); + setColumnAlignment( col_ip, AlignCenter ); addColumn( tr( "Manufacturer" ) ); - setColumnAlignment( 6, AlignCenter ); + setColumnAlignment( col_manuf, AlignCenter ); addColumn( tr( "First Seen" ) ); - setColumnAlignment( 7, AlignCenter ); + setColumnAlignment( col_firstseen, AlignCenter ); addColumn( tr( "Last Seen" ) ); - setColumnAlignment( 8, AlignCenter ); + setColumnAlignment( col_lastseen, AlignCenter ); setRootIsDecorated( true ); @@ -105,7 +109,6 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo - qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", - (const char*) type, - (const char*) essid, - (const char*) macaddr, - channel ); + #ifdef DEBUG + qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, + (const char*) essid, (const char*) macaddr, channel ); + #endif @@ -119,3 +122,5 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo { + #ifdef DEBUG qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); + #endif item = static_cast<MScanListItem*> ( item->nextSibling() ); @@ -133,3 +138,5 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo { + #ifdef DEBUG qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); + #endif item = static_cast<MScanListItem*> ( item->nextSibling() ); @@ -149,4 +156,4 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo { - s.sprintf( "(i) new network: '%s'", (const char*) essid ); - //TODO send s to logwindow + s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); + MLogWindow::logwindow()->log( s ); network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); @@ -158,3 +165,5 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo + #ifdef DEBUG qDebug( "inserting new station %s", (const char*) macaddr ); + #endif @@ -166,3 +175,3 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo { - s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); + s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); } @@ -170,5 +179,5 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo { - s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); + s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); } - //TODO send s to logwindow + MLogWindow::logwindow()->log( s ); @@ -183,3 +192,5 @@ void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, cons { + #ifdef DEBUG qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); + #endif subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); @@ -205,3 +216,3 @@ void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, cons { - s.sprintf( "(i) new station in '%s' [??]", (const char*) network->text( col_essid ) ); + s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); } @@ -209,5 +220,5 @@ void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, cons { - s.sprintf( "(i) new wireless station in '%s' [??]", (const char*) network->text( col_essid ) ); + s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); } - //TODO send s to logwindow + MLogWindow::logwindow()->log( s ); } @@ -235,2 +246,3 @@ void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QStri qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); + MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); } @@ -256,2 +268,4 @@ void MScanListView::toDStraffic( QString from, QString to, QString via ) qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); + MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); + } @@ -259,2 +273,3 @@ void MScanListView::toDStraffic( QString from, QString to, QString via ) + void MScanListView::fromDStraffic( QString from, QString to, QString via ) @@ -276,2 +291,3 @@ void MScanListView::fromDStraffic( QString from, QString to, QString via ) qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); + MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); } @@ -279,2 +295,3 @@ void MScanListView::fromDStraffic( QString from, QString to, QString via ) + void MScanListView::IBSStraffic( QString from, QString to, QString via ) @@ -282,4 +299,25 @@ void MScanListView::IBSStraffic( QString from, QString to, QString via ) qWarning( "D'oh! Not yet implemented..." ); + MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); } + +void MScanListView::identify( const QString& macaddr, const QString& ip ) +{ + qDebug( "identify %s = %s", (const char*) macaddr, (const char*) ip ); + + QListViewItemIterator it( this ); + for ( ; it.current(); ++it ) + { + if ( it.current()->text( col_ap ) == macaddr ) + { + it.current()->setText( col_ip, ip ); + return; + } + } + qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); + MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", + (const char*) macaddr, (const char*) ip ) ); +} + + //============================================================ @@ -294,3 +332,5 @@ MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QS { + #ifdef DEBUG qDebug( "creating scanlist item" ); + #endif if ( WellenreiterConfigWindow::instance() && type == "network" ) @@ -304,3 +344,5 @@ MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid { + #ifdef DEBUG qDebug( "creating scanlist item" ); + #endif decorateItem( type, essid, macaddr, wep, channel, signal ); @@ -315,3 +357,5 @@ void MScanListItem::serializeTo( QDataStream& s ) const { + #ifdef DEBUG qDebug( "serializing MScanListItem" ); + #endif OListViewItem::serializeTo( s ); @@ -324,3 +368,5 @@ void MScanListItem::serializeFrom( QDataStream& s ) { + #ifdef DEBUG qDebug( "serializing MScanListItem" ); + #endif OListViewItem::serializeFrom( s ); @@ -342,2 +388,3 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, { + #ifdef DEBUG qDebug( "decorating scanlist item %s / %s / %s [%d]", @@ -347,2 +394,3 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, channel ); + #endif diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 56bf837..4cb9216 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h @@ -48,2 +48,4 @@ class MScanListView: public OListView + void identify( const QString& macaddr, const QString& ipaddr ); + protected: diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 62bda91..9e1010b 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -139,42 +139,119 @@ void Wellenreiter::channelHopped(int c) -void Wellenreiter::receivePacket(OPacket* p) +void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) { - hexWindow()->log( p->dump( 8 ) ); + QString type; + if ( beacon->canIBSS() ) + { + type = "adhoc"; + } + else if ( beacon->canESS() ) + { + type = "managed"; + } + else + { + qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); + return; + } - // check if we received a beacon frame - OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); - if ( beacon && beacon->managementType() == "Beacon" ) + OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); + QString essid = ssid ? ssid->ID() : QString("<unknown>"); + OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); + int channel = ds ? ds->channel() : -1; + + OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); + netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); + + // update graph window + if ( ds ) { - QString type; - if ( beacon->canIBSS() ) - { - type = "adhoc"; - } - else if ( beacon->canESS() ) + OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); + if ( prism ) + graphwindow->traffic( ds->channel(), prism->signalStrength() ); + else + graphwindow->traffic( ds->channel(), 95 ); + } +} + + +void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) +{ + OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); + if ( wlan->fromDS() && !wlan->toDS() ) + { + qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", + (const char*) wlan->macAddress3().toString(true), + (const char*) wlan->macAddress1().toString(true), + (const char*) wlan->macAddress2().toString(true) ); + netView()->fromDStraffic( wlan->macAddress3().toString(), + wlan->macAddress1().toString(), + wlan->macAddress2().toString() ); + } + else + if ( !wlan->fromDS() && wlan->toDS() ) + { + qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", + (const char*) wlan->macAddress2().toString(true), + (const char*) wlan->macAddress3().toString(true), + (const char*) wlan->macAddress1().toString(true) ); + netView()->toDStraffic( wlan->macAddress2().toString(), + wlan->macAddress3().toString(), + wlan->macAddress1().toString() ); + } + else + if ( wlan->fromDS() && wlan->toDS() ) + { + qDebug( "WDS(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", + (const char*) wlan->macAddress4().toString(true), + (const char*) wlan->macAddress3().toString(true), + (const char*) wlan->macAddress1().toString(true), + (const char*) wlan->macAddress2().toString(true) ); + netView()->WDStraffic( wlan->macAddress4().toString(), + wlan->macAddress3().toString(), + wlan->macAddress1().toString(), + wlan->macAddress2().toString() ); + } + else + { + qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", + (const char*) wlan->macAddress2().toString(true), + (const char*) wlan->macAddress1().toString(true), + (const char*) wlan->macAddress3().toString(true) ); + netView()->IBSStraffic( wlan->macAddress2().toString(), + wlan->macAddress1().toString(), + wlan->macAddress3().toString() ); + } + + OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); + if ( arp ) + { + qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); + if ( arp->type() == "REQUEST" ) { - type = "managed"; + netView()->identify( arp->senderMacAddress().toString(), arp->senderIPV4Address().toString() ); } - else + else if ( arp->type() == "REPLY" ) { - qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) ); - return; + netView()->identify( arp->senderMacAddress().toString(), arp->senderIPV4Address().toString() ); + netView()->identify( arp->targetMacAddress().toString(), arp->targetIPV4Address().toString() ); } + } + + OIPPacket* ip = (OIPPacket*) p->child( "IP" ); + if ( ip ) + { + qDebug( "Received IP packet." ); + } +} - OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); - QString essid = ssid ? ssid->ID() : QString("<unknown>"); - OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); - int channel = ds ? ds->channel() : -1; - OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); - netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); +void Wellenreiter::receivePacket( OPacket* p ) +{ + hexWindow()->log( p->dump( 8 ) ); - // update graph window - if ( ds ) - { - OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); - if ( prism ) - graphwindow->traffic( ds->channel(), prism->signalStrength() ); - else - graphwindow->traffic( ds->channel(), 95 ); - } + // check if we received a beacon frame + OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); + if ( beacon && beacon->managementType() == "Beacon" ) + { + handleBeacon( p, beacon ); return; @@ -182,2 +259,4 @@ void Wellenreiter::receivePacket(OPacket* p) + //TODO: WEP check here + // check for a data frame @@ -186,48 +265,3 @@ void Wellenreiter::receivePacket(OPacket* p) { - OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); - if ( wlan->fromDS() && !wlan->toDS() ) - { - qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", - (const char*) wlan->macAddress3().toString(true), - (const char*) wlan->macAddress1().toString(true), - (const char*) wlan->macAddress2().toString(true) ); - netView()->fromDStraffic( wlan->macAddress3().toString(), - wlan->macAddress1().toString(), - wlan->macAddress2().toString() ); - } - else - if ( !wlan->fromDS() && wlan->toDS() ) - { - qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", - (const char*) wlan->macAddress2().toString(true), - (const char*) wlan->macAddress3().toString(true), - (const char*) wlan->macAddress1().toString(true) ); - netView()->toDStraffic( wlan->macAddress2().toString(), - wlan->macAddress3().toString(), - wlan->macAddress1().toString() ); - } - else - if ( wlan->fromDS() && wlan->toDS() ) - { - qDebug( "WDS(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", - (const char*) wlan->macAddress4().toString(true), - (const char*) wlan->macAddress3().toString(true), - (const char*) wlan->macAddress1().toString(true), - (const char*) wlan->macAddress2().toString(true) ); - netView()->WDStraffic( wlan->macAddress4().toString(), - wlan->macAddress3().toString(), - wlan->macAddress1().toString(), - wlan->macAddress2().toString() ); - } - else - { - qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", - (const char*) wlan->macAddress2().toString(true), - (const char*) wlan->macAddress1().toString(true), - (const char*) wlan->macAddress3().toString(true) ); - netView()->IBSStraffic( wlan->macAddress2().toString(), - wlan->macAddress1().toString(), - wlan->macAddress3().toString() ); - } - return; + handleData( p, data ); } diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index c37a9f2..ea8a692 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -28,5 +28,6 @@ class QPixmap; class OPacket; +class OWaveLanManagementPacket; +class OWaveLanDataPacket; class OPacketCapturer; class OWirelessNetworkInterface; - class ManufacturerDB; @@ -65,2 +66,6 @@ class Wellenreiter : public WellenreiterBase { private: + void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); + void handleData( OPacket* p, OWaveLanDataPacket* data ); + + private: #ifdef QWS |