author | mickeyl <mickeyl> | 2004-05-02 18:14:46 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-05-02 18:14:46 (UTC) |
commit | 3e8fab5fddb3a38d93eaca1a8d69d8f668c7cd99 (patch) (unidiff) | |
tree | 4ea10a8f334f5af1133c9e762462701fb38b4f76 | |
parent | 1ddcf3566b3339bb649b07b64bd5802b735f37ba (diff) | |
download | opie-3e8fab5fddb3a38d93eaca1a8d69d8f668c7cd99.zip opie-3e8fab5fddb3a38d93eaca1a8d69d8f668c7cd99.tar.gz opie-3e8fab5fddb3a38d93eaca1a8d69d8f668c7cd99.tar.bz2 |
fix one odebug warning
-rw-r--r-- | libopie2/opienet/opcap.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index a9dc577..8ec4f47 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -78,258 +78,258 @@ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* | |||
78 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) _data, this ); | 78 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) _data, this ); |
79 | break; | 79 | break; |
80 | 80 | ||
81 | case DLT_PRISM_HEADER: | 81 | case DLT_PRISM_HEADER: |
82 | odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl; | 82 | odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl; |
83 | new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) _data, this ); | 83 | new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) _data, this ); |
84 | break; | 84 | break; |
85 | 85 | ||
86 | default: | 86 | default: |
87 | owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl; | 87 | owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | OPacket::~OPacket() | 92 | OPacket::~OPacket() |
93 | { | 93 | { |
94 | odebug << "~OPacket( " << name() << " )" << oendl; | 94 | odebug << "~OPacket( " << name() << " )" << oendl; |
95 | delete _data; | 95 | delete _data; |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | timevalstruct OPacket::timeval() const | 99 | timevalstruct OPacket::timeval() const |
100 | { | 100 | { |
101 | return _hdr.ts; | 101 | return _hdr.ts; |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | int OPacket::caplen() const | 105 | int OPacket::caplen() const |
106 | { | 106 | { |
107 | return _hdr.caplen; | 107 | return _hdr.caplen; |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) | 111 | void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) |
112 | { | 112 | { |
113 | if (!l) return; | 113 | if (!l) return; |
114 | QObject* o = l->first(); | 114 | QObject* o = l->first(); |
115 | while ( o ) | 115 | while ( o ) |
116 | { | 116 | { |
117 | stats[o->name()]++; | 117 | stats[o->name()]++; |
118 | updateStats( stats, const_cast<QObjectList*>( o->children() ) ); | 118 | updateStats( stats, const_cast<QObjectList*>( o->children() ) ); |
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; |
152 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); | 152 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); |
153 | str.append( "0000: " ); | 153 | str.append( "0000: " ); |
154 | QString tmp; | 154 | QString tmp; |
155 | QString bytes; | 155 | QString bytes; |
156 | QString chars; | 156 | QString chars; |
157 | 157 | ||
158 | for ( int i = 0; i < len; ++i ) | 158 | for ( int i = 0; i < len; ++i ) |
159 | { | 159 | { |
160 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); | 160 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); |
161 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); | 161 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); |
162 | else chars.append( '.' ); | 162 | else chars.append( '.' ); |
163 | 163 | ||
164 | if ( !((i+1) % bpl) ) | 164 | if ( !((i+1) % bpl) ) |
165 | { | 165 | { |
166 | str.append( bytes ); | 166 | str.append( bytes ); |
167 | str.append( ' ' ); | 167 | str.append( ' ' ); |
168 | str.append( chars ); | 168 | str.append( chars ); |
169 | str.append( '\n' ); | 169 | str.append( '\n' ); |
170 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); | 170 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); |
171 | bytes = ""; | 171 | bytes = ""; |
172 | chars = ""; | 172 | chars = ""; |
173 | } | 173 | } |
174 | 174 | ||
175 | } | 175 | } |
176 | if ( (len % bpl) ) | 176 | if ( (len % bpl) ) |
177 | { | 177 | { |
178 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); | 178 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); |
179 | str.append( chars ); | 179 | str.append( chars ); |
180 | } | 180 | } |
181 | str.append( '\n' ); | 181 | str.append( '\n' ); |
182 | return str; | 182 | return str; |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
186 | int OPacket::len() const | 186 | int OPacket::len() const |
187 | { | 187 | { |
188 | return _hdr.len; | 188 | return _hdr.len; |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | QTextStream& operator<<( QTextStream& s, const OPacket& p ) | 192 | QTextStream& operator<<( QTextStream& s, const OPacket& p ) |
193 | { | 193 | { |
194 | s << p.dumpStructure(); | 194 | s << p.dumpStructure(); |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | /*====================================================================================== | 198 | /*====================================================================================== |
199 | * OEthernetPacket | 199 | * OEthernetPacket |
200 | *======================================================================================*/ | 200 | *======================================================================================*/ |
201 | 201 | ||
202 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) | 202 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) |
203 | :QObject( parent, "Ethernet" ), _ether( data ) | 203 | :QObject( parent, "Ethernet" ), _ether( data ) |
204 | { | 204 | { |
205 | 205 | ||
206 | odebug << "Source = " << sourceAddress().toString(); | 206 | odebug << "Source = " << sourceAddress().toString() << oendl; |
207 | odebug << "Destination = " << destinationAddress().toString(); | 207 | odebug << "Destination = " << destinationAddress().toString() << oendl; |
208 | 208 | ||
209 | if ( sourceAddress() == OMacAddress::broadcast ) | 209 | if ( sourceAddress() == OMacAddress::broadcast ) |
210 | odebug << "Source is broadcast address" << oendl; | 210 | odebug << "Source is broadcast address" << oendl; |
211 | if ( destinationAddress() == OMacAddress::broadcast ) | 211 | if ( destinationAddress() == OMacAddress::broadcast ) |
212 | odebug << "Destination is broadcast address" << oendl; | 212 | odebug << "Destination is broadcast address" << oendl; |
213 | 213 | ||
214 | switch ( type() ) | 214 | switch ( type() ) |
215 | { | 215 | { |
216 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; | 216 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; |
217 | case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; | 217 | case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; |
218 | case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } | 218 | case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } |
219 | default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl; | 219 | default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl; |
220 | } | 220 | } |
221 | 221 | ||
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | OEthernetPacket::~OEthernetPacket() | 225 | OEthernetPacket::~OEthernetPacket() |
226 | { | 226 | { |
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | OMacAddress OEthernetPacket::sourceAddress() const | 230 | OMacAddress OEthernetPacket::sourceAddress() const |
231 | { | 231 | { |
232 | return OMacAddress( _ether->ether_shost ); | 232 | return OMacAddress( _ether->ether_shost ); |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | OMacAddress OEthernetPacket::destinationAddress() const | 236 | OMacAddress OEthernetPacket::destinationAddress() const |
237 | { | 237 | { |
238 | return OMacAddress( _ether->ether_dhost ); | 238 | return OMacAddress( _ether->ether_dhost ); |
239 | } | 239 | } |
240 | 240 | ||
241 | int OEthernetPacket::type() const | 241 | int OEthernetPacket::type() const |
242 | { | 242 | { |
243 | return ntohs( _ether->ether_type ); | 243 | return ntohs( _ether->ether_type ); |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | /*====================================================================================== | 247 | /*====================================================================================== |
248 | * OIPPacket | 248 | * OIPPacket |
249 | *======================================================================================*/ | 249 | *======================================================================================*/ |
250 | 250 | ||
251 | 251 | ||
252 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) | 252 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) |
253 | :QObject( parent, "IP" ), _iphdr( data ) | 253 | :QObject( parent, "IP" ), _iphdr( data ) |
254 | { | 254 | { |
255 | odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl; | 255 | odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl; |
256 | 256 | ||
257 | odebug << "FromAddress = " << fromIPAddress().toString() << oendl; | 257 | odebug << "FromAddress = " << fromIPAddress().toString() << oendl; |
258 | odebug << " toAddress = " << toIPAddress().toString() << oendl; | 258 | odebug << " toAddress = " << toIPAddress().toString() << oendl; |
259 | 259 | ||
260 | switch ( protocol() ) | 260 | switch ( protocol() ) |
261 | { | 261 | { |
262 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; | 262 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; |
263 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; | 263 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; |
264 | default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl; | 264 | default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl; |
265 | } | 265 | } |
266 | 266 | ||
267 | } | 267 | } |
268 | 268 | ||
269 | OIPPacket::~OIPPacket() | 269 | OIPPacket::~OIPPacket() |
270 | { | 270 | { |
271 | } | 271 | } |
272 | 272 | ||
273 | 273 | ||
274 | QHostAddress OIPPacket::fromIPAddress() const | 274 | QHostAddress OIPPacket::fromIPAddress() const |
275 | { | 275 | { |
276 | return EXTRACT_32BITS( &_iphdr->saddr ); | 276 | return EXTRACT_32BITS( &_iphdr->saddr ); |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | QHostAddress OIPPacket::toIPAddress() const | 280 | QHostAddress OIPPacket::toIPAddress() const |
281 | { | 281 | { |
282 | return EXTRACT_32BITS( &_iphdr->saddr ); | 282 | return EXTRACT_32BITS( &_iphdr->saddr ); |
283 | } | 283 | } |
284 | 284 | ||
285 | 285 | ||
286 | int OIPPacket::tos() const | 286 | int OIPPacket::tos() const |
287 | { | 287 | { |
288 | return _iphdr->tos; | 288 | return _iphdr->tos; |
289 | } | 289 | } |
290 | 290 | ||
291 | 291 | ||
292 | int OIPPacket::len() const | 292 | int OIPPacket::len() const |
293 | { | 293 | { |
294 | return EXTRACT_16BITS( &_iphdr->tot_len ); | 294 | return EXTRACT_16BITS( &_iphdr->tot_len ); |
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | int OIPPacket::id() const | 298 | int OIPPacket::id() const |
299 | { | 299 | { |
300 | return EXTRACT_16BITS( &_iphdr->id ); | 300 | return EXTRACT_16BITS( &_iphdr->id ); |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | int OIPPacket::offset() const | 304 | int OIPPacket::offset() const |
305 | { | 305 | { |
306 | return EXTRACT_16BITS( &_iphdr->frag_off ); | 306 | return EXTRACT_16BITS( &_iphdr->frag_off ); |
307 | } | 307 | } |
308 | 308 | ||
309 | 309 | ||
310 | int OIPPacket::ttl() const | 310 | int OIPPacket::ttl() const |
311 | { | 311 | { |
312 | return _iphdr->ttl; | 312 | return _iphdr->ttl; |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | int OIPPacket::protocol() const | 316 | int OIPPacket::protocol() const |
317 | { | 317 | { |
318 | return _iphdr->protocol; | 318 | return _iphdr->protocol; |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | int OIPPacket::checksum() const | 322 | int OIPPacket::checksum() const |
323 | { | 323 | { |
324 | return EXTRACT_16BITS( &_iphdr->check ); | 324 | return EXTRACT_16BITS( &_iphdr->check ); |
325 | } | 325 | } |
326 | 326 | ||
327 | /*====================================================================================== | 327 | /*====================================================================================== |
328 | * OARPPacket | 328 | * OARPPacket |
329 | *======================================================================================*/ | 329 | *======================================================================================*/ |
330 | 330 | ||
331 | 331 | ||
332 | OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) | 332 | OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) |
333 | :QObject( parent, "ARP" ), _arphdr( data ) | 333 | :QObject( parent, "ARP" ), _arphdr( data ) |
334 | { | 334 | { |
335 | odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl; | 335 | odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl; |