summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp21
-rw-r--r--libopie2/opienet/opcap.h16
2 files changed, 31 insertions, 6 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 4081d4f..c5df041 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -59,3 +59,3 @@ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char*
{
- //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
+ qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
@@ -89,2 +89,3 @@ OPacket::~OPacket()
{
+ qDebug( "OPacket::~OPacket( %s )", name() );
}
@@ -1065,3 +1066,3 @@ QString OWaveLanControlPacket::controlType() const
OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
- :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 )
+ :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ), _autodelete( true )
{
@@ -1080,2 +1081,14 @@ OPacketCapturer::~OPacketCapturer()
+void OPacketCapturer::setAutoDelete( bool b )
+{
+ _autodelete = b;
+}
+
+
+bool OPacketCapturer::autoDelete() const
+{
+ return _autodelete;
+}
+
+
void OPacketCapturer::setBlocking( bool b )
@@ -1323,4 +1336,4 @@ void OPacketCapturer::readyToReceive()
emit receivedPacket( p );
- // emit is synchronous - packet has been dealt with, now it's safe to delete
- delete p;
+ // emit is synchronous - packet has been dealt with, now it's safe to delete (if enabled)
+ if ( _autodelete ) delete p;
}
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 72a78de..4ff8495 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -136,5 +136,4 @@ class OPacket : public QObject
- private:
-
QString dumpStructure() const;
+ private:
QString _dumpStructure( QObjectList* ) const;
@@ -695,2 +694,14 @@ class OPacketCapturer : public QObject
const QMap<QString,int>& statistics() const;
+ /**
+ * Enable or disable the auto-delete option.
+ * If auto-delete is enabled, then the packet capturer will delete a packet right
+ * after it has been emit'ted. This is the default, which is useful if the packet
+ * capturer has the only reference to the packets. If you pass the packet for adding
+ * into a collection or do processing after the SLOT, the auto delete must be disabled.
+ */
+ void setAutoDelete( bool enable );
+ /**
+ * @returns the auto-delete value.
+ */
+ bool autoDelete() const;
@@ -713,2 +724,3 @@ class OPacketCapturer : public QObject
QMap<QString, int> _stats; // statistics;
+ bool _autodelete; // if we auto delete packets after emit
class Private; // Private Forward declaration