-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 @@ -36,12 +36,30 @@ TARGET = wellenreiter message( qws ) include ( $(OPIEDIR)/include.pro ) LIBS += -lqpe -lopie -lopiecore2 -lopieui2 -lopienet2 -lstdc++ } contains( platform, x11 ) { LIBS += -L$(OPIEDIR)/output/lib -Wl,-rpath,$(OPIEDIR)/output/lib -Wl,-rpath,/usr/local/lib -lwellenreiter SOURCES += resource.cpp HEADERS += resource.h DESTDIR = $(OPIEDIR)/output/bin } +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 @@ -8,29 +8,33 @@ ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "logwindow.h" #include <qmultilineedit.h> #include <qdatetime.h> +MLogWindow* MLogWindow::_instance; + MLogWindow::MLogWindow( QWidget * parent, const char * name, WFlags f ) :QVBox( parent, name, f ) { ledit = new QMultiLineEdit( this ); ledit->setReadOnly( true ); + + MLogWindow::_instance = this; } void MLogWindow::log( QString text ) { QTime time = QTime::currentTime(); QString line; line.sprintf( "[%s] %s\n", (const char*) time.toString(), (const char*) text ); int col; int row; ledit->getCursorPosition( &col, &row ); ledit->insertAt( line, col, row ); 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 @@ -22,19 +22,24 @@ class QString; class QMultiLineEdit; class MLogWindow: public QVBox { public: MLogWindow( QWidget * parent = 0, const char * name = "MLogWindow", WFlags f = 0 ); void log( QString text ); const QString getLog() const; void clear(); + static MLogWindow* logwindow() { return MLogWindow::_instance; }; + protected: QMultiLineEdit* ledit; + private: + static MLogWindow* _instance; + }; #endif 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 @@ -123,29 +123,29 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n QPopupMenu* sniffer = new QPopupMenu( mb ); sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); sniffer->insertSeparator(); startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); sniffer->setItemEnabled( startID, false ); stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); sniffer->setItemEnabled( stopID, false ); QPopupMenu* demo = new QPopupMenu( mb ); demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); 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 ); #ifdef QWS mb->insertItem( startButton ); mb->insertItem( stopButton ); mb->insertItem( c ); mb->insertItem( d ); #else // Qt3 changed the insertion order. It's now totally random :( mb->insertItem( d ); mb->insertItem( c ); mb->insertItem( stopButton ); mb->insertItem( startButton ); #endif 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 @@ -6,24 +6,25 @@ ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "scanlist.h" #include "configwindow.h" +#include "logwindow.h" #include <assert.h> #include "manufacturers.h" #include <qdatetime.h> #include <qtextstream.h> #ifdef QWS #include <opie/odevice.h> using namespace Opie; #endif @@ -31,53 +32,56 @@ using namespace Opie; #include <qpe/resource.h> #else #include "resource.h" #endif const int col_type = 0; const int col_essid = 0; const int col_sig = 1; const int col_ap = 2; const int col_channel = 3; 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; MScanListView::MScanListView( QWidget* parent, const char* name ) :OListView( parent, name ), _manufacturerdb( 0 ) { setFrameShape( QListView::StyledPanel ); setFrameShadow( QListView::Sunken ); 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 ); setAllColumnsShowFocus( true ); }; MScanListView::~MScanListView() { }; OListViewItem* MScanListView::childFactory() { return new MScanListItem( this ); } @@ -94,266 +98,310 @@ void MScanListView::serializeFrom( QDataStream& s) OListView::serializeFrom( s ); } void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) { _manufacturerdb = manufacturerdb; } void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) { // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) - 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 // search, if we already have seen this net QString s; MScanListItem* network; MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); while ( item && ( item->text( col_essid ) != essid ) ) { + #ifdef DEBUG qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); + #endif item = static_cast<MScanListItem*> ( item->nextSibling() ); } if ( item ) { // we have already seen this net, check all childs if MAC exists network = item; item = static_cast<MScanListItem*> ( item->firstChild() ); assert( item ); // this shouldn't fail while ( item && ( item->text( col_ap ) != macaddr ) ) { + #ifdef DEBUG qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); + #endif item = static_cast<MScanListItem*> ( item->nextSibling() ); } if ( item ) { // we have already seen this item, it's a dupe #ifdef DEBUG qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); #endif item->receivedBeacon(); return; } } else { - 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 ); } // insert new station as child from network // no essid to reduce clutter, maybe later we have a nick or stationname to display!? + #ifdef DEBUG qDebug( "inserting new station %s", (const char*) macaddr ); + #endif MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); if ( _manufacturerdb ) station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); if ( type == "managed" ) { - 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 ); } else { - 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 ); } void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, const QString& type ) { MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); while ( subitem && ( subitem->text( col_ap ) != addr ) ) { + #ifdef DEBUG qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); + #endif subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); } if ( subitem ) { // we have already seen this item, it's a dupe #ifdef DEBUG qDebug( "%s is a dupe - ignoring...", (const char*) addr ); #endif subitem->receivedBeacon(); //FIXME: sent data bit return; } // Hey, it seems to be a new item :-D MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr, false, -1, -1 ); if ( _manufacturerdb ) station->setManufacturer( _manufacturerdb->lookup( addr ) ); QString s; if ( type == "station" ) { - 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 ) ); } else { - 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 ); } void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QString viaTo ) { QString s; MScanListItem* network; QListViewItemIterator it( this ); while ( it.current() && it.current()->text( col_ap ) != viaFrom && it.current()->text( col_ap ) != viaTo ) ++it; MScanListItem* item = static_cast<MScanListItem*>( it.current() ); if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations { addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); } else { qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); + MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); } } void MScanListView::toDStraffic( QString from, QString to, QString via ) { QString s; MScanListItem* network; QListViewItemIterator it( this ); while ( it.current() && it.current()->text( col_ap ) != via ) ++it; MScanListItem* item = static_cast<MScanListItem*>( it.current() ); if ( item ) // AP has shown up yet, so just add our new "from" - station { addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); } else { qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); + MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); + } } + void MScanListView::fromDStraffic( QString from, QString to, QString via ) { QString s; MScanListItem* network; QListViewItemIterator it( this ); while ( it.current() && it.current()->text( col_ap ) != via ) ++it; MScanListItem* item = static_cast<MScanListItem*>( it.current() ); if ( item ) // AP has shown up yet, so just add our new "from" - station { addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); } else { qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); + MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); } } + 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 ) ); +} + + //============================================================ // MScanListItem //============================================================ MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), _channel( channel ), _signal( signal ), _beacons( 1 ) { + #ifdef DEBUG qDebug( "creating scanlist item" ); + #endif if ( WellenreiterConfigWindow::instance() && type == "network" ) playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); decorateItem( type, essid, macaddr, wep, channel, signal ); } MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) { + #ifdef DEBUG qDebug( "creating scanlist item" ); + #endif decorateItem( type, essid, macaddr, wep, channel, signal ); } OListViewItem* MScanListItem::childFactory() { return new MScanListItem( this ); } void MScanListItem::serializeTo( QDataStream& s ) const { + #ifdef DEBUG qDebug( "serializing MScanListItem" ); + #endif OListViewItem::serializeTo( s ); s << _type; s << (Q_UINT8) ( _wep ? 'y' : 'n' ); } void MScanListItem::serializeFrom( QDataStream& s ) { + #ifdef DEBUG qDebug( "serializing MScanListItem" ); + #endif OListViewItem::serializeFrom( s ); char wep; s >> _type; s >> (Q_UINT8) wep; _wep = (wep == 'y'); QString name; name.sprintf( "wellenreiter/%s", (const char*) _type ); setPixmap( col_type, Resource::loadPixmap( name ) ); if ( _wep ) setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! listView()->triggerUpdate(); } void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) { + #ifdef DEBUG qDebug( "decorating scanlist item %s / %s / %s [%d]", (const char*) type, (const char*) essid, (const char*) macaddr, channel ); + #endif // set icon for managed or adhoc mode QString name; name.sprintf( "wellenreiter/%s", (const char*) type ); setPixmap( col_type, Resource::loadPixmap( name ) ); // set icon for wep (wireless encryption protocol) if ( wep ) setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! // set channel and signal text 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 @@ -37,24 +37,26 @@ class MScanListView: public OListView virtual OListViewItem* childFactory(); virtual void serializeTo( QDataStream& s ) const; virtual void serializeFrom( QDataStream& s ); public slots: void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); void fromDStraffic( QString from, QString to, QString via ); // NYI void toDStraffic( QString from, QString to, QString via ); void WDStraffic( QString from, QString to, QString viaFrom, QString viaTo ); void IBSStraffic( QString from, QString to, QString via ); // NYI + void identify( const QString& macaddr, const QString& ipaddr ); + protected: void addIfNotExisting( MScanListItem* parent, QString addr, const QString& type = "station" ); private: ManufacturerDB* _manufacturerdb; }; //****************************** MScanListItem **************************************************************** class MScanListItem: public OListViewItem { 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 @@ -128,117 +128,151 @@ void Wellenreiter::channelHopped(int c) { QString right; right.fill( '.', iface->channels()-c ); title.append( right ); } title.append( "]" ); //title.append( QString().sprintf( " %02d", c ) ); assert( parent() ); ( (QMainWindow*) parent() )->setCaption( title ); } -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; } + //TODO: WEP check here + // check for a data frame OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); if ( 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() ); - } - return; + handleData( p, data ); } } void Wellenreiter::stopClicked() { if ( iface ) { disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); iface->setChannelHopping(); // stop hopping channels } 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 @@ -17,27 +17,28 @@ #define WELLENREITER_H #include "wellenreiterbase.h" #ifdef QWS #include <opie/odevice.h> using namespace Opie; #endif class QTimerEvent; class QPixmap; class OPacket; +class OWaveLanManagementPacket; +class OWaveLanDataPacket; class OPacketCapturer; class OWirelessNetworkInterface; - class ManufacturerDB; class WellenreiterConfigWindow; class MLogWindow; class MHexWindow; class Wellenreiter : public WellenreiterBase { Q_OBJECT public: Wellenreiter( QWidget* parent = 0 ); ~Wellenreiter(); @@ -54,24 +55,28 @@ class Wellenreiter : public WellenreiterBase { public slots: void channelHopped(int); void receivePacket(OPacket*); void startClicked(); void stopClicked(); signals: void startedSniffing(); void stoppedSniffing(); private: + void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); + void handleData( OPacket* p, OWaveLanDataPacket* data ); + + private: #ifdef QWS OSystem _system; // Opie Operating System identifier #endif OWirelessNetworkInterface* iface; OPacketCapturer* pcap; ManufacturerDB* manufacturerdb; WellenreiterConfigWindow* configwindow; //void readConfig(); //void writeConfig(); }; |