author | mickeyl <mickeyl> | 2005-05-19 11:59:32 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-05-19 11:59:32 (UTC) |
commit | ed7ba8b228d3d0ffae9c9b68900b7f723d7ade4a (patch) (unidiff) | |
tree | 83b59755f58747cdb7e543a4c237e9e217b03fbd /libopie2/opienet | |
parent | cb243f00d12c5fc40de02e7f9f20009b52303a66 (diff) | |
download | opie-ed7ba8b228d3d0ffae9c9b68900b7f723d7ade4a.zip opie-ed7ba8b228d3d0ffae9c9b68900b7f723d7ade4a.tar.gz opie-ed7ba8b228d3d0ffae9c9b68900b7f723d7ade4a.tar.bz2 |
- add linux pcmcia subsystem wrapper: OPcmciaSystem and OPcmciaCard
- move linux-only subsystems in subdirectory linux
- minor header cleanups
-rw-r--r-- | libopie2/opienet/opcap.cpp | 2 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 1 |
2 files changed, 1 insertions, 2 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index eafbeea..c548356 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -1,524 +1,524 @@ | |||
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; version 2 of the License. | 11 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 12 | ._= =} : |
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 | return s; | 193 | return s; |
194 | } | 194 | } |
195 | 195 | ||
196 | 196 | ||
197 | /*====================================================================================== | 197 | /*====================================================================================== |
198 | * OEthernetPacket | 198 | * OEthernetPacket |
199 | *======================================================================================*/ | 199 | *======================================================================================*/ |
200 | 200 | ||
201 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) | 201 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) |
202 | :QObject( parent, "Ethernet" ), _ether( data ) | 202 | :QObject( parent, "Ethernet" ), _ether( data ) |
203 | { | 203 | { |
204 | 204 | ||
205 | odebug << "Source = " << sourceAddress().toString() << oendl; | 205 | odebug << "Source = " << sourceAddress().toString() << oendl; |
206 | odebug << "Destination = " << destinationAddress().toString() << oendl; | 206 | odebug << "Destination = " << destinationAddress().toString() << oendl; |
207 | 207 | ||
208 | if ( sourceAddress() == OMacAddress::broadcast ) | 208 | if ( sourceAddress() == OMacAddress::broadcast ) |
209 | odebug << "Source is broadcast address" << oendl; | 209 | odebug << "Source is broadcast address" << oendl; |
210 | if ( destinationAddress() == OMacAddress::broadcast ) | 210 | if ( destinationAddress() == OMacAddress::broadcast ) |
211 | odebug << "Destination is broadcast address" << oendl; | 211 | odebug << "Destination is broadcast address" << oendl; |
212 | 212 | ||
213 | switch ( type() ) | 213 | switch ( type() ) |
214 | { | 214 | { |
215 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; | 215 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; |
216 | case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; | 216 | case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; |
217 | case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } | 217 | case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } |
218 | default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl; | 218 | default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl; |
219 | } | 219 | } |
220 | 220 | ||
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | OEthernetPacket::~OEthernetPacket() | 224 | OEthernetPacket::~OEthernetPacket() |
225 | { | 225 | { |
226 | } | 226 | } |
227 | 227 | ||
228 | 228 | ||
229 | OMacAddress OEthernetPacket::sourceAddress() const | 229 | OMacAddress OEthernetPacket::sourceAddress() const |
230 | { | 230 | { |
231 | return OMacAddress( _ether->ether_shost ); | 231 | return OMacAddress( _ether->ether_shost ); |
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||
235 | OMacAddress OEthernetPacket::destinationAddress() const | 235 | OMacAddress OEthernetPacket::destinationAddress() const |
236 | { | 236 | { |
237 | return OMacAddress( _ether->ether_dhost ); | 237 | return OMacAddress( _ether->ether_dhost ); |
238 | } | 238 | } |
239 | 239 | ||
240 | int OEthernetPacket::type() const | 240 | int OEthernetPacket::type() const |
241 | { | 241 | { |
242 | return ntohs( _ether->ether_type ); | 242 | return ntohs( _ether->ether_type ); |
243 | } | 243 | } |
244 | 244 | ||
245 | 245 | ||
246 | /*====================================================================================== | 246 | /*====================================================================================== |
247 | * OIPPacket | 247 | * OIPPacket |
248 | *======================================================================================*/ | 248 | *======================================================================================*/ |
249 | 249 | ||
250 | 250 | ||
251 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) | 251 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) |
252 | :QObject( parent, "IP" ), _iphdr( data ) | 252 | :QObject( parent, "IP" ), _iphdr( data ) |
253 | { | 253 | { |
254 | odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl; | 254 | odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl; |
255 | 255 | ||
256 | odebug << "FromAddress = " << fromIPAddress().toString() << oendl; | 256 | odebug << "FromAddress = " << fromIPAddress().toString() << oendl; |
257 | odebug << " toAddress = " << toIPAddress().toString() << oendl; | 257 | odebug << " toAddress = " << toIPAddress().toString() << oendl; |
258 | 258 | ||
259 | switch ( protocol() ) | 259 | switch ( protocol() ) |
260 | { | 260 | { |
261 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; | 261 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; |
262 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; | 262 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; |
263 | default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl; | 263 | default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl; |
264 | } | 264 | } |
265 | 265 | ||
266 | } | 266 | } |
267 | 267 | ||
268 | OIPPacket::~OIPPacket() | 268 | OIPPacket::~OIPPacket() |
269 | { | 269 | { |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | QHostAddress OIPPacket::fromIPAddress() const | 273 | QHostAddress OIPPacket::fromIPAddress() const |
274 | { | 274 | { |
275 | return EXTRACT_32BITS( &_iphdr->saddr ); | 275 | return EXTRACT_32BITS( &_iphdr->saddr ); |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
279 | QHostAddress OIPPacket::toIPAddress() const | 279 | QHostAddress OIPPacket::toIPAddress() const |
280 | { | 280 | { |
281 | return EXTRACT_32BITS( &_iphdr->saddr ); | 281 | return EXTRACT_32BITS( &_iphdr->saddr ); |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | int OIPPacket::tos() const | 285 | int OIPPacket::tos() const |
286 | { | 286 | { |
287 | return _iphdr->tos; | 287 | return _iphdr->tos; |
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | int OIPPacket::len() const | 291 | int OIPPacket::len() const |
292 | { | 292 | { |
293 | return EXTRACT_16BITS( &_iphdr->tot_len ); | 293 | return EXTRACT_16BITS( &_iphdr->tot_len ); |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | int OIPPacket::id() const | 297 | int OIPPacket::id() const |
298 | { | 298 | { |
299 | return EXTRACT_16BITS( &_iphdr->id ); | 299 | return EXTRACT_16BITS( &_iphdr->id ); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | int OIPPacket::offset() const | 303 | int OIPPacket::offset() const |
304 | { | 304 | { |
305 | return EXTRACT_16BITS( &_iphdr->frag_off ); | 305 | return EXTRACT_16BITS( &_iphdr->frag_off ); |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | int OIPPacket::ttl() const | 309 | int OIPPacket::ttl() const |
310 | { | 310 | { |
311 | return _iphdr->ttl; | 311 | return _iphdr->ttl; |
312 | } | 312 | } |
313 | 313 | ||
314 | 314 | ||
315 | int OIPPacket::protocol() const | 315 | int OIPPacket::protocol() const |
316 | { | 316 | { |
317 | return _iphdr->protocol; | 317 | return _iphdr->protocol; |
318 | } | 318 | } |
319 | 319 | ||
320 | 320 | ||
321 | int OIPPacket::checksum() const | 321 | int OIPPacket::checksum() const |
322 | { | 322 | { |
323 | return EXTRACT_16BITS( &_iphdr->check ); | 323 | return EXTRACT_16BITS( &_iphdr->check ); |
324 | } | 324 | } |
325 | 325 | ||
326 | /*====================================================================================== | 326 | /*====================================================================================== |
327 | * OARPPacket | 327 | * OARPPacket |
328 | *======================================================================================*/ | 328 | *======================================================================================*/ |
329 | 329 | ||
330 | 330 | ||
331 | OARPPacket::OARPPacket( const unsigned char* /*end*/, const struct myarphdr* data, QObject* parent ) | 331 | OARPPacket::OARPPacket( const unsigned char* /*end*/, const struct myarphdr* data, QObject* parent ) |
332 | :QObject( parent, "ARP" ), _arphdr( data ) | 332 | :QObject( parent, "ARP" ), _arphdr( data ) |
333 | { | 333 | { |
334 | odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl; | 334 | odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl; |
335 | odebug << "ARP type seems to be " << EXTRACT_16BITS( &_arphdr->ar_op ) << " = " << type() << oendl; | 335 | odebug << "ARP type seems to be " << EXTRACT_16BITS( &_arphdr->ar_op ) << " = " << type() << oendl; |
336 | odebug << "Sender: MAC " << senderMacAddress().toString() << " = IP " << senderIPV4Address().toString() << oendl; | 336 | odebug << "Sender: MAC " << senderMacAddress().toString() << " = IP " << senderIPV4Address().toString() << oendl; |
337 | odebug << "Target: MAC " << targetMacAddress().toString() << " = IP " << targetIPV4Address().toString() << oendl; | 337 | odebug << "Target: MAC " << targetMacAddress().toString() << " = IP " << targetIPV4Address().toString() << oendl; |
338 | } | 338 | } |
339 | 339 | ||
340 | 340 | ||
341 | OARPPacket::~OARPPacket() | 341 | OARPPacket::~OARPPacket() |
342 | { | 342 | { |
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | QString OARPPacket::type() const | 346 | QString OARPPacket::type() const |
347 | { | 347 | { |
348 | switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) | 348 | switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) |
349 | { | 349 | { |
350 | case 1: return "REQUEST"; | 350 | case 1: return "REQUEST"; |
351 | case 2: return "REPLY"; | 351 | case 2: return "REPLY"; |
352 | case 3: return "RREQUEST"; | 352 | case 3: return "RREQUEST"; |
353 | case 4: return "RREPLY"; | 353 | case 4: return "RREPLY"; |
354 | case 8: return "InREQUEST"; | 354 | case 8: return "InREQUEST"; |
355 | case 9: return "InREPLY"; | 355 | case 9: return "InREPLY"; |
356 | case 10: return "NAK"; | 356 | case 10: return "NAK"; |
357 | default: owarn << "OARPPacket::type(): invalid ARP type!" << oendl; return "<unknown>"; | 357 | default: owarn << "OARPPacket::type(): invalid ARP type!" << oendl; return "<unknown>"; |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | QHostAddress OARPPacket::senderIPV4Address() const | 362 | QHostAddress OARPPacket::senderIPV4Address() const |
363 | { | 363 | { |
364 | return EXTRACT_32BITS( &_arphdr->ar_sip ); | 364 | return EXTRACT_32BITS( &_arphdr->ar_sip ); |
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
368 | QHostAddress OARPPacket::targetIPV4Address() const | 368 | QHostAddress OARPPacket::targetIPV4Address() const |
369 | { | 369 | { |
370 | return EXTRACT_32BITS( &_arphdr->ar_tip ); | 370 | return EXTRACT_32BITS( &_arphdr->ar_tip ); |
371 | } | 371 | } |
372 | 372 | ||
373 | 373 | ||
374 | OMacAddress OARPPacket::senderMacAddress() const | 374 | OMacAddress OARPPacket::senderMacAddress() const |
375 | { | 375 | { |
376 | return OMacAddress( _arphdr->ar_sha ); | 376 | return OMacAddress( _arphdr->ar_sha ); |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | OMacAddress OARPPacket::targetMacAddress() const | 380 | OMacAddress OARPPacket::targetMacAddress() const |
381 | { | 381 | { |
382 | return OMacAddress( _arphdr->ar_tha ); | 382 | return OMacAddress( _arphdr->ar_tha ); |
383 | } | 383 | } |
384 | 384 | ||
385 | 385 | ||
386 | /*====================================================================================== | 386 | /*====================================================================================== |
387 | * OUDPPacket | 387 | * OUDPPacket |
388 | *======================================================================================*/ | 388 | *======================================================================================*/ |
389 | 389 | ||
390 | 390 | ||
391 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) | 391 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) |
392 | :QObject( parent, "UDP" ), _udphdr( data ) | 392 | :QObject( parent, "UDP" ), _udphdr( data ) |
393 | 393 | ||
394 | { | 394 | { |
395 | odebug << "OUDPPacket::OUDPPacket(): decoding UDP header..." << oendl; | 395 | odebug << "OUDPPacket::OUDPPacket(): decoding UDP header..." << oendl; |
396 | odebug << "fromPort = " << fromPort() << oendl; | 396 | odebug << "fromPort = " << fromPort() << oendl; |
397 | odebug << " toPort = " << toPort() << oendl; | 397 | odebug << " toPort = " << toPort() << oendl; |
398 | 398 | ||
399 | // TODO: Make this a case or a hash if we know more udp protocols | 399 | // TODO: Make this a case or a hash if we know more udp protocols |
400 | 400 | ||
401 | if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC || | 401 | if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC || |
402 | toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC ) | 402 | toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC ) |
403 | { | 403 | { |
404 | odebug << "seems to be part of a DHCP conversation => creating DHCP packet." << oendl; | 404 | odebug << "seems to be part of a DHCP conversation => creating DHCP packet." << oendl; |
405 | new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this ); | 405 | new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this ); |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | 409 | ||
410 | OUDPPacket::~OUDPPacket() | 410 | OUDPPacket::~OUDPPacket() |
411 | { | 411 | { |
412 | } | 412 | } |
413 | 413 | ||
414 | 414 | ||
415 | int OUDPPacket::fromPort() const | 415 | int OUDPPacket::fromPort() const |
416 | { | 416 | { |
417 | return EXTRACT_16BITS( &_udphdr->source ); | 417 | return EXTRACT_16BITS( &_udphdr->source ); |
418 | } | 418 | } |
419 | 419 | ||
420 | 420 | ||
421 | int OUDPPacket::toPort() const | 421 | int OUDPPacket::toPort() const |
422 | { | 422 | { |
423 | return EXTRACT_16BITS( &_udphdr->dest ); | 423 | return EXTRACT_16BITS( &_udphdr->dest ); |
424 | } | 424 | } |
425 | 425 | ||
426 | 426 | ||
427 | int OUDPPacket::length() const | 427 | int OUDPPacket::length() const |
428 | { | 428 | { |
429 | return EXTRACT_16BITS( &_udphdr->len ); | 429 | return EXTRACT_16BITS( &_udphdr->len ); |
430 | } | 430 | } |
431 | 431 | ||
432 | 432 | ||
433 | int OUDPPacket::checksum() const | 433 | int OUDPPacket::checksum() const |
434 | { | 434 | { |
435 | return EXTRACT_16BITS( &_udphdr->check ); | 435 | return EXTRACT_16BITS( &_udphdr->check ); |
436 | } | 436 | } |
437 | 437 | ||
438 | 438 | ||
439 | /*====================================================================================== | 439 | /*====================================================================================== |
440 | * ODHCPPacket | 440 | * ODHCPPacket |
441 | *======================================================================================*/ | 441 | *======================================================================================*/ |
442 | 442 | ||
443 | 443 | ||
444 | ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent ) | 444 | ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent ) |
445 | :QObject( parent, "DHCP" ), _dhcphdr( data ) | 445 | :QObject( parent, "DHCP" ), _dhcphdr( data ) |
446 | 446 | ||
447 | { | 447 | { |
448 | odebug << "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." << oendl; | 448 | odebug << "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." << oendl; |
449 | odebug << "DHCP opcode seems to be " << _dhcphdr->op << ": " << ( isRequest() ? "REQUEST" : "REPLY" ) << oendl; | 449 | odebug << "DHCP opcode seems to be " << _dhcphdr->op << ": " << ( isRequest() ? "REQUEST" : "REPLY" ) << oendl; |
450 | odebug << "clientAddress = " << clientAddress().toString() << oendl; | 450 | odebug << "clientAddress = " << clientAddress().toString() << oendl; |
451 | odebug << " yourAddress = " << yourAddress().toString() << oendl; | 451 | odebug << " yourAddress = " << yourAddress().toString() << oendl; |
452 | odebug << "serverAddress = " << serverAddress().toString() << oendl; | 452 | odebug << "serverAddress = " << serverAddress().toString() << oendl; |
453 | odebug << " relayAddress = " << relayAddress().toString() << oendl; | 453 | odebug << " relayAddress = " << relayAddress().toString() << oendl; |
454 | odebug << "parsing DHCP options..." << oendl; | 454 | odebug << "parsing DHCP options..." << oendl; |
455 | 455 | ||
456 | _type = 0; | 456 | _type = 0; |
457 | 457 | ||
458 | const unsigned char* option = &_dhcphdr->options[4]; | 458 | const unsigned char* option = &_dhcphdr->options[4]; |
459 | char tag = -1; | 459 | char tag = -1; |
460 | char len = -1; | 460 | char len = -1; |
461 | 461 | ||
462 | while ( ( tag = *option++ ) != -1 /* end of option field */ ) | 462 | while ( ( tag = *option++ ) != -1 /* end of option field */ ) |
463 | { | 463 | { |
464 | len = *option++; | 464 | len = *option++; |
465 | odebug << "recognized DHCP option #" << tag << ", length " << len << oendl; | 465 | odebug << "recognized DHCP option #" << tag << ", length " << len << oendl; |
466 | 466 | ||
467 | if ( tag == DHO_DHCP_MESSAGE_TYPE ) | 467 | if ( tag == DHO_DHCP_MESSAGE_TYPE ) |
468 | _type = *option; | 468 | _type = *option; |
469 | 469 | ||
470 | option += len; | 470 | option += len; |
471 | if ( option >= end ) | 471 | if ( option >= end ) |
472 | { | 472 | { |
473 | owarn << "DHCP parsing ERROR: sanity check says the packet is at its end!" << oendl; | 473 | owarn << "DHCP parsing ERROR: sanity check says the packet is at its end!" << oendl; |
474 | break; | 474 | break; |
475 | } | 475 | } |
476 | } | 476 | } |
477 | 477 | ||
478 | odebug << "DHCP type seems to be << " << type() << oendl; | 478 | odebug << "DHCP type seems to be << " << type() << oendl; |
479 | } | 479 | } |
480 | 480 | ||
481 | 481 | ||
482 | ODHCPPacket::~ODHCPPacket() | 482 | ODHCPPacket::~ODHCPPacket() |
483 | { | 483 | { |
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | bool ODHCPPacket::isRequest() const | 487 | bool ODHCPPacket::isRequest() const |
488 | { | 488 | { |
489 | return ( _dhcphdr->op == 01 ); | 489 | return ( _dhcphdr->op == 01 ); |
490 | } | 490 | } |
491 | 491 | ||
492 | 492 | ||
493 | bool ODHCPPacket::isReply() const | 493 | bool ODHCPPacket::isReply() const |
494 | { | 494 | { |
495 | return ( _dhcphdr->op == 02 ); | 495 | return ( _dhcphdr->op == 02 ); |
496 | } | 496 | } |
497 | 497 | ||
498 | 498 | ||
499 | QString ODHCPPacket::type() const | 499 | QString ODHCPPacket::type() const |
500 | { | 500 | { |
501 | switch ( _type ) | 501 | switch ( _type ) |
502 | { | 502 | { |
503 | case 1: return "DISCOVER"; | 503 | case 1: return "DISCOVER"; |
504 | case 2: return "OFFER"; | 504 | case 2: return "OFFER"; |
505 | case 3: return "REQUEST"; | 505 | case 3: return "REQUEST"; |
506 | case 4: return "DECLINE"; | 506 | case 4: return "DECLINE"; |
507 | case 5: return "ACK"; | 507 | case 5: return "ACK"; |
508 | case 6: return "NAK"; | 508 | case 6: return "NAK"; |
509 | case 7: return "RELEASE"; | 509 | case 7: return "RELEASE"; |
510 | case 8: return "INFORM"; | 510 | case 8: return "INFORM"; |
511 | default: owarn << "ODHCPPacket::type(): invalid DHCP type " << _dhcphdr->op << oendl; return "<unknown>"; | 511 | default: owarn << "ODHCPPacket::type(): invalid DHCP type " << _dhcphdr->op << oendl; return "<unknown>"; |
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | 515 | ||
516 | QHostAddress ODHCPPacket::clientAddress() const | 516 | QHostAddress ODHCPPacket::clientAddress() const |
517 | { | 517 | { |
518 | return EXTRACT_32BITS( &_dhcphdr->ciaddr ); | 518 | return EXTRACT_32BITS( &_dhcphdr->ciaddr ); |
519 | } | 519 | } |
520 | 520 | ||
521 | 521 | ||
522 | QHostAddress ODHCPPacket::yourAddress() const | 522 | QHostAddress ODHCPPacket::yourAddress() const |
523 | { | 523 | { |
524 | return EXTRACT_32BITS( &_dhcphdr->yiaddr ); | 524 | return EXTRACT_32BITS( &_dhcphdr->yiaddr ); |
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index 149e573..8b415a2 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h | |||
@@ -1,573 +1,572 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | Copyright (C) 2003 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; version 2 of the License. | 11 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 12 | ._= =} : |
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 | #ifndef OPCAP_H | 31 | #ifndef OPCAP_H |
32 | #define OPCAP_H | 32 | #define OPCAP_H |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | #include <opie2/onetutils.h> | 35 | #include <opie2/onetutils.h> |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qevent.h> | 38 | #include <qevent.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qhostaddress.h> | 40 | #include <qhostaddress.h> |
41 | #include <qobject.h> | 41 | #include <qobject.h> |
42 | #include <qstring.h> | 42 | #include <qstring.h> |
43 | #include <qtextstream.h> | 43 | #include <qtextstream.h> |
44 | #include <qmap.h> | 44 | #include <qmap.h> |
45 | 45 | ||
46 | /* STD */ | 46 | /* STD */ |
47 | extern "C" // work around a bpf/pcap conflict in recent headers | 47 | extern "C" // work around a bpf/pcap conflict in recent headers |
48 | { | 48 | { |
49 | #include <pcap.h> | 49 | #include <pcap.h> |
50 | } | 50 | } |
51 | #include <netinet/ether.h> | 51 | #include <netinet/ether.h> |
52 | #include <netinet/ip.h> | 52 | #include <netinet/ip.h> |
53 | #include <netinet/udp.h> | 53 | #include <netinet/udp.h> |
54 | #include <netinet/tcp.h> | 54 | #include <netinet/tcp.h> |
55 | #include <time.h> | 55 | #include <time.h> |
56 | 56 | ||
57 | /* Custom Network Includes (must go here, don't reorder!) */ | 57 | /* Custom Network Includes (must go here, don't reorder!) */ |
58 | #include "802_11_user.h" | 58 | #include "802_11_user.h" |
59 | #include "dhcp.h" | 59 | #include "dhcp.h" |
60 | 60 | ||
61 | |||
62 | /* TYPEDEFS */ | 61 | /* TYPEDEFS */ |
63 | typedef struct timeval timevalstruct; | 62 | typedef struct timeval timevalstruct; |
64 | typedef struct pcap_pkthdr packetheaderstruct; | 63 | typedef struct pcap_pkthdr packetheaderstruct; |
65 | 64 | ||
66 | /* FORWARDS */ | 65 | /* FORWARDS */ |
67 | class QSocketNotifier; | 66 | class QSocketNotifier; |
68 | namespace Opie { | 67 | namespace Opie { |
69 | namespace Net { | 68 | namespace Net { |
70 | class OPacketCapturer; | 69 | class OPacketCapturer; |
71 | 70 | ||
72 | /*====================================================================================== | 71 | /*====================================================================================== |
73 | * OPacket - A frame on the wire | 72 | * OPacket - A frame on the wire |
74 | *======================================================================================*/ | 73 | *======================================================================================*/ |
75 | 74 | ||
76 | /** @brief A class representing a data frame on the wire. | 75 | /** @brief A class representing a data frame on the wire. |
77 | * | 76 | * |
78 | * The whole family of the packet classes are used when capturing frames from a network. | 77 | * The whole family of the packet classes are used when capturing frames from a network. |
79 | * Most standard network protocols in use share a common architecture, which mostly is | 78 | * Most standard network protocols in use share a common architecture, which mostly is |
80 | * a packet header and then the packet payload. In layered architectures, each lower layer | 79 | * a packet header and then the packet payload. In layered architectures, each lower layer |
81 | * encapsulates data from its upper layer - that is it | 80 | * encapsulates data from its upper layer - that is it |
82 | * treats the data from its upper layer as payload and prepends an own header to the packet, | 81 | * treats the data from its upper layer as payload and prepends an own header to the packet, |
83 | * which - again - is treated as the payload for the layer below. The figure below is an | 82 | * which - again - is treated as the payload for the layer below. The figure below is an |
84 | * example for how such a data frame is composed out of packets, e.g. when sending a mail. | 83 | * example for how such a data frame is composed out of packets, e.g. when sending a mail. |
85 | * | 84 | * |
86 | * <pre> | 85 | * <pre> |
87 | * | User Data | == Mail Data | 86 | * | User Data | == Mail Data |
88 | * | SMTP Header | User Data | == SMTP | 87 | * | SMTP Header | User Data | == SMTP |
89 | * | TCP Header | SMTP Header | User Data | == TCP | 88 | * | TCP Header | SMTP Header | User Data | == TCP |
90 | * | IP Header | TCP Header | SMTP Header | User Data | == IP | 89 | * | IP Header | TCP Header | SMTP Header | User Data | == IP |
91 | * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC | 90 | * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC |
92 | * | 91 | * |
93 | * </pre> | 92 | * </pre> |
94 | * | 93 | * |
95 | * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer | 94 | * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer |
96 | * also contains a few more levels of encapsulation. | 95 | * also contains a few more levels of encapsulation. |
97 | * Since the type of the payload is more or less independent from the encapsulating protocol, | 96 | * Since the type of the payload is more or less independent from the encapsulating protocol, |
98 | * the header must be inspected before attempting to decode the payload. Hence, the | 97 | * the header must be inspected before attempting to decode the payload. Hence, the |
99 | * encapsulation level varies and can't be deduced without actually looking into the packets. | 98 | * encapsulation level varies and can't be deduced without actually looking into the packets. |
100 | * | 99 | * |
101 | * For actually working with captured frames, it's useful to identify the packets via names and | 100 | * For actually working with captured frames, it's useful to identify the packets via names and |
102 | * insert them into a parent/child - relationship based on the encapsulation. This is why | 101 | * insert them into a parent/child - relationship based on the encapsulation. This is why |
103 | * all packet classes derive from QObject. The amount of overhead caused by the QObject is | 102 | * all packet classes derive from QObject. The amount of overhead caused by the QObject is |
104 | * not a problem in this case, because we're talking about a theoratical maximum of about | 103 | * not a problem in this case, because we're talking about a theoratical maximum of about |
105 | * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the | 104 | * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the |
106 | * QObject also cares about destroying the sub-, (child-) packets. | 105 | * QObject also cares about destroying the sub-, (child-) packets. |
107 | * | 106 | * |
108 | * This enables us to perform a simple look for packets of a certain type: | 107 | * This enables us to perform a simple look for packets of a certain type: |
109 | * @code | 108 | * @code |
110 | * OPacketCapturer* pcap = new OPacketCapturer(); | 109 | * OPacketCapturer* pcap = new OPacketCapturer(); |
111 | * pcap->open( "eth0" ); | 110 | * pcap->open( "eth0" ); |
112 | * OPacket* p = pcap->next(); | 111 | * OPacket* p = pcap->next(); |
113 | * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists | 112 | * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists |
114 | * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; | 113 | * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; |
115 | * | 114 | * |
116 | */ | 115 | */ |
117 | 116 | ||
118 | class OPacket : public QObject | 117 | class OPacket : public QObject |
119 | { | 118 | { |
120 | Q_OBJECT | 119 | Q_OBJECT |
121 | 120 | ||
122 | friend class OPacketCapturer; | 121 | friend class OPacketCapturer; |
123 | friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); | 122 | friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); |
124 | 123 | ||
125 | public: | 124 | public: |
126 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); | 125 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); |
127 | virtual ~OPacket(); | 126 | virtual ~OPacket(); |
128 | 127 | ||
129 | timevalstruct timeval() const; | 128 | timevalstruct timeval() const; |
130 | 129 | ||
131 | int caplen() const; | 130 | int caplen() const; |
132 | int len() const; | 131 | int len() const; |
133 | QString dump( int = 32 ) const; //FIXME: remove that | 132 | QString dump( int = 32 ) const; //FIXME: remove that |
134 | 133 | ||
135 | void updateStats( QMap<QString,int>&, QObjectList* ); //FIXME: Revise | 134 | void updateStats( QMap<QString,int>&, QObjectList* ); //FIXME: Revise |
136 | 135 | ||
137 | QString dumpStructure() const; //FIXME: Revise | 136 | QString dumpStructure() const; //FIXME: Revise |
138 | private: | 137 | private: |
139 | QString _dumpStructure( QObjectList* ) const; //FIXME: Revise | 138 | QString _dumpStructure( QObjectList* ) const; //FIXME: Revise |
140 | 139 | ||
141 | private: | 140 | private: |
142 | const packetheaderstruct _hdr; // pcap packet header | 141 | const packetheaderstruct _hdr; // pcap packet header |
143 | const unsigned char* _data; // pcap packet data | 142 | const unsigned char* _data; // pcap packet data |
144 | const unsigned char* _end; // end of pcap packet data | 143 | const unsigned char* _end; // end of pcap packet data |
145 | private: | 144 | private: |
146 | class Private; | 145 | class Private; |
147 | Private *d; | 146 | Private *d; |
148 | }; | 147 | }; |
149 | 148 | ||
150 | QTextStream& operator<<( QTextStream& s, const OPacket& p ); //FIXME: Revise | 149 | QTextStream& operator<<( QTextStream& s, const OPacket& p ); //FIXME: Revise |
151 | 150 | ||
152 | /*====================================================================================== | 151 | /*====================================================================================== |
153 | * OEthernetPacket - DLT_EN10MB frame | 152 | * OEthernetPacket - DLT_EN10MB frame |
154 | *======================================================================================*/ | 153 | *======================================================================================*/ |
155 | 154 | ||
156 | class OEthernetPacket : public QObject | 155 | class OEthernetPacket : public QObject |
157 | { | 156 | { |
158 | Q_OBJECT | 157 | Q_OBJECT |
159 | 158 | ||
160 | public: | 159 | public: |
161 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); | 160 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); |
162 | virtual ~OEthernetPacket(); | 161 | virtual ~OEthernetPacket(); |
163 | 162 | ||
164 | OMacAddress sourceAddress() const; | 163 | OMacAddress sourceAddress() const; |
165 | OMacAddress destinationAddress() const; | 164 | OMacAddress destinationAddress() const; |
166 | int type() const; | 165 | int type() const; |
167 | 166 | ||
168 | private: | 167 | private: |
169 | const struct ether_header* _ether; | 168 | const struct ether_header* _ether; |
170 | private: | 169 | private: |
171 | class Private; | 170 | class Private; |
172 | Private *d; | 171 | Private *d; |
173 | }; | 172 | }; |
174 | 173 | ||
175 | /*====================================================================================== | 174 | /*====================================================================================== |
176 | * OPrismHeaderPacket - DLT_PRISM_HEADER frame | 175 | * OPrismHeaderPacket - DLT_PRISM_HEADER frame |
177 | *======================================================================================*/ | 176 | *======================================================================================*/ |
178 | 177 | ||
179 | class OPrismHeaderPacket : public QObject | 178 | class OPrismHeaderPacket : public QObject |
180 | { | 179 | { |
181 | Q_OBJECT | 180 | Q_OBJECT |
182 | 181 | ||
183 | public: | 182 | public: |
184 | OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); | 183 | OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); |
185 | virtual ~OPrismHeaderPacket(); | 184 | virtual ~OPrismHeaderPacket(); |
186 | 185 | ||
187 | unsigned int signalStrength() const; | 186 | unsigned int signalStrength() const; |
188 | 187 | ||
189 | private: | 188 | private: |
190 | const struct prism_hdr* _header; | 189 | const struct prism_hdr* _header; |
191 | class Private; | 190 | class Private; |
192 | Private *d; | 191 | Private *d; |
193 | }; | 192 | }; |
194 | 193 | ||
195 | /*====================================================================================== | 194 | /*====================================================================================== |
196 | * OWaveLanPacket - DLT_IEEE802_11 frame | 195 | * OWaveLanPacket - DLT_IEEE802_11 frame |
197 | *======================================================================================*/ | 196 | *======================================================================================*/ |
198 | 197 | ||
199 | class OWaveLanPacket : public QObject | 198 | class OWaveLanPacket : public QObject |
200 | { | 199 | { |
201 | Q_OBJECT | 200 | Q_OBJECT |
202 | 201 | ||
203 | public: | 202 | public: |
204 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); | 203 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); |
205 | virtual ~OWaveLanPacket(); | 204 | virtual ~OWaveLanPacket(); |
206 | 205 | ||
207 | int duration() const; | 206 | int duration() const; |
208 | bool fromDS() const; | 207 | bool fromDS() const; |
209 | bool toDS() const; | 208 | bool toDS() const; |
210 | virtual OMacAddress macAddress1() const; | 209 | virtual OMacAddress macAddress1() const; |
211 | virtual OMacAddress macAddress2() const; | 210 | virtual OMacAddress macAddress2() const; |
212 | virtual OMacAddress macAddress3() const; | 211 | virtual OMacAddress macAddress3() const; |
213 | virtual OMacAddress macAddress4() const; | 212 | virtual OMacAddress macAddress4() const; |
214 | bool usesPowerManagement() const; | 213 | bool usesPowerManagement() const; |
215 | int type() const; | 214 | int type() const; |
216 | int subType() const; | 215 | int subType() const; |
217 | int version() const; | 216 | int version() const; |
218 | bool usesWep() const; | 217 | bool usesWep() const; |
219 | 218 | ||
220 | private: | 219 | private: |
221 | const struct ieee_802_11_header* _wlanhdr; | 220 | const struct ieee_802_11_header* _wlanhdr; |
222 | class Private; | 221 | class Private; |
223 | Private *d; | 222 | Private *d; |
224 | }; | 223 | }; |
225 | 224 | ||
226 | 225 | ||
227 | /*====================================================================================== | 226 | /*====================================================================================== |
228 | * OWaveLanManagementPacket - type: management (T_MGMT) | 227 | * OWaveLanManagementPacket - type: management (T_MGMT) |
229 | *======================================================================================*/ | 228 | *======================================================================================*/ |
230 | 229 | ||
231 | class OWaveLanManagementPacket : public QObject | 230 | class OWaveLanManagementPacket : public QObject |
232 | { | 231 | { |
233 | Q_OBJECT | 232 | Q_OBJECT |
234 | 233 | ||
235 | public: | 234 | public: |
236 | OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); | 235 | OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); |
237 | virtual ~OWaveLanManagementPacket(); | 236 | virtual ~OWaveLanManagementPacket(); |
238 | 237 | ||
239 | QString managementType() const; | 238 | QString managementType() const; |
240 | 239 | ||
241 | int beaconInterval() const; | 240 | int beaconInterval() const; |
242 | int capabilities() const; // generic | 241 | int capabilities() const; // generic |
243 | 242 | ||
244 | bool canESS() const; | 243 | bool canESS() const; |
245 | bool canIBSS() const; | 244 | bool canIBSS() const; |
246 | bool canCFP() const; | 245 | bool canCFP() const; |
247 | bool canCFP_REQ() const; | 246 | bool canCFP_REQ() const; |
248 | bool canPrivacy() const; | 247 | bool canPrivacy() const; |
249 | 248 | ||
250 | private: | 249 | private: |
251 | const struct ieee_802_11_mgmt_header* _header; | 250 | const struct ieee_802_11_mgmt_header* _header; |
252 | const struct ieee_802_11_mgmt_body* _body; | 251 | const struct ieee_802_11_mgmt_body* _body; |
253 | class Private; | 252 | class Private; |
254 | Private *d; | 253 | Private *d; |
255 | }; | 254 | }; |
256 | 255 | ||
257 | 256 | ||
258 | /*====================================================================================== | 257 | /*====================================================================================== |
259 | * OWaveLanManagementSSID | 258 | * OWaveLanManagementSSID |
260 | *======================================================================================*/ | 259 | *======================================================================================*/ |
261 | 260 | ||
262 | class OWaveLanManagementSSID : public QObject | 261 | class OWaveLanManagementSSID : public QObject |
263 | { | 262 | { |
264 | Q_OBJECT | 263 | Q_OBJECT |
265 | 264 | ||
266 | public: | 265 | public: |
267 | OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); | 266 | OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); |
268 | virtual ~OWaveLanManagementSSID(); | 267 | virtual ~OWaveLanManagementSSID(); |
269 | 268 | ||
270 | QString ID( bool decloak = false ) const; | 269 | QString ID( bool decloak = false ) const; |
271 | 270 | ||
272 | private: | 271 | private: |
273 | const struct ssid_t* _data; | 272 | const struct ssid_t* _data; |
274 | class Private; | 273 | class Private; |
275 | Private *d; | 274 | Private *d; |
276 | }; | 275 | }; |
277 | 276 | ||
278 | /*====================================================================================== | 277 | /*====================================================================================== |
279 | * OWaveLanManagementRates | 278 | * OWaveLanManagementRates |
280 | *======================================================================================*/ | 279 | *======================================================================================*/ |
281 | 280 | ||
282 | class OWaveLanManagementRates : public QObject | 281 | class OWaveLanManagementRates : public QObject |
283 | { | 282 | { |
284 | Q_OBJECT | 283 | Q_OBJECT |
285 | 284 | ||
286 | public: | 285 | public: |
287 | OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); | 286 | OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); |
288 | virtual ~OWaveLanManagementRates(); | 287 | virtual ~OWaveLanManagementRates(); |
289 | 288 | ||
290 | private: | 289 | private: |
291 | const struct rates_t* _data; | 290 | const struct rates_t* _data; |
292 | class Private; | 291 | class Private; |
293 | Private *d; | 292 | Private *d; |
294 | }; | 293 | }; |
295 | 294 | ||
296 | /*====================================================================================== | 295 | /*====================================================================================== |
297 | * OWaveLanManagementCF | 296 | * OWaveLanManagementCF |
298 | *======================================================================================*/ | 297 | *======================================================================================*/ |
299 | 298 | ||
300 | class OWaveLanManagementCF : public QObject | 299 | class OWaveLanManagementCF : public QObject |
301 | { | 300 | { |
302 | Q_OBJECT | 301 | Q_OBJECT |
303 | 302 | ||
304 | public: | 303 | public: |
305 | OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); | 304 | OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); |
306 | virtual ~OWaveLanManagementCF(); | 305 | virtual ~OWaveLanManagementCF(); |
307 | 306 | ||
308 | private: | 307 | private: |
309 | const struct cf_t* _data; | 308 | const struct cf_t* _data; |
310 | class Private; | 309 | class Private; |
311 | Private *d; | 310 | Private *d; |
312 | }; | 311 | }; |
313 | 312 | ||
314 | /*====================================================================================== | 313 | /*====================================================================================== |
315 | * OWaveLanManagementFH | 314 | * OWaveLanManagementFH |
316 | *======================================================================================*/ | 315 | *======================================================================================*/ |
317 | 316 | ||
318 | class OWaveLanManagementFH : public QObject | 317 | class OWaveLanManagementFH : public QObject |
319 | { | 318 | { |
320 | Q_OBJECT | 319 | Q_OBJECT |
321 | 320 | ||
322 | public: | 321 | public: |
323 | OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); | 322 | OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); |
324 | virtual ~OWaveLanManagementFH(); | 323 | virtual ~OWaveLanManagementFH(); |
325 | 324 | ||
326 | private: | 325 | private: |
327 | const struct fh_t* _data; | 326 | const struct fh_t* _data; |
328 | class Private; | 327 | class Private; |
329 | Private *d; | 328 | Private *d; |
330 | }; | 329 | }; |
331 | 330 | ||
332 | /*====================================================================================== | 331 | /*====================================================================================== |
333 | * OWaveLanManagementDS | 332 | * OWaveLanManagementDS |
334 | *======================================================================================*/ | 333 | *======================================================================================*/ |
335 | 334 | ||
336 | class OWaveLanManagementDS : public QObject | 335 | class OWaveLanManagementDS : public QObject |
337 | { | 336 | { |
338 | Q_OBJECT | 337 | Q_OBJECT |
339 | 338 | ||
340 | public: | 339 | public: |
341 | OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); | 340 | OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); |
342 | virtual ~OWaveLanManagementDS(); | 341 | virtual ~OWaveLanManagementDS(); |
343 | 342 | ||
344 | int channel() const; | 343 | int channel() const; |
345 | 344 | ||
346 | private: | 345 | private: |
347 | const struct ds_t* _data; | 346 | const struct ds_t* _data; |
348 | class Private; | 347 | class Private; |
349 | Private *d; | 348 | Private *d; |
350 | }; | 349 | }; |
351 | 350 | ||
352 | /*====================================================================================== | 351 | /*====================================================================================== |
353 | * OWaveLanManagementTim | 352 | * OWaveLanManagementTim |
354 | *======================================================================================*/ | 353 | *======================================================================================*/ |
355 | 354 | ||
356 | class OWaveLanManagementTim : public QObject | 355 | class OWaveLanManagementTim : public QObject |
357 | { | 356 | { |
358 | Q_OBJECT | 357 | Q_OBJECT |
359 | 358 | ||
360 | public: | 359 | public: |
361 | OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); | 360 | OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); |
362 | virtual ~OWaveLanManagementTim(); | 361 | virtual ~OWaveLanManagementTim(); |
363 | 362 | ||
364 | private: | 363 | private: |
365 | const struct tim_t* _data; | 364 | const struct tim_t* _data; |
366 | class Private; | 365 | class Private; |
367 | Private *d; | 366 | Private *d; |
368 | }; | 367 | }; |
369 | 368 | ||
370 | /*====================================================================================== | 369 | /*====================================================================================== |
371 | * OWaveLanManagementIBSS | 370 | * OWaveLanManagementIBSS |
372 | *======================================================================================*/ | 371 | *======================================================================================*/ |
373 | 372 | ||
374 | class OWaveLanManagementIBSS : public QObject | 373 | class OWaveLanManagementIBSS : public QObject |
375 | { | 374 | { |
376 | Q_OBJECT | 375 | Q_OBJECT |
377 | 376 | ||
378 | public: | 377 | public: |
379 | OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); | 378 | OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); |
380 | virtual ~OWaveLanManagementIBSS(); | 379 | virtual ~OWaveLanManagementIBSS(); |
381 | 380 | ||
382 | private: | 381 | private: |
383 | const struct ibss_t* _data; | 382 | const struct ibss_t* _data; |
384 | class Private; | 383 | class Private; |
385 | Private *d; | 384 | Private *d; |
386 | }; | 385 | }; |
387 | 386 | ||
388 | /*====================================================================================== | 387 | /*====================================================================================== |
389 | * OWaveLanManagementChallenge | 388 | * OWaveLanManagementChallenge |
390 | *======================================================================================*/ | 389 | *======================================================================================*/ |
391 | 390 | ||
392 | class OWaveLanManagementChallenge : public QObject | 391 | class OWaveLanManagementChallenge : public QObject |
393 | { | 392 | { |
394 | Q_OBJECT | 393 | Q_OBJECT |
395 | 394 | ||
396 | public: | 395 | public: |
397 | OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); | 396 | OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); |
398 | virtual ~OWaveLanManagementChallenge(); | 397 | virtual ~OWaveLanManagementChallenge(); |
399 | 398 | ||
400 | private: | 399 | private: |
401 | const struct challenge_t* _data; | 400 | const struct challenge_t* _data; |
402 | class Private; | 401 | class Private; |
403 | Private *d; | 402 | Private *d; |
404 | }; | 403 | }; |
405 | 404 | ||
406 | /*====================================================================================== | 405 | /*====================================================================================== |
407 | * OWaveLanDataPacket - type: data (T_DATA) | 406 | * OWaveLanDataPacket - type: data (T_DATA) |
408 | *======================================================================================*/ | 407 | *======================================================================================*/ |
409 | 408 | ||
410 | class OWaveLanDataPacket : public QObject | 409 | class OWaveLanDataPacket : public QObject |
411 | { | 410 | { |
412 | Q_OBJECT | 411 | Q_OBJECT |
413 | 412 | ||
414 | public: | 413 | public: |
415 | OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); | 414 | OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); |
416 | virtual ~OWaveLanDataPacket(); | 415 | virtual ~OWaveLanDataPacket(); |
417 | 416 | ||
418 | private: | 417 | private: |
419 | const struct ieee_802_11_data_header* _header; | 418 | const struct ieee_802_11_data_header* _header; |
420 | class Private; | 419 | class Private; |
421 | Private *d; | 420 | Private *d; |
422 | }; | 421 | }; |
423 | 422 | ||
424 | /*====================================================================================== | 423 | /*====================================================================================== |
425 | * OWaveLanControlPacket - type: control (T_CTRL) | 424 | * OWaveLanControlPacket - type: control (T_CTRL) |
426 | *======================================================================================*/ | 425 | *======================================================================================*/ |
427 | 426 | ||
428 | class OWaveLanControlPacket : public QObject | 427 | class OWaveLanControlPacket : public QObject |
429 | { | 428 | { |
430 | Q_OBJECT | 429 | Q_OBJECT |
431 | 430 | ||
432 | public: | 431 | public: |
433 | OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); | 432 | OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); |
434 | virtual ~OWaveLanControlPacket(); | 433 | virtual ~OWaveLanControlPacket(); |
435 | 434 | ||
436 | QString controlType() const; | 435 | QString controlType() const; |
437 | 436 | ||
438 | private: | 437 | private: |
439 | const struct ieee_802_11_control_header* _header; | 438 | const struct ieee_802_11_control_header* _header; |
440 | class Private; | 439 | class Private; |
441 | Private *d; | 440 | Private *d; |
442 | }; | 441 | }; |
443 | 442 | ||
444 | /*====================================================================================== | 443 | /*====================================================================================== |
445 | * OLLCPacket - IEEE 802.2 Link Level Control | 444 | * OLLCPacket - IEEE 802.2 Link Level Control |
446 | *======================================================================================*/ | 445 | *======================================================================================*/ |
447 | 446 | ||
448 | class OLLCPacket : public QObject | 447 | class OLLCPacket : public QObject |
449 | { | 448 | { |
450 | Q_OBJECT | 449 | Q_OBJECT |
451 | 450 | ||
452 | public: | 451 | public: |
453 | OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); | 452 | OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); |
454 | virtual ~OLLCPacket(); | 453 | virtual ~OLLCPacket(); |
455 | 454 | ||
456 | private: | 455 | private: |
457 | const struct ieee_802_11_802_2_header* _header; | 456 | const struct ieee_802_11_802_2_header* _header; |
458 | class Private; | 457 | class Private; |
459 | Private *d; | 458 | Private *d; |
460 | }; | 459 | }; |
461 | 460 | ||
462 | /*====================================================================================== | 461 | /*====================================================================================== |
463 | * OIPPacket | 462 | * OIPPacket |
464 | *======================================================================================*/ | 463 | *======================================================================================*/ |
465 | 464 | ||
466 | class OIPPacket : public QObject | 465 | class OIPPacket : public QObject |
467 | { | 466 | { |
468 | Q_OBJECT | 467 | Q_OBJECT |
469 | 468 | ||
470 | public: | 469 | public: |
471 | OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); | 470 | OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); |
472 | virtual ~OIPPacket(); | 471 | virtual ~OIPPacket(); |
473 | 472 | ||
474 | QHostAddress fromIPAddress() const; | 473 | QHostAddress fromIPAddress() const; |
475 | QHostAddress toIPAddress() const; | 474 | QHostAddress toIPAddress() const; |
476 | 475 | ||
477 | int tos() const; | 476 | int tos() const; |
478 | int len() const; | 477 | int len() const; |
479 | int id() const; | 478 | int id() const; |
480 | int offset() const; | 479 | int offset() const; |
481 | int ttl() const; | 480 | int ttl() const; |
482 | int protocol() const; | 481 | int protocol() const; |
483 | int checksum() const; | 482 | int checksum() const; |
484 | 483 | ||
485 | private: | 484 | private: |
486 | const struct iphdr* _iphdr; | 485 | const struct iphdr* _iphdr; |
487 | class Private; | 486 | class Private; |
488 | Private *d; | 487 | Private *d; |
489 | }; | 488 | }; |
490 | 489 | ||
491 | /*====================================================================================== | 490 | /*====================================================================================== |
492 | * OARPPacket | 491 | * OARPPacket |
493 | *======================================================================================*/ | 492 | *======================================================================================*/ |
494 | 493 | ||
495 | class OARPPacket : public QObject | 494 | class OARPPacket : public QObject |
496 | { | 495 | { |
497 | Q_OBJECT | 496 | Q_OBJECT |
498 | 497 | ||
499 | public: | 498 | public: |
500 | OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); | 499 | OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); |
501 | virtual ~OARPPacket(); | 500 | virtual ~OARPPacket(); |
502 | 501 | ||
503 | QHostAddress senderIPV4Address() const; | 502 | QHostAddress senderIPV4Address() const; |
504 | OMacAddress senderMacAddress() const; | 503 | OMacAddress senderMacAddress() const; |
505 | QHostAddress targetIPV4Address() const; | 504 | QHostAddress targetIPV4Address() const; |
506 | OMacAddress targetMacAddress() const; | 505 | OMacAddress targetMacAddress() const; |
507 | 506 | ||
508 | //int type() const; | 507 | //int type() const; |
509 | QString type() const; | 508 | QString type() const; |
510 | 509 | ||
511 | private: | 510 | private: |
512 | const struct myarphdr* _arphdr; | 511 | const struct myarphdr* _arphdr; |
513 | class Private; | 512 | class Private; |
514 | Private *d; | 513 | Private *d; |
515 | }; | 514 | }; |
516 | 515 | ||
517 | /*====================================================================================== | 516 | /*====================================================================================== |
518 | * OUDPPacket | 517 | * OUDPPacket |
519 | *======================================================================================*/ | 518 | *======================================================================================*/ |
520 | 519 | ||
521 | class OUDPPacket : public QObject | 520 | class OUDPPacket : public QObject |
522 | { | 521 | { |
523 | Q_OBJECT | 522 | Q_OBJECT |
524 | 523 | ||
525 | public: | 524 | public: |
526 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); | 525 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); |
527 | virtual ~OUDPPacket(); | 526 | virtual ~OUDPPacket(); |
528 | 527 | ||
529 | int fromPort() const; | 528 | int fromPort() const; |
530 | int toPort() const; | 529 | int toPort() const; |
531 | int length() const; | 530 | int length() const; |
532 | int checksum() const; | 531 | int checksum() const; |
533 | 532 | ||
534 | private: | 533 | private: |
535 | const struct udphdr* _udphdr; | 534 | const struct udphdr* _udphdr; |
536 | class Private; | 535 | class Private; |
537 | Private *d; | 536 | Private *d; |
538 | }; | 537 | }; |
539 | 538 | ||
540 | /*====================================================================================== | 539 | /*====================================================================================== |
541 | * ODHCPPacket | 540 | * ODHCPPacket |
542 | *======================================================================================*/ | 541 | *======================================================================================*/ |
543 | 542 | ||
544 | class ODHCPPacket : public QObject | 543 | class ODHCPPacket : public QObject |
545 | { | 544 | { |
546 | Q_OBJECT | 545 | Q_OBJECT |
547 | 546 | ||
548 | public: | 547 | public: |
549 | ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); | 548 | ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); |
550 | virtual ~ODHCPPacket(); | 549 | virtual ~ODHCPPacket(); |
551 | 550 | ||
552 | QHostAddress clientAddress() const; | 551 | QHostAddress clientAddress() const; |
553 | QHostAddress yourAddress() const; | 552 | QHostAddress yourAddress() const; |
554 | QHostAddress serverAddress() const; | 553 | QHostAddress serverAddress() const; |
555 | QHostAddress relayAddress() const; | 554 | QHostAddress relayAddress() const; |
556 | 555 | ||
557 | OMacAddress clientMacAddress() const; | 556 | OMacAddress clientMacAddress() const; |
558 | 557 | ||
559 | bool isRequest() const; | 558 | bool isRequest() const; |
560 | bool isReply() const; | 559 | bool isReply() const; |
561 | QString type() const; | 560 | QString type() const; |
562 | 561 | ||
563 | private: | 562 | private: |
564 | const struct dhcp_packet* _dhcphdr; | 563 | const struct dhcp_packet* _dhcphdr; |
565 | unsigned char _type; | 564 | unsigned char _type; |
566 | class Private; | 565 | class Private; |
567 | Private *d; | 566 | Private *d; |
568 | }; | 567 | }; |
569 | 568 | ||
570 | /*====================================================================================== | 569 | /*====================================================================================== |
571 | * OTCPPacket | 570 | * OTCPPacket |
572 | *======================================================================================*/ | 571 | *======================================================================================*/ |
573 | 572 | ||