-rw-r--r-- | libopie2/opienet/opcap.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 8184f21..03e4502 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp @@ -47,97 +47,97 @@ using namespace Opie::Core; #include <unistd.h> #include <string.h> namespace Opie { namespace Net { /*====================================================================================== * OPacket *======================================================================================*/ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) :QObject( parent, "Generic" ), _hdr( header ), _data( 0 ) { _data = new unsigned char[ header.len ]; assert( _data ); memcpy( const_cast<unsigned char*>(_data), data, header.len ); // We have to copy the data structure here, because the 'data' pointer handed by libpcap // points to an internal region which is reused by lipcap. odebug << "OPacket: Length = " << header.len << ", Caplen = " << header.caplen << oendl; _end = (unsigned char*) _data + header.len; switch ( datalink ) { case DLT_EN10MB: odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl; new OEthernetPacket( _end, (const struct ether_header*) _data, this ); break; case DLT_IEEE802_11: odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl; new OWaveLanPacket( _end, (const struct ieee_802_11_header*) _data, this ); break; case DLT_PRISM_HEADER: odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl; new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) _data, this ); break; default: owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl; } } OPacket::~OPacket() { odebug << "~OPacket( " << name() << " )" << oendl; - delete _data; + delete [] _data; } timevalstruct OPacket::timeval() const { return _hdr.ts; } int OPacket::caplen() const { return _hdr.caplen; } void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) { if (!l) return; QObject* o = l->first(); while ( o ) { stats[o->name()]++; updateStats( stats, const_cast<QObjectList*>( o->children() ) ); o = l->next(); } } QString OPacket::dumpStructure() const { return "[ |" + _dumpStructure( const_cast<QObjectList*>( this->children() ) ) + " ]"; } QString OPacket::_dumpStructure( QObjectList* l ) const { if (!l) return QString::null; QObject* o = l->first(); QString str(" "); while ( o ) { str.append( o->name() ); str.append( " |" ); str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); o = l->next(); } return str; |