author | mickeyl <mickeyl> | 2004-03-12 13:04:07 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-03-12 13:04:07 (UTC) |
commit | d38384a6edb0110117e0297864f813b379d52789 (patch) (side-by-side diff) | |
tree | 82929ccdea4c9e30e39971beea1a9f4a51bc7b57 /libopie2/opienet/opcap.cpp | |
parent | 36d9d18055dbed7a85ab2979d1e96dfb4017560b (diff) | |
download | opie-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 );
-rw-r--r-- | libopie2/opienet/opcap.cpp | 21 |
1 files changed, 12 insertions, 9 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 @@ -105,24 +105,23 @@ void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) { stats[o->name()]++; updateStats( stats, const_cast<QObjectList*>( o->children() ) ); o = l->next(); } } -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; QObject* o = l->first(); QString str(" "); while ( o ) { str.append( o->name() ); @@ -174,16 +173,22 @@ QString OPacket::dump( int bpl ) const int OPacket::len() const { return _hdr.len; } +QTextStream& operator<<( QTextStream& s, const OPacket& p ) +{ + s << p.dumpStructure(); +} + + /*====================================================================================== * OEthernetPacket *======================================================================================*/ OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) :QObject( parent, "Ethernet" ), _ether( data ) { @@ -724,17 +729,17 @@ OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, co odebug << "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." << oendl; odebug << "Detected subtype is " << managementType() << oendl; // Grab tagged values. // Beacons contain a 12 byte long fixed parameters set before the tagged parameters come, // Other management frames don't - which is why we have to inspect the subtype here. const unsigned char* ptr = managementType() == "Beacon" ? (const unsigned char*) (_body+1) : (const unsigned char*) (_header+1); - + while (ptr < end) { switch ( *ptr ) { case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break; case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break; case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break; case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break; @@ -1183,19 +1188,17 @@ OPacket* OPacketCapturer::next() { OPacket* p = new OPacket( dataLink(), header, pdata, 0 ); // packets shouldn't be inserted in the QObject child-parent hierarchy, // because due to memory constraints they will be deleted as soon // as possible - that is right after they have been processed // by emit() [ see below ] //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; } else { owarn << "OPacketCapturer::next() - no packet received!" << oendl; return 0; } } @@ -1333,12 +1336,12 @@ int OPacketCapturer::snapShot() const bool OPacketCapturer::swapped() const { return pcap_is_swapped( _pch ); } 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 ) ); } |