author | mickeyl <mickeyl> | 2003-04-08 14:17:38 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-08 14:17:38 (UTC) |
commit | 0d48ba39224582c83d68c2938e6cbedc4c77ec7d (patch) (side-by-side diff) | |
tree | 654c387625978b5a1f0c0111d0c279cea2edfab9 | |
parent | 1af4ae3d621d63c82f7d78efda05218a3457981f (diff) | |
download | opie-0d48ba39224582c83d68c2938e6cbedc4c77ec7d.zip opie-0d48ba39224582c83d68c2938e6cbedc4c77ec7d.tar.gz opie-0d48ba39224582c83d68c2938e6cbedc4c77ec7d.tar.bz2 |
- fix <unknown> entries bug caused by interpretating not-yet-handled 802.11 management frames
This thing gets complicated... I really should implement a state machine for the beta.
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 15 |
2 files changed, 16 insertions, 5 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 1525934..1ef24d2 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp @@ -181,183 +181,185 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); if ( type == "managed" ) { s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); } else { s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); } } void MScanListView::traffic( QString type, QString from, QString to, QString via, QString additional ) { if ( type != "toDS" ) return; qDebug( "MScanList::traffic( [%s] | %s -> %s (via %s)", (const char*) type, (const char*) from, (const char*) to, (const char*) 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 been shown up, so just add our new "from" - station { network = static_cast<MScanListItem*>( item->parent() ); MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); while ( subitem && ( subitem->text( col_ap ) != from ) ) { qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); subitem = static_cast<MScanListItem*> ( subitem->itemBelow() ); } if ( subitem ) { // we have already seen this item, it's a dupe #ifdef DEBUG qDebug( "%s is a dupe - ignoring...", (const char*) from ); #endif subitem->receivedBeacon(); //FIXME: sent data bit return; } // Hey, it seems to be a new item :-D MScanListItem* station = new MScanListItem( item->parent(), "adhoc", /* network->text( col_essid ) */ "", from, false, -1, -1 ); if ( _manufacturerdb ) station->setManufacturer( _manufacturerdb->lookup( from ) ); } else { qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in alpha-4 version :-D" ); } } //============================================================ // 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 ) { qDebug( "creating scanlist item" ); if ( WellenreiterConfigWindow::instance() && type == "networks" ) 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 ) { qDebug( "creating scanlist item" ); decorateItem( type, essid, macaddr, wep, channel, signal ); } OListViewItem* MScanListItem::childFactory() { return new MScanListItem( this ); } void MScanListItem::serializeTo( QDataStream& s ) const { qDebug( "serializing MScanListItem" ); OListViewItem::serializeTo( s ); s << _type; - s << (Q_UINT8) _wep; + s << (Q_UINT8) ( _wep ? 'y' : 'n' ); } void MScanListItem::serializeFrom( QDataStream& s ) { qDebug( "serializing MScanListItem" ); OListViewItem::serializeFrom( s ); + char wep; s >> _type; - s >> (Q_UINT8) _wep; + 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 ) { qDebug( "decorating scanlist item %s / %s / %s [%d]", (const char*) type, (const char*) essid, (const char*) macaddr, channel ); // 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 if ( signal != -1 ) setText( col_sig, QString::number( signal ) ); if ( channel != -1 ) setText( col_channel, QString::number( channel ) ); setText( col_firstseen, QTime::currentTime().toString() ); //setText( col_lastseen, QTime::currentTime().toString() ); listView()->triggerUpdate(); this->type = type; _type = type; _essid = essid; _macaddr = macaddr; _channel = channel; _beacons = 1; _signal = 0; } void MScanListItem::setManufacturer( const QString& manufacturer ) { setText( col_manuf, manufacturer ); } void MScanListItem::playSound( const QString& sound ) const { #ifdef QWS if ( sound == "Ignore" ) return; else if ( sound == "Touch" ) ODevice::inst()->touchSound(); else if ( sound == "Key" ) ODevice::inst()->keySound(); else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); #endif } void MScanListItem::receivedBeacon() { _beacons++; #ifdef DEBUG qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); #endif setText( col_sig, QString::number( _beacons ) ); setText( col_lastseen, QTime::currentTime().toString() ); if ( WellenreiterConfigWindow::instance() ) playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() ); } diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 8d18f73..8c2c315 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -21,207 +21,216 @@ using namespace Opie; #endif #ifdef QWS #include <opie2/oapplication.h> #else #include <qapplication.h> #endif #include <opie2/onetwork.h> #include <opie2/opcap.h> // Qt #include <qpushbutton.h> #include <qmessagebox.h> #include <qcombobox.h> #include <qspinbox.h> #include <qsocketnotifier.h> // Standard #include <assert.h> #include <errno.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <stdlib.h> // Local #include "wellenreiter.h" #include "scanlist.h" #include "logwindow.h" #include "hexwindow.h" #include "configwindow.h" #include "manufacturers.h" Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) { // // construct manufacturer database // QString manufile; #ifdef QWS manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); #else manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); #endif manufacturerdb = new ManufacturerDB( manufile ); logwindow->log( "(i) Wellenreiter has been started." ); // // detect operating system // #ifdef QWS QString sys; sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); _system = ODevice::inst()->system(); logwindow->log( sys ); #endif // setup GUI netview->setColumnWidthMode( 1, QListView::Manual ); if ( manufacturerdb ) netview->setManufacturerDB( manufacturerdb ); pcap = new OPacketCapturer(); } Wellenreiter::~Wellenreiter() { // no need to delete child widgets, Qt does it all for us delete manufacturerdb; delete pcap; } void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) { configwindow = cw; } void Wellenreiter::receivePacket(OPacket* p) { hexWindow()->log( p->dump( 8 ) ); // check if we received a beacon frame OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); - if ( beacon ) + if ( beacon && beacon->managementType() == "Beacon" ) { QString type; if ( beacon->canIBSS() ) + { type = "adhoc"; - else + } + else if ( beacon->canESS() ) + { type = "managed"; + } + else + { + qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) ); + return; + } 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(), header->usesWep(), channel, 0 ); + netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); return; } // 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()->traffic( "fromDS", 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()->traffic( "toDS", wlan->macAddress2().toString(), wlan->macAddress3().toString(), wlan->macAddress1().toString() ); } else if ( wlan->fromDS() && wlan->toDS() ) { qDebug( "WSD(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()->traffic( "WSD", 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()->traffic( "fromDS", wlan->macAddress2().toString(), wlan->macAddress1().toString(), wlan->macAddress3().toString() ); } return; } } void Wellenreiter::startStopClicked() { if ( sniffing ) { disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); iface->setChannelHopping(); // stop hopping channels pcap->close(); sniffing = false; #ifdef QWS oApp->setTitle(); #else qApp->mainWidget()->setCaption( "Wellenreiter II" ); #endif // get interface name from config window const QString& interface = configwindow->interfaceName->currentText(); ONetwork* net = ONetwork::instance(); iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // switch off monitor mode iface->setMonitorMode( false ); // switch off promisc flag iface->setPromiscuousMode( false ); system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess logwindow->log( "(i) Stopped Scanning." ); // message the user QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); } else { // get configuration from config window const QString& interface = configwindow->interfaceName->currentText(); const int cardtype = configwindow->daemonDeviceType(); const int interval = configwindow->daemonHopInterval(); |