author | mickeyl <mickeyl> | 2003-10-06 17:38:00 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-06 17:38:00 (UTC) |
commit | e0acd0d9400bb489415d21ec715c5f6704c22b95 (patch) (unidiff) | |
tree | a6bb6077c3da3d31bc9e86d6f8276aed90bd3d5c | |
parent | 634a68b636a0fa24232029b79ffa915a5621b2be (diff) | |
download | opie-e0acd0d9400bb489415d21ec715c5f6704c22b95.zip opie-e0acd0d9400bb489415d21ec715c5f6704c22b95.tar.gz opie-e0acd0d9400bb489415d21ec715c5f6704c22b95.tar.bz2 |
decode DHCP ACK packets and show the extracted client IP address
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 9d6ed6a..1cca507 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -186,384 +186,384 @@ void MScanListView::addNewItem( const QString& type, | |||
186 | #ifdef DEBUG | 186 | #ifdef DEBUG |
187 | qDebug( "inserting new station %s", (const char*) macaddr ); | 187 | qDebug( "inserting new station %s", (const char*) macaddr ); |
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 190 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
191 | station->setManufacturer( mac.manufacturer() ); | 191 | station->setManufacturer( mac.manufacturer() ); |
192 | station->setLocation( loc.latitude, loc.longitude ); | 192 | station->setLocation( loc.latitude, loc.longitude ); |
193 | 193 | ||
194 | if ( type == "managed" ) | 194 | if ( type == "managed" ) |
195 | { | 195 | { |
196 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 196 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
197 | } | 197 | } |
198 | else | 198 | else |
199 | { | 199 | { |
200 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); | 200 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); |
201 | } | 201 | } |
202 | MLogWindow::logwindow()->log( s ); | 202 | MLogWindow::logwindow()->log( s ); |
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 207 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
208 | { | 208 | { |
209 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 209 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
210 | 210 | ||
211 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 211 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
212 | { | 212 | { |
213 | #ifdef DEBUG | 213 | #ifdef DEBUG |
214 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 214 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
215 | #endif | 215 | #endif |
216 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 216 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
217 | } | 217 | } |
218 | 218 | ||
219 | if ( subitem ) | 219 | if ( subitem ) |
220 | { | 220 | { |
221 | // we have already seen this item, it's a dupe | 221 | // we have already seen this item, it's a dupe |
222 | #ifdef DEBUG | 222 | #ifdef DEBUG |
223 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); | 223 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); |
224 | #endif | 224 | #endif |
225 | subitem->receivedBeacon(); //FIXME: sent data bit | 225 | subitem->receivedBeacon(); //FIXME: sent data bit |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | // Hey, it seems to be a new item :-D | 229 | // Hey, it seems to be a new item :-D |
230 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); | 230 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); |
231 | station->setManufacturer( addr.manufacturer() ); | 231 | station->setManufacturer( addr.manufacturer() ); |
232 | 232 | ||
233 | QString s; | 233 | QString s; |
234 | if ( type == "station" ) | 234 | if ( type == "station" ) |
235 | { | 235 | { |
236 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 236 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
237 | } | 237 | } |
238 | else | 238 | else |
239 | { | 239 | { |
240 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 240 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
241 | } | 241 | } |
242 | MLogWindow::logwindow()->log( s ); | 242 | MLogWindow::logwindow()->log( s ); |
243 | } | 243 | } |
244 | 244 | ||
245 | 245 | ||
246 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 246 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
247 | { | 247 | { |
248 | QString s; | 248 | QString s; |
249 | MScanListItem* network; | 249 | MScanListItem* network; |
250 | 250 | ||
251 | QListViewItemIterator it( this ); | 251 | QListViewItemIterator it( this ); |
252 | while ( it.current() && | 252 | while ( it.current() && |
253 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 253 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
254 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 254 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
255 | 255 | ||
256 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 256 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
257 | 257 | ||
258 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 258 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
259 | { | 259 | { |
260 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 260 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
261 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 261 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
262 | } | 262 | } |
263 | else | 263 | else |
264 | { | 264 | { |
265 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 265 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); |
266 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); | 266 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 271 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
272 | { | 272 | { |
273 | QString s; | 273 | QString s; |
274 | MScanListItem* network; | 274 | MScanListItem* network; |
275 | 275 | ||
276 | QListViewItemIterator it( this ); | 276 | QListViewItemIterator it( this ); |
277 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 277 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
278 | 278 | ||
279 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 279 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
280 | 280 | ||
281 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 281 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
282 | { | 282 | { |
283 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 283 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
284 | } | 284 | } |
285 | else | 285 | else |
286 | { | 286 | { |
287 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 287 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
288 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 288 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
289 | 289 | ||
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
294 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 294 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
295 | { | 295 | { |
296 | QString s; | 296 | QString s; |
297 | MScanListItem* network; | 297 | MScanListItem* network; |
298 | 298 | ||
299 | QListViewItemIterator it( this ); | 299 | QListViewItemIterator it( this ); |
300 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 300 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
301 | 301 | ||
302 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 302 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
303 | 303 | ||
304 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 304 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
305 | { | 305 | { |
306 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 306 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
307 | } | 307 | } |
308 | else | 308 | else |
309 | { | 309 | { |
310 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 310 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
311 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 311 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 316 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
317 | { | 317 | { |
318 | qWarning( "D'oh! Not yet implemented..." ); | 318 | qWarning( "D'oh! Not yet implemented..." ); |
319 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 319 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 323 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
324 | { | 324 | { |
325 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); | 325 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); |
326 | 326 | ||
327 | QListViewItemIterator it( this ); | 327 | QListViewItemIterator it( this ); |
328 | for ( ; it.current(); ++it ) | 328 | for ( ; it.current(); ++it ) |
329 | { | 329 | { |
330 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 330 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
331 | { | 331 | { |
332 | it.current()->setText( col_ip, ip ); | 332 | it.current()->setText( col_ip, ip ); |
333 | return; | 333 | return; |
334 | } | 334 | } |
335 | } | 335 | } |
336 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 336 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
337 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", | 337 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
338 | (const char*) macaddr.toString(), (const char*) ip ) ); | 338 | (const char*) macaddr.toString(), (const char*) ip ) ); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 342 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
343 | { | 343 | { |
344 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); | 344 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); |
345 | 345 | ||
346 | //TODO: Refactor that out, we need it all over the place. | 346 | //TODO: Refactor that out, we need it all over the place. |
347 | // Best to do it in a more comfortable abstraction in OListView | 347 | // Best to do it in a more comfortable abstraction in OListView |
348 | // (Hmm, didn't I already start something in this direction?) | 348 | // (Hmm, didn't I already start something in this direction?) |
349 | 349 | ||
350 | QListViewItemIterator it( this ); | 350 | QListViewItemIterator it( this ); |
351 | for ( ; it.current(); ++it ) | 351 | for ( ; it.current(); ++it ) |
352 | { | 352 | { |
353 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 353 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
354 | { | 354 | { |
355 | 355 | ||
356 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); | 356 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); |
357 | 357 | ||
358 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | 358 | while ( subitem && ( subitem->text( col_essid ) != name ) ) |
359 | { | 359 | { |
360 | #ifdef DEBUG | 360 | #ifdef DEBUG |
361 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); | 361 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); |
362 | #endif | 362 | #endif |
363 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 363 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
364 | } | 364 | } |
365 | 365 | ||
366 | if ( subitem ) | 366 | if ( subitem ) |
367 | { | 367 | { |
368 | // we have already seen this item, it's a dupe | 368 | // we have already seen this item, it's a dupe |
369 | #ifdef DEBUG | 369 | #ifdef DEBUG |
370 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); | 370 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); |
371 | #endif | 371 | #endif |
372 | subitem->receivedBeacon(); //FIXME: sent data bit | 372 | subitem->receivedBeacon(); //FIXME: sent data bit |
373 | return; | 373 | return; |
374 | } | 374 | } |
375 | 375 | ||
376 | // never seen that - add new item | 376 | // never seen that - add new item |
377 | 377 | ||
378 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", false, -1, -1 ); | 378 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); |
379 | item->setText( col_essid, name ); | 379 | item->setText( col_essid, name ); |
380 | 380 | ||
381 | return; | 381 | return; |
382 | } | 382 | } |
383 | } | 383 | } |
384 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 384 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
385 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", | 385 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", |
386 | (const char*) macaddr.toString(), (const char*) ip ) ); | 386 | (const char*) macaddr.toString(), (const char*) ip ) ); |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 390 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
391 | { | 391 | { |
392 | if ( !item ) return; | 392 | if ( !item ) return; |
393 | 393 | ||
394 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 394 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
395 | 395 | ||
396 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 396 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
397 | (const char*) itm->text(0), (const char*) itm->type, col ); | 397 | (const char*) itm->text(0), (const char*) itm->type, col ); |
398 | 398 | ||
399 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 399 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
400 | { | 400 | { |
401 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | 401 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); |
402 | 402 | ||
403 | QPopupMenu m( this ); | 403 | QPopupMenu m( this ); |
404 | m.insertItem( entry, 37773, 0 ); | 404 | m.insertItem( entry, 37773, 0 ); |
405 | int result = m.exec( QCursor::pos() ); | 405 | int result = m.exec( QCursor::pos() ); |
406 | if ( result == 37773 ) | 406 | if ( result == 37773 ) |
407 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 407 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
408 | } | 408 | } |
409 | } | 409 | } |
410 | 410 | ||
411 | //============================================================ | 411 | //============================================================ |
412 | // MScanListItem | 412 | // MScanListItem |
413 | //============================================================ | 413 | //============================================================ |
414 | 414 | ||
415 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 415 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, |
416 | bool wep, int channel, int signal ) | 416 | bool wep, int channel, int signal ) |
417 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 417 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
418 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 418 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
419 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 419 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
420 | { | 420 | { |
421 | #ifdef DEBUG | 421 | #ifdef DEBUG |
422 | qDebug( "creating scanlist item" ); | 422 | qDebug( "creating scanlist item" ); |
423 | #endif | 423 | #endif |
424 | if ( WellenreiterConfigWindow::instance() && type == "network" ) | 424 | if ( WellenreiterConfigWindow::instance() && type == "network" ) |
425 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); | 425 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); |
426 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 426 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
427 | } | 427 | } |
428 | 428 | ||
429 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 429 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, |
430 | bool wep, int channel, int signal ) | 430 | bool wep, int channel, int signal ) |
431 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 431 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
432 | { | 432 | { |
433 | #ifdef DEBUG | 433 | #ifdef DEBUG |
434 | qDebug( "creating scanlist item" ); | 434 | qDebug( "creating scanlist item" ); |
435 | #endif | 435 | #endif |
436 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 436 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
437 | } | 437 | } |
438 | 438 | ||
439 | const QString& MScanListItem::essid() const | 439 | const QString& MScanListItem::essid() const |
440 | { | 440 | { |
441 | if ( type == "network" ) | 441 | if ( type == "network" ) |
442 | return _essid; | 442 | return _essid; |
443 | else | 443 | else |
444 | return ( (MScanListItem*) parent() )->essid(); | 444 | return ( (MScanListItem*) parent() )->essid(); |
445 | } | 445 | } |
446 | 446 | ||
447 | OListViewItem* MScanListItem::childFactory() | 447 | OListViewItem* MScanListItem::childFactory() |
448 | { | 448 | { |
449 | return new MScanListItem( this ); | 449 | return new MScanListItem( this ); |
450 | } | 450 | } |
451 | 451 | ||
452 | void MScanListItem::serializeTo( QDataStream& s ) const | 452 | void MScanListItem::serializeTo( QDataStream& s ) const |
453 | { | 453 | { |
454 | #ifdef DEBUG | 454 | #ifdef DEBUG |
455 | qDebug( "serializing MScanListItem" ); | 455 | qDebug( "serializing MScanListItem" ); |
456 | #endif | 456 | #endif |
457 | OListViewItem::serializeTo( s ); | 457 | OListViewItem::serializeTo( s ); |
458 | 458 | ||
459 | s << _type; | 459 | s << _type; |
460 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 460 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
461 | } | 461 | } |
462 | 462 | ||
463 | void MScanListItem::serializeFrom( QDataStream& s ) | 463 | void MScanListItem::serializeFrom( QDataStream& s ) |
464 | { | 464 | { |
465 | #ifdef DEBUG | 465 | #ifdef DEBUG |
466 | qDebug( "serializing MScanListItem" ); | 466 | qDebug( "serializing MScanListItem" ); |
467 | #endif | 467 | #endif |
468 | OListViewItem::serializeFrom( s ); | 468 | OListViewItem::serializeFrom( s ); |
469 | 469 | ||
470 | char wep; | 470 | char wep; |
471 | s >> _type; | 471 | s >> _type; |
472 | s >> (Q_UINT8) wep; | 472 | s >> (Q_UINT8) wep; |
473 | _wep = (wep == 'y'); | 473 | _wep = (wep == 'y'); |
474 | 474 | ||
475 | QString name; | 475 | QString name; |
476 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 476 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
477 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 477 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
478 | if ( _wep ) | 478 | if ( _wep ) |
479 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 479 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
480 | listView()->triggerUpdate(); | 480 | listView()->triggerUpdate(); |
481 | } | 481 | } |
482 | 482 | ||
483 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 483 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
484 | { | 484 | { |
485 | #ifdef DEBUG | 485 | #ifdef DEBUG |
486 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 486 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
487 | (const char*) type, | 487 | (const char*) type, |
488 | (const char*) essid, | 488 | (const char*) essid, |
489 | (const char*) macaddr, | 489 | (const char*) macaddr, |
490 | channel ); | 490 | channel ); |
491 | #endif | 491 | #endif |
492 | 492 | ||
493 | // set icon for managed or adhoc mode | 493 | // set icon for managed or adhoc mode |
494 | QString name; | 494 | QString name; |
495 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 495 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
496 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 496 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
497 | 497 | ||
498 | // set icon for wep (wireless encryption protocol) | 498 | // set icon for wep (wireless encryption protocol) |
499 | if ( wep ) | 499 | if ( wep ) |
500 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 500 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
501 | 501 | ||
502 | // set channel and signal text | 502 | // set channel and signal text |
503 | 503 | ||
504 | if ( signal != -1 ) | 504 | if ( signal != -1 ) |
505 | setText( col_sig, QString::number( signal ) ); | 505 | setText( col_sig, QString::number( signal ) ); |
506 | if ( channel != -1 ) | 506 | if ( channel != -1 ) |
507 | setText( col_channel, QString::number( channel ) ); | 507 | setText( col_channel, QString::number( channel ) ); |
508 | 508 | ||
509 | setText( col_firstseen, QTime::currentTime().toString() ); | 509 | setText( col_firstseen, QTime::currentTime().toString() ); |
510 | //setText( col_lastseen, QTime::currentTime().toString() ); | 510 | //setText( col_lastseen, QTime::currentTime().toString() ); |
511 | 511 | ||
512 | listView()->triggerUpdate(); | 512 | listView()->triggerUpdate(); |
513 | 513 | ||
514 | this->type = type; | 514 | this->type = type; |
515 | _type = type; | 515 | _type = type; |
516 | _essid = essid; | 516 | _essid = essid; |
517 | _macaddr = macaddr; | 517 | _macaddr = macaddr; |
518 | _channel = channel; | 518 | _channel = channel; |
519 | _beacons = 1; | 519 | _beacons = 1; |
520 | _signal = 0; | 520 | _signal = 0; |
521 | 521 | ||
522 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) | 522 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) |
523 | { | 523 | { |
524 | listView()->ensureItemVisible( this ); | 524 | listView()->ensureItemVisible( this ); |
525 | } | 525 | } |
526 | 526 | ||
527 | } | 527 | } |
528 | 528 | ||
529 | 529 | ||
530 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 530 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
531 | { | 531 | { |
532 | setText( col_manuf, manufacturer ); | 532 | setText( col_manuf, manufacturer ); |
533 | } | 533 | } |
534 | 534 | ||
535 | 535 | ||
536 | void MScanListItem::setLocation( const float& latitude, const float& longitude ) | 536 | void MScanListItem::setLocation( const float& latitude, const float& longitude ) |
537 | { | 537 | { |
538 | if ( latitude == 0.0 || longitude == 0.0 ) | 538 | if ( latitude == 0.0 || longitude == 0.0 ) |
539 | setText( col_location, "N/A" ); | 539 | setText( col_location, "N/A" ); |
540 | else | 540 | else |
541 | setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) ); | 541 | setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) ); |
542 | } | 542 | } |
543 | 543 | ||
544 | 544 | ||
545 | void MScanListItem::playSound( const QString& sound ) const | 545 | void MScanListItem::playSound( const QString& sound ) const |
546 | { | 546 | { |
547 | #ifdef QWS | 547 | #ifdef QWS |
548 | if ( sound == "Ignore" ) return; | 548 | if ( sound == "Ignore" ) return; |
549 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); | 549 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); |
550 | else if ( sound == "Key" ) ODevice::inst()->keySound(); | 550 | else if ( sound == "Key" ) ODevice::inst()->keySound(); |
551 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); | 551 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); |
552 | #endif | 552 | #endif |
553 | } | 553 | } |
554 | 554 | ||
555 | 555 | ||
556 | void MScanListItem::receivedBeacon() | 556 | void MScanListItem::receivedBeacon() |
557 | { | 557 | { |
558 | _beacons++; | 558 | _beacons++; |
559 | #ifdef DEBUG | 559 | #ifdef DEBUG |
560 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 560 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); |
561 | #endif | 561 | #endif |
562 | setText( col_sig, QString::number( _beacons ) ); | 562 | setText( col_sig, QString::number( _beacons ) ); |
563 | setText( col_lastseen, QTime::currentTime().toString() ); | 563 | setText( col_lastseen, QTime::currentTime().toString() ); |
564 | 564 | ||
565 | MScanListItem* p = (MScanListItem*) parent(); | 565 | MScanListItem* p = (MScanListItem*) parent(); |
566 | if ( p ) p->receivedBeacon(); | 566 | if ( p ) p->receivedBeacon(); |
567 | 567 | ||
568 | } | 568 | } |
569 | 569 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 7394742..9460f56 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -67,390 +67,393 @@ using namespace Opie; | |||
67 | Wellenreiter::Wellenreiter( QWidget* parent ) | 67 | Wellenreiter::Wellenreiter( QWidget* parent ) |
68 | : WellenreiterBase( parent, 0, 0 ), | 68 | : WellenreiterBase( parent, 0, 0 ), |
69 | sniffing( false ), iface( 0 ), configwindow( 0 ) | 69 | sniffing( false ), iface( 0 ), configwindow( 0 ) |
70 | { | 70 | { |
71 | 71 | ||
72 | logwindow->log( "(i) Wellenreiter has been started." ); | 72 | logwindow->log( "(i) Wellenreiter has been started." ); |
73 | 73 | ||
74 | // | 74 | // |
75 | // detect operating system | 75 | // detect operating system |
76 | // | 76 | // |
77 | 77 | ||
78 | #ifdef QWS | 78 | #ifdef QWS |
79 | QString sys; | 79 | QString sys; |
80 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 80 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
81 | _system = ODevice::inst()->system(); | 81 | _system = ODevice::inst()->system(); |
82 | logwindow->log( sys ); | 82 | logwindow->log( sys ); |
83 | #endif | 83 | #endif |
84 | 84 | ||
85 | netview->setColumnWidthMode( 1, QListView::Manual ); | 85 | netview->setColumnWidthMode( 1, QListView::Manual ); |
86 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), | 86 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), |
87 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); | 87 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); |
88 | pcap = new OPacketCapturer(); | 88 | pcap = new OPacketCapturer(); |
89 | 89 | ||
90 | gps = new GPS( this ); | 90 | gps = new GPS( this ); |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | Wellenreiter::~Wellenreiter() | 94 | Wellenreiter::~Wellenreiter() |
95 | { | 95 | { |
96 | delete pcap; | 96 | delete pcap; |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 100 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
101 | { | 101 | { |
102 | configwindow = cw; | 102 | configwindow = cw; |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | void Wellenreiter::channelHopped(int c) | 106 | void Wellenreiter::channelHopped(int c) |
107 | { | 107 | { |
108 | QString title = "Wellenreiter II -scan- ["; | 108 | QString title = "Wellenreiter II -scan- ["; |
109 | QString left; | 109 | QString left; |
110 | if ( c > 1 ) left.fill( '.', c-1 ); | 110 | if ( c > 1 ) left.fill( '.', c-1 ); |
111 | title.append( left ); | 111 | title.append( left ); |
112 | title.append( '|' ); | 112 | title.append( '|' ); |
113 | if ( c < iface->channels() ) | 113 | if ( c < iface->channels() ) |
114 | { | 114 | { |
115 | QString right; | 115 | QString right; |
116 | right.fill( '.', iface->channels()-c ); | 116 | right.fill( '.', iface->channels()-c ); |
117 | title.append( right ); | 117 | title.append( right ); |
118 | } | 118 | } |
119 | title.append( "]" ); | 119 | title.append( "]" ); |
120 | //title.append( QString().sprintf( " %02d", c ) ); | 120 | //title.append( QString().sprintf( " %02d", c ) ); |
121 | assert( parent() ); | 121 | assert( parent() ); |
122 | ( (QMainWindow*) parent() )->setCaption( title ); | 122 | ( (QMainWindow*) parent() )->setCaption( title ); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void Wellenreiter::handleNotification( OPacket* p ) | 126 | void Wellenreiter::handleNotification( OPacket* p ) |
127 | { | 127 | { |
128 | QObjectList* l = p->queryList(); | 128 | QObjectList* l = p->queryList(); |
129 | QObjectListIt it( *l ); | 129 | QObjectListIt it( *l ); |
130 | QObject* o; | 130 | QObject* o; |
131 | 131 | ||
132 | while ( (o = it.current()) != 0 ) | 132 | while ( (o = it.current()) != 0 ) |
133 | { | 133 | { |
134 | QString name = it.current()->name(); | 134 | QString name = it.current()->name(); |
135 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) | 135 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) |
136 | { | 136 | { |
137 | QString action = configwindow->parsePackets->protocolAction( name ); | 137 | QString action = configwindow->parsePackets->protocolAction( name ); |
138 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 138 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
139 | doAction( action, name, p ); | 139 | doAction( action, name, p ); |
140 | } | 140 | } |
141 | else | 141 | else |
142 | { | 142 | { |
143 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); | 143 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); |
144 | } | 144 | } |
145 | ++it; | 145 | ++it; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
150 | void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | 150 | void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) |
151 | { | 151 | { |
152 | QString type; | 152 | QString type; |
153 | if ( beacon->canIBSS() ) | 153 | if ( beacon->canIBSS() ) |
154 | { | 154 | { |
155 | type = "adhoc"; | 155 | type = "adhoc"; |
156 | } | 156 | } |
157 | else if ( beacon->canESS() ) | 157 | else if ( beacon->canESS() ) |
158 | { | 158 | { |
159 | type = "managed"; | 159 | type = "managed"; |
160 | } | 160 | } |
161 | else | 161 | else |
162 | { | 162 | { |
163 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); | 163 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | 166 | ||
167 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 167 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
168 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 168 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
169 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 169 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
170 | int channel = ds ? ds->channel() : -1; | 170 | int channel = ds ? ds->channel() : -1; |
171 | 171 | ||
172 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 172 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
173 | 173 | ||
174 | GpsLocation loc( 0, 0 ); | 174 | GpsLocation loc( 0, 0 ); |
175 | if ( configwindow->enableGPS->isChecked() ) | 175 | if ( configwindow->enableGPS->isChecked() ) |
176 | { | 176 | { |
177 | // TODO: add check if GPS is working!? | 177 | // TODO: add check if GPS is working!? |
178 | qDebug( "Wellenreiter::gathering GPS data..." ); | 178 | qDebug( "Wellenreiter::gathering GPS data..." ); |
179 | loc = gps->position(); | 179 | loc = gps->position(); |
180 | qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude ); | 180 | qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude ); |
181 | } | 181 | } |
182 | 182 | ||
183 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); | 183 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); |
184 | 184 | ||
185 | // update graph window | 185 | // update graph window |
186 | if ( ds ) | 186 | if ( ds ) |
187 | { | 187 | { |
188 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); | 188 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); |
189 | if ( prism ) | 189 | if ( prism ) |
190 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); | 190 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); |
191 | else | 191 | else |
192 | graphwindow->traffic( ds->channel(), 95 ); | 192 | graphwindow->traffic( ds->channel(), 95 ); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | 196 | ||
197 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) | 197 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) |
198 | { | 198 | { |
199 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 199 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
200 | if ( wlan->fromDS() && !wlan->toDS() ) | 200 | if ( wlan->fromDS() && !wlan->toDS() ) |
201 | { | 201 | { |
202 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 202 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
203 | from = wlan->macAddress3(); | 203 | from = wlan->macAddress3(); |
204 | to = wlan->macAddress2(); | 204 | to = wlan->macAddress2(); |
205 | } | 205 | } |
206 | else if ( !wlan->fromDS() && wlan->toDS() ) | 206 | else if ( !wlan->fromDS() && wlan->toDS() ) |
207 | { | 207 | { |
208 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); | 208 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); |
209 | from = wlan->macAddress2(); | 209 | from = wlan->macAddress2(); |
210 | to = wlan->macAddress3(); | 210 | to = wlan->macAddress3(); |
211 | } | 211 | } |
212 | else if ( wlan->fromDS() && wlan->toDS() ) | 212 | else if ( wlan->fromDS() && wlan->toDS() ) |
213 | { | 213 | { |
214 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 214 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
215 | from = wlan->macAddress4(); | 215 | from = wlan->macAddress4(); |
216 | to = wlan->macAddress3(); | 216 | to = wlan->macAddress3(); |
217 | } | 217 | } |
218 | else | 218 | else |
219 | { | 219 | { |
220 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); | 220 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); |
221 | from = wlan->macAddress2(); | 221 | from = wlan->macAddress2(); |
222 | to = wlan->macAddress1(); | 222 | to = wlan->macAddress1(); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) | 227 | void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) |
228 | { | 228 | { |
229 | from = data->sourceAddress(); | 229 | from = data->sourceAddress(); |
230 | to = data->destinationAddress(); | 230 | to = data->destinationAddress(); |
231 | 231 | ||
232 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); | 232 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) | 236 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) |
237 | { | 237 | { |
238 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); | 238 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); |
239 | if ( arp ) | 239 | if ( arp ) |
240 | { | 240 | { |
241 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); | 241 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); |
242 | if ( arp->type() == "REQUEST" ) | 242 | if ( arp->type() == "REQUEST" ) |
243 | { | 243 | { |
244 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 244 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
245 | } | 245 | } |
246 | else if ( arp->type() == "REPLY" ) | 246 | else if ( arp->type() == "REPLY" ) |
247 | { | 247 | { |
248 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 248 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
249 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); | 249 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); | 253 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); |
254 | if ( dhcp ) | 254 | if ( dhcp ) |
255 | { | 255 | { |
256 | qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); | 256 | qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); |
257 | if ( dhcp->type() == "OFFER" ) | 257 | if ( dhcp->type() == "OFFER" ) |
258 | { | 258 | { |
259 | qDebug( "ADDSERVICE: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); | 259 | qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); |
260 | //netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); | ||
261 | |||
262 | netView()->identify( source, dhcp->serverAddress().toString() ); | 260 | netView()->identify( source, dhcp->serverAddress().toString() ); |
263 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); | 261 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); |
264 | } | 262 | } |
263 | else if ( dhcp->type() == "ACK" ) | ||
264 | { | ||
265 | qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); | ||
266 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); | ||
267 | } | ||
265 | } | 268 | } |
266 | } | 269 | } |
267 | 270 | ||
268 | 271 | ||
269 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) | 272 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) |
270 | { | 273 | { |
271 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) | 274 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) |
272 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) | 275 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) |
273 | return 0; | 276 | return 0; |
274 | 277 | ||
275 | return p->child( protocol ); | 278 | return p->child( protocol ); |
276 | } | 279 | } |
277 | 280 | ||
278 | 281 | ||
279 | bool Wellenreiter::checkDumpPacket( OPacket* p ) | 282 | bool Wellenreiter::checkDumpPacket( OPacket* p ) |
280 | { | 283 | { |
281 | // go through all child packets and see if one is inside the child hierarchy for p | 284 | // go through all child packets and see if one is inside the child hierarchy for p |
282 | // if so, do what the user requested (protocolAction), e.g. pass or discard | 285 | // if so, do what the user requested (protocolAction), e.g. pass or discard |
283 | if ( !configwindow->writeCaptureFile->isChecked() ) | 286 | if ( !configwindow->writeCaptureFile->isChecked() ) |
284 | return false; | 287 | return false; |
285 | 288 | ||
286 | QObjectList* l = p->queryList(); | 289 | QObjectList* l = p->queryList(); |
287 | QObjectListIt it( *l ); | 290 | QObjectListIt it( *l ); |
288 | QObject* o; | 291 | QObject* o; |
289 | 292 | ||
290 | while ( (o = it.current()) != 0 ) | 293 | while ( (o = it.current()) != 0 ) |
291 | { | 294 | { |
292 | QString name = it.current()->name(); | 295 | QString name = it.current()->name(); |
293 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) | 296 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) |
294 | { | 297 | { |
295 | QString action = configwindow->capturePackets->protocolAction( name ); | 298 | QString action = configwindow->capturePackets->protocolAction( name ); |
296 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 299 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
297 | if ( action == "Discard" ) | 300 | if ( action == "Discard" ) |
298 | { | 301 | { |
299 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); | 302 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); |
300 | return false; | 303 | return false; |
301 | } | 304 | } |
302 | } | 305 | } |
303 | else | 306 | else |
304 | { | 307 | { |
305 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); | 308 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); |
306 | } | 309 | } |
307 | ++it; | 310 | ++it; |
308 | } | 311 | } |
309 | return true; | 312 | return true; |
310 | } | 313 | } |
311 | 314 | ||
312 | 315 | ||
313 | void Wellenreiter::receivePacket( OPacket* p ) | 316 | void Wellenreiter::receivePacket( OPacket* p ) |
314 | { | 317 | { |
315 | hexWindow()->log( p->dump( 8 ) ); | 318 | hexWindow()->log( p->dump( 8 ) ); |
316 | 319 | ||
317 | if ( checkDumpPacket( p ) ) | 320 | if ( checkDumpPacket( p ) ) |
318 | { | 321 | { |
319 | pcap->dump( p ); | 322 | pcap->dump( p ); |
320 | } | 323 | } |
321 | 324 | ||
322 | // check if we received a beacon frame | 325 | // check if we received a beacon frame |
323 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); | 326 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); |
324 | if ( beacon && beacon->managementType() == "Beacon" ) | 327 | if ( beacon && beacon->managementType() == "Beacon" ) |
325 | { | 328 | { |
326 | handleBeacon( p, beacon ); | 329 | handleBeacon( p, beacon ); |
327 | return; | 330 | return; |
328 | } | 331 | } |
329 | 332 | ||
330 | OMacAddress source; | 333 | OMacAddress source; |
331 | OMacAddress dest; | 334 | OMacAddress dest; |
332 | 335 | ||
333 | //TODO: WEP check here | 336 | //TODO: WEP check here |
334 | 337 | ||
335 | // check for a wireless data frame | 338 | // check for a wireless data frame |
336 | OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); | 339 | OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); |
337 | if ( wlan ) | 340 | if ( wlan ) |
338 | { | 341 | { |
339 | handleWlanData( p, wlan, source, dest ); | 342 | handleWlanData( p, wlan, source, dest ); |
340 | } | 343 | } |
341 | 344 | ||
342 | // check for a wired data frame | 345 | // check for a wired data frame |
343 | OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); | 346 | OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); |
344 | if ( eth ) | 347 | if ( eth ) |
345 | { | 348 | { |
346 | handleEthernetData( p, eth, source, dest ); | 349 | handleEthernetData( p, eth, source, dest ); |
347 | } | 350 | } |
348 | 351 | ||
349 | // check for a ip frame | 352 | // check for a ip frame |
350 | OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); | 353 | OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); |
351 | if ( ip ) | 354 | if ( ip ) |
352 | { | 355 | { |
353 | handleIPData( p, ip, source, dest ); | 356 | handleIPData( p, ip, source, dest ); |
354 | } | 357 | } |
355 | 358 | ||
356 | //handleNotification( p ); | 359 | //handleNotification( p ); |
357 | 360 | ||
358 | } | 361 | } |
359 | 362 | ||
360 | 363 | ||
361 | void Wellenreiter::stopClicked() | 364 | void Wellenreiter::stopClicked() |
362 | { | 365 | { |
363 | if ( iface ) | 366 | if ( iface ) |
364 | { | 367 | { |
365 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 368 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
366 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 369 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
367 | iface->setChannelHopping(); // stop hopping channels | 370 | iface->setChannelHopping(); // stop hopping channels |
368 | } | 371 | } |
369 | else | 372 | else |
370 | killTimers(); | 373 | killTimers(); |
371 | 374 | ||
372 | pcap->close(); | 375 | pcap->close(); |
373 | sniffing = false; | 376 | sniffing = false; |
374 | 377 | ||
375 | if ( iface ) | 378 | if ( iface ) |
376 | { | 379 | { |
377 | // switch off monitor mode | 380 | // switch off monitor mode |
378 | iface->setMonitorMode( false ); | 381 | iface->setMonitorMode( false ); |
379 | // switch off promisc flag | 382 | // switch off promisc flag |
380 | iface->setPromiscuousMode( false ); | 383 | iface->setPromiscuousMode( false ); |
381 | 384 | ||
382 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 385 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
383 | } | 386 | } |
384 | 387 | ||
385 | logwindow->log( "(i) Stopped Scanning." ); | 388 | logwindow->log( "(i) Stopped Scanning." ); |
386 | assert( parent() ); | 389 | assert( parent() ); |
387 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | 390 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); |
388 | 391 | ||
389 | // message the user | 392 | // message the user |
390 | QMessageBox::information( this, "Wellenreiter II", | 393 | QMessageBox::information( this, "Wellenreiter II", |
391 | tr( "Your wireless card\nshould now be usable again." ) ); | 394 | tr( "Your wireless card\nshould now be usable again." ) ); |
392 | 395 | ||
393 | sniffing = false; | 396 | sniffing = false; |
394 | emit( stoppedSniffing() ); | 397 | emit( stoppedSniffing() ); |
395 | 398 | ||
396 | #ifdef QWS | 399 | #ifdef QWS |
397 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | 400 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) |
398 | { | 401 | { |
399 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 402 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
400 | } | 403 | } |
401 | #else | 404 | #else |
402 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 405 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
403 | #endif | 406 | #endif |
404 | 407 | ||
405 | // print out statistics | 408 | // print out statistics |
406 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) | 409 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) |
407 | statwindow->updateCounter( it.key(), it.data() ); | 410 | statwindow->updateCounter( it.key(), it.data() ); |
408 | } | 411 | } |
409 | 412 | ||
410 | 413 | ||
411 | void Wellenreiter::startClicked() | 414 | void Wellenreiter::startClicked() |
412 | { | 415 | { |
413 | // get configuration from config window | 416 | // get configuration from config window |
414 | 417 | ||
415 | const QString& interface = configwindow->interfaceName->currentText(); | 418 | const QString& interface = configwindow->interfaceName->currentText(); |
416 | const int cardtype = configwindow->driverType(); | 419 | const int cardtype = configwindow->driverType(); |
417 | const int interval = configwindow->hoppingInterval(); | 420 | const int interval = configwindow->hoppingInterval(); |
418 | 421 | ||
419 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 422 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
420 | { | 423 | { |
421 | QMessageBox::information( this, "Wellenreiter II", | 424 | QMessageBox::information( this, "Wellenreiter II", |
422 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); | 425 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); |
423 | return; | 426 | return; |
424 | } | 427 | } |
425 | 428 | ||
426 | // configure device | 429 | // configure device |
427 | ONetwork* net = ONetwork::instance(); | 430 | ONetwork* net = ONetwork::instance(); |
428 | 431 | ||
429 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces | 432 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces |
430 | 433 | ||
431 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! | 434 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! |
432 | 435 | ||
433 | // bring device UP | 436 | // bring device UP |
434 | if ( cardtype != DEVTYPE_FILE ) | 437 | if ( cardtype != DEVTYPE_FILE ) |
435 | { | 438 | { |
436 | iface->setUp( true ); | 439 | iface->setUp( true ); |
437 | if ( !iface->isUp() ) | 440 | if ( !iface->isUp() ) |
438 | { | 441 | { |
439 | QMessageBox::warning( this, "Wellenreiter II", | 442 | QMessageBox::warning( this, "Wellenreiter II", |
440 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); | 443 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); |
441 | return; | 444 | return; |
442 | } | 445 | } |
443 | } | 446 | } |
444 | // set monitor mode | 447 | // set monitor mode |
445 | bool usePrism = configwindow->usePrismHeader(); | 448 | bool usePrism = configwindow->usePrismHeader(); |
446 | 449 | ||
447 | switch ( cardtype ) | 450 | switch ( cardtype ) |
448 | { | 451 | { |
449 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; | 452 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; |
450 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; | 453 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; |
451 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; | 454 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; |
452 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; | 455 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; |
453 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; | 456 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; |
454 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; | 457 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; |
455 | default: assert( 0 ); // shouldn't reach this | 458 | default: assert( 0 ); // shouldn't reach this |
456 | } | 459 | } |