From 634a68b636a0fa24232029b79ffa915a5621b2be Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sun, 05 Oct 2003 13:12:45 +0000 Subject: * start with preparations for scanning wired networks * dhcp recognition now works nicely --- (limited to 'libopie2/opienet') diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index 08c40b4..ad0e89d 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp @@ -58,8 +58,13 @@ const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); +//TODO: Incorporate Ethernet Manufacturer database here! (inline or so) + +OMacAddress::OMacAddress() +{ + memcpy( _bytes, __unknown, 6 ); +} -//TODO: Incorporate Ethernet Manufacturer database here! OMacAddress::OMacAddress( unsigned char* p ) { diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index 9611518..18731ba 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h @@ -51,6 +51,7 @@ class OMacAddress { public: // QString c'tor? -zecke + OMacAddress(); OMacAddress( unsigned char* ); OMacAddress( const unsigned char* ); OMacAddress( struct ifreq& ); diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 7a6f61b..313f5bb 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp @@ -108,6 +108,29 @@ void OPacket::updateStats( QMap& stats, QObjectList* l ) } +void OPacket::dumpStructure( QObjectList* l ) +{ + QString packetString( "[ |" + _dumpStructure( l ) + " ]" ); + qDebug( "OPacket::dumpStructure: %s", (const char*) packetString ); +} + + +QString OPacket::_dumpStructure( QObjectList* l ) +{ + if (!l) return QString::null; + QObject* o = l->first(); + QString str(" "); + + while ( o ) + { + str.append( o->name() ); + str.append( " |" ); + str += _dumpStructure( const_cast( o->children() ) ); + o = l->next(); + } + return str; +} + QString OPacket::dump( int bpl ) const { static int index = 0; @@ -1116,7 +1139,9 @@ OPacket* OPacketCapturer::next() // by emit() [ see below ] //TODO: make gathering statistics optional, because it takes time p->updateStats( _stats, const_cast( p->children() ) ); - + #ifndef NODEBUG + p->dumpStructure( const_cast( p->children() ) ); + #endif return p; } else diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index a031dd1..f0d1d81 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h @@ -133,6 +133,11 @@ class OPacket : public QObject void updateStats( QMap&, QObjectList* ); private: + + void dumpStructure( QObjectList* ); + QString _dumpStructure( QObjectList* ); + + private: const packetheaderstruct _hdr; // pcap packet header const unsigned char* _data; // pcap packet data const unsigned char* _end; // end of pcap packet data -- cgit v0.9.0.2