summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/wellenreiter.cpp
authormickeyl <mickeyl>2003-05-04 20:40:28 (UTC)
committer mickeyl <mickeyl>2003-05-04 20:40:28 (UTC)
commit7372d0271b19bc6ead8e796a949746ae45fe13fa (patch) (side-by-side diff)
tree35f2e418dfc4184ae335f24a487bce5a6787f129 /noncore/net/wellenreiter/gui/wellenreiter.cpp
parent09dceae91b14a4b2d936ebfc6c7c276686c2b98c (diff)
downloadopie-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
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp186
1 files changed, 110 insertions, 76 deletions
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<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 );
}
}