summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-03-12 13:04:07 (UTC)
committer mickeyl <mickeyl>2004-03-12 13:04:07 (UTC)
commitd38384a6edb0110117e0297864f813b379d52789 (patch) (side-by-side diff)
tree82929ccdea4c9e30e39971beea1a9f4a51bc7b57
parent36d9d18055dbed7a85ab2979d1e96dfb4017560b (diff)
downloadopie-d38384a6edb0110117e0297864f813b379d52789.zip
opie-d38384a6edb0110117e0297864f813b379d52789.tar.gz
opie-d38384a6edb0110117e0297864f813b379d52789.tar.bz2
API change: OPacket::dumpStructure() now returns a QString and accepts void
API change: add QTextStream& operator<<( QTextStream& s, const OPacket& p );
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp21
-rw-r--r--libopie2/opienet/opcap.h35
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
@@ -111,12 +111,11 @@ 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() ) ) + " ]";
}
-QString OPacket::_dumpStructure( QObjectList* l )
+QString OPacket::_dumpStructure( QObjectList* l ) const
{
if (!l) return QString::null;
@@ -180,4 +179,10 @@ int OPacket::len() const
+QTextStream& operator<<( QTextStream& s, const OPacket& p )
+{
+ s << p.dumpStructure();
+}
+
+
/*======================================================================================
* OEthernetPacket
@@ -730,5 +735,5 @@ 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)
{
@@ -1189,7 +1194,5 @@ OPacket* OPacketCapturer::next()
//TODO: make gathering statistics optional, because it takes time
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;
}
@@ -1339,5 +1342,5 @@ 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
@@ -32,14 +32,6 @@
#define OPCAP_H
-/* 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>
/* QT */
@@ -49,13 +41,23 @@ extern "C" // work around a bpf/pcap conflict in recent headers
#include <qobject.h>
#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"
#include "dhcp.h"
+
/* TYPEDEFS */
typedef struct timeval timevalstruct;
@@ -117,4 +119,5 @@ class OPacket : public QObject
friend class OPacketCapturer;
+ friend QTextStream& operator<<( QTextStream& s, const OPacket& p );
public:
@@ -132,6 +135,6 @@ class OPacket : public QObject
private:
- void dumpStructure( QObjectList* );
- QString _dumpStructure( QObjectList* );
+ QString dumpStructure() const;
+ QString _dumpStructure( QObjectList* ) const;
private:
@@ -141,4 +144,6 @@ class OPacket : public QObject
};
+QTextStream& operator<<( QTextStream& s, const OPacket& p );
+
/*======================================================================================
* OEthernetPacket - DLT_EN10MB frame