-rw-r--r-- | libopie2/opienet/opcap.cpp | 21 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 20 |
2 files changed, 33 insertions, 8 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 4081d4f..c5df041 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -1,281 +1,282 @@ | |||
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; 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 | /* OPIE */ | 31 | /* OPIE */ |
32 | #include <opie2/opcap.h> | 32 | #include <opie2/opcap.h> |
33 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
34 | 34 | ||
35 | /* QT */ | 35 | /* QT */ |
36 | #include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) | 36 | #include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) |
37 | #include <qsocketnotifier.h> | 37 | #include <qsocketnotifier.h> |
38 | #include <qobjectlist.h> | 38 | #include <qobjectlist.h> |
39 | 39 | ||
40 | /* SYSTEM */ | 40 | /* SYSTEM */ |
41 | #include <sys/time.h> | 41 | #include <sys/time.h> |
42 | #include <sys/types.h> | 42 | #include <sys/types.h> |
43 | #include <unistd.h> | 43 | #include <unistd.h> |
44 | 44 | ||
45 | /* LOCAL */ | 45 | /* LOCAL */ |
46 | #include "udp_ports.h" | 46 | #include "udp_ports.h" |
47 | 47 | ||
48 | using namespace Opie::Core; | 48 | using namespace Opie::Core; |
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( data ) | 58 | :QObject( parent, "Generic" ), _hdr( header ), _data( data ) |
59 | { | 59 | { |
60 | //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); | 60 | qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); |
61 | 61 | ||
62 | _end = (unsigned char*) data + header.len; | 62 | _end = (unsigned char*) data + header.len; |
63 | //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); | 63 | //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); |
64 | 64 | ||
65 | switch ( datalink ) | 65 | switch ( datalink ) |
66 | { | 66 | { |
67 | case DLT_EN10MB: | 67 | case DLT_EN10MB: |
68 | odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl; | 68 | odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl; |
69 | new OEthernetPacket( _end, (const struct ether_header*) data, this ); | 69 | new OEthernetPacket( _end, (const struct ether_header*) data, this ); |
70 | break; | 70 | break; |
71 | 71 | ||
72 | case DLT_IEEE802_11: | 72 | case DLT_IEEE802_11: |
73 | odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl; | 73 | odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl; |
74 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); | 74 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); |
75 | break; | 75 | break; |
76 | 76 | ||
77 | case DLT_PRISM_HEADER: | 77 | case DLT_PRISM_HEADER: |
78 | odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl; | 78 | odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl; |
79 | new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); | 79 | new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); |
80 | break; | 80 | break; |
81 | 81 | ||
82 | default: | 82 | default: |
83 | owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl; | 83 | owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
88 | OPacket::~OPacket() | 88 | OPacket::~OPacket() |
89 | { | 89 | { |
90 | qDebug( "OPacket::~OPacket( %s )", name() ); | ||
90 | } | 91 | } |
91 | 92 | ||
92 | 93 | ||
93 | timevalstruct OPacket::timeval() const | 94 | timevalstruct OPacket::timeval() const |
94 | { | 95 | { |
95 | return _hdr.ts; | 96 | return _hdr.ts; |
96 | } | 97 | } |
97 | 98 | ||
98 | 99 | ||
99 | int OPacket::caplen() const | 100 | int OPacket::caplen() const |
100 | { | 101 | { |
101 | return _hdr.caplen; | 102 | return _hdr.caplen; |
102 | } | 103 | } |
103 | 104 | ||
104 | 105 | ||
105 | void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) | 106 | void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) |
106 | { | 107 | { |
107 | if (!l) return; | 108 | if (!l) return; |
108 | QObject* o = l->first(); | 109 | QObject* o = l->first(); |
109 | while ( o ) | 110 | while ( o ) |
110 | { | 111 | { |
111 | stats[o->name()]++; | 112 | stats[o->name()]++; |
112 | updateStats( stats, const_cast<QObjectList*>( o->children() ) ); | 113 | updateStats( stats, const_cast<QObjectList*>( o->children() ) ); |
113 | o = l->next(); | 114 | o = l->next(); |
114 | } | 115 | } |
115 | } | 116 | } |
116 | 117 | ||
117 | 118 | ||
118 | QString OPacket::dumpStructure() const | 119 | QString OPacket::dumpStructure() const |
119 | { | 120 | { |
120 | return "[ |" + _dumpStructure( const_cast<QObjectList*>( this->children() ) ) + " ]"; | 121 | return "[ |" + _dumpStructure( const_cast<QObjectList*>( this->children() ) ) + " ]"; |
121 | } | 122 | } |
122 | 123 | ||
123 | 124 | ||
124 | QString OPacket::_dumpStructure( QObjectList* l ) const | 125 | QString OPacket::_dumpStructure( QObjectList* l ) const |
125 | { | 126 | { |
126 | if (!l) return QString::null; | 127 | if (!l) return QString::null; |
127 | QObject* o = l->first(); | 128 | QObject* o = l->first(); |
128 | QString str(" "); | 129 | QString str(" "); |
129 | 130 | ||
130 | while ( o ) | 131 | while ( o ) |
131 | { | 132 | { |
132 | str.append( o->name() ); | 133 | str.append( o->name() ); |
133 | str.append( " |" ); | 134 | str.append( " |" ); |
134 | str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); | 135 | str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); |
135 | o = l->next(); | 136 | o = l->next(); |
136 | } | 137 | } |
137 | return str; | 138 | return str; |
138 | } | 139 | } |
139 | 140 | ||
140 | QString OPacket::dump( int bpl ) const | 141 | QString OPacket::dump( int bpl ) const |
141 | { | 142 | { |
142 | static int index = 0; | 143 | static int index = 0; |
143 | index++; | 144 | index++; |
144 | int len = _hdr.caplen; | 145 | int len = _hdr.caplen; |
145 | QString str; | 146 | QString str; |
146 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); | 147 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); |
147 | str.append( "0000: " ); | 148 | str.append( "0000: " ); |
148 | QString tmp; | 149 | QString tmp; |
149 | QString bytes; | 150 | QString bytes; |
150 | QString chars; | 151 | QString chars; |
151 | 152 | ||
152 | for ( int i = 0; i < len; ++i ) | 153 | for ( int i = 0; i < len; ++i ) |
153 | { | 154 | { |
154 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); | 155 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); |
155 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); | 156 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); |
156 | else chars.append( '.' ); | 157 | else chars.append( '.' ); |
157 | 158 | ||
158 | if ( !((i+1) % bpl) ) | 159 | if ( !((i+1) % bpl) ) |
159 | { | 160 | { |
160 | str.append( bytes ); | 161 | str.append( bytes ); |
161 | str.append( ' ' ); | 162 | str.append( ' ' ); |
162 | str.append( chars ); | 163 | str.append( chars ); |
163 | str.append( '\n' ); | 164 | str.append( '\n' ); |
164 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); | 165 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); |
165 | bytes = ""; | 166 | bytes = ""; |
166 | chars = ""; | 167 | chars = ""; |
167 | } | 168 | } |
168 | 169 | ||
169 | } | 170 | } |
170 | if ( (len % bpl) ) | 171 | if ( (len % bpl) ) |
171 | { | 172 | { |
172 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); | 173 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); |
173 | str.append( chars ); | 174 | str.append( chars ); |
174 | } | 175 | } |
175 | str.append( '\n' ); | 176 | str.append( '\n' ); |
176 | return str; | 177 | return str; |
177 | } | 178 | } |
178 | 179 | ||
179 | 180 | ||
180 | int OPacket::len() const | 181 | int OPacket::len() const |
181 | { | 182 | { |
182 | return _hdr.len; | 183 | return _hdr.len; |
183 | } | 184 | } |
184 | 185 | ||
185 | 186 | ||
186 | QTextStream& operator<<( QTextStream& s, const OPacket& p ) | 187 | QTextStream& operator<<( QTextStream& s, const OPacket& p ) |
187 | { | 188 | { |
188 | s << p.dumpStructure(); | 189 | s << p.dumpStructure(); |
189 | } | 190 | } |
190 | 191 | ||
191 | 192 | ||
192 | /*====================================================================================== | 193 | /*====================================================================================== |
193 | * OEthernetPacket | 194 | * OEthernetPacket |
194 | *======================================================================================*/ | 195 | *======================================================================================*/ |
195 | 196 | ||
196 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) | 197 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) |
197 | :QObject( parent, "Ethernet" ), _ether( data ) | 198 | :QObject( parent, "Ethernet" ), _ether( data ) |
198 | { | 199 | { |
199 | 200 | ||
200 | odebug << "Source = " << sourceAddress().toString(); | 201 | odebug << "Source = " << sourceAddress().toString(); |
201 | odebug << "Destination = " << destinationAddress().toString(); | 202 | odebug << "Destination = " << destinationAddress().toString(); |
202 | 203 | ||
203 | if ( sourceAddress() == OMacAddress::broadcast ) | 204 | if ( sourceAddress() == OMacAddress::broadcast ) |
204 | odebug << "Source is broadcast address" << oendl; | 205 | odebug << "Source is broadcast address" << oendl; |
205 | if ( destinationAddress() == OMacAddress::broadcast ) | 206 | if ( destinationAddress() == OMacAddress::broadcast ) |
206 | odebug << "Destination is broadcast address" << oendl; | 207 | odebug << "Destination is broadcast address" << oendl; |
207 | 208 | ||
208 | switch ( type() ) | 209 | switch ( type() ) |
209 | { | 210 | { |
210 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; | 211 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; |
211 | case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; | 212 | case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; |
212 | case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } | 213 | case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; } |
213 | default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl; | 214 | default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl; |
214 | } | 215 | } |
215 | 216 | ||
216 | } | 217 | } |
217 | 218 | ||
218 | 219 | ||
219 | OEthernetPacket::~OEthernetPacket() | 220 | OEthernetPacket::~OEthernetPacket() |
220 | { | 221 | { |
221 | } | 222 | } |
222 | 223 | ||
223 | 224 | ||
224 | OMacAddress OEthernetPacket::sourceAddress() const | 225 | OMacAddress OEthernetPacket::sourceAddress() const |
225 | { | 226 | { |
226 | return OMacAddress( _ether->ether_shost ); | 227 | return OMacAddress( _ether->ether_shost ); |
227 | } | 228 | } |
228 | 229 | ||
229 | 230 | ||
230 | OMacAddress OEthernetPacket::destinationAddress() const | 231 | OMacAddress OEthernetPacket::destinationAddress() const |
231 | { | 232 | { |
232 | return OMacAddress( _ether->ether_dhost ); | 233 | return OMacAddress( _ether->ether_dhost ); |
233 | } | 234 | } |
234 | 235 | ||
235 | int OEthernetPacket::type() const | 236 | int OEthernetPacket::type() const |
236 | { | 237 | { |
237 | return ntohs( _ether->ether_type ); | 238 | return ntohs( _ether->ether_type ); |
238 | } | 239 | } |
239 | 240 | ||
240 | 241 | ||
241 | /*====================================================================================== | 242 | /*====================================================================================== |
242 | * OIPPacket | 243 | * OIPPacket |
243 | *======================================================================================*/ | 244 | *======================================================================================*/ |
244 | 245 | ||
245 | 246 | ||
246 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) | 247 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) |
247 | :QObject( parent, "IP" ), _iphdr( data ) | 248 | :QObject( parent, "IP" ), _iphdr( data ) |
248 | { | 249 | { |
249 | odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl; | 250 | odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl; |
250 | 251 | ||
251 | odebug << "FromAddress = " << fromIPAddress().toString() << oendl; | 252 | odebug << "FromAddress = " << fromIPAddress().toString() << oendl; |
252 | odebug << " toAddress = " << toIPAddress().toString() << oendl; | 253 | odebug << " toAddress = " << toIPAddress().toString() << oendl; |
253 | 254 | ||
254 | switch ( protocol() ) | 255 | switch ( protocol() ) |
255 | { | 256 | { |
256 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; | 257 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; |
257 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; | 258 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; |
258 | default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl; | 259 | default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl; |
259 | } | 260 | } |
260 | 261 | ||
261 | } | 262 | } |
262 | 263 | ||
263 | OIPPacket::~OIPPacket() | 264 | OIPPacket::~OIPPacket() |
264 | { | 265 | { |
265 | } | 266 | } |
266 | 267 | ||
267 | 268 | ||
268 | QHostAddress OIPPacket::fromIPAddress() const | 269 | QHostAddress OIPPacket::fromIPAddress() const |
269 | { | 270 | { |
270 | return EXTRACT_32BITS( &_iphdr->saddr ); | 271 | return EXTRACT_32BITS( &_iphdr->saddr ); |
271 | } | 272 | } |
272 | 273 | ||
273 | 274 | ||
274 | QHostAddress OIPPacket::toIPAddress() const | 275 | QHostAddress OIPPacket::toIPAddress() const |
275 | { | 276 | { |
276 | return EXTRACT_32BITS( &_iphdr->saddr ); | 277 | return EXTRACT_32BITS( &_iphdr->saddr ); |
277 | } | 278 | } |
278 | 279 | ||
279 | 280 | ||
280 | int OIPPacket::tos() const | 281 | int OIPPacket::tos() const |
281 | { | 282 | { |
@@ -874,480 +875,492 @@ OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, cons | |||
874 | 875 | ||
875 | 876 | ||
876 | OWaveLanManagementRates::~OWaveLanManagementRates() | 877 | OWaveLanManagementRates::~OWaveLanManagementRates() |
877 | { | 878 | { |
878 | } | 879 | } |
879 | 880 | ||
880 | /*====================================================================================== | 881 | /*====================================================================================== |
881 | * OWaveLanManagementCF | 882 | * OWaveLanManagementCF |
882 | *======================================================================================*/ | 883 | *======================================================================================*/ |
883 | 884 | ||
884 | OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent ) | 885 | OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent ) |
885 | :QObject( parent, "802.11 CF" ), _data( data ) | 886 | :QObject( parent, "802.11 CF" ), _data( data ) |
886 | { | 887 | { |
887 | odebug << "OWaveLanManagementCF()" << oendl; | 888 | odebug << "OWaveLanManagementCF()" << oendl; |
888 | } | 889 | } |
889 | 890 | ||
890 | 891 | ||
891 | OWaveLanManagementCF::~OWaveLanManagementCF() | 892 | OWaveLanManagementCF::~OWaveLanManagementCF() |
892 | { | 893 | { |
893 | } | 894 | } |
894 | 895 | ||
895 | /*====================================================================================== | 896 | /*====================================================================================== |
896 | * OWaveLanManagementFH | 897 | * OWaveLanManagementFH |
897 | *======================================================================================*/ | 898 | *======================================================================================*/ |
898 | 899 | ||
899 | OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent ) | 900 | OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent ) |
900 | :QObject( parent, "802.11 FH" ), _data( data ) | 901 | :QObject( parent, "802.11 FH" ), _data( data ) |
901 | { | 902 | { |
902 | odebug << "OWaveLanManagementFH()" << oendl; | 903 | odebug << "OWaveLanManagementFH()" << oendl; |
903 | } | 904 | } |
904 | 905 | ||
905 | 906 | ||
906 | OWaveLanManagementFH::~OWaveLanManagementFH() | 907 | OWaveLanManagementFH::~OWaveLanManagementFH() |
907 | { | 908 | { |
908 | } | 909 | } |
909 | 910 | ||
910 | /*====================================================================================== | 911 | /*====================================================================================== |
911 | * OWaveLanManagementDS | 912 | * OWaveLanManagementDS |
912 | *======================================================================================*/ | 913 | *======================================================================================*/ |
913 | 914 | ||
914 | OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent ) | 915 | OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent ) |
915 | :QObject( parent, "802.11 DS" ), _data( data ) | 916 | :QObject( parent, "802.11 DS" ), _data( data ) |
916 | { | 917 | { |
917 | odebug << "OWaveLanManagementDS()" << oendl; | 918 | odebug << "OWaveLanManagementDS()" << oendl; |
918 | } | 919 | } |
919 | 920 | ||
920 | 921 | ||
921 | OWaveLanManagementDS::~OWaveLanManagementDS() | 922 | OWaveLanManagementDS::~OWaveLanManagementDS() |
922 | { | 923 | { |
923 | } | 924 | } |
924 | 925 | ||
925 | 926 | ||
926 | int OWaveLanManagementDS::channel() const | 927 | int OWaveLanManagementDS::channel() const |
927 | { | 928 | { |
928 | return _data->channel; | 929 | return _data->channel; |
929 | } | 930 | } |
930 | 931 | ||
931 | /*====================================================================================== | 932 | /*====================================================================================== |
932 | * OWaveLanManagementTim | 933 | * OWaveLanManagementTim |
933 | *======================================================================================*/ | 934 | *======================================================================================*/ |
934 | 935 | ||
935 | OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent ) | 936 | OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent ) |
936 | :QObject( parent, "802.11 Tim" ), _data( data ) | 937 | :QObject( parent, "802.11 Tim" ), _data( data ) |
937 | { | 938 | { |
938 | odebug << "OWaveLanManagementTim()" << oendl; | 939 | odebug << "OWaveLanManagementTim()" << oendl; |
939 | } | 940 | } |
940 | 941 | ||
941 | 942 | ||
942 | OWaveLanManagementTim::~OWaveLanManagementTim() | 943 | OWaveLanManagementTim::~OWaveLanManagementTim() |
943 | { | 944 | { |
944 | } | 945 | } |
945 | 946 | ||
946 | /*====================================================================================== | 947 | /*====================================================================================== |
947 | * OWaveLanManagementIBSS | 948 | * OWaveLanManagementIBSS |
948 | *======================================================================================*/ | 949 | *======================================================================================*/ |
949 | 950 | ||
950 | OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent ) | 951 | OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent ) |
951 | :QObject( parent, "802.11 IBSS" ), _data( data ) | 952 | :QObject( parent, "802.11 IBSS" ), _data( data ) |
952 | { | 953 | { |
953 | odebug << "OWaveLanManagementIBSS()" << oendl; | 954 | odebug << "OWaveLanManagementIBSS()" << oendl; |
954 | } | 955 | } |
955 | 956 | ||
956 | 957 | ||
957 | OWaveLanManagementIBSS::~OWaveLanManagementIBSS() | 958 | OWaveLanManagementIBSS::~OWaveLanManagementIBSS() |
958 | { | 959 | { |
959 | } | 960 | } |
960 | 961 | ||
961 | /*====================================================================================== | 962 | /*====================================================================================== |
962 | * OWaveLanManagementChallenge | 963 | * OWaveLanManagementChallenge |
963 | *======================================================================================*/ | 964 | *======================================================================================*/ |
964 | 965 | ||
965 | OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent ) | 966 | OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent ) |
966 | :QObject( parent, "802.11 Challenge" ), _data( data ) | 967 | :QObject( parent, "802.11 Challenge" ), _data( data ) |
967 | { | 968 | { |
968 | odebug << "OWaveLanManagementChallenge()" << oendl; | 969 | odebug << "OWaveLanManagementChallenge()" << oendl; |
969 | } | 970 | } |
970 | 971 | ||
971 | 972 | ||
972 | OWaveLanManagementChallenge::~OWaveLanManagementChallenge() | 973 | OWaveLanManagementChallenge::~OWaveLanManagementChallenge() |
973 | { | 974 | { |
974 | } | 975 | } |
975 | 976 | ||
976 | /*====================================================================================== | 977 | /*====================================================================================== |
977 | * OWaveLanDataPacket | 978 | * OWaveLanDataPacket |
978 | *======================================================================================*/ | 979 | *======================================================================================*/ |
979 | 980 | ||
980 | OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) | 981 | OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) |
981 | :QObject( parent, "802.11 Data" ), _header( data ) | 982 | :QObject( parent, "802.11 Data" ), _header( data ) |
982 | { | 983 | { |
983 | odebug << "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." << oendl; | 984 | odebug << "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." << oendl; |
984 | 985 | ||
985 | const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); | 986 | const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); |
986 | 987 | ||
987 | #warning The next line works for most cases, but can not be correct generally! | 988 | #warning The next line works for most cases, but can not be correct generally! |
988 | if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address | 989 | if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address |
989 | 990 | ||
990 | new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); | 991 | new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); |
991 | } | 992 | } |
992 | 993 | ||
993 | 994 | ||
994 | OWaveLanDataPacket::~OWaveLanDataPacket() | 995 | OWaveLanDataPacket::~OWaveLanDataPacket() |
995 | { | 996 | { |
996 | } | 997 | } |
997 | 998 | ||
998 | 999 | ||
999 | /*====================================================================================== | 1000 | /*====================================================================================== |
1000 | * OLLCPacket | 1001 | * OLLCPacket |
1001 | *======================================================================================*/ | 1002 | *======================================================================================*/ |
1002 | 1003 | ||
1003 | OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) | 1004 | OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) |
1004 | :QObject( parent, "802.11 LLC" ), _header( data ) | 1005 | :QObject( parent, "802.11 LLC" ), _header( data ) |
1005 | { | 1006 | { |
1006 | odebug << "OLLCPacket::OLLCPacket(): decoding frame..." << oendl; | 1007 | odebug << "OLLCPacket::OLLCPacket(): decoding frame..." << oendl; |
1007 | 1008 | ||
1008 | if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) | 1009 | if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) |
1009 | { | 1010 | { |
1010 | owarn << "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type = " << EXTRACT_16BITS( &_header->type ) << ")" << oendl; | 1011 | owarn << "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type = " << EXTRACT_16BITS( &_header->type ) << ")" << oendl; |
1011 | 1012 | ||
1012 | switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h | 1013 | switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h |
1013 | { | 1014 | { |
1014 | case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; | 1015 | case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; |
1015 | case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; | 1016 | case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; |
1016 | default: owarn << "OLLCPacket::OLLCPacket(): Unknown Encapsulation type = " << EXTRACT_16BITS( &_header->type ) << oendl; | 1017 | default: owarn << "OLLCPacket::OLLCPacket(): Unknown Encapsulation type = " << EXTRACT_16BITS( &_header->type ) << oendl; |
1017 | } | 1018 | } |
1018 | } | 1019 | } |
1019 | } | 1020 | } |
1020 | 1021 | ||
1021 | 1022 | ||
1022 | OLLCPacket::~OLLCPacket() | 1023 | OLLCPacket::~OLLCPacket() |
1023 | { | 1024 | { |
1024 | } | 1025 | } |
1025 | 1026 | ||
1026 | 1027 | ||
1027 | /*====================================================================================== | 1028 | /*====================================================================================== |
1028 | * OWaveLanControlPacket | 1029 | * OWaveLanControlPacket |
1029 | *======================================================================================*/ | 1030 | *======================================================================================*/ |
1030 | 1031 | ||
1031 | OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent ) | 1032 | OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent ) |
1032 | :QObject( parent, "802.11 Control" ), _header( data ) | 1033 | :QObject( parent, "802.11 Control" ), _header( data ) |
1033 | { | 1034 | { |
1034 | odebug << "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." << oendl; | 1035 | odebug << "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." << oendl; |
1035 | odebug << "Detected subtype is " << controlType() << oendl; | 1036 | odebug << "Detected subtype is " << controlType() << oendl; |
1036 | } | 1037 | } |
1037 | 1038 | ||
1038 | 1039 | ||
1039 | OWaveLanControlPacket::~OWaveLanControlPacket() | 1040 | OWaveLanControlPacket::~OWaveLanControlPacket() |
1040 | { | 1041 | { |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | 1044 | ||
1044 | QString OWaveLanControlPacket::controlType() const | 1045 | QString OWaveLanControlPacket::controlType() const |
1045 | { | 1046 | { |
1046 | switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ) | 1047 | switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ) |
1047 | { | 1048 | { |
1048 | case CTRL_PS_POLL: return "PowerSavePoll"; break; | 1049 | case CTRL_PS_POLL: return "PowerSavePoll"; break; |
1049 | case CTRL_RTS: return "RequestToSend"; break; | 1050 | case CTRL_RTS: return "RequestToSend"; break; |
1050 | case CTRL_CTS: return "ClearToSend"; break; | 1051 | case CTRL_CTS: return "ClearToSend"; break; |
1051 | case CTRL_ACK: return "Acknowledge"; break; | 1052 | case CTRL_ACK: return "Acknowledge"; break; |
1052 | case CTRL_CF_END: return "ContentionFreeEnd"; break; | 1053 | case CTRL_CF_END: return "ContentionFreeEnd"; break; |
1053 | case CTRL_END_ACK: return "AcknowledgeEnd"; break; | 1054 | case CTRL_END_ACK: return "AcknowledgeEnd"; break; |
1054 | default: | 1055 | default: |
1055 | owarn << "OWaveLanControlPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl; | 1056 | owarn << "OWaveLanControlPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl; |
1056 | return "Unknown"; | 1057 | return "Unknown"; |
1057 | } | 1058 | } |
1058 | } | 1059 | } |
1059 | 1060 | ||
1060 | 1061 | ||
1061 | /*====================================================================================== | 1062 | /*====================================================================================== |
1062 | * OPacketCapturer | 1063 | * OPacketCapturer |
1063 | *======================================================================================*/ | 1064 | *======================================================================================*/ |
1064 | 1065 | ||
1065 | OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) | 1066 | OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) |
1066 | :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ) | 1067 | :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ), _autodelete( true ) |
1067 | { | 1068 | { |
1068 | } | 1069 | } |
1069 | 1070 | ||
1070 | 1071 | ||
1071 | OPacketCapturer::~OPacketCapturer() | 1072 | OPacketCapturer::~OPacketCapturer() |
1072 | { | 1073 | { |
1073 | if ( _open ) | 1074 | if ( _open ) |
1074 | { | 1075 | { |
1075 | odebug << "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." << oendl; | 1076 | odebug << "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." << oendl; |
1076 | close(); | 1077 | close(); |
1077 | } | 1078 | } |
1078 | } | 1079 | } |
1079 | 1080 | ||
1080 | 1081 | ||
1082 | void OPacketCapturer::setAutoDelete( bool b ) | ||
1083 | { | ||
1084 | _autodelete = b; | ||
1085 | } | ||
1086 | |||
1087 | |||
1088 | bool OPacketCapturer::autoDelete() const | ||
1089 | { | ||
1090 | return _autodelete; | ||
1091 | } | ||
1092 | |||
1093 | |||
1081 | void OPacketCapturer::setBlocking( bool b ) | 1094 | void OPacketCapturer::setBlocking( bool b ) |
1082 | { | 1095 | { |
1083 | if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) | 1096 | if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) |
1084 | { | 1097 | { |
1085 | odebug << "OPacketCapturer::setBlocking(): blocking mode changed successfully." << oendl; | 1098 | odebug << "OPacketCapturer::setBlocking(): blocking mode changed successfully." << oendl; |
1086 | } | 1099 | } |
1087 | else | 1100 | else |
1088 | { | 1101 | { |
1089 | odebug << "OPacketCapturer::setBlocking(): can't change blocking mode: " << _errbuf << oendl; | 1102 | odebug << "OPacketCapturer::setBlocking(): can't change blocking mode: " << _errbuf << oendl; |
1090 | } | 1103 | } |
1091 | } | 1104 | } |
1092 | 1105 | ||
1093 | 1106 | ||
1094 | bool OPacketCapturer::blocking() const | 1107 | bool OPacketCapturer::blocking() const |
1095 | { | 1108 | { |
1096 | int b = pcap_getnonblock( _pch, _errbuf ); | 1109 | int b = pcap_getnonblock( _pch, _errbuf ); |
1097 | if ( b == -1 ) | 1110 | if ( b == -1 ) |
1098 | { | 1111 | { |
1099 | odebug << "OPacketCapturer::blocking(): can't get blocking mode: " << _errbuf << oendl; | 1112 | odebug << "OPacketCapturer::blocking(): can't get blocking mode: " << _errbuf << oendl; |
1100 | return -1; | 1113 | return -1; |
1101 | } | 1114 | } |
1102 | return !b; | 1115 | return !b; |
1103 | } | 1116 | } |
1104 | 1117 | ||
1105 | 1118 | ||
1106 | void OPacketCapturer::closeDumpFile() | 1119 | void OPacketCapturer::closeDumpFile() |
1107 | { | 1120 | { |
1108 | if ( _pcd ) | 1121 | if ( _pcd ) |
1109 | { | 1122 | { |
1110 | pcap_dump_close( _pcd ); | 1123 | pcap_dump_close( _pcd ); |
1111 | _pcd = 0; | 1124 | _pcd = 0; |
1112 | } | 1125 | } |
1113 | pcap_close( _pch ); | 1126 | pcap_close( _pch ); |
1114 | } | 1127 | } |
1115 | 1128 | ||
1116 | 1129 | ||
1117 | void OPacketCapturer::close() | 1130 | void OPacketCapturer::close() |
1118 | { | 1131 | { |
1119 | if ( _open ) | 1132 | if ( _open ) |
1120 | { | 1133 | { |
1121 | if ( _sn ) | 1134 | if ( _sn ) |
1122 | { | 1135 | { |
1123 | _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); | 1136 | _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); |
1124 | delete _sn; | 1137 | delete _sn; |
1125 | } | 1138 | } |
1126 | closeDumpFile(); | 1139 | closeDumpFile(); |
1127 | _open = false; | 1140 | _open = false; |
1128 | } | 1141 | } |
1129 | 1142 | ||
1130 | odebug << "OPacketCapturer::close() --- dumping capturing statistics..." << oendl; | 1143 | odebug << "OPacketCapturer::close() --- dumping capturing statistics..." << oendl; |
1131 | odebug << "--------------------------------------------------" << oendl; | 1144 | odebug << "--------------------------------------------------" << oendl; |
1132 | for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it ) | 1145 | for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it ) |
1133 | odebug << it.key() << " = " << it.data() << oendl; | 1146 | odebug << it.key() << " = " << it.data() << oendl; |
1134 | odebug << "--------------------------------------------------" << oendl; | 1147 | odebug << "--------------------------------------------------" << oendl; |
1135 | 1148 | ||
1136 | } | 1149 | } |
1137 | 1150 | ||
1138 | 1151 | ||
1139 | int OPacketCapturer::dataLink() const | 1152 | int OPacketCapturer::dataLink() const |
1140 | { | 1153 | { |
1141 | return pcap_datalink( _pch ); | 1154 | return pcap_datalink( _pch ); |
1142 | } | 1155 | } |
1143 | 1156 | ||
1144 | 1157 | ||
1145 | void OPacketCapturer::dump( OPacket* p ) | 1158 | void OPacketCapturer::dump( OPacket* p ) |
1146 | { | 1159 | { |
1147 | if ( !_pcd ) | 1160 | if ( !_pcd ) |
1148 | { | 1161 | { |
1149 | owarn << "OPacketCapturer::dump() - cannot dump without open capture file!" << oendl; | 1162 | owarn << "OPacketCapturer::dump() - cannot dump without open capture file!" << oendl; |
1150 | return; | 1163 | return; |
1151 | } | 1164 | } |
1152 | pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data ); | 1165 | pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data ); |
1153 | } | 1166 | } |
1154 | 1167 | ||
1155 | 1168 | ||
1156 | int OPacketCapturer::fileno() const | 1169 | int OPacketCapturer::fileno() const |
1157 | { | 1170 | { |
1158 | if ( _open ) | 1171 | if ( _open ) |
1159 | { | 1172 | { |
1160 | return pcap_fileno( _pch ); | 1173 | return pcap_fileno( _pch ); |
1161 | } | 1174 | } |
1162 | else | 1175 | else |
1163 | { | 1176 | { |
1164 | return -1; | 1177 | return -1; |
1165 | } | 1178 | } |
1166 | } | 1179 | } |
1167 | 1180 | ||
1168 | 1181 | ||
1169 | OPacket* OPacketCapturer::next( int time ) | 1182 | OPacket* OPacketCapturer::next( int time ) |
1170 | { | 1183 | { |
1171 | fd_set fds; | 1184 | fd_set fds; |
1172 | struct timeval tv; | 1185 | struct timeval tv; |
1173 | FD_ZERO( &fds ); | 1186 | FD_ZERO( &fds ); |
1174 | FD_SET( pcap_fileno( _pch ), &fds ); | 1187 | FD_SET( pcap_fileno( _pch ), &fds ); |
1175 | tv.tv_sec = time / 1000; | 1188 | tv.tv_sec = time / 1000; |
1176 | tv.tv_usec = time % 1000; | 1189 | tv.tv_usec = time % 1000; |
1177 | int retval = select( pcap_fileno( _pch )+1, &fds, NULL, NULL, &tv); | 1190 | int retval = select( pcap_fileno( _pch )+1, &fds, NULL, NULL, &tv); |
1178 | if ( retval > 0 ) // clear to read! | 1191 | if ( retval > 0 ) // clear to read! |
1179 | return next(); | 1192 | return next(); |
1180 | else | 1193 | else |
1181 | return 0; | 1194 | return 0; |
1182 | } | 1195 | } |
1183 | 1196 | ||
1184 | 1197 | ||
1185 | OPacket* OPacketCapturer::next() | 1198 | OPacket* OPacketCapturer::next() |
1186 | { | 1199 | { |
1187 | packetheaderstruct header; | 1200 | packetheaderstruct header; |
1188 | odebug << "==> OPacketCapturer::next()" << oendl; | 1201 | odebug << "==> OPacketCapturer::next()" << oendl; |
1189 | const unsigned char* pdata = pcap_next( _pch, &header ); | 1202 | const unsigned char* pdata = pcap_next( _pch, &header ); |
1190 | odebug << "<== OPacketCapturer::next()" << oendl; | 1203 | odebug << "<== OPacketCapturer::next()" << oendl; |
1191 | 1204 | ||
1192 | if ( pdata && header.len ) | 1205 | if ( pdata && header.len ) |
1193 | { | 1206 | { |
1194 | OPacket* p = new OPacket( dataLink(), header, pdata, 0 ); | 1207 | OPacket* p = new OPacket( dataLink(), header, pdata, 0 ); |
1195 | // packets shouldn't be inserted in the QObject child-parent hierarchy, | 1208 | // packets shouldn't be inserted in the QObject child-parent hierarchy, |
1196 | // because due to memory constraints they will be deleted as soon | 1209 | // because due to memory constraints they will be deleted as soon |
1197 | // as possible - that is right after they have been processed | 1210 | // as possible - that is right after they have been processed |
1198 | // by emit() [ see below ] | 1211 | // by emit() [ see below ] |
1199 | //TODO: make gathering statistics optional, because it takes time | 1212 | //TODO: make gathering statistics optional, because it takes time |
1200 | p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); | 1213 | p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); |
1201 | odebug << "OPacket::dumpStructure: " << p->dumpStructure() << oendl; | 1214 | odebug << "OPacket::dumpStructure: " << p->dumpStructure() << oendl; |
1202 | return p; | 1215 | return p; |
1203 | } | 1216 | } |
1204 | else | 1217 | else |
1205 | { | 1218 | { |
1206 | owarn << "OPacketCapturer::next() - no packet received!" << oendl; | 1219 | owarn << "OPacketCapturer::next() - no packet received!" << oendl; |
1207 | return 0; | 1220 | return 0; |
1208 | } | 1221 | } |
1209 | } | 1222 | } |
1210 | 1223 | ||
1211 | 1224 | ||
1212 | bool OPacketCapturer::open( const QString& name ) | 1225 | bool OPacketCapturer::open( const QString& name ) |
1213 | { | 1226 | { |
1214 | if ( _open ) | 1227 | if ( _open ) |
1215 | { | 1228 | { |
1216 | if ( name == _name ) // ignore opening an already openend device | 1229 | if ( name == _name ) // ignore opening an already openend device |
1217 | { | 1230 | { |
1218 | return true; | 1231 | return true; |
1219 | } | 1232 | } |
1220 | else // close the last opened device | 1233 | else // close the last opened device |
1221 | { | 1234 | { |
1222 | close(); | 1235 | close(); |
1223 | } | 1236 | } |
1224 | } | 1237 | } |
1225 | 1238 | ||
1226 | _name = name; | 1239 | _name = name; |
1227 | 1240 | ||
1228 | // open libpcap | 1241 | // open libpcap |
1229 | pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] ); | 1242 | pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] ); |
1230 | 1243 | ||
1231 | if ( !handle ) | 1244 | if ( !handle ) |
1232 | { | 1245 | { |
1233 | owarn << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl; | 1246 | owarn << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl; |
1234 | return false; | 1247 | return false; |
1235 | } | 1248 | } |
1236 | 1249 | ||
1237 | odebug << "OPacketCapturer::open(): libpcap [" << name << "] opened successfully." << oendl; | 1250 | odebug << "OPacketCapturer::open(): libpcap [" << name << "] opened successfully." << oendl; |
1238 | _pch = handle; | 1251 | _pch = handle; |
1239 | _open = true; | 1252 | _open = true; |
1240 | _stats.clear(); | 1253 | _stats.clear(); |
1241 | 1254 | ||
1242 | // in case we have an application object, create a socket notifier | 1255 | // in case we have an application object, create a socket notifier |
1243 | if ( qApp ) //TODO: I don't like this here... | 1256 | if ( qApp ) //TODO: I don't like this here... |
1244 | { | 1257 | { |
1245 | _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); | 1258 | _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); |
1246 | connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); | 1259 | connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); |
1247 | } | 1260 | } |
1248 | 1261 | ||
1249 | return true; | 1262 | return true; |
1250 | } | 1263 | } |
1251 | 1264 | ||
1252 | 1265 | ||
1253 | bool OPacketCapturer::openDumpFile( const QString& filename ) | 1266 | bool OPacketCapturer::openDumpFile( const QString& filename ) |
1254 | { | 1267 | { |
1255 | pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); | 1268 | pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); |
1256 | if ( !dump ) | 1269 | if ( !dump ) |
1257 | { | 1270 | { |
1258 | owarn << "OPacketCapturer::open(): can't open dump with '" << filename << "': " << _errbuf << oendl; | 1271 | owarn << "OPacketCapturer::open(): can't open dump with '" << filename << "': " << _errbuf << oendl; |
1259 | return false; | 1272 | return false; |
1260 | } | 1273 | } |
1261 | odebug << "OPacketCapturer::open(): dump [" << filename << "] opened successfully." << oendl; | 1274 | odebug << "OPacketCapturer::open(): dump [" << filename << "] opened successfully." << oendl; |
1262 | _pcd = dump; | 1275 | _pcd = dump; |
1263 | 1276 | ||
1264 | return true; | 1277 | return true; |
1265 | } | 1278 | } |
1266 | 1279 | ||
1267 | 1280 | ||
1268 | bool OPacketCapturer::open( const QFile& file ) | 1281 | bool OPacketCapturer::open( const QFile& file ) |
1269 | { | 1282 | { |
1270 | QString name = file.name(); | 1283 | QString name = file.name(); |
1271 | 1284 | ||
1272 | if ( _open ) | 1285 | if ( _open ) |
1273 | { | 1286 | { |
1274 | close(); | 1287 | close(); |
1275 | if ( name == _name ) // ignore opening an already openend device | 1288 | if ( name == _name ) // ignore opening an already openend device |
1276 | { | 1289 | { |
1277 | return true; | 1290 | return true; |
1278 | } | 1291 | } |
1279 | else // close the last opened device | 1292 | else // close the last opened device |
1280 | { | 1293 | { |
1281 | close(); | 1294 | close(); |
1282 | } | 1295 | } |
1283 | } | 1296 | } |
1284 | 1297 | ||
1285 | _name = name; | 1298 | _name = name; |
1286 | 1299 | ||
1287 | pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] ); | 1300 | pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] ); |
1288 | 1301 | ||
1289 | if ( handle ) | 1302 | if ( handle ) |
1290 | { | 1303 | { |
1291 | odebug << "OPacketCapturer::open(): libpcap opened successfully." << oendl; | 1304 | odebug << "OPacketCapturer::open(): libpcap opened successfully." << oendl; |
1292 | _pch = handle; | 1305 | _pch = handle; |
1293 | _open = true; | 1306 | _open = true; |
1294 | 1307 | ||
1295 | // in case we have an application object, create a socket notifier | 1308 | // in case we have an application object, create a socket notifier |
1296 | if ( qApp ) | 1309 | if ( qApp ) |
1297 | { | 1310 | { |
1298 | _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); | 1311 | _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); |
1299 | connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); | 1312 | connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); |
1300 | } | 1313 | } |
1301 | 1314 | ||
1302 | return true; | 1315 | return true; |
1303 | } | 1316 | } |
1304 | else | 1317 | else |
1305 | { | 1318 | { |
1306 | odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl; | 1319 | odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl; |
1307 | return false; | 1320 | return false; |
1308 | } | 1321 | } |
1309 | 1322 | ||
1310 | } | 1323 | } |
1311 | 1324 | ||
1312 | 1325 | ||
1313 | bool OPacketCapturer::isOpen() const | 1326 | bool OPacketCapturer::isOpen() const |
1314 | { | 1327 | { |
1315 | return _open; | 1328 | return _open; |
1316 | } | 1329 | } |
1317 | 1330 | ||
1318 | 1331 | ||
1319 | void OPacketCapturer::readyToReceive() | 1332 | void OPacketCapturer::readyToReceive() |
1320 | { | 1333 | { |
1321 | odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl; | 1334 | odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl; |
1322 | OPacket* p = next(); | 1335 | OPacket* p = next(); |
1323 | emit receivedPacket( p ); | 1336 | emit receivedPacket( p ); |
1324 | // emit is synchronous - packet has been dealt with, now it's safe to delete | 1337 | // emit is synchronous - packet has been dealt with, now it's safe to delete (if enabled) |
1325 | delete p; | 1338 | if ( _autodelete ) delete p; |
1326 | } | 1339 | } |
1327 | 1340 | ||
1328 | 1341 | ||
1329 | const QMap<QString,int>& OPacketCapturer::statistics() const | 1342 | const QMap<QString,int>& OPacketCapturer::statistics() const |
1330 | { | 1343 | { |
1331 | return _stats; | 1344 | return _stats; |
1332 | } | 1345 | } |
1333 | 1346 | ||
1334 | 1347 | ||
1335 | int OPacketCapturer::snapShot() const | 1348 | int OPacketCapturer::snapShot() const |
1336 | { | 1349 | { |
1337 | return pcap_snapshot( _pch ); | 1350 | return pcap_snapshot( _pch ); |
1338 | } | 1351 | } |
1339 | 1352 | ||
1340 | 1353 | ||
1341 | bool OPacketCapturer::swapped() const | 1354 | bool OPacketCapturer::swapped() const |
1342 | { | 1355 | { |
1343 | return pcap_is_swapped( _pch ); | 1356 | return pcap_is_swapped( _pch ); |
1344 | } | 1357 | } |
1345 | 1358 | ||
1346 | 1359 | ||
1347 | QString OPacketCapturer::version() const | 1360 | QString OPacketCapturer::version() const |
1348 | { | 1361 | { |
1349 | return QString().sprintf( "%d.%d", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); | 1362 | return QString().sprintf( "%d.%d", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); |
1350 | } | 1363 | } |
1351 | 1364 | ||
1352 | } | 1365 | } |
1353 | } | 1366 | } |
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index 72a78de..4ff8495 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h | |||
@@ -1,331 +1,330 @@ | |||
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; 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 | #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 | 61 | ||
62 | /* TYPEDEFS */ | 62 | /* TYPEDEFS */ |
63 | typedef struct timeval timevalstruct; | 63 | typedef struct timeval timevalstruct; |
64 | typedef struct pcap_pkthdr packetheaderstruct; | 64 | typedef struct pcap_pkthdr packetheaderstruct; |
65 | 65 | ||
66 | /* FORWARDS */ | 66 | /* FORWARDS */ |
67 | class QSocketNotifier; | 67 | class QSocketNotifier; |
68 | namespace Opie { | 68 | namespace Opie { |
69 | namespace Net { | 69 | namespace Net { |
70 | class OPacketCapturer; | 70 | class OPacketCapturer; |
71 | 71 | ||
72 | /*====================================================================================== | 72 | /*====================================================================================== |
73 | * OPacket - A frame on the wire | 73 | * OPacket - A frame on the wire |
74 | *======================================================================================*/ | 74 | *======================================================================================*/ |
75 | 75 | ||
76 | /** @brief A class representing a data frame on the wire. | 76 | /** @brief A class representing a data frame on the wire. |
77 | * | 77 | * |
78 | * The whole family of the packet classes are used when capturing frames from a network. | 78 | * 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 | 79 | * 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 | 80 | * a packet header and then the packet payload. In layered architectures, each lower layer |
81 | * encapsulates data from its upper layer - that is it | 81 | * 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, | 82 | * 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 | 83 | * 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. | 84 | * example for how such a data frame is composed out of packets, e.g. when sending a mail. |
85 | * | 85 | * |
86 | * <pre> | 86 | * <pre> |
87 | * | User Data | == Mail Data | 87 | * | User Data | == Mail Data |
88 | * | SMTP Header | User Data | == SMTP | 88 | * | SMTP Header | User Data | == SMTP |
89 | * | TCP Header | SMTP Header | User Data | == TCP | 89 | * | TCP Header | SMTP Header | User Data | == TCP |
90 | * | IP Header | TCP Header | SMTP Header | User Data | == IP | 90 | * | IP Header | TCP Header | SMTP Header | User Data | == IP |
91 | * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC | 91 | * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC |
92 | * | 92 | * |
93 | * </pre> | 93 | * </pre> |
94 | * | 94 | * |
95 | * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer | 95 | * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer |
96 | * also contains a few more levels of encapsulation. | 96 | * also contains a few more levels of encapsulation. |
97 | * Since the type of the payload is more or less independent from the encapsulating protocol, | 97 | * 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 | 98 | * 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. | 99 | * encapsulation level varies and can't be deduced without actually looking into the packets. |
100 | * | 100 | * |
101 | * For actually working with captured frames, it's useful to identify the packets via names and | 101 | * 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 | 102 | * 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 | 103 | * 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 | 104 | * 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 | 105 | * 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. | 106 | * QObject also cares about destroying the sub-, (child-) packets. |
107 | * | 107 | * |
108 | * This enables us to perform a simple look for packets of a certain type: | 108 | * This enables us to perform a simple look for packets of a certain type: |
109 | * @code | 109 | * @code |
110 | * OPacketCapturer* pcap = new OPacketCapturer(); | 110 | * OPacketCapturer* pcap = new OPacketCapturer(); |
111 | * pcap->open( "eth0" ); | 111 | * pcap->open( "eth0" ); |
112 | * OPacket* p = pcap->next(); | 112 | * OPacket* p = pcap->next(); |
113 | * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists | 113 | * 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; | 114 | * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; |
115 | * | 115 | * |
116 | */ | 116 | */ |
117 | 117 | ||
118 | class OPacket : public QObject | 118 | class OPacket : public QObject |
119 | { | 119 | { |
120 | Q_OBJECT | 120 | Q_OBJECT |
121 | 121 | ||
122 | friend class OPacketCapturer; | 122 | friend class OPacketCapturer; |
123 | friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); | 123 | friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); |
124 | 124 | ||
125 | public: | 125 | public: |
126 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); | 126 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); |
127 | virtual ~OPacket(); | 127 | virtual ~OPacket(); |
128 | 128 | ||
129 | timevalstruct timeval() const; | 129 | timevalstruct timeval() const; |
130 | 130 | ||
131 | int caplen() const; | 131 | int caplen() const; |
132 | int len() const; | 132 | int len() const; |
133 | QString dump( int = 32 ) const; | 133 | QString dump( int = 32 ) const; |
134 | 134 | ||
135 | void updateStats( QMap<QString,int>&, QObjectList* ); | 135 | void updateStats( QMap<QString,int>&, QObjectList* ); |
136 | 136 | ||
137 | private: | ||
138 | |||
139 | QString dumpStructure() const; | 137 | QString dumpStructure() const; |
138 | private: | ||
140 | QString _dumpStructure( QObjectList* ) const; | 139 | QString _dumpStructure( QObjectList* ) const; |
141 | 140 | ||
142 | private: | 141 | private: |
143 | const packetheaderstruct _hdr; // pcap packet header | 142 | const packetheaderstruct _hdr; // pcap packet header |
144 | const unsigned char* _data; // pcap packet data | 143 | const unsigned char* _data; // pcap packet data |
145 | const unsigned char* _end; // end of pcap packet data | 144 | const unsigned char* _end; // end of pcap packet data |
146 | private: | 145 | private: |
147 | class Private; | 146 | class Private; |
148 | Private *d; | 147 | Private *d; |
149 | }; | 148 | }; |
150 | 149 | ||
151 | QTextStream& operator<<( QTextStream& s, const OPacket& p ); | 150 | QTextStream& operator<<( QTextStream& s, const OPacket& p ); |
152 | 151 | ||
153 | /*====================================================================================== | 152 | /*====================================================================================== |
154 | * OEthernetPacket - DLT_EN10MB frame | 153 | * OEthernetPacket - DLT_EN10MB frame |
155 | *======================================================================================*/ | 154 | *======================================================================================*/ |
156 | 155 | ||
157 | class OEthernetPacket : public QObject | 156 | class OEthernetPacket : public QObject |
158 | { | 157 | { |
159 | Q_OBJECT | 158 | Q_OBJECT |
160 | 159 | ||
161 | public: | 160 | public: |
162 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); | 161 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); |
163 | virtual ~OEthernetPacket(); | 162 | virtual ~OEthernetPacket(); |
164 | 163 | ||
165 | OMacAddress sourceAddress() const; | 164 | OMacAddress sourceAddress() const; |
166 | OMacAddress destinationAddress() const; | 165 | OMacAddress destinationAddress() const; |
167 | int type() const; | 166 | int type() const; |
168 | 167 | ||
169 | private: | 168 | private: |
170 | const struct ether_header* _ether; | 169 | const struct ether_header* _ether; |
171 | private: | 170 | private: |
172 | class Private; | 171 | class Private; |
173 | Private *d; | 172 | Private *d; |
174 | }; | 173 | }; |
175 | 174 | ||
176 | /*====================================================================================== | 175 | /*====================================================================================== |
177 | * OPrismHeaderPacket - DLT_PRISM_HEADER frame | 176 | * OPrismHeaderPacket - DLT_PRISM_HEADER frame |
178 | *======================================================================================*/ | 177 | *======================================================================================*/ |
179 | 178 | ||
180 | class OPrismHeaderPacket : public QObject | 179 | class OPrismHeaderPacket : public QObject |
181 | { | 180 | { |
182 | Q_OBJECT | 181 | Q_OBJECT |
183 | 182 | ||
184 | public: | 183 | public: |
185 | OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); | 184 | OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); |
186 | virtual ~OPrismHeaderPacket(); | 185 | virtual ~OPrismHeaderPacket(); |
187 | 186 | ||
188 | unsigned int signalStrength() const; | 187 | unsigned int signalStrength() const; |
189 | 188 | ||
190 | private: | 189 | private: |
191 | const struct prism_hdr* _header; | 190 | const struct prism_hdr* _header; |
192 | class Private; | 191 | class Private; |
193 | Private *d; | 192 | Private *d; |
194 | }; | 193 | }; |
195 | 194 | ||
196 | /*====================================================================================== | 195 | /*====================================================================================== |
197 | * OWaveLanPacket - DLT_IEEE802_11 frame | 196 | * OWaveLanPacket - DLT_IEEE802_11 frame |
198 | *======================================================================================*/ | 197 | *======================================================================================*/ |
199 | 198 | ||
200 | class OWaveLanPacket : public QObject | 199 | class OWaveLanPacket : public QObject |
201 | { | 200 | { |
202 | Q_OBJECT | 201 | Q_OBJECT |
203 | 202 | ||
204 | public: | 203 | public: |
205 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); | 204 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); |
206 | virtual ~OWaveLanPacket(); | 205 | virtual ~OWaveLanPacket(); |
207 | 206 | ||
208 | int duration() const; | 207 | int duration() const; |
209 | bool fromDS() const; | 208 | bool fromDS() const; |
210 | bool toDS() const; | 209 | bool toDS() const; |
211 | virtual OMacAddress macAddress1() const; | 210 | virtual OMacAddress macAddress1() const; |
212 | virtual OMacAddress macAddress2() const; | 211 | virtual OMacAddress macAddress2() const; |
213 | virtual OMacAddress macAddress3() const; | 212 | virtual OMacAddress macAddress3() const; |
214 | virtual OMacAddress macAddress4() const; | 213 | virtual OMacAddress macAddress4() const; |
215 | bool usesPowerManagement() const; | 214 | bool usesPowerManagement() const; |
216 | int type() const; | 215 | int type() const; |
217 | int subType() const; | 216 | int subType() const; |
218 | int version() const; | 217 | int version() const; |
219 | bool usesWep() const; | 218 | bool usesWep() const; |
220 | 219 | ||
221 | private: | 220 | private: |
222 | const struct ieee_802_11_header* _wlanhdr; | 221 | const struct ieee_802_11_header* _wlanhdr; |
223 | class Private; | 222 | class Private; |
224 | Private *d; | 223 | Private *d; |
225 | }; | 224 | }; |
226 | 225 | ||
227 | 226 | ||
228 | /*====================================================================================== | 227 | /*====================================================================================== |
229 | * OWaveLanManagementPacket - type: management (T_MGMT) | 228 | * OWaveLanManagementPacket - type: management (T_MGMT) |
230 | *======================================================================================*/ | 229 | *======================================================================================*/ |
231 | 230 | ||
232 | class OWaveLanManagementPacket : public QObject | 231 | class OWaveLanManagementPacket : public QObject |
233 | { | 232 | { |
234 | Q_OBJECT | 233 | Q_OBJECT |
235 | 234 | ||
236 | public: | 235 | public: |
237 | OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); | 236 | OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); |
238 | virtual ~OWaveLanManagementPacket(); | 237 | virtual ~OWaveLanManagementPacket(); |
239 | 238 | ||
240 | QString managementType() const; | 239 | QString managementType() const; |
241 | 240 | ||
242 | int beaconInterval() const; | 241 | int beaconInterval() const; |
243 | int capabilities() const; // generic | 242 | int capabilities() const; // generic |
244 | 243 | ||
245 | bool canESS() const; | 244 | bool canESS() const; |
246 | bool canIBSS() const; | 245 | bool canIBSS() const; |
247 | bool canCFP() const; | 246 | bool canCFP() const; |
248 | bool canCFP_REQ() const; | 247 | bool canCFP_REQ() const; |
249 | bool canPrivacy() const; | 248 | bool canPrivacy() const; |
250 | 249 | ||
251 | private: | 250 | private: |
252 | const struct ieee_802_11_mgmt_header* _header; | 251 | const struct ieee_802_11_mgmt_header* _header; |
253 | const struct ieee_802_11_mgmt_body* _body; | 252 | const struct ieee_802_11_mgmt_body* _body; |
254 | class Private; | 253 | class Private; |
255 | Private *d; | 254 | Private *d; |
256 | }; | 255 | }; |
257 | 256 | ||
258 | 257 | ||
259 | /*====================================================================================== | 258 | /*====================================================================================== |
260 | * OWaveLanManagementSSID | 259 | * OWaveLanManagementSSID |
261 | *======================================================================================*/ | 260 | *======================================================================================*/ |
262 | 261 | ||
263 | class OWaveLanManagementSSID : public QObject | 262 | class OWaveLanManagementSSID : public QObject |
264 | { | 263 | { |
265 | Q_OBJECT | 264 | Q_OBJECT |
266 | 265 | ||
267 | public: | 266 | public: |
268 | OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); | 267 | OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); |
269 | virtual ~OWaveLanManagementSSID(); | 268 | virtual ~OWaveLanManagementSSID(); |
270 | 269 | ||
271 | QString ID( bool decloak = false ) const; | 270 | QString ID( bool decloak = false ) const; |
272 | 271 | ||
273 | private: | 272 | private: |
274 | const struct ssid_t* _data; | 273 | const struct ssid_t* _data; |
275 | class Private; | 274 | class Private; |
276 | Private *d; | 275 | Private *d; |
277 | }; | 276 | }; |
278 | 277 | ||
279 | /*====================================================================================== | 278 | /*====================================================================================== |
280 | * OWaveLanManagementRates | 279 | * OWaveLanManagementRates |
281 | *======================================================================================*/ | 280 | *======================================================================================*/ |
282 | 281 | ||
283 | class OWaveLanManagementRates : public QObject | 282 | class OWaveLanManagementRates : public QObject |
284 | { | 283 | { |
285 | Q_OBJECT | 284 | Q_OBJECT |
286 | 285 | ||
287 | public: | 286 | public: |
288 | OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); | 287 | OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); |
289 | virtual ~OWaveLanManagementRates(); | 288 | virtual ~OWaveLanManagementRates(); |
290 | 289 | ||
291 | private: | 290 | private: |
292 | const struct rates_t* _data; | 291 | const struct rates_t* _data; |
293 | class Private; | 292 | class Private; |
294 | Private *d; | 293 | Private *d; |
295 | }; | 294 | }; |
296 | 295 | ||
297 | /*====================================================================================== | 296 | /*====================================================================================== |
298 | * OWaveLanManagementCF | 297 | * OWaveLanManagementCF |
299 | *======================================================================================*/ | 298 | *======================================================================================*/ |
300 | 299 | ||
301 | class OWaveLanManagementCF : public QObject | 300 | class OWaveLanManagementCF : public QObject |
302 | { | 301 | { |
303 | Q_OBJECT | 302 | Q_OBJECT |
304 | 303 | ||
305 | public: | 304 | public: |
306 | OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); | 305 | OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); |
307 | virtual ~OWaveLanManagementCF(); | 306 | virtual ~OWaveLanManagementCF(); |
308 | 307 | ||
309 | private: | 308 | private: |
310 | const struct cf_t* _data; | 309 | const struct cf_t* _data; |
311 | class Private; | 310 | class Private; |
312 | Private *d; | 311 | Private *d; |
313 | }; | 312 | }; |
314 | 313 | ||
315 | /*====================================================================================== | 314 | /*====================================================================================== |
316 | * OWaveLanManagementFH | 315 | * OWaveLanManagementFH |
317 | *======================================================================================*/ | 316 | *======================================================================================*/ |
318 | 317 | ||
319 | class OWaveLanManagementFH : public QObject | 318 | class OWaveLanManagementFH : public QObject |
320 | { | 319 | { |
321 | Q_OBJECT | 320 | Q_OBJECT |
322 | 321 | ||
323 | public: | 322 | public: |
324 | OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); | 323 | OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); |
325 | virtual ~OWaveLanManagementFH(); | 324 | virtual ~OWaveLanManagementFH(); |
326 | 325 | ||
327 | private: | 326 | private: |
328 | const struct fh_t* _data; | 327 | const struct fh_t* _data; |
329 | class Private; | 328 | class Private; |
330 | Private *d; | 329 | Private *d; |
331 | }; | 330 | }; |
@@ -504,218 +503,231 @@ class OARPPacket : public QObject | |||
504 | QHostAddress senderIPV4Address() const; | 503 | QHostAddress senderIPV4Address() const; |
505 | OMacAddress senderMacAddress() const; | 504 | OMacAddress senderMacAddress() const; |
506 | QHostAddress targetIPV4Address() const; | 505 | QHostAddress targetIPV4Address() const; |
507 | OMacAddress targetMacAddress() const; | 506 | OMacAddress targetMacAddress() const; |
508 | 507 | ||
509 | //int type() const; | 508 | //int type() const; |
510 | QString type() const; | 509 | QString type() const; |
511 | 510 | ||
512 | private: | 511 | private: |
513 | const struct myarphdr* _arphdr; | 512 | const struct myarphdr* _arphdr; |
514 | class Private; | 513 | class Private; |
515 | Private *d; | 514 | Private *d; |
516 | }; | 515 | }; |
517 | 516 | ||
518 | /*====================================================================================== | 517 | /*====================================================================================== |
519 | * OUDPPacket | 518 | * OUDPPacket |
520 | *======================================================================================*/ | 519 | *======================================================================================*/ |
521 | 520 | ||
522 | class OUDPPacket : public QObject | 521 | class OUDPPacket : public QObject |
523 | { | 522 | { |
524 | Q_OBJECT | 523 | Q_OBJECT |
525 | 524 | ||
526 | public: | 525 | public: |
527 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); | 526 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); |
528 | virtual ~OUDPPacket(); | 527 | virtual ~OUDPPacket(); |
529 | 528 | ||
530 | int fromPort() const; | 529 | int fromPort() const; |
531 | int toPort() const; | 530 | int toPort() const; |
532 | int length() const; | 531 | int length() const; |
533 | int checksum() const; | 532 | int checksum() const; |
534 | 533 | ||
535 | private: | 534 | private: |
536 | const struct udphdr* _udphdr; | 535 | const struct udphdr* _udphdr; |
537 | class Private; | 536 | class Private; |
538 | Private *d; | 537 | Private *d; |
539 | }; | 538 | }; |
540 | 539 | ||
541 | /*====================================================================================== | 540 | /*====================================================================================== |
542 | * ODHCPPacket | 541 | * ODHCPPacket |
543 | *======================================================================================*/ | 542 | *======================================================================================*/ |
544 | 543 | ||
545 | class ODHCPPacket : public QObject | 544 | class ODHCPPacket : public QObject |
546 | { | 545 | { |
547 | Q_OBJECT | 546 | Q_OBJECT |
548 | 547 | ||
549 | public: | 548 | public: |
550 | ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); | 549 | ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); |
551 | virtual ~ODHCPPacket(); | 550 | virtual ~ODHCPPacket(); |
552 | 551 | ||
553 | QHostAddress clientAddress() const; | 552 | QHostAddress clientAddress() const; |
554 | QHostAddress yourAddress() const; | 553 | QHostAddress yourAddress() const; |
555 | QHostAddress serverAddress() const; | 554 | QHostAddress serverAddress() const; |
556 | QHostAddress relayAddress() const; | 555 | QHostAddress relayAddress() const; |
557 | 556 | ||
558 | OMacAddress clientMacAddress() const; | 557 | OMacAddress clientMacAddress() const; |
559 | 558 | ||
560 | bool isRequest() const; | 559 | bool isRequest() const; |
561 | bool isReply() const; | 560 | bool isReply() const; |
562 | QString type() const; | 561 | QString type() const; |
563 | 562 | ||
564 | private: | 563 | private: |
565 | const struct dhcp_packet* _dhcphdr; | 564 | const struct dhcp_packet* _dhcphdr; |
566 | unsigned char _type; | 565 | unsigned char _type; |
567 | class Private; | 566 | class Private; |
568 | Private *d; | 567 | Private *d; |
569 | }; | 568 | }; |
570 | 569 | ||
571 | /*====================================================================================== | 570 | /*====================================================================================== |
572 | * OTCPPacket | 571 | * OTCPPacket |
573 | *======================================================================================*/ | 572 | *======================================================================================*/ |
574 | 573 | ||
575 | class OTCPPacket : public QObject | 574 | class OTCPPacket : public QObject |
576 | { | 575 | { |
577 | Q_OBJECT | 576 | Q_OBJECT |
578 | 577 | ||
579 | public: | 578 | public: |
580 | OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); | 579 | OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); |
581 | virtual ~OTCPPacket(); | 580 | virtual ~OTCPPacket(); |
582 | 581 | ||
583 | int fromPort() const; | 582 | int fromPort() const; |
584 | int toPort() const; | 583 | int toPort() const; |
585 | int seq() const; | 584 | int seq() const; |
586 | int ack() const; | 585 | int ack() const; |
587 | int window() const; | 586 | int window() const; |
588 | int checksum() const; | 587 | int checksum() const; |
589 | 588 | ||
590 | private: | 589 | private: |
591 | const struct tcphdr* _tcphdr; | 590 | const struct tcphdr* _tcphdr; |
592 | class Private; | 591 | class Private; |
593 | Private *d; | 592 | Private *d; |
594 | }; | 593 | }; |
595 | 594 | ||
596 | 595 | ||
597 | /*====================================================================================== | 596 | /*====================================================================================== |
598 | * OPacketCapturer | 597 | * OPacketCapturer |
599 | *======================================================================================*/ | 598 | *======================================================================================*/ |
600 | 599 | ||
601 | /** | 600 | /** |
602 | * @brief A class based wrapper for network packet capturing. | 601 | * @brief A class based wrapper for network packet capturing. |
603 | * | 602 | * |
604 | * This class is the base of a high-level interface to the well known packet capturing | 603 | * This class is the base of a high-level interface to the well known packet capturing |
605 | * library libpcap. | 604 | * library libpcap. |
606 | * @see http://tcpdump.org | 605 | * @see http://tcpdump.org |
607 | */ | 606 | */ |
608 | class OPacketCapturer : public QObject | 607 | class OPacketCapturer : public QObject |
609 | { | 608 | { |
610 | Q_OBJECT | 609 | Q_OBJECT |
611 | 610 | ||
612 | public: | 611 | public: |
613 | /** | 612 | /** |
614 | * Constructor. | 613 | * Constructor. |
615 | */ | 614 | */ |
616 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); | 615 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); |
617 | /** | 616 | /** |
618 | * Destructor. | 617 | * Destructor. |
619 | */ | 618 | */ |
620 | ~OPacketCapturer(); | 619 | ~OPacketCapturer(); |
621 | /** | 620 | /** |
622 | * Set the packet capturer to use blocking or non-blocking IO. This can be useful when | 621 | * Set the packet capturer to use blocking or non-blocking IO. This can be useful when |
623 | * not using the socket notifier, e.g. without an application object. | 622 | * not using the socket notifier, e.g. without an application object. |
624 | */ | 623 | */ |
625 | void setBlocking( bool ); | 624 | void setBlocking( bool ); |
626 | /** | 625 | /** |
627 | * @returns true if the packet capturer uses blocking IO calls. | 626 | * @returns true if the packet capturer uses blocking IO calls. |
628 | */ | 627 | */ |
629 | bool blocking() const; | 628 | bool blocking() const; |
630 | /** | 629 | /** |
631 | * Close the packet capturer. This is automatically done in the destructor. | 630 | * Close the packet capturer. This is automatically done in the destructor. |
632 | */ | 631 | */ |
633 | void close(); | 632 | void close(); |
634 | /** | 633 | /** |
635 | * Close the output capture file. | 634 | * Close the output capture file. |
636 | */ | 635 | */ |
637 | void closeDumpFile(); | 636 | void closeDumpFile(); |
638 | /** | 637 | /** |
639 | * @returns the data link type. | 638 | * @returns the data link type. |
640 | * @see <pcap.h> for possible values. | 639 | * @see <pcap.h> for possible values. |
641 | */ | 640 | */ |
642 | int dataLink() const; | 641 | int dataLink() const; |
643 | /** | 642 | /** |
644 | * Dump a packet to the output capture file. | 643 | * Dump a packet to the output capture file. |
645 | */ | 644 | */ |
646 | void dump( OPacket* ); | 645 | void dump( OPacket* ); |
647 | /** | 646 | /** |
648 | * @returns the file descriptor of the packet capturer. This is only useful, if | 647 | * @returns the file descriptor of the packet capturer. This is only useful, if |
649 | * not using the socket notifier, e.g. without an application object. | 648 | * not using the socket notifier, e.g. without an application object. |
650 | */ | 649 | */ |
651 | int fileno() const; | 650 | int fileno() const; |
652 | /** | 651 | /** |
653 | * @returns the next @ref OPacket from the packet capturer. | 652 | * @returns the next @ref OPacket from the packet capturer. |
654 | * @note If blocking mode is true then this call might block. | 653 | * @note If blocking mode is true then this call might block. |
655 | */ | 654 | */ |
656 | OPacket* next(); | 655 | OPacket* next(); |
657 | /** | 656 | /** |
658 | * @returns the next @ref OPacket from the packet capturer, if | 657 | * @returns the next @ref OPacket from the packet capturer, if |
659 | * one arrives within @a time milliseconds. | 658 | * one arrives within @a time milliseconds. |
660 | */ | 659 | */ |
661 | OPacket* next( int time ); | 660 | OPacket* next( int time ); |
662 | /** | 661 | /** |
663 | * Open the packet capturer to capture packets in live-mode from @a interface. | 662 | * Open the packet capturer to capture packets in live-mode from @a interface. |
664 | */ | 663 | */ |
665 | bool open( const QString& interface ); | 664 | bool open( const QString& interface ); |
666 | /** | 665 | /** |
667 | * Open the packet capturer to capture packets in offline-mode from @a file. | 666 | * Open the packet capturer to capture packets in offline-mode from @a file. |
668 | */ | 667 | */ |
669 | bool open( const QFile& file ); | 668 | bool open( const QFile& file ); |
670 | /** | 669 | /** |
671 | * Open a prerecorded tcpdump compatible capture file for use with @ref dump() | 670 | * Open a prerecorded tcpdump compatible capture file for use with @ref dump() |
672 | */ | 671 | */ |
673 | bool openDumpFile( const QString& filename ); | 672 | bool openDumpFile( const QString& filename ); |
674 | /** | 673 | /** |
675 | * @returns true if the packet capturer is open | 674 | * @returns true if the packet capturer is open |
676 | */ | 675 | */ |
677 | bool isOpen() const; | 676 | bool isOpen() const; |
678 | /** | 677 | /** |
679 | * @returns the snapshot length of this packet capturer | 678 | * @returns the snapshot length of this packet capturer |
680 | */ | 679 | */ |
681 | int snapShot() const; | 680 | int snapShot() const; |
682 | /** | 681 | /** |
683 | * @returns true if the input capture file has a different byte-order | 682 | * @returns true if the input capture file has a different byte-order |
684 | * than the byte-order of the running system. | 683 | * than the byte-order of the running system. |
685 | */ | 684 | */ |
686 | bool swapped() const; | 685 | bool swapped() const; |
687 | /** | 686 | /** |
688 | * @returns the libpcap version string used to write the input capture file. | 687 | * @returns the libpcap version string used to write the input capture file. |
689 | */ | 688 | */ |
690 | QString version() const; | 689 | QString version() const; |
691 | /** | 690 | /** |
692 | * @returns the packet statistic database. | 691 | * @returns the packet statistic database. |
693 | * @see QMap | 692 | * @see QMap |
694 | */ | 693 | */ |
695 | const QMap<QString,int>& statistics() const; | 694 | const QMap<QString,int>& statistics() const; |
695 | /** | ||
696 | * Enable or disable the auto-delete option. | ||
697 | * If auto-delete is enabled, then the packet capturer will delete a packet right | ||
698 | * after it has been emit'ted. This is the default, which is useful if the packet | ||
699 | * capturer has the only reference to the packets. If you pass the packet for adding | ||
700 | * into a collection or do processing after the SLOT, the auto delete must be disabled. | ||
701 | */ | ||
702 | void setAutoDelete( bool enable ); | ||
703 | /** | ||
704 | * @returns the auto-delete value. | ||
705 | */ | ||
706 | bool autoDelete() const; | ||
696 | 707 | ||
697 | signals: | 708 | signals: |
698 | /** | 709 | /** |
699 | * This signal is emitted, when a packet has been received. | 710 | * This signal is emitted, when a packet has been received. |
700 | */ | 711 | */ |
701 | void receivedPacket( Opie::Net::OPacket* ); | 712 | void receivedPacket( Opie::Net::OPacket* ); |
702 | 713 | ||
703 | protected slots: | 714 | protected slots: |
704 | void readyToReceive(); | 715 | void readyToReceive(); |
705 | 716 | ||
706 | protected: | 717 | protected: |
707 | QString _name; // devicename | 718 | QString _name; // devicename |
708 | bool _open; // check this before doing pcap calls | 719 | bool _open; // check this before doing pcap calls |
709 | pcap_t* _pch; // pcap library handle | 720 | pcap_t* _pch; // pcap library handle |
710 | pcap_dumper_t* _pcd; // pcap dumper handle | 721 | pcap_dumper_t* _pcd; // pcap dumper handle |
711 | QSocketNotifier* _sn; // socket notifier for main loop | 722 | QSocketNotifier* _sn; // socket notifier for main loop |
712 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap | 723 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap |
713 | QMap<QString, int> _stats; // statistics; | 724 | QMap<QString, int> _stats; // statistics; |
714 | class Private; // Private Forward declaration | 725 | bool _autodelete; // if we auto delete packets after emit |
715 | Private *d; // if we need to add data | 726 | class Private; // Private Forward declaration |
727 | Private *d; // if we need to add data | ||
716 | }; | 728 | }; |
717 | } | 729 | } |
718 | } | 730 | } |
719 | 731 | ||
720 | #endif // OPCAP_H | 732 | #endif // OPCAP_H |
721 | 733 | ||