-rw-r--r-- | libopie2/opienet/opcap.h | 160 |
1 files changed, 151 insertions, 9 deletions
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index 65c550c..0b06572 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h | |||
@@ -60,6 +60,7 @@ typedef struct pcap_pkthdr packetheaderstruct; | |||
60 | 60 | ||
61 | /* FORWARDS */ | 61 | /* FORWARDS */ |
62 | class OPacketCapturer; | 62 | class OPacketCapturer; |
63 | class QSocketNotifier; | ||
63 | 64 | ||
64 | /*====================================================================================== | 65 | /*====================================================================================== |
65 | * OPacket - A frame on the wire | 66 | * OPacket - A frame on the wire |
@@ -84,6 +85,7 @@ class OPacket : public QObject | |||
84 | private: | 85 | private: |
85 | const packetheaderstruct _hdr; // pcap packet header | 86 | const packetheaderstruct _hdr; // pcap packet header |
86 | const unsigned char* _data; // pcap packet data | 87 | const unsigned char* _data; // pcap packet data |
88 | const unsigned char* _end; // end of pcap packet data | ||
87 | }; | 89 | }; |
88 | 90 | ||
89 | /*====================================================================================== | 91 | /*====================================================================================== |
@@ -95,7 +97,7 @@ class OEthernetPacket : public QObject | |||
95 | Q_OBJECT | 97 | Q_OBJECT |
96 | 98 | ||
97 | public: | 99 | public: |
98 | OEthernetPacket( const struct ether_header*, QObject* parent = 0 ); | 100 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); |
99 | virtual ~OEthernetPacket(); | 101 | virtual ~OEthernetPacket(); |
100 | 102 | ||
101 | OMacAddress sourceAddress() const; | 103 | OMacAddress sourceAddress() const; |
@@ -116,7 +118,7 @@ class OWaveLanPacket : public QObject | |||
116 | Q_OBJECT | 118 | Q_OBJECT |
117 | 119 | ||
118 | public: | 120 | public: |
119 | OWaveLanPacket( const struct ieee_802_11_header*, QObject* parent = 0 ); | 121 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); |
120 | virtual ~OWaveLanPacket(); | 122 | virtual ~OWaveLanPacket(); |
121 | 123 | ||
122 | int duration() const; | 124 | int duration() const; |
@@ -146,10 +148,17 @@ class OWaveLanManagementPacket : public QObject | |||
146 | Q_OBJECT | 148 | Q_OBJECT |
147 | 149 | ||
148 | public: | 150 | public: |
149 | OWaveLanManagementPacket( const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); | 151 | OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); |
150 | virtual ~OWaveLanManagementPacket(); | 152 | virtual ~OWaveLanManagementPacket(); |
151 | 153 | ||
152 | QString SSID() const; | 154 | int beaconInterval() const; |
155 | int capabilities() const; // generic | ||
156 | |||
157 | bool canESS() const; | ||
158 | bool canIBSS() const; | ||
159 | bool canCFP() const; | ||
160 | bool canCFP_REQ() const; | ||
161 | bool canPrivacy() const; | ||
153 | 162 | ||
154 | private: | 163 | private: |
155 | const struct ieee_802_11_mgmt_header* _header; | 164 | const struct ieee_802_11_mgmt_header* _header; |
@@ -158,6 +167,138 @@ class OWaveLanManagementPacket : public QObject | |||
158 | 167 | ||
159 | 168 | ||
160 | /*====================================================================================== | 169 | /*====================================================================================== |
170 | * OWaveLanManagementSSID | ||
171 | *======================================================================================*/ | ||
172 | |||
173 | class OWaveLanManagementSSID : public QObject | ||
174 | { | ||
175 | Q_OBJECT | ||
176 | |||
177 | public: | ||
178 | OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); | ||
179 | virtual ~OWaveLanManagementSSID(); | ||
180 | |||
181 | QString ID() const; | ||
182 | |||
183 | private: | ||
184 | const struct ssid_t* _data; | ||
185 | }; | ||
186 | |||
187 | /*====================================================================================== | ||
188 | * OWaveLanManagementRates | ||
189 | *======================================================================================*/ | ||
190 | |||
191 | class OWaveLanManagementRates : public QObject | ||
192 | { | ||
193 | Q_OBJECT | ||
194 | |||
195 | public: | ||
196 | OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); | ||
197 | virtual ~OWaveLanManagementRates(); | ||
198 | |||
199 | private: | ||
200 | const struct rates_t* _data; | ||
201 | }; | ||
202 | |||
203 | /*====================================================================================== | ||
204 | * OWaveLanManagementCF | ||
205 | *======================================================================================*/ | ||
206 | |||
207 | class OWaveLanManagementCF : public QObject | ||
208 | { | ||
209 | Q_OBJECT | ||
210 | |||
211 | public: | ||
212 | OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); | ||
213 | virtual ~OWaveLanManagementCF(); | ||
214 | |||
215 | private: | ||
216 | const struct cf_t* _data; | ||
217 | }; | ||
218 | |||
219 | /*====================================================================================== | ||
220 | * OWaveLanManagementFH | ||
221 | *======================================================================================*/ | ||
222 | |||
223 | class OWaveLanManagementFH : public QObject | ||
224 | { | ||
225 | Q_OBJECT | ||
226 | |||
227 | public: | ||
228 | OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); | ||
229 | virtual ~OWaveLanManagementFH(); | ||
230 | |||
231 | private: | ||
232 | const struct fh_t* _data; | ||
233 | }; | ||
234 | |||
235 | /*====================================================================================== | ||
236 | * OWaveLanManagementDS | ||
237 | *======================================================================================*/ | ||
238 | |||
239 | class OWaveLanManagementDS : public QObject | ||
240 | { | ||
241 | Q_OBJECT | ||
242 | |||
243 | public: | ||
244 | OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); | ||
245 | virtual ~OWaveLanManagementDS(); | ||
246 | |||
247 | int channel() const; | ||
248 | |||
249 | private: | ||
250 | const struct ds_t* _data; | ||
251 | }; | ||
252 | |||
253 | /*====================================================================================== | ||
254 | * OWaveLanManagementTim | ||
255 | *======================================================================================*/ | ||
256 | |||
257 | class OWaveLanManagementTim : public QObject | ||
258 | { | ||
259 | Q_OBJECT | ||
260 | |||
261 | public: | ||
262 | OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); | ||
263 | virtual ~OWaveLanManagementTim(); | ||
264 | |||
265 | private: | ||
266 | const struct tim_t* _data; | ||
267 | }; | ||
268 | |||
269 | /*====================================================================================== | ||
270 | * OWaveLanManagementIBSS | ||
271 | *======================================================================================*/ | ||
272 | |||
273 | class OWaveLanManagementIBSS : public QObject | ||
274 | { | ||
275 | Q_OBJECT | ||
276 | |||
277 | public: | ||
278 | OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); | ||
279 | virtual ~OWaveLanManagementIBSS(); | ||
280 | |||
281 | private: | ||
282 | const struct ibss_t* _data; | ||
283 | }; | ||
284 | |||
285 | /*====================================================================================== | ||
286 | * OWaveLanManagementChallenge | ||
287 | *======================================================================================*/ | ||
288 | |||
289 | class OWaveLanManagementChallenge : public QObject | ||
290 | { | ||
291 | Q_OBJECT | ||
292 | |||
293 | public: | ||
294 | OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); | ||
295 | virtual ~OWaveLanManagementChallenge(); | ||
296 | |||
297 | private: | ||
298 | const struct challenge_t* _data; | ||
299 | }; | ||
300 | |||
301 | /*====================================================================================== | ||
161 | * OWaveLanDataPacket - type: data (T_DATA) | 302 | * OWaveLanDataPacket - type: data (T_DATA) |
162 | *======================================================================================*/ | 303 | *======================================================================================*/ |
163 | 304 | ||
@@ -166,7 +307,7 @@ class OWaveLanDataPacket : public QObject | |||
166 | Q_OBJECT | 307 | Q_OBJECT |
167 | 308 | ||
168 | public: | 309 | public: |
169 | OWaveLanDataPacket( const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); | 310 | OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); |
170 | virtual ~OWaveLanDataPacket(); | 311 | virtual ~OWaveLanDataPacket(); |
171 | 312 | ||
172 | private: | 313 | private: |
@@ -182,7 +323,7 @@ class OLLCPacket : public QObject | |||
182 | Q_OBJECT | 323 | Q_OBJECT |
183 | 324 | ||
184 | public: | 325 | public: |
185 | OLLCPacket( const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); | 326 | OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); |
186 | virtual ~OLLCPacket(); | 327 | virtual ~OLLCPacket(); |
187 | 328 | ||
188 | private: | 329 | private: |
@@ -198,7 +339,7 @@ class OIPPacket : public QObject | |||
198 | Q_OBJECT | 339 | Q_OBJECT |
199 | 340 | ||
200 | public: | 341 | public: |
201 | OIPPacket( const struct iphdr*, QObject* parent = 0 ); | 342 | OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); |
202 | virtual ~OIPPacket(); | 343 | virtual ~OIPPacket(); |
203 | 344 | ||
204 | QHostAddress fromIPAddress() const; | 345 | QHostAddress fromIPAddress() const; |
@@ -225,7 +366,7 @@ class OUDPPacket : public QObject | |||
225 | Q_OBJECT | 366 | Q_OBJECT |
226 | 367 | ||
227 | public: | 368 | public: |
228 | OUDPPacket( const struct udphdr*, QObject* parent = 0 ); | 369 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); |
229 | virtual ~OUDPPacket(); | 370 | virtual ~OUDPPacket(); |
230 | 371 | ||
231 | int fromPort() const; | 372 | int fromPort() const; |
@@ -244,7 +385,7 @@ class OTCPPacket : public QObject | |||
244 | Q_OBJECT | 385 | Q_OBJECT |
245 | 386 | ||
246 | public: | 387 | public: |
247 | OTCPPacket( const struct tcphdr*, QObject* parent = 0 ); | 388 | OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); |
248 | virtual ~OTCPPacket(); | 389 | virtual ~OTCPPacket(); |
249 | 390 | ||
250 | int fromPort() const; | 391 | int fromPort() const; |
@@ -287,6 +428,7 @@ class OPacketCapturer : public QObject | |||
287 | QString _name; // devicename | 428 | QString _name; // devicename |
288 | bool _open; // check this before doing pcap calls | 429 | bool _open; // check this before doing pcap calls |
289 | pcap_t* _pch; // pcap library handle | 430 | pcap_t* _pch; // pcap library handle |
431 | QSocketNotifier* _sn; // socket notifier for main loop | ||
290 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; | 432 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; |
291 | }; | 433 | }; |
292 | 434 | ||