-rw-r--r-- | libopie2/opienet/opcap.cpp | 21 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 35 |
2 files changed, 32 insertions, 24 deletions
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 @@ -112,6 +112,5 @@ void OPacket::updateStats( QMap<QString,int>& 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<QObjectList*>( this->children() ) ) + " ]"; } @@ -119,3 +118,3 @@ void OPacket::dumpStructure( QObjectList* l ) -QString OPacket::_dumpStructure( QObjectList* l ) +QString OPacket::_dumpStructure( QObjectList* l ) const { @@ -181,2 +180,8 @@ int OPacket::len() const +QTextStream& operator<<( QTextStream& s, const OPacket& p ) +{ + s << p.dumpStructure(); +} + + /*====================================================================================== @@ -731,3 +736,3 @@ OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, co const unsigned char* ptr = managementType() == "Beacon" ? (const unsigned char*) (_body+1) : (const unsigned char*) (_header+1); - + while (ptr < end) @@ -1190,5 +1195,3 @@ OPacket* OPacketCapturer::next() p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); - #ifndef NODEBUG - p->dumpStructure( const_cast<QObjectList*>( p->children() ) ); - #endif + odebug << "OPacket::dumpStructure: " << p->dumpStructure() << oendl; return p; @@ -1340,3 +1343,3 @@ 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 @@ -33,12 +33,4 @@ -/* LINUX */ -extern "C" // work around a bpf/pcap conflict in recent headers -{ - #include <pcap.h> -} -#include <netinet/ether.h> -#include <netinet/ip.h> -#include <netinet/udp.h> -#include <netinet/tcp.h> -#include <time.h> +/* OPIE */ +#include <opie2/onetutils.h> @@ -50,8 +42,17 @@ extern "C" // work around a bpf/pcap conflict in recent headers #include <qstring.h> +#include <qtextstream.h> #include <qmap.h> -/* OPIE */ -#include <opie2/onetutils.h> +/* STD */ +extern "C" // work around a bpf/pcap conflict in recent headers +{ + #include <pcap.h> +} +#include <netinet/ether.h> +#include <netinet/ip.h> +#include <netinet/udp.h> +#include <netinet/tcp.h> +#include <time.h> -/* Custom Network Includes */ +/* Custom Network Includes (must go here, don't reorder!) */ #include "802_11_user.h" @@ -59,2 +60,3 @@ extern "C" // work around a bpf/pcap conflict in recent headers + /* TYPEDEFS */ @@ -118,2 +120,3 @@ class OPacket : public QObject friend class OPacketCapturer; + friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); @@ -133,4 +136,4 @@ class OPacket : public QObject - void dumpStructure( QObjectList* ); - QString _dumpStructure( QObjectList* ); + QString dumpStructure() const; + QString _dumpStructure( QObjectList* ) const; @@ -142,2 +145,4 @@ class OPacket : public QObject +QTextStream& operator<<( QTextStream& s, const OPacket& p ); + /*====================================================================================== |