summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-06 18:08:05 (UTC)
committer mickeyl <mickeyl>2003-10-06 18:08:05 (UTC)
commitb8ac6724a0aaed78a1df712d87110fe39b16955f (patch) (side-by-side diff)
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
@@ -212,64 +212,70 @@ void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAdd
else if ( wlan->fromDS() && wlan->toDS() )
{
netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
from = wlan->macAddress4();
to = wlan->macAddress3();
}
else
{
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 )
+void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest )
{
OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
if ( arp )
{
qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
if ( arp->type() == "REQUEST" )
{
netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
}
else if ( arp->type() == "REPLY" )
{
netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
}
}
+}
+
+
+void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
+{
+ //TODO: Implement more IP based protocols
ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
if ( dhcp )
{
qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
if ( dhcp->type() == "OFFER" )
{
qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
netView()->identify( source, dhcp->serverAddress().toString() );
netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
}
else if ( dhcp->type() == "ACK" )
{
qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() );
netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
}
}
}
QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
{
if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
@@ -328,48 +334,56 @@ void Wellenreiter::receivePacket( OPacket* p )
{
handleBeacon( p, beacon );
return;
}
OMacAddress source;
OMacAddress dest;
//TODO: WEP check here
// 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 an arp frame since arp frames come in two flavours:
+ // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
+ OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
+ if ( arp )
+ {
+ handleARPData( p, arp, source, dest );
+ }
+
// check for a ip frame
OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
if ( ip )
{
handleIPData( p, ip, source, dest );
}
//handleNotification( p );
}
void Wellenreiter::stopClicked()
{
if ( iface )
{
disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
iface->setChannelHopping(); // stop hopping channels
}
else
killTimers();
pcap->close();
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
@@ -8,91 +8,93 @@
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#ifndef WELLENREITER_H
#define WELLENREITER_H
#include "wellenreiterbase.h"
#ifdef QWS
#include <opie/odevice.h>
using namespace Opie;
#endif
class QTimerEvent;
class QPixmap;
class OPacket;
class OWaveLanManagementPacket;
class OWaveLanDataPacket;
class OEthernetPacket;
+class OARPPacket;
class OMacAddress;
class OIPPacket;
class OPacketCapturer;
class OWirelessNetworkInterface;
class WellenreiterConfigWindow;
class MLogWindow;
class MHexWindow;
class GPS;
class Wellenreiter : public WellenreiterBase {
Q_OBJECT
public:
Wellenreiter( QWidget* parent = 0 );
~Wellenreiter();
void setConfigWindow( WellenreiterConfigWindow* cw );
MScanListView* netView() const { return netview; };
MLogWindow* logWindow() const { return logwindow; };
MHexWindow* hexWindow() const { return hexwindow; };
bool isDaemonRunning() const { return sniffing; };
public:
bool sniffing;
protected:
virtual void timerEvent( QTimerEvent* );
public slots:
void channelHopped(int);
void receivePacket(OPacket*);
void startClicked();
void stopClicked();
void joinNetwork(const QString&,const QString&,int,const QString&);
signals:
void startedSniffing();
void stoppedSniffing();
private:
void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon );
void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to );
void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to );
+ void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to );
void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to );
void handleNotification( OPacket* p );
void doAction( const QString& action, const QString& protocol, OPacket* p );
QObject* childIfToParse( OPacket* p, const QString& protocol );
bool checkDumpPacket( OPacket* p );
private:
#ifdef QWS
OSystem _system; // Opie Operating System identifier
#endif
OWirelessNetworkInterface* iface;
OPacketCapturer* pcap;
WellenreiterConfigWindow* configwindow;
GPS* gps;
//void readConfig();
//void writeConfig();
};
#endif