author | mickeyl <mickeyl> | 2004-05-02 19:17:27 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-05-02 19:17:27 (UTC) |
commit | 8602449caa5a055bd5f033e3792d0a59a0b41bfa (patch) (side-by-side diff) | |
tree | 17f60677ff09e89eb270f1e6cc837687b0eab871 | |
parent | 3e8fab5fddb3a38d93eaca1a8d69d8f668c7cd99 (diff) | |
download | opie-8602449caa5a055bd5f033e3792d0a59a0b41bfa.zip opie-8602449caa5a055bd5f033e3792d0a59a0b41bfa.tar.gz opie-8602449caa5a055bd5f033e3792d0a59a0b41bfa.tar.bz2 |
dump takes less space now
NOTE: I think dump really doesn't belong here
-rw-r--r-- | libopie2/opienet/opcap.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 8ec4f47..8184f21 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp @@ -103,116 +103,114 @@ timevalstruct OPacket::timeval() const 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; } QString OPacket::dump( int bpl ) const { static int index = 0; index++; int len = _hdr.caplen; - QString str; - str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); - str.append( "0000: " ); + QString str( "000:" ); QString tmp; QString bytes; QString chars; for ( int i = 0; i < len; ++i ) { tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); else chars.append( '.' ); if ( !((i+1) % bpl) ) { str.append( bytes ); str.append( ' ' ); str.append( chars ); str.append( '\n' ); - tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); + tmp.sprintf( "%03X:", i+1 ); str.append( tmp ); bytes = ""; chars = ""; } } if ( (len % bpl) ) { str.append( bytes.leftJustify( 1 + 3*bpl ) ); str.append( chars ); } str.append( '\n' ); return str; } 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 ) { odebug << "Source = " << sourceAddress().toString() << oendl; odebug << "Destination = " << destinationAddress().toString() << oendl; if ( sourceAddress() == OMacAddress::broadcast ) odebug << "Source is broadcast address" << oendl; if ( destinationAddress() == OMacAddress::broadcast ) odebug << "Destination is broadcast address" << oendl; switch ( type() ) { case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } |