summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-05 13:12:45 (UTC)
committer mickeyl <mickeyl>2003-10-05 13:12:45 (UTC)
commit634a68b636a0fa24232029b79ffa915a5621b2be (patch) (unidiff)
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 );
60 60
61//TODO: Incorporate Ethernet Manufacturer database here! (inline or so)
62
63OMacAddress::OMacAddress()
64{
65 memcpy( _bytes, __unknown, 6 );
66}
61 67
62//TODO: Incorporate Ethernet Manufacturer database here!
63 68
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
53 // QString c'tor? -zecke 53 // QString c'tor? -zecke
54 OMacAddress();
54 OMacAddress( unsigned char* ); 55 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 )
110 110
111void OPacket::dumpStructure( QObjectList* l )
112{
113 QString packetString( "[ |" + _dumpStructure( l ) + " ]" );
114 qDebug( "OPacket::dumpStructure: %s", (const char*) packetString );
115}
116
117
118QString OPacket::_dumpStructure( QObjectList* l )
119{
120 if (!l) return QString::null;
121 QObject* o = l->first();
122 QString str(" ");
123
124 while ( o )
125 {
126 str.append( o->name() );
127 str.append( " |" );
128 str += _dumpStructure( const_cast<QObjectList*>( o->children() ) );
129 o = l->next();
130 }
131 return str;
132}
133
111QString OPacket::dump( int bpl ) const 134QString OPacket::dump( int bpl ) const
@@ -1118,3 +1141,5 @@ OPacket* OPacketCapturer::next()
1118 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); 1141 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) );
1119 1142 #ifndef NODEBUG
1143 p->dumpStructure( const_cast<QObjectList*>( p->children() ) );
1144 #endif
1120 return p; 1145 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
135 private: 135 private:
136
137 void dumpStructure( QObjectList* );
138 QString _dumpStructure( QObjectList* );
139
140 private:
136 const packetheaderstruct _hdr; // pcap packet header 141 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 )
341 341
342void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip )
343{
344 qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip );
345
346 //TODO: Refactor that out, we need it all over the place.
347 // Best to do it in a more comfortable abstraction in OListView
348 // (Hmm, didn't I already start something in this direction?)
349
350 QListViewItemIterator it( this );
351 for ( ; it.current(); ++it )
352 {
353 if ( it.current()->text( col_ap ) == macaddr.toString(true) )
354 {
355
356 MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() );
357
358 while ( subitem && ( subitem->text( col_essid ) != name ) )
359 {
360 #ifdef DEBUG
361 qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) );
362 #endif
363 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
364 }
365
366 if ( subitem )
367 {
368 // we have already seen this item, it's a dupe
369 #ifdef DEBUG
370 qDebug( "%s is a dupe - ignoring...", (const char*) name );
371 #endif
372 subitem->receivedBeacon(); //FIXME: sent data bit
373 return;
374 }
375
376 // never seen that - add new item
377
378 MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", false, -1, -1 );
379 item->setText( col_essid, name );
380
381 return;
382 }
383 }
384 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" );
385 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!",
386 (const char*) macaddr.toString(), (const char*) ip ) );
387}
388
389
342void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) 390void 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
44 void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location ); 44 void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location );
45 void addService( const QString& name, const OMacAddress& macaddr, const QString& ip );
45 46
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 )
196 196
197void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) 197void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to )
198{ 198{
@@ -202,2 +202,4 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
202 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 202 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
203 from = wlan->macAddress3();
204 to = wlan->macAddress2();
203 } 205 }
@@ -206,2 +208,4 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
206 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 208 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
209 from = wlan->macAddress2();
210 to = wlan->macAddress3();
207 } 211 }
@@ -210,2 +214,4 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
210 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 214 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
215 from = wlan->macAddress4();
216 to = wlan->macAddress3();
211 } 217 }
@@ -214,4 +220,19 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
214 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 220 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
221 from = wlan->macAddress2();
222 to = wlan->macAddress1();
215 } 223 }
224}
225
226
227void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
228{
229 from = data->sourceAddress();
230 to = data->destinationAddress();
231
232 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) );
233}
234
216 235
236void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
237{
217 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 238 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
@@ -231,6 +252,14 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
231 252
232 OIPPacket* ip = (OIPPacket*) p->child( "IP" ); 253 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
233 if ( ip ) 254 if ( dhcp )
234 { 255 {
235 qDebug( "Received IP packet." ); 256 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
257 if ( dhcp->type() == "OFFER" )
258 {
259 qDebug( "ADDSERVICE: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
260 //netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) );
261
262 netView()->identify( source, dhcp->serverAddress().toString() );
263 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
264 }
236 } 265 }
@@ -300,12 +329,29 @@ void Wellenreiter::receivePacket( OPacket* p )
300 329
330 OMacAddress source;
331 OMacAddress dest;
332
301 //TODO: WEP check here 333 //TODO: WEP check here
302 334
303 // check for a data frame 335 // check for a wireless data frame
304 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 336 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
305 if ( data ) 337 if ( wlan )
338 {
339 handleWlanData( p, wlan, source, dest );
340 }
341
342 // check for a wired data frame
343 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
344 if ( eth )
345 {
346 handleEthernetData( p, eth, source, dest );
347 }
348
349 // check for a ip frame
350 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
351 if ( ip )
306 { 352 {
307 handleData( p, data ); 353 handleIPData( p, ip, source, dest );
308 } 354 }
309 355
310 handleNotification( p ); 356 //handleNotification( p );
311 357
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;
30class OWaveLanDataPacket; 30class OWaveLanDataPacket;
31class OEthernetPacket;
32class OMacAddress;
33class OIPPacket;
31class OPacketCapturer; 34class OPacketCapturer;
@@ -70,3 +73,5 @@ class Wellenreiter : public WellenreiterBase {
70 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); 73 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon );
71 void handleData( OPacket* p, OWaveLanDataPacket* data ); 74 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to );
75 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to );
76 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to );
72 void handleNotification( OPacket* p ); 77 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