summaryrefslogtreecommitdiff
path: root/libopie2/opienet/opcap.cpp
authormickeyl <mickeyl>2003-04-22 22:11:28 (UTC)
committer mickeyl <mickeyl>2003-04-22 22:11:28 (UTC)
commita0ffe9079338a8b870de5267a22ddbb01cb1cc27 (patch) (side-by-side diff)
treefe240ab38bd11cd32d51674e4f79a465092476e5 /libopie2/opienet/opcap.cpp
parentbb8965d31b06ec122a0916d8c5bc4c4b68873a14 (diff)
downloadopie-a0ffe9079338a8b870de5267a22ddbb01cb1cc27.zip
opie-a0ffe9079338a8b870de5267a22ddbb01cb1cc27.tar.gz
opie-a0ffe9079338a8b870de5267a22ddbb01cb1cc27.tar.bz2
add prism header parsing capability!
Diffstat (limited to 'libopie2/opienet/opcap.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index e362883..675818e 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -36,64 +36,69 @@
#include <opie2/opcap.h>
/* QT */
#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
#include <qsocketnotifier.h>
#include <qobjectlist.h>
/*======================================================================================
* OPacket
*======================================================================================*/
OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
:QObject( parent, "Generic" ), _hdr( header ), _data( data )
{
//qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
_end = (unsigned char*) data + header.len;
//qDebug( "OPacket::data @ %0x, end @ %0x", data, _end );
switch ( datalink )
{
case DLT_EN10MB:
qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" );
new OEthernetPacket( _end, (const struct ether_header*) data, this );
break;
case DLT_IEEE802_11:
qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" );
new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this );
break;
+ case DLT_PRISM_HEADER:
+ qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" );
+ new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this );
+ break;
+
default:
qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink '%s'!", datalink );
}
}
OPacket::~OPacket()
{
}
timevalstruct OPacket::timeval() const
{
return _hdr.ts;
}
int OPacket::caplen() const
{
return _hdr.caplen;
}
void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l )
{
if (!l) return;
QObject* o = l->first();
while ( o )
{
stats[o->name()]++;
updateStats( stats, const_cast<QObjectList*>( o->children() ) );
o = l->next();
@@ -287,64 +292,90 @@ int OIPPacket::checksum() const
OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent )
:QObject( parent, "UDP" ), _udphdr( data )
{
qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." );
}
OUDPPacket::~OUDPPacket()
{
}
/*======================================================================================
* OTCPPacket
*======================================================================================*/
OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent )
:QObject( parent, "TCP" ), _tcphdr( data )
{
qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." );
}
OTCPPacket::~OTCPPacket()
{
}
/*======================================================================================
+ * OPrismHeaderPacket
+ *======================================================================================*/
+
+
+OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent )
+ :QObject( parent, "Prism" ), _header( data )
+
+{
+ qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." );
+
+ qDebug( "Signal Strength = %d", data->signal.data );
+
+ new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this );
+}
+
+OPrismHeaderPacket::~OPrismHeaderPacket()
+{
+}
+
+
+unsigned int OPrismHeaderPacket::signalStrength() const
+{
+ return _header->signal.data;
+}
+
+/*======================================================================================
* OWaveLanPacket
*======================================================================================*/
OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent )
:QObject( parent, "802.11" ), _wlanhdr( data )
{
qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." );
qDebug( "type: %0X", type() );
qDebug( "subType: %0X", subType() );
qDebug( "duration: %d", duration() );
qDebug( "powermanagement: %d", usesPowerManagement() );
qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" );
qDebug( "MAC1: %s", (const char*) macAddress1().toString() );
qDebug( "MAC2: %s", (const char*) macAddress2().toString() );
qDebug( "MAC3: %s", (const char*) macAddress3().toString() );
qDebug( "MAC4: %s", (const char*) macAddress4().toString() );
switch ( type() )
{
case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break;
case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break;
case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break;
default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() );
}
}
OWaveLanPacket::~OWaveLanPacket()
{
}