author | mickeyl <mickeyl> | 2003-10-06 18:08:05 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-06 18:08:05 (UTC) |
commit | b8ac6724a0aaed78a1df712d87110fe39b16955f (patch) (unidiff) | |
tree | f8607b34284882bd4ce99281d0377f83b6b2c086 | |
parent | 42aefe8bc6a8089b771d6f109fed22a770295cc8 (diff) | |
download | opie-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.
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 16 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 2 |
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 | |||
@@ -230,13 +230,13 @@ void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAd | |||
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 | ||
236 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) | 236 | void 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" ) |
@@ -246,12 +246,18 @@ void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, | |||
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 | |||
255 | void 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" ) |
@@ -346,12 +352,20 @@ void Wellenreiter::receivePacket( OPacket* p ) | |||
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 | } |
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 | |||
@@ -26,12 +26,13 @@ using namespace Opie; | |||
26 | class QTimerEvent; | 26 | class QTimerEvent; |
27 | class QPixmap; | 27 | class QPixmap; |
28 | class OPacket; | 28 | class OPacket; |
29 | class OWaveLanManagementPacket; | 29 | class OWaveLanManagementPacket; |
30 | class OWaveLanDataPacket; | 30 | class OWaveLanDataPacket; |
31 | class OEthernetPacket; | 31 | class OEthernetPacket; |
32 | class OARPPacket; | ||
32 | class OMacAddress; | 33 | class OMacAddress; |
33 | class OIPPacket; | 34 | class OIPPacket; |
34 | class OPacketCapturer; | 35 | class OPacketCapturer; |
35 | class OWirelessNetworkInterface; | 36 | class OWirelessNetworkInterface; |
36 | class WellenreiterConfigWindow; | 37 | class WellenreiterConfigWindow; |
37 | class MLogWindow; | 38 | class MLogWindow; |
@@ -70,12 +71,13 @@ class Wellenreiter : public WellenreiterBase { | |||
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 | ||