From d38384a6edb0110117e0297864f813b379d52789 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Fri, 12 Mar 2004 13:04:07 +0000 Subject: API change: OPacket::dumpStructure() now returns a QString and accepts void API change: add QTextStream& operator<<( QTextStream& s, const OPacket& p ); --- (limited to 'libopie2') diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 7463320..fdd519c 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp @@ -110,14 +110,13 @@ void OPacket::updateStats( QMap& stats, QObjectList* l ) } -void OPacket::dumpStructure( QObjectList* l ) +QString OPacket::dumpStructure() const { - QString packetString( "[ |" + _dumpStructure( l ) + " ]" ); - odebug << "OPacket::dumpStructure: " << packetString << oendl; + return "[ |" + _dumpStructure( const_cast( this->children() ) ) + " ]"; } -QString OPacket::_dumpStructure( QObjectList* l ) +QString OPacket::_dumpStructure( QObjectList* l ) const { if (!l) return QString::null; QObject* o = l->first(); @@ -179,6 +178,12 @@ int OPacket::len() const } +QTextStream& operator<<( QTextStream& s, const OPacket& p ) +{ + s << p.dumpStructure(); +} + + /*====================================================================================== * OEthernetPacket *======================================================================================*/ @@ -729,7 +734,7 @@ OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, co // Other management frames don't - which is why we have to inspect the subtype here. const unsigned char* ptr = managementType() == "Beacon" ? (const unsigned char*) (_body+1) : (const unsigned char*) (_header+1); - + while (ptr < end) { switch ( *ptr ) @@ -1188,9 +1193,7 @@ OPacket* OPacketCapturer::next() // by emit() [ see below ] //TODO: make gathering statistics optional, because it takes time p->updateStats( _stats, const_cast( p->children() ) ); - #ifndef NODEBUG - p->dumpStructure( const_cast( p->children() ) ); - #endif + odebug << "OPacket::dumpStructure: " << p->dumpStructure() << oendl; return p; } else @@ -1338,7 +1341,7 @@ bool OPacketCapturer::swapped() const QString OPacketCapturer::version() const { - return QString().sprintf( "%s.%s", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); + return QString().sprintf( "%d.%d", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); } diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index f5dc5c0..b873b49 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h @@ -31,16 +31,8 @@ #ifndef OPCAP_H #define OPCAP_H -/* LINUX */ -extern "C" // work around a bpf/pcap conflict in recent headers -{ - #include -} -#include -#include -#include -#include -#include +/* OPIE */ +#include /* QT */ #include @@ -48,15 +40,25 @@ extern "C" // work around a bpf/pcap conflict in recent headers #include #include #include +#include #include -/* OPIE */ -#include +/* STD */ +extern "C" // work around a bpf/pcap conflict in recent headers +{ + #include +} +#include +#include +#include +#include +#include -/* Custom Network Includes */ +/* Custom Network Includes (must go here, don't reorder!) */ #include "802_11_user.h" #include "dhcp.h" + /* TYPEDEFS */ typedef struct timeval timevalstruct; typedef struct pcap_pkthdr packetheaderstruct; @@ -116,6 +118,7 @@ class OPacket : public QObject Q_OBJECT friend class OPacketCapturer; + friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); public: OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); @@ -131,8 +134,8 @@ class OPacket : public QObject private: - void dumpStructure( QObjectList* ); - QString _dumpStructure( QObjectList* ); + QString dumpStructure() const; + QString _dumpStructure( QObjectList* ) const; private: const packetheaderstruct _hdr; // pcap packet header @@ -140,6 +143,8 @@ class OPacket : public QObject const unsigned char* _end; // end of pcap packet data }; +QTextStream& operator<<( QTextStream& s, const OPacket& p ); + /*====================================================================================== * OEthernetPacket - DLT_EN10MB frame *======================================================================================*/ -- cgit v0.9.0.2