-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 | |||
@@ -119,84 +119,82 @@ void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) | |||
119 | o = l->next(); | 119 | o = l->next(); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | QString OPacket::dumpStructure() const | 124 | QString OPacket::dumpStructure() const |
125 | { | 125 | { |
126 | return "[ |" + _dumpStructure( const_cast<QObjectList*>( this->children() ) ) + " ]"; | 126 | return "[ |" + _dumpStructure( const_cast<QObjectList*>( this->children() ) ) + " ]"; |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | QString OPacket::_dumpStructure( QObjectList* l ) const | 130 | QString OPacket::_dumpStructure( QObjectList* l ) const |
131 | { | 131 | { |
132 | if (!l) return QString::null; | 132 | if (!l) return QString::null; |
133 | QObject* o = l->first(); | 133 | QObject* o = l->first(); |
134 | QString str(" "); | 134 | QString str(" "); |
135 | 135 | ||
136 | while ( o ) | 136 | while ( o ) |
137 | { | 137 | { |
138 | str.append( o->name() ); | 138 | str.append( o->name() ); |
139 | str.append( " |" ); | 139 | str.append( " |" ); |
140 | str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); | 140 | str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); |
141 | o = l->next(); | 141 | o = l->next(); |
142 | } | 142 | } |
143 | return str; | 143 | return str; |
144 | } | 144 | } |
145 | 145 | ||
146 | QString OPacket::dump( int bpl ) const | 146 | QString OPacket::dump( int bpl ) const |
147 | { | 147 | { |
148 | static int index = 0; | 148 | static int index = 0; |
149 | index++; | 149 | index++; |
150 | int len = _hdr.caplen; | 150 | int len = _hdr.caplen; |
151 | QString str; | 151 | QString str( "000:" ); |
152 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); | ||
153 | str.append( "0000: " ); | ||
154 | QString tmp; | 152 | QString tmp; |
155 | QString bytes; | 153 | QString bytes; |
156 | QString chars; | 154 | QString chars; |
157 | 155 | ||
158 | for ( int i = 0; i < len; ++i ) | 156 | for ( int i = 0; i < len; ++i ) |
159 | { | 157 | { |
160 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); | 158 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); |
161 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); | 159 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); |
162 | else chars.append( '.' ); | 160 | else chars.append( '.' ); |
163 | 161 | ||
164 | if ( !((i+1) % bpl) ) | 162 | if ( !((i+1) % bpl) ) |
165 | { | 163 | { |
166 | str.append( bytes ); | 164 | str.append( bytes ); |
167 | str.append( ' ' ); | 165 | str.append( ' ' ); |
168 | str.append( chars ); | 166 | str.append( chars ); |
169 | str.append( '\n' ); | 167 | str.append( '\n' ); |
170 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); | 168 | tmp.sprintf( "%03X:", i+1 ); str.append( tmp ); |
171 | bytes = ""; | 169 | bytes = ""; |
172 | chars = ""; | 170 | chars = ""; |
173 | } | 171 | } |
174 | 172 | ||
175 | } | 173 | } |
176 | if ( (len % bpl) ) | 174 | if ( (len % bpl) ) |
177 | { | 175 | { |
178 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); | 176 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); |
179 | str.append( chars ); | 177 | str.append( chars ); |
180 | } | 178 | } |
181 | str.append( '\n' ); | 179 | str.append( '\n' ); |
182 | return str; | 180 | return str; |
183 | } | 181 | } |
184 | 182 | ||
185 | 183 | ||
186 | int OPacket::len() const | 184 | int OPacket::len() const |
187 | { | 185 | { |
188 | return _hdr.len; | 186 | return _hdr.len; |
189 | } | 187 | } |
190 | 188 | ||
191 | 189 | ||
192 | QTextStream& operator<<( QTextStream& s, const OPacket& p ) | 190 | QTextStream& operator<<( QTextStream& s, const OPacket& p ) |
193 | { | 191 | { |
194 | s << p.dumpStructure(); | 192 | s << p.dumpStructure(); |
195 | } | 193 | } |
196 | 194 | ||
197 | 195 | ||
198 | /*====================================================================================== | 196 | /*====================================================================================== |
199 | * OEthernetPacket | 197 | * OEthernetPacket |
200 | *======================================================================================*/ | 198 | *======================================================================================*/ |
201 | 199 | ||
202 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) | 200 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) |