summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-05 13:12:45 (UTC)
committer mickeyl <mickeyl>2003-10-05 13:12:45 (UTC)
commit634a68b636a0fa24232029b79ffa915a5621b2be (patch) (side-by-side diff)
tree3e4c58bebfd624e841c314f1db68d985d81cdc6c
parentdc9510f788212a6be063349461540e4bea690f51 (diff)
downloadopie-634a68b636a0fa24232029b79ffa915a5621b2be.zip
opie-634a68b636a0fa24232029b79ffa915a5621b2be.tar.gz
opie-634a68b636a0fa24232029b79ffa915a5621b2be.tar.bz2
* start with preparations for scanning wired networks
* dhcp recognition now works nicely
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetutils.cpp7
-rw-r--r--libopie2/opienet/onetutils.h1
-rw-r--r--libopie2/opienet/opcap.cpp27
-rw-r--r--libopie2/opienet/opcap.h5
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp48
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h1
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp64
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h7
-rwxr-xr-xpics/wellenreiter/service.pngbin0 -> 863 bytes
9 files changed, 148 insertions, 12 deletions
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index 08c40b4..ad0e89d 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -60,4 +60,9 @@ const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
+//TODO: Incorporate Ethernet Manufacturer database here! (inline or so)
+
+OMacAddress::OMacAddress()
+{
+ memcpy( _bytes, __unknown, 6 );
+}
-//TODO: Incorporate Ethernet Manufacturer database here!
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h
index 9611518..18731ba 100644
--- a/libopie2/opienet/onetutils.h
+++ b/libopie2/opienet/onetutils.h
@@ -53,2 +53,3 @@ class OMacAddress
// QString c'tor? -zecke
+ OMacAddress();
OMacAddress( unsigned char* );
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 7a6f61b..313f5bb 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -110,2 +110,25 @@ void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l )
+void OPacket::dumpStructure( QObjectList* l )
+{
+ QString packetString( "[ |" + _dumpStructure( l ) + " ]" );
+ qDebug( "OPacket::dumpStructure: %s", (const char*) packetString );
+}
+
+
+QString OPacket::_dumpStructure( QObjectList* l )
+{
+ if (!l) return QString::null;
+ QObject* o = l->first();
+ QString str(" ");
+
+ while ( o )
+ {
+ str.append( o->name() );
+ str.append( " |" );
+ str += _dumpStructure( const_cast<QObjectList*>( o->children() ) );
+ o = l->next();
+ }
+ return str;
+}
+
QString OPacket::dump( int bpl ) const
@@ -1118,3 +1141,5 @@ OPacket* OPacketCapturer::next()
p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) );
-
+ #ifndef NODEBUG
+ p->dumpStructure( const_cast<QObjectList*>( p->children() ) );
+ #endif
return p;
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index a031dd1..f0d1d81 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -135,2 +135,7 @@ class OPacket : public QObject
private:
+
+ void dumpStructure( QObjectList* );
+ QString _dumpStructure( QObjectList* );
+
+ private:
const packetheaderstruct _hdr; // pcap packet header
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 245290d..9d6ed6a 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -341,2 +341,50 @@ void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
+void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip )
+{
+ qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip );
+
+ //TODO: Refactor that out, we need it all over the place.
+ // Best to do it in a more comfortable abstraction in OListView
+ // (Hmm, didn't I already start something in this direction?)
+
+ QListViewItemIterator it( this );
+ for ( ; it.current(); ++it )
+ {
+ if ( it.current()->text( col_ap ) == macaddr.toString(true) )
+ {
+
+ MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() );
+
+ while ( subitem && ( subitem->text( col_essid ) != name ) )
+ {
+ #ifdef DEBUG
+ qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) );
+ #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*) name );
+ #endif
+ subitem->receivedBeacon(); //FIXME: sent data bit
+ return;
+ }
+
+ // never seen that - add new item
+
+ MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", false, -1, -1 );
+ item->setText( col_essid, name );
+
+ return;
+ }
+ }
+ qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" );
+ MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!",
+ (const char*) macaddr.toString(), (const char*) ip ) );
+}
+
+
void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col )
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index 2703b6a..a9b74f1 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -44,2 +44,3 @@ class MScanListView: public OListView
void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location );
+ void addService( const QString& name, const OMacAddress& macaddr, const QString& ip );
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 405eda8..7394742 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -196,3 +196,3 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
-void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
+void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to )
{
@@ -202,2 +202,4 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
+ from = wlan->macAddress3();
+ to = wlan->macAddress2();
}
@@ -206,2 +208,4 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
+ from = wlan->macAddress2();
+ to = wlan->macAddress3();
}
@@ -210,2 +214,4 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
+ from = wlan->macAddress4();
+ to = wlan->macAddress3();
}
@@ -214,4 +220,19 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
+ from = wlan->macAddress2();
+ to = wlan->macAddress1();
}
+}
+
+
+void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
+{
+ from = data->sourceAddress();
+ to = data->destinationAddress();
+
+ netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) );
+}
+
+void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
+{
OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
@@ -231,6 +252,14 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
- OIPPacket* ip = (OIPPacket*) p->child( "IP" );
- if ( ip )
+ ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
+ if ( dhcp )
{
- qDebug( "Received IP packet." );
+ qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
+ if ( dhcp->type() == "OFFER" )
+ {
+ qDebug( "ADDSERVICE: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
+ //netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) );
+
+ netView()->identify( source, dhcp->serverAddress().toString() );
+ netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
+ }
}
@@ -300,12 +329,29 @@ void Wellenreiter::receivePacket( OPacket* p )
+ OMacAddress source;
+ OMacAddress dest;
+
//TODO: WEP check here
- // check for a data frame
- OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
- if ( data )
+ // check for a wireless data frame
+ OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
+ if ( wlan )
+ {
+ handleWlanData( p, wlan, source, dest );
+ }
+
+ // check for a wired data frame
+ OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
+ if ( eth )
+ {
+ handleEthernetData( p, eth, source, dest );
+ }
+
+ // check for a ip frame
+ OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
+ if ( ip )
{
- handleData( p, data );
+ handleIPData( p, ip, source, dest );
}
- handleNotification( p );
+ //handleNotification( p );
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index 43f6f99..ed96375 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -30,2 +30,5 @@ class OWaveLanManagementPacket;
class OWaveLanDataPacket;
+class OEthernetPacket;
+class OMacAddress;
+class OIPPacket;
class OPacketCapturer;
@@ -70,3 +73,5 @@ class Wellenreiter : public WellenreiterBase {
void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon );
- void handleData( OPacket* p, OWaveLanDataPacket* data );
+ void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to );
+ void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to );
+ void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to );
void handleNotification( OPacket* p );
diff --git a/pics/wellenreiter/service.png b/pics/wellenreiter/service.png
new file mode 100755
index 0000000..4e06a0a
--- a/dev/null
+++ b/pics/wellenreiter/service.png
Binary files differ