summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-06 18:08:05 (UTC)
committer mickeyl <mickeyl>2003-10-06 18:08:05 (UTC)
commitb8ac6724a0aaed78a1df712d87110fe39b16955f (patch) (unidiff)
treef8607b34284882bd4ce99281d0377f83b6b2c086
parent42aefe8bc6a8089b771d6f109fed22a770295cc8 (diff)
downloadopie-b8ac6724a0aaed78a1df712d87110fe39b16955f.zip
opie-b8ac6724a0aaed78a1df712d87110fe39b16955f.tar.gz
opie-b8ac6724a0aaed78a1df712d87110fe39b16955f.tar.bz2
fix ARP decoding for wired networks. Interestingly, 802.11 encapsulates
these in IP packets, while wired ethernet just tags the type_of_protocol.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp16
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h2
2 files changed, 17 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 9460f56..60bf231 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -220,48 +220,54 @@ void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAdd
220 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 220 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
221 from = wlan->macAddress2(); 221 from = wlan->macAddress2();
222 to = wlan->macAddress1(); 222 to = wlan->macAddress1();
223 } 223 }
224} 224}
225 225
226 226
227void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) 227void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
228{ 228{
229 from = data->sourceAddress(); 229 from = data->sourceAddress();
230 to = data->destinationAddress(); 230 to = data->destinationAddress();
231 231
232 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); 232 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) );
233} 233}
234 234
235 235
236void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) 236void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest )
237{ 237{
238 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 238 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
239 if ( arp ) 239 if ( arp )
240 { 240 {
241 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); 241 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
242 if ( arp->type() == "REQUEST" ) 242 if ( arp->type() == "REQUEST" )
243 { 243 {
244 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 244 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
245 } 245 }
246 else if ( arp->type() == "REPLY" ) 246 else if ( arp->type() == "REPLY" )
247 { 247 {
248 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 248 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
249 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 249 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
250 } 250 }
251 } 251 }
252}
253
254
255void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
256{
257 //TODO: Implement more IP based protocols
252 258
253 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 259 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
254 if ( dhcp ) 260 if ( dhcp )
255 { 261 {
256 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); 262 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
257 if ( dhcp->type() == "OFFER" ) 263 if ( dhcp->type() == "OFFER" )
258 { 264 {
259 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); 265 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
260 netView()->identify( source, dhcp->serverAddress().toString() ); 266 netView()->identify( source, dhcp->serverAddress().toString() );
261 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 267 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
262 } 268 }
263 else if ( dhcp->type() == "ACK" ) 269 else if ( dhcp->type() == "ACK" )
264 { 270 {
265 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); 271 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() );
266 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 272 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
267 } 273 }
@@ -336,32 +342,40 @@ void Wellenreiter::receivePacket( OPacket* p )
336 //TODO: WEP check here 342 //TODO: WEP check here
337 343
338 // check for a wireless data frame 344 // check for a wireless data frame
339 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 345 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
340 if ( wlan ) 346 if ( wlan )
341 { 347 {
342 handleWlanData( p, wlan, source, dest ); 348 handleWlanData( p, wlan, source, dest );
343 } 349 }
344 350
345 // check for a wired data frame 351 // check for a wired data frame
346 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); 352 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
347 if ( eth ) 353 if ( eth )
348 { 354 {
349 handleEthernetData( p, eth, source, dest ); 355 handleEthernetData( p, eth, source, dest );
350 } 356 }
351 357
358 // check for an arp frame since arp frames come in two flavours:
359 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
360 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
361 if ( arp )
362 {
363 handleARPData( p, arp, source, dest );
364 }
365
352 // check for a ip frame 366 // check for a ip frame
353 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); 367 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
354 if ( ip ) 368 if ( ip )
355 { 369 {
356 handleIPData( p, ip, source, dest ); 370 handleIPData( p, ip, source, dest );
357 } 371 }
358 372
359 //handleNotification( p ); 373 //handleNotification( p );
360 374
361} 375}
362 376
363 377
364void Wellenreiter::stopClicked() 378void Wellenreiter::stopClicked()
365{ 379{
366 if ( iface ) 380 if ( iface )
367 { 381 {
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index ed96375..25a5e8d 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -16,32 +16,33 @@
16#ifndef WELLENREITER_H 16#ifndef WELLENREITER_H
17#define WELLENREITER_H 17#define WELLENREITER_H
18 18
19#include "wellenreiterbase.h" 19#include "wellenreiterbase.h"
20 20
21#ifdef QWS 21#ifdef QWS
22#include <opie/odevice.h> 22#include <opie/odevice.h>
23using namespace Opie; 23using namespace Opie;
24#endif 24#endif
25 25
26class QTimerEvent; 26class QTimerEvent;
27class QPixmap; 27class QPixmap;
28class OPacket; 28class OPacket;
29class OWaveLanManagementPacket; 29class OWaveLanManagementPacket;
30class OWaveLanDataPacket; 30class OWaveLanDataPacket;
31class OEthernetPacket; 31class OEthernetPacket;
32class OARPPacket;
32class OMacAddress; 33class OMacAddress;
33class OIPPacket; 34class OIPPacket;
34class OPacketCapturer; 35class OPacketCapturer;
35class OWirelessNetworkInterface; 36class OWirelessNetworkInterface;
36class WellenreiterConfigWindow; 37class WellenreiterConfigWindow;
37class MLogWindow; 38class MLogWindow;
38class MHexWindow; 39class MHexWindow;
39class GPS; 40class GPS;
40 41
41class Wellenreiter : public WellenreiterBase { 42class Wellenreiter : public WellenreiterBase {
42 Q_OBJECT 43 Q_OBJECT
43 44
44 public: 45 public:
45 Wellenreiter( QWidget* parent = 0 ); 46 Wellenreiter( QWidget* parent = 0 );
46 ~Wellenreiter(); 47 ~Wellenreiter();
47 48
@@ -60,32 +61,33 @@ class Wellenreiter : public WellenreiterBase {
60 public slots: 61 public slots:
61 void channelHopped(int); 62 void channelHopped(int);
62 void receivePacket(OPacket*); 63 void receivePacket(OPacket*);
63 void startClicked(); 64 void startClicked();
64 void stopClicked(); 65 void stopClicked();
65 66
66 void joinNetwork(const QString&,const QString&,int,const QString&); 67 void joinNetwork(const QString&,const QString&,int,const QString&);
67 68
68 signals: 69 signals:
69 void startedSniffing(); 70 void startedSniffing();
70 void stoppedSniffing(); 71 void stoppedSniffing();
71 72
72 private: 73 private:
73 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); 74 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon );
74 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ); 75 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to );
75 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ); 76 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to );
77 void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to );
76 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to ); 78 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to );
77 void handleNotification( OPacket* p ); 79 void handleNotification( OPacket* p );
78 void doAction( const QString& action, const QString& protocol, OPacket* p ); 80 void doAction( const QString& action, const QString& protocol, OPacket* p );
79 QObject* childIfToParse( OPacket* p, const QString& protocol ); 81 QObject* childIfToParse( OPacket* p, const QString& protocol );
80 bool checkDumpPacket( OPacket* p ); 82 bool checkDumpPacket( OPacket* p );
81 83
82 private: 84 private:
83 #ifdef QWS 85 #ifdef QWS
84 OSystem _system; // Opie Operating System identifier 86 OSystem _system; // Opie Operating System identifier
85 #endif 87 #endif
86 88
87 OWirelessNetworkInterface* iface; 89 OWirelessNetworkInterface* iface;
88 OPacketCapturer* pcap; 90 OPacketCapturer* pcap;
89 WellenreiterConfigWindow* configwindow; 91 WellenreiterConfigWindow* configwindow;
90 GPS* gps; 92 GPS* gps;
91 93