summaryrefslogtreecommitdiff
path: root/libopie2/opienet/opcap.cpp
authormickeyl <mickeyl>2004-03-28 16:52:43 (UTC)
committer mickeyl <mickeyl>2004-03-28 16:52:43 (UTC)
commite2368b92a101437f7ed289d5ae62f7e7e2466344 (patch) (unidiff)
tree1e7775ee681d970c9cd785b9afb6946143c212e1 /libopie2/opienet/opcap.cpp
parent6c102bd456d760fbe237fd49ce46f212614f228a (diff)
downloadopie-e2368b92a101437f7ed289d5ae62f7e7e2466344.zip
opie-e2368b92a101437f7ed289d5ae62f7e7e2466344.tar.gz
opie-e2368b92a101437f7ed289d5ae62f7e7e2466344.tar.bz2
OPacketCapturer API addition: setAutoDelete() and autoDelete()
Diffstat (limited to 'libopie2/opienet/opcap.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp21
1 files changed, 17 insertions, 4 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
@@ -57,7 +57,7 @@ namespace Net {
57OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) 57OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
58 :QObject( parent, "Generic" ), _hdr( header ), _data( data ) 58 :QObject( parent, "Generic" ), _hdr( header ), _data( data )
59{ 59{
60 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); 60 qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
61 61
62 _end = (unsigned char*) data + header.len; 62 _end = (unsigned char*) data + header.len;
63 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); 63 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end );
@@ -87,6 +87,7 @@ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char*
87 87
88OPacket::~OPacket() 88OPacket::~OPacket()
89{ 89{
90 qDebug( "OPacket::~OPacket( %s )", name() );
90} 91}
91 92
92 93
@@ -1063,7 +1064,7 @@ QString OWaveLanControlPacket::controlType() const
1063 *======================================================================================*/ 1064 *======================================================================================*/
1064 1065
1065OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) 1066OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
1066 :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ) 1067 :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ), _autodelete( true )
1067{ 1068{
1068} 1069}
1069 1070
@@ -1078,6 +1079,18 @@ OPacketCapturer::~OPacketCapturer()
1078} 1079}
1079 1080
1080 1081
1082void OPacketCapturer::setAutoDelete( bool b )
1083{
1084 _autodelete = b;
1085}
1086
1087
1088bool OPacketCapturer::autoDelete() const
1089{
1090 return _autodelete;
1091}
1092
1093
1081void OPacketCapturer::setBlocking( bool b ) 1094void OPacketCapturer::setBlocking( bool b )
1082{ 1095{
1083 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) 1096 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 )
@@ -1321,8 +1334,8 @@ void OPacketCapturer::readyToReceive()
1321 odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl; 1334 odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl;
1322 OPacket* p = next(); 1335 OPacket* p = next();
1323 emit receivedPacket( p ); 1336 emit receivedPacket( p );
1324 // emit is synchronous - packet has been dealt with, now it's safe to delete 1337 // emit is synchronous - packet has been dealt with, now it's safe to delete (if enabled)
1325 delete p; 1338 if ( _autodelete ) delete p;
1326} 1339}
1327 1340
1328 1341