From 7372d0271b19bc6ead8e796a949746ae45fe13fa Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sun, 04 May 2003 20:40:28 +0000 Subject: - cleanup and code refactoring towards 1.0 - match IP addresses to MAC addresses by looking @ ARP packets - show IP addresses - reduce debug output --- (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') 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 @@ -137,99 +137,133 @@ 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( p->child( "802.11 Management" ) ); - if ( beacon && beacon->managementType() == "Beacon" ) + OWaveLanManagementSSID* ssid = static_cast( p->child( "802.11 SSID" ) ); + QString essid = ssid ? ssid->ID() : QString(""); + OWaveLanManagementDS* ds = static_cast( p->child( "802.11 DS" ) ); + int channel = ds ? ds->channel() : -1; + + OWaveLanPacket* header = static_cast( 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( 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( p->child( "802.11 SSID" ) ); - QString essid = ssid ? ssid->ID() : QString(""); - OWaveLanManagementDS* ds = static_cast( p->child( "802.11 DS" ) ); - int channel = ds ? ds->channel() : -1; - OWaveLanPacket* header = static_cast( 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( 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( 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( 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 ); } } -- cgit v0.9.0.2