-rw-r--r-- | libopie2/opienet/opcap.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 8184f21..03e4502 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -1,351 +1,351 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003-2004 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | Copyright (C) 2003-2004 by Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "udp_ports.h" | 31 | #include "udp_ports.h" |
32 | #include "opcap.h" | 32 | #include "opcap.h" |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | #include <opie2/odebug.h> | 35 | #include <opie2/odebug.h> |
36 | using namespace Opie::Core; | 36 | using namespace Opie::Core; |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | #include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) | 39 | #include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) |
40 | #include <qsocketnotifier.h> | 40 | #include <qsocketnotifier.h> |
41 | #include <qobjectlist.h> | 41 | #include <qobjectlist.h> |
42 | 42 | ||
43 | /* STD */ | 43 | /* STD */ |
44 | #include <sys/time.h> | 44 | #include <sys/time.h> |
45 | #include <sys/types.h> | 45 | #include <sys/types.h> |
46 | #include <assert.h> | 46 | #include <assert.h> |
47 | #include <unistd.h> | 47 | #include <unistd.h> |
48 | #include <string.h> | 48 | #include <string.h> |
49 | 49 | ||
50 | namespace Opie { | 50 | namespace Opie { |
51 | namespace Net { | 51 | namespace Net { |
52 | 52 | ||
53 | /*====================================================================================== | 53 | /*====================================================================================== |
54 | * OPacket | 54 | * OPacket |
55 | *======================================================================================*/ | 55 | *======================================================================================*/ |
56 | 56 | ||
57 | OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) | 57 | OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) |
58 | :QObject( parent, "Generic" ), _hdr( header ), _data( 0 ) | 58 | :QObject( parent, "Generic" ), _hdr( header ), _data( 0 ) |
59 | { | 59 | { |
60 | 60 | ||
61 | _data = new unsigned char[ header.len ]; | 61 | _data = new unsigned char[ header.len ]; |
62 | assert( _data ); | 62 | assert( _data ); |
63 | memcpy( const_cast<unsigned char*>(_data), data, header.len ); | 63 | memcpy( const_cast<unsigned char*>(_data), data, header.len ); |
64 | // We have to copy the data structure here, because the 'data' pointer handed by libpcap | 64 | // We have to copy the data structure here, because the 'data' pointer handed by libpcap |
65 | // points to an internal region which is reused by lipcap. | 65 | // points to an internal region which is reused by lipcap. |
66 | odebug << "OPacket: Length = " << header.len << ", Caplen = " << header.caplen << oendl; | 66 | odebug << "OPacket: Length = " << header.len << ", Caplen = " << header.caplen << oendl; |
67 | _end = (unsigned char*) _data + header.len; | 67 | _end = (unsigned char*) _data + header.len; |
68 | 68 | ||
69 | switch ( datalink ) | 69 | switch ( datalink ) |
70 | { | 70 | { |
71 | case DLT_EN10MB: | 71 | case DLT_EN10MB: |
72 | odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl; | 72 | odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl; |
73 | new OEthernetPacket( _end, (const struct ether_header*) _data, this ); | 73 | new OEthernetPacket( _end, (const struct ether_header*) _data, this ); |
74 | break; | 74 | break; |
75 | 75 | ||
76 | case DLT_IEEE802_11: | 76 | case DLT_IEEE802_11: |
77 | odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl; | 77 | odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl; |
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( "000:" ); | 151 | QString str( "000:" ); |
152 | QString tmp; | 152 | QString tmp; |
153 | QString bytes; | 153 | QString bytes; |
154 | QString chars; | 154 | QString chars; |
155 | 155 | ||
156 | for ( int i = 0; i < len; ++i ) | 156 | for ( int i = 0; i < len; ++i ) |
157 | { | 157 | { |
158 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); | 158 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); |
159 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); | 159 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); |
160 | else chars.append( '.' ); | 160 | else chars.append( '.' ); |
161 | 161 | ||
162 | if ( !((i+1) % bpl) ) | 162 | if ( !((i+1) % bpl) ) |
163 | { | 163 | { |
164 | str.append( bytes ); | 164 | str.append( bytes ); |
165 | str.append( ' ' ); | 165 | str.append( ' ' ); |
166 | str.append( chars ); | 166 | str.append( chars ); |
167 | str.append( '\n' ); | 167 | str.append( '\n' ); |
168 | tmp.sprintf( "%03X:", i+1 ); str.append( tmp ); | 168 | tmp.sprintf( "%03X:", i+1 ); str.append( tmp ); |
169 | bytes = ""; | 169 | bytes = ""; |
170 | chars = ""; | 170 | chars = ""; |
171 | } | 171 | } |
172 | 172 | ||
173 | } | 173 | } |
174 | if ( (len % bpl) ) | 174 | if ( (len % bpl) ) |
175 | { | 175 | { |
176 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); | 176 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); |
177 | str.append( chars ); | 177 | str.append( chars ); |
178 | } | 178 | } |
179 | str.append( '\n' ); | 179 | str.append( '\n' ); |
180 | return str; | 180 | return str; |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | int OPacket::len() const | 184 | int OPacket::len() const |
185 | { | 185 | { |
186 | return _hdr.len; | 186 | return _hdr.len; |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | QTextStream& operator<<( QTextStream& s, const OPacket& p ) | 190 | QTextStream& operator<<( QTextStream& s, const OPacket& p ) |
191 | { | 191 | { |
192 | s << p.dumpStructure(); | 192 | s << p.dumpStructure(); |
193 | } | 193 | } |
194 | 194 | ||
195 | 195 | ||
196 | /*====================================================================================== | 196 | /*====================================================================================== |
197 | * OEthernetPacket | 197 | * OEthernetPacket |
198 | *======================================================================================*/ | 198 | *======================================================================================*/ |
199 | 199 | ||
200 | 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 ) |
201 | :QObject( parent, "Ethernet" ), _ether( data ) | 201 | :QObject( parent, "Ethernet" ), _ether( data ) |
202 | { | 202 | { |
203 | 203 | ||
204 | odebug << "Source = " << sourceAddress().toString() << oendl; | 204 | odebug << "Source = " << sourceAddress().toString() << oendl; |
205 | odebug << "Destination = " << destinationAddress().toString() << oendl; | 205 | odebug << "Destination = " << destinationAddress().toString() << oendl; |
206 | 206 | ||
207 | if ( sourceAddress() == OMacAddress::broadcast ) | 207 | if ( sourceAddress() == OMacAddress::broadcast ) |
208 | odebug << "Source is broadcast address" << oendl; | 208 | odebug << "Source is broadcast address" << oendl; |
209 | if ( destinationAddress() == OMacAddress::broadcast ) | 209 | if ( destinationAddress() == OMacAddress::broadcast ) |
210 | odebug << "Destination is broadcast address" << oendl; | 210 | odebug << "Destination is broadcast address" << oendl; |
211 | 211 | ||
212 | switch ( type() ) | 212 | switch ( type() ) |
213 | { | 213 | { |
214 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; | 214 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; |
215 | case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; | 215 | case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; |
216 | case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } | 216 | case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } |
217 | default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl; | 217 | default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl; |
218 | } | 218 | } |
219 | 219 | ||
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | OEthernetPacket::~OEthernetPacket() | 223 | OEthernetPacket::~OEthernetPacket() |
224 | { | 224 | { |
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | OMacAddress OEthernetPacket::sourceAddress() const | 228 | OMacAddress OEthernetPacket::sourceAddress() const |
229 | { | 229 | { |
230 | return OMacAddress( _ether->ether_shost ); | 230 | return OMacAddress( _ether->ether_shost ); |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | OMacAddress OEthernetPacket::destinationAddress() const | 234 | OMacAddress OEthernetPacket::destinationAddress() const |
235 | { | 235 | { |
236 | return OMacAddress( _ether->ether_dhost ); | 236 | return OMacAddress( _ether->ether_dhost ); |
237 | } | 237 | } |
238 | 238 | ||
239 | int OEthernetPacket::type() const | 239 | int OEthernetPacket::type() const |
240 | { | 240 | { |
241 | return ntohs( _ether->ether_type ); | 241 | return ntohs( _ether->ether_type ); |
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||
245 | /*====================================================================================== | 245 | /*====================================================================================== |
246 | * OIPPacket | 246 | * OIPPacket |
247 | *======================================================================================*/ | 247 | *======================================================================================*/ |
248 | 248 | ||
249 | 249 | ||
250 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) | 250 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) |
251 | :QObject( parent, "IP" ), _iphdr( data ) | 251 | :QObject( parent, "IP" ), _iphdr( data ) |
252 | { | 252 | { |
253 | odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl; | 253 | odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl; |
254 | 254 | ||
255 | odebug << "FromAddress = " << fromIPAddress().toString() << oendl; | 255 | odebug << "FromAddress = " << fromIPAddress().toString() << oendl; |
256 | odebug << " toAddress = " << toIPAddress().toString() << oendl; | 256 | odebug << " toAddress = " << toIPAddress().toString() << oendl; |
257 | 257 | ||
258 | switch ( protocol() ) | 258 | switch ( protocol() ) |
259 | { | 259 | { |
260 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; | 260 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; |
261 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; | 261 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; |
262 | default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl; | 262 | default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl; |
263 | } | 263 | } |
264 | 264 | ||
265 | } | 265 | } |
266 | 266 | ||
267 | OIPPacket::~OIPPacket() | 267 | OIPPacket::~OIPPacket() |
268 | { | 268 | { |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | QHostAddress OIPPacket::fromIPAddress() const | 272 | QHostAddress OIPPacket::fromIPAddress() const |
273 | { | 273 | { |
274 | return EXTRACT_32BITS( &_iphdr->saddr ); | 274 | return EXTRACT_32BITS( &_iphdr->saddr ); |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | QHostAddress OIPPacket::toIPAddress() const | 278 | QHostAddress OIPPacket::toIPAddress() const |
279 | { | 279 | { |
280 | return EXTRACT_32BITS( &_iphdr->saddr ); | 280 | return EXTRACT_32BITS( &_iphdr->saddr ); |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | int OIPPacket::tos() const | 284 | int OIPPacket::tos() const |
285 | { | 285 | { |
286 | return _iphdr->tos; | 286 | return _iphdr->tos; |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | int OIPPacket::len() const | 290 | int OIPPacket::len() const |
291 | { | 291 | { |
292 | return EXTRACT_16BITS( &_iphdr->tot_len ); | 292 | return EXTRACT_16BITS( &_iphdr->tot_len ); |
293 | } | 293 | } |
294 | 294 | ||
295 | 295 | ||
296 | int OIPPacket::id() const | 296 | int OIPPacket::id() const |
297 | { | 297 | { |
298 | return EXTRACT_16BITS( &_iphdr->id ); | 298 | return EXTRACT_16BITS( &_iphdr->id ); |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | int OIPPacket::offset() const | 302 | int OIPPacket::offset() const |
303 | { | 303 | { |
304 | return EXTRACT_16BITS( &_iphdr->frag_off ); | 304 | return EXTRACT_16BITS( &_iphdr->frag_off ); |
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||
308 | int OIPPacket::ttl() const | 308 | int OIPPacket::ttl() const |
309 | { | 309 | { |
310 | return _iphdr->ttl; | 310 | return _iphdr->ttl; |
311 | } | 311 | } |
312 | 312 | ||
313 | 313 | ||
314 | int OIPPacket::protocol() const | 314 | int OIPPacket::protocol() const |
315 | { | 315 | { |
316 | return _iphdr->protocol; | 316 | return _iphdr->protocol; |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | int OIPPacket::checksum() const | 320 | int OIPPacket::checksum() const |
321 | { | 321 | { |
322 | return EXTRACT_16BITS( &_iphdr->check ); | 322 | return EXTRACT_16BITS( &_iphdr->check ); |
323 | } | 323 | } |
324 | 324 | ||
325 | /*====================================================================================== | 325 | /*====================================================================================== |
326 | * OARPPacket | 326 | * OARPPacket |
327 | *======================================================================================*/ | 327 | *======================================================================================*/ |
328 | 328 | ||
329 | 329 | ||
330 | OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) | 330 | OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) |
331 | :QObject( parent, "ARP" ), _arphdr( data ) | 331 | :QObject( parent, "ARP" ), _arphdr( data ) |
332 | { | 332 | { |
333 | odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl; | 333 | odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl; |
334 | odebug << "ARP type seems to be " << EXTRACT_16BITS( &_arphdr->ar_op ) << " = " << type() << oendl; | 334 | odebug << "ARP type seems to be " << EXTRACT_16BITS( &_arphdr->ar_op ) << " = " << type() << oendl; |
335 | odebug << "Sender: MAC " << senderMacAddress().toString() << " = IP " << senderIPV4Address().toString() << oendl; | 335 | odebug << "Sender: MAC " << senderMacAddress().toString() << " = IP " << senderIPV4Address().toString() << oendl; |
336 | odebug << "Target: MAC " << targetMacAddress().toString() << " = IP " << targetIPV4Address().toString() << oendl; | 336 | odebug << "Target: MAC " << targetMacAddress().toString() << " = IP " << targetIPV4Address().toString() << oendl; |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | OARPPacket::~OARPPacket() | 340 | OARPPacket::~OARPPacket() |
341 | { | 341 | { |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | QString OARPPacket::type() const | 345 | QString OARPPacket::type() const |
346 | { | 346 | { |
347 | switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) | 347 | switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) |
348 | { | 348 | { |
349 | case 1: return "REQUEST"; | 349 | case 1: return "REQUEST"; |
350 | case 2: return "REPLY"; | 350 | case 2: return "REPLY"; |
351 | case 3: return "RREQUEST"; | 351 | case 3: return "RREQUEST"; |