author | mickeyl <mickeyl> | 2003-04-22 22:11:28 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-22 22:11:28 (UTC) |
commit | a0ffe9079338a8b870de5267a22ddbb01cb1cc27 (patch) (unidiff) | |
tree | fe240ab38bd11cd32d51674e4f79a465092476e5 | |
parent | bb8965d31b06ec122a0916d8c5bc4c4b68873a14 (diff) | |
download | opie-a0ffe9079338a8b870de5267a22ddbb01cb1cc27.zip opie-a0ffe9079338a8b870de5267a22ddbb01cb1cc27.tar.gz opie-a0ffe9079338a8b870de5267a22ddbb01cb1cc27.tar.bz2 |
add prism header parsing capability!
-rw-r--r-- | libopie2/opienet/802_11_user.h | 14 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 5 | ||||
-rw-r--r-- | libopie2/opienet/opcap.cpp | 31 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 19 |
4 files changed, 67 insertions, 2 deletions
diff --git a/libopie2/opienet/802_11_user.h b/libopie2/opienet/802_11_user.h index f596bd8..cd98503 100644 --- a/libopie2/opienet/802_11_user.h +++ b/libopie2/opienet/802_11_user.h | |||
@@ -308,128 +308,142 @@ struct ds_t { | |||
308 | u_int8_telement_id; | 308 | u_int8_telement_id; |
309 | u_int8_tlength; | 309 | u_int8_tlength; |
310 | u_int8_tchannel; | 310 | u_int8_tchannel; |
311 | }; | 311 | }; |
312 | 312 | ||
313 | 313 | ||
314 | struct cf_t { | 314 | struct cf_t { |
315 | u_int8_telement_id; | 315 | u_int8_telement_id; |
316 | u_int8_tlength; | 316 | u_int8_tlength; |
317 | u_int8_tcount; | 317 | u_int8_tcount; |
318 | u_int8_tperiod; | 318 | u_int8_tperiod; |
319 | u_int16_tmax_duration; | 319 | u_int16_tmax_duration; |
320 | u_int16_tdur_remaing; | 320 | u_int16_tdur_remaing; |
321 | }; | 321 | }; |
322 | 322 | ||
323 | 323 | ||
324 | struct tim_t { | 324 | struct tim_t { |
325 | u_int8_telement_id; | 325 | u_int8_telement_id; |
326 | u_int8_tlength; | 326 | u_int8_tlength; |
327 | u_int8_tcount; | 327 | u_int8_tcount; |
328 | u_int8_tperiod; | 328 | u_int8_tperiod; |
329 | u_int8_tbitmap_control; | 329 | u_int8_tbitmap_control; |
330 | u_int8_tbitmap[251]; | 330 | u_int8_tbitmap[251]; |
331 | }; | 331 | }; |
332 | 332 | ||
333 | 333 | ||
334 | struct ibss_t { | 334 | struct ibss_t { |
335 | u_int8_telement_id; | 335 | u_int8_telement_id; |
336 | u_int8_tlength; | 336 | u_int8_tlength; |
337 | u_int16_tatim_window; | 337 | u_int16_tatim_window; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | #define E_SSID 0 | 341 | #define E_SSID 0 |
342 | #define E_RATES 1 | 342 | #define E_RATES 1 |
343 | #define E_FH 2 | 343 | #define E_FH 2 |
344 | #define E_DS 3 | 344 | #define E_DS 3 |
345 | #define E_CF 4 | 345 | #define E_CF 4 |
346 | #define E_TIM 5 | 346 | #define E_TIM 5 |
347 | #define E_IBSS 6 | 347 | #define E_IBSS 6 |
348 | #define E_CHALLENGE 16 | 348 | #define E_CHALLENGE 16 |
349 | #define E_CISCO 133 | 349 | #define E_CISCO 133 |
350 | 350 | ||
351 | 351 | ||
352 | struct ieee_802_11_mgmt_body { | 352 | struct ieee_802_11_mgmt_body { |
353 | u_int8_t timestamp[8]; | 353 | u_int8_t timestamp[8]; |
354 | u_int16_t beacon_interval; | 354 | u_int16_t beacon_interval; |
355 | // u_int16_t listen_interval; | 355 | // u_int16_t listen_interval; |
356 | // u_int16_t status_code; | 356 | // u_int16_t status_code; |
357 | // u_int16_t aid; | 357 | // u_int16_t aid; |
358 | // u_char ap[6]; | 358 | // u_char ap[6]; |
359 | // u_int16_treason_code; | 359 | // u_int16_treason_code; |
360 | // u_int16_tauth_alg; | 360 | // u_int16_tauth_alg; |
361 | // u_int16_tauth_trans_seq_num; | 361 | // u_int16_tauth_trans_seq_num; |
362 | // struct challenge_t challenge; | 362 | // struct challenge_t challenge; |
363 | u_int16_t capability_info; | 363 | u_int16_t capability_info; |
364 | // struct ssid_tssid; | 364 | // struct ssid_tssid; |
365 | // struct rates_t rates; | 365 | // struct rates_t rates; |
366 | // struct ds_tds; | 366 | // struct ds_tds; |
367 | // struct cf_tcf; | 367 | // struct cf_tcf; |
368 | // struct fh_tfh; | 368 | // struct fh_tfh; |
369 | // struct tim_ttim; | 369 | // struct tim_ttim; |
370 | }; | 370 | }; |
371 | 371 | ||
372 | /* a 802.11 value */ | ||
373 | struct val_80211 { | ||
374 | unsigned int did; | ||
375 | unsigned short status, len; | ||
376 | unsigned int data; | ||
377 | }; | ||
378 | |||
379 | /* header attached during prism monitor mode */ | ||
380 | struct prism_hdr { | ||
381 | unsigned int msgcode, msglen; | ||
382 | char devname[16]; | ||
383 | struct val_80211 hosttime, mactime, channel, rssi, sq, signal, | ||
384 | noise, rate, istx, frmlen; | ||
385 | }; | ||
372 | 386 | ||
373 | struct ieee_802_11_data_body { | 387 | struct ieee_802_11_data_body { |
374 | //FIXME | 388 | //FIXME |
375 | }; | 389 | }; |
376 | 390 | ||
377 | struct ieee_802_11_control_body { | 391 | struct ieee_802_11_control_body { |
378 | //FIXME | 392 | //FIXME |
379 | }; | 393 | }; |
380 | 394 | ||
381 | struct ctrl_rts_t { | 395 | struct ctrl_rts_t { |
382 | u_int16_tfc; | 396 | u_int16_tfc; |
383 | u_int16_tduration; | 397 | u_int16_tduration; |
384 | u_int8_tra[6]; | 398 | u_int8_tra[6]; |
385 | u_int8_tta[6]; | 399 | u_int8_tta[6]; |
386 | u_int8_tfcs[4]; | 400 | u_int8_tfcs[4]; |
387 | }; | 401 | }; |
388 | 402 | ||
389 | #define CTRL_RTS_LEN(2+2+6+6+4) | 403 | #define CTRL_RTS_LEN(2+2+6+6+4) |
390 | 404 | ||
391 | struct ctrl_cts_t { | 405 | struct ctrl_cts_t { |
392 | u_int16_tfc; | 406 | u_int16_tfc; |
393 | u_int16_tduration; | 407 | u_int16_tduration; |
394 | u_int8_tra[6]; | 408 | u_int8_tra[6]; |
395 | u_int8_tfcs[4]; | 409 | u_int8_tfcs[4]; |
396 | }; | 410 | }; |
397 | 411 | ||
398 | #define CTRL_CTS_LEN(2+2+6+4) | 412 | #define CTRL_CTS_LEN(2+2+6+4) |
399 | 413 | ||
400 | struct ctrl_ack_t { | 414 | struct ctrl_ack_t { |
401 | u_int16_tfc; | 415 | u_int16_tfc; |
402 | u_int16_tduration; | 416 | u_int16_tduration; |
403 | u_int8_tra[6]; | 417 | u_int8_tra[6]; |
404 | u_int8_tfcs[4]; | 418 | u_int8_tfcs[4]; |
405 | }; | 419 | }; |
406 | 420 | ||
407 | #define CTRL_ACK_LEN(2+2+6+4) | 421 | #define CTRL_ACK_LEN(2+2+6+4) |
408 | 422 | ||
409 | struct ctrl_ps_poll_t { | 423 | struct ctrl_ps_poll_t { |
410 | u_int16_tfc; | 424 | u_int16_tfc; |
411 | u_int16_taid; | 425 | u_int16_taid; |
412 | u_int8_tbssid[6]; | 426 | u_int8_tbssid[6]; |
413 | u_int8_tta[6]; | 427 | u_int8_tta[6]; |
414 | u_int8_tfcs[4]; | 428 | u_int8_tfcs[4]; |
415 | }; | 429 | }; |
416 | 430 | ||
417 | #define CTRL_PS_POLL_LEN(2+2+6+6+4) | 431 | #define CTRL_PS_POLL_LEN(2+2+6+6+4) |
418 | 432 | ||
419 | struct ctrl_end_t { | 433 | struct ctrl_end_t { |
420 | u_int16_tfc; | 434 | u_int16_tfc; |
421 | u_int16_tduration; | 435 | u_int16_tduration; |
422 | u_int8_tra[6]; | 436 | u_int8_tra[6]; |
423 | u_int8_tbssid[6]; | 437 | u_int8_tbssid[6]; |
424 | u_int8_tfcs[4]; | 438 | u_int8_tfcs[4]; |
425 | }; | 439 | }; |
426 | 440 | ||
427 | #define CTRL_END_LEN(2+2+6+6+4) | 441 | #define CTRL_END_LEN(2+2+6+6+4) |
428 | 442 | ||
429 | struct ctrl_end_ack_t { | 443 | struct ctrl_end_ack_t { |
430 | u_int16_tfc; | 444 | u_int16_tfc; |
431 | u_int16_tduration; | 445 | u_int16_tduration; |
432 | u_int8_tra[6]; | 446 | u_int8_tra[6]; |
433 | u_int8_tbssid[6]; | 447 | u_int8_tbssid[6]; |
434 | u_int8_tfcs[4]; | 448 | u_int8_tfcs[4]; |
435 | }; | 449 | }; |
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index be2736a..95e7043 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -590,129 +590,130 @@ void OWirelessNetworkInterface::setChannel( int c ) const | |||
590 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 590 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
591 | _iwr.u.freq.m = c; | 591 | _iwr.u.freq.m = c; |
592 | _iwr.u.freq.e = 0; | 592 | _iwr.u.freq.e = 0; |
593 | wioctl( SIOCSIWFREQ ); | 593 | wioctl( SIOCSIWFREQ ); |
594 | } | 594 | } |
595 | else | 595 | else |
596 | { | 596 | { |
597 | _mon->setChannel( c ); | 597 | _mon->setChannel( c ); |
598 | } | 598 | } |
599 | } | 599 | } |
600 | 600 | ||
601 | 601 | ||
602 | double OWirelessNetworkInterface::frequency() const | 602 | double OWirelessNetworkInterface::frequency() const |
603 | { | 603 | { |
604 | if ( !wioctl( SIOCGIWFREQ ) ) | 604 | if ( !wioctl( SIOCGIWFREQ ) ) |
605 | { | 605 | { |
606 | return -1.0; | 606 | return -1.0; |
607 | } | 607 | } |
608 | else | 608 | else |
609 | { | 609 | { |
610 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; | 610 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; |
611 | } | 611 | } |
612 | } | 612 | } |
613 | 613 | ||
614 | 614 | ||
615 | int OWirelessNetworkInterface::channels() const | 615 | int OWirelessNetworkInterface::channels() const |
616 | { | 616 | { |
617 | return _channels.count(); | 617 | return _channels.count(); |
618 | } | 618 | } |
619 | 619 | ||
620 | 620 | ||
621 | void OWirelessNetworkInterface::setChannelHopping( int interval ) | 621 | void OWirelessNetworkInterface::setChannelHopping( int interval ) |
622 | { | 622 | { |
623 | if ( !_hopper ) _hopper = new OChannelHopper( this ); | 623 | if ( !_hopper ) _hopper = new OChannelHopper( this ); |
624 | _hopper->setInterval( interval ); | 624 | _hopper->setInterval( interval ); |
625 | //FIXME: When and by whom will the channel hopper be deleted? | 625 | //FIXME: When and by whom will the channel hopper be deleted? |
626 | //TODO: rely on QObject hierarchy | 626 | //TODO: rely on QObject hierarchy |
627 | } | 627 | } |
628 | 628 | ||
629 | 629 | ||
630 | int OWirelessNetworkInterface::channelHopping() const | 630 | int OWirelessNetworkInterface::channelHopping() const |
631 | { | 631 | { |
632 | return _hopper->interval(); | 632 | return _hopper->interval(); |
633 | } | 633 | } |
634 | 634 | ||
635 | 635 | ||
636 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const | 636 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const |
637 | { | 637 | { |
638 | return _hopper; | 638 | return _hopper; |
639 | } | 639 | } |
640 | 640 | ||
641 | 641 | ||
642 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 642 | void OWirelessNetworkInterface::setMonitorMode( bool b ) |
643 | { | 643 | { |
644 | if ( _mon ) | 644 | if ( _mon ) |
645 | _mon->setEnabled( b ); | 645 | _mon->setEnabled( b ); |
646 | else | 646 | else |
647 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | 647 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); |
648 | } | 648 | } |
649 | 649 | ||
650 | 650 | ||
651 | bool OWirelessNetworkInterface::monitorMode() const | 651 | bool OWirelessNetworkInterface::monitorMode() const |
652 | { | 652 | { |
653 | qDebug( "dataLinkType = %d", dataLinkType() ); | 653 | qDebug( "dataLinkType = %d", dataLinkType() ); |
654 | return dataLinkType() == ARPHRD_IEEE80211; | 654 | return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ); |
655 | // 802 is the header type for PRISM - Linux support for this is pending... | ||
655 | } | 656 | } |
656 | 657 | ||
657 | 658 | ||
658 | QString OWirelessNetworkInterface::nickName() const | 659 | QString OWirelessNetworkInterface::nickName() const |
659 | { | 660 | { |
660 | char str[IW_ESSID_MAX_SIZE]; | 661 | char str[IW_ESSID_MAX_SIZE]; |
661 | _iwr.u.data.pointer = &str[0]; | 662 | _iwr.u.data.pointer = &str[0]; |
662 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 663 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
663 | if ( !wioctl( SIOCGIWNICKN ) ) | 664 | if ( !wioctl( SIOCGIWNICKN ) ) |
664 | { | 665 | { |
665 | return "<unknown>"; | 666 | return "<unknown>"; |
666 | } | 667 | } |
667 | else | 668 | else |
668 | { | 669 | { |
669 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string | 670 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string |
670 | return str; | 671 | return str; |
671 | } | 672 | } |
672 | } | 673 | } |
673 | 674 | ||
674 | 675 | ||
675 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) | 676 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) |
676 | { | 677 | { |
677 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); | 678 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); |
678 | if ( !priv ) | 679 | if ( !priv ) |
679 | { | 680 | { |
680 | qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); | 681 | qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); |
681 | return; | 682 | return; |
682 | } | 683 | } |
683 | if ( priv->numberSetArgs() != numargs ) | 684 | if ( priv->numberSetArgs() != numargs ) |
684 | { | 685 | { |
685 | qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); | 686 | qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); |
686 | return; | 687 | return; |
687 | } | 688 | } |
688 | 689 | ||
689 | qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); | 690 | qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); |
690 | memset( &_iwr, 0, sizeof _iwr ); | 691 | memset( &_iwr, 0, sizeof _iwr ); |
691 | va_list argp; | 692 | va_list argp; |
692 | va_start( argp, numargs ); | 693 | va_start( argp, numargs ); |
693 | for ( int i = 0; i < numargs; ++i ) | 694 | for ( int i = 0; i < numargs; ++i ) |
694 | { | 695 | { |
695 | priv->setParameter( i, va_arg( argp, int ) ); | 696 | priv->setParameter( i, va_arg( argp, int ) ); |
696 | } | 697 | } |
697 | va_end( argp ); | 698 | va_end( argp ); |
698 | priv->invoke(); | 699 | priv->invoke(); |
699 | } | 700 | } |
700 | 701 | ||
701 | 702 | ||
702 | void OWirelessNetworkInterface::getPrivate( const QString& call ) | 703 | void OWirelessNetworkInterface::getPrivate( const QString& call ) |
703 | { | 704 | { |
704 | qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); | 705 | qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); |
705 | } | 706 | } |
706 | 707 | ||
707 | 708 | ||
708 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | 709 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) |
709 | { | 710 | { |
710 | return child( (const char*) call ); | 711 | return child( (const char*) call ); |
711 | } | 712 | } |
712 | 713 | ||
713 | 714 | ||
714 | QString OWirelessNetworkInterface::SSID() const | 715 | QString OWirelessNetworkInterface::SSID() const |
715 | { | 716 | { |
716 | char str[IW_ESSID_MAX_SIZE]; | 717 | char str[IW_ESSID_MAX_SIZE]; |
717 | _iwr.u.essid.pointer = &str[0]; | 718 | _iwr.u.essid.pointer = &str[0]; |
718 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 719 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
@@ -872,85 +873,85 @@ QString OWlanNGMonitoringInterface::name() const | |||
872 | 873 | ||
873 | void OWlanNGMonitoringInterface::setChannel( int ) | 874 | void OWlanNGMonitoringInterface::setChannel( int ) |
874 | { | 875 | { |
875 | // wlan-ng devices automatically switch channels when in monitor mode | 876 | // wlan-ng devices automatically switch channels when in monitor mode |
876 | } | 877 | } |
877 | 878 | ||
878 | 879 | ||
879 | /*====================================================================================== | 880 | /*====================================================================================== |
880 | * OHostAPMonitoringInterface | 881 | * OHostAPMonitoringInterface |
881 | *======================================================================================*/ | 882 | *======================================================================================*/ |
882 | 883 | ||
883 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) | 884 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) |
884 | :OMonitoringInterface( iface ) | 885 | :OMonitoringInterface( iface ) |
885 | { | 886 | { |
886 | iface->setMonitoring( this ); | 887 | iface->setMonitoring( this ); |
887 | } | 888 | } |
888 | 889 | ||
889 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() | 890 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() |
890 | { | 891 | { |
891 | } | 892 | } |
892 | 893 | ||
893 | void OHostAPMonitoringInterface::setEnabled( bool b ) | 894 | void OHostAPMonitoringInterface::setEnabled( bool b ) |
894 | { | 895 | { |
895 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | 896 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 |
896 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | 897 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring |
897 | 898 | ||
898 | //TODO: check wireless extensions version on runtime and use | 899 | //TODO: check wireless extensions version on runtime and use |
899 | //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15 | 900 | //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15 |
900 | 901 | ||
901 | if ( b ) | 902 | if ( b ) |
902 | { | 903 | { |
903 | _if->setPrivate( "monitor", 1, 2 ); | 904 | _if->setPrivate( "monitor", 1, 2 ); |
904 | } | 905 | } |
905 | else | 906 | else |
906 | { | 907 | { |
907 | _if->setPrivate( "monitor", 1, 0 ); | 908 | _if->setPrivate( "monitor", 1, 0 ); |
908 | } | 909 | } |
909 | } | 910 | } |
910 | 911 | ||
911 | 912 | ||
912 | QString OHostAPMonitoringInterface::name() const | 913 | QString OHostAPMonitoringInterface::name() const |
913 | { | 914 | { |
914 | return "hostap"; | 915 | return "hostap"; |
915 | } | 916 | } |
916 | 917 | ||
917 | 918 | ||
918 | /*====================================================================================== | 919 | /*====================================================================================== |
919 | * OOrinocoNetworkInterface | 920 | * OOrinocoNetworkInterface |
920 | *======================================================================================*/ | 921 | *======================================================================================*/ |
921 | 922 | ||
922 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) | 923 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) |
923 | :OMonitoringInterface( iface ) | 924 | :OMonitoringInterface( iface ) |
924 | { | 925 | { |
925 | iface->setMonitoring( this ); | 926 | iface->setMonitoring( this ); |
926 | } | 927 | } |
927 | 928 | ||
928 | 929 | ||
929 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() | 930 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() |
930 | { | 931 | { |
931 | } | 932 | } |
932 | 933 | ||
933 | 934 | ||
934 | void OOrinocoMonitoringInterface::setChannel( int c ) | 935 | void OOrinocoMonitoringInterface::setChannel( int c ) |
935 | { | 936 | { |
936 | _if->setPrivate( "monitor", 2, 2, c ); | 937 | _if->setPrivate( "monitor", 2, 1, c ); |
937 | } | 938 | } |
938 | 939 | ||
939 | 940 | ||
940 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 941 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
941 | { | 942 | { |
942 | if ( b ) | 943 | if ( b ) |
943 | { | 944 | { |
944 | setChannel( 1 ); | 945 | setChannel( 1 ); |
945 | } | 946 | } |
946 | else | 947 | else |
947 | { | 948 | { |
948 | _if->setPrivate( "monitor", 2, 0, 0 ); | 949 | _if->setPrivate( "monitor", 2, 0, 0 ); |
949 | } | 950 | } |
950 | } | 951 | } |
951 | 952 | ||
952 | 953 | ||
953 | QString OOrinocoMonitoringInterface::name() const | 954 | QString OOrinocoMonitoringInterface::name() const |
954 | { | 955 | { |
955 | return "orinoco"; | 956 | return "orinoco"; |
956 | } | 957 | } |
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index e362883..675818e 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -4,128 +4,133 @@ | |||
4 | Martin J. Muench <mjm@remote-exploit.org> | 4 | Martin J. Muench <mjm@remote-exploit.org> |
5 | Max Moser <mmo@remote-exploit.org | 5 | Max Moser <mmo@remote-exploit.org |
6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | 35 | ||
36 | #include <opie2/opcap.h> | 36 | #include <opie2/opcap.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | 39 | ||
40 | #include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) | 40 | #include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) |
41 | #include <qsocketnotifier.h> | 41 | #include <qsocketnotifier.h> |
42 | #include <qobjectlist.h> | 42 | #include <qobjectlist.h> |
43 | 43 | ||
44 | /*====================================================================================== | 44 | /*====================================================================================== |
45 | * OPacket | 45 | * OPacket |
46 | *======================================================================================*/ | 46 | *======================================================================================*/ |
47 | 47 | ||
48 | OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) | 48 | OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) |
49 | :QObject( parent, "Generic" ), _hdr( header ), _data( data ) | 49 | :QObject( parent, "Generic" ), _hdr( header ), _data( data ) |
50 | { | 50 | { |
51 | //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); | 51 | //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); |
52 | 52 | ||
53 | _end = (unsigned char*) data + header.len; | 53 | _end = (unsigned char*) data + header.len; |
54 | //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); | 54 | //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); |
55 | 55 | ||
56 | switch ( datalink ) | 56 | switch ( datalink ) |
57 | { | 57 | { |
58 | case DLT_EN10MB: | 58 | case DLT_EN10MB: |
59 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); | 59 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); |
60 | new OEthernetPacket( _end, (const struct ether_header*) data, this ); | 60 | new OEthernetPacket( _end, (const struct ether_header*) data, this ); |
61 | break; | 61 | break; |
62 | 62 | ||
63 | case DLT_IEEE802_11: | 63 | case DLT_IEEE802_11: |
64 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); | 64 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); |
65 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); | 65 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); |
66 | break; | 66 | break; |
67 | 67 | ||
68 | case DLT_PRISM_HEADER: | ||
69 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" ); | ||
70 | new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); | ||
71 | break; | ||
72 | |||
68 | default: | 73 | default: |
69 | qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink '%s'!", datalink ); | 74 | qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink '%s'!", datalink ); |
70 | } | 75 | } |
71 | } | 76 | } |
72 | 77 | ||
73 | 78 | ||
74 | OPacket::~OPacket() | 79 | OPacket::~OPacket() |
75 | { | 80 | { |
76 | } | 81 | } |
77 | 82 | ||
78 | 83 | ||
79 | timevalstruct OPacket::timeval() const | 84 | timevalstruct OPacket::timeval() const |
80 | { | 85 | { |
81 | return _hdr.ts; | 86 | return _hdr.ts; |
82 | } | 87 | } |
83 | 88 | ||
84 | 89 | ||
85 | int OPacket::caplen() const | 90 | int OPacket::caplen() const |
86 | { | 91 | { |
87 | return _hdr.caplen; | 92 | return _hdr.caplen; |
88 | } | 93 | } |
89 | 94 | ||
90 | 95 | ||
91 | void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) | 96 | void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) |
92 | { | 97 | { |
93 | if (!l) return; | 98 | if (!l) return; |
94 | QObject* o = l->first(); | 99 | QObject* o = l->first(); |
95 | while ( o ) | 100 | while ( o ) |
96 | { | 101 | { |
97 | stats[o->name()]++; | 102 | stats[o->name()]++; |
98 | updateStats( stats, const_cast<QObjectList*>( o->children() ) ); | 103 | updateStats( stats, const_cast<QObjectList*>( o->children() ) ); |
99 | o = l->next(); | 104 | o = l->next(); |
100 | } | 105 | } |
101 | } | 106 | } |
102 | 107 | ||
103 | 108 | ||
104 | QString OPacket::dump( int bpl ) const | 109 | QString OPacket::dump( int bpl ) const |
105 | { | 110 | { |
106 | static int index = 0; | 111 | static int index = 0; |
107 | index++; | 112 | index++; |
108 | int len = _hdr.caplen; | 113 | int len = _hdr.caplen; |
109 | QString str; | 114 | QString str; |
110 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); | 115 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); |
111 | str.append( "0000: " ); | 116 | str.append( "0000: " ); |
112 | QString tmp; | 117 | QString tmp; |
113 | QString bytes; | 118 | QString bytes; |
114 | QString chars; | 119 | QString chars; |
115 | 120 | ||
116 | for ( int i = 0; i < len; ++i ) | 121 | for ( int i = 0; i < len; ++i ) |
117 | { | 122 | { |
118 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); | 123 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); |
119 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); | 124 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); |
120 | else chars.append( '.' ); | 125 | else chars.append( '.' ); |
121 | 126 | ||
122 | if ( !((i+1) % bpl) ) | 127 | if ( !((i+1) % bpl) ) |
123 | { | 128 | { |
124 | str.append( bytes ); | 129 | str.append( bytes ); |
125 | str.append( ' ' ); | 130 | str.append( ' ' ); |
126 | str.append( chars ); | 131 | str.append( chars ); |
127 | str.append( '\n' ); | 132 | str.append( '\n' ); |
128 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); | 133 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); |
129 | bytes = ""; | 134 | bytes = ""; |
130 | chars = ""; | 135 | chars = ""; |
131 | } | 136 | } |
@@ -255,128 +260,154 @@ int OIPPacket::len() const | |||
255 | int OIPPacket::id() const | 260 | int OIPPacket::id() const |
256 | { | 261 | { |
257 | return EXTRACT_16BITS( &_iphdr->id ); | 262 | return EXTRACT_16BITS( &_iphdr->id ); |
258 | } | 263 | } |
259 | 264 | ||
260 | 265 | ||
261 | int OIPPacket::offset() const | 266 | int OIPPacket::offset() const |
262 | { | 267 | { |
263 | return EXTRACT_16BITS( &_iphdr->frag_off ); | 268 | return EXTRACT_16BITS( &_iphdr->frag_off ); |
264 | } | 269 | } |
265 | 270 | ||
266 | 271 | ||
267 | int OIPPacket::ttl() const | 272 | int OIPPacket::ttl() const |
268 | { | 273 | { |
269 | return _iphdr->ttl; | 274 | return _iphdr->ttl; |
270 | } | 275 | } |
271 | 276 | ||
272 | 277 | ||
273 | int OIPPacket::protocol() const | 278 | int OIPPacket::protocol() const |
274 | { | 279 | { |
275 | return _iphdr->protocol; | 280 | return _iphdr->protocol; |
276 | } | 281 | } |
277 | 282 | ||
278 | 283 | ||
279 | int OIPPacket::checksum() const | 284 | int OIPPacket::checksum() const |
280 | { | 285 | { |
281 | return EXTRACT_16BITS( &_iphdr->check ); | 286 | return EXTRACT_16BITS( &_iphdr->check ); |
282 | } | 287 | } |
283 | 288 | ||
284 | /*====================================================================================== | 289 | /*====================================================================================== |
285 | * OUDPPacket | 290 | * OUDPPacket |
286 | *======================================================================================*/ | 291 | *======================================================================================*/ |
287 | 292 | ||
288 | 293 | ||
289 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) | 294 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) |
290 | :QObject( parent, "UDP" ), _udphdr( data ) | 295 | :QObject( parent, "UDP" ), _udphdr( data ) |
291 | 296 | ||
292 | { | 297 | { |
293 | qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); | 298 | qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); |
294 | } | 299 | } |
295 | 300 | ||
296 | OUDPPacket::~OUDPPacket() | 301 | OUDPPacket::~OUDPPacket() |
297 | { | 302 | { |
298 | } | 303 | } |
299 | 304 | ||
300 | 305 | ||
301 | /*====================================================================================== | 306 | /*====================================================================================== |
302 | * OTCPPacket | 307 | * OTCPPacket |
303 | *======================================================================================*/ | 308 | *======================================================================================*/ |
304 | 309 | ||
305 | 310 | ||
306 | OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) | 311 | OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) |
307 | :QObject( parent, "TCP" ), _tcphdr( data ) | 312 | :QObject( parent, "TCP" ), _tcphdr( data ) |
308 | 313 | ||
309 | { | 314 | { |
310 | qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); | 315 | qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); |
311 | } | 316 | } |
312 | 317 | ||
313 | OTCPPacket::~OTCPPacket() | 318 | OTCPPacket::~OTCPPacket() |
314 | { | 319 | { |
315 | } | 320 | } |
316 | 321 | ||
317 | 322 | ||
318 | /*====================================================================================== | 323 | /*====================================================================================== |
324 | * OPrismHeaderPacket | ||
325 | *======================================================================================*/ | ||
326 | |||
327 | |||
328 | OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent ) | ||
329 | :QObject( parent, "Prism" ), _header( data ) | ||
330 | |||
331 | { | ||
332 | qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." ); | ||
333 | |||
334 | qDebug( "Signal Strength = %d", data->signal.data ); | ||
335 | |||
336 | new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this ); | ||
337 | } | ||
338 | |||
339 | OPrismHeaderPacket::~OPrismHeaderPacket() | ||
340 | { | ||
341 | } | ||
342 | |||
343 | |||
344 | unsigned int OPrismHeaderPacket::signalStrength() const | ||
345 | { | ||
346 | return _header->signal.data; | ||
347 | } | ||
348 | |||
349 | /*====================================================================================== | ||
319 | * OWaveLanPacket | 350 | * OWaveLanPacket |
320 | *======================================================================================*/ | 351 | *======================================================================================*/ |
321 | 352 | ||
322 | 353 | ||
323 | OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) | 354 | OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) |
324 | :QObject( parent, "802.11" ), _wlanhdr( data ) | 355 | :QObject( parent, "802.11" ), _wlanhdr( data ) |
325 | 356 | ||
326 | { | 357 | { |
327 | qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); | 358 | qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); |
328 | qDebug( "type: %0X", type() ); | 359 | qDebug( "type: %0X", type() ); |
329 | qDebug( "subType: %0X", subType() ); | 360 | qDebug( "subType: %0X", subType() ); |
330 | qDebug( "duration: %d", duration() ); | 361 | qDebug( "duration: %d", duration() ); |
331 | qDebug( "powermanagement: %d", usesPowerManagement() ); | 362 | qDebug( "powermanagement: %d", usesPowerManagement() ); |
332 | qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" ); | 363 | qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" ); |
333 | qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); | 364 | qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); |
334 | qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); | 365 | qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); |
335 | qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); | 366 | qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); |
336 | qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); | 367 | qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); |
337 | 368 | ||
338 | switch ( type() ) | 369 | switch ( type() ) |
339 | { | 370 | { |
340 | case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; | 371 | case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; |
341 | case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; | 372 | case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; |
342 | case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break; | 373 | case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break; |
343 | default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() ); | 374 | default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() ); |
344 | } | 375 | } |
345 | } | 376 | } |
346 | 377 | ||
347 | OWaveLanPacket::~OWaveLanPacket() | 378 | OWaveLanPacket::~OWaveLanPacket() |
348 | { | 379 | { |
349 | } | 380 | } |
350 | 381 | ||
351 | 382 | ||
352 | int OWaveLanPacket::duration() const | 383 | int OWaveLanPacket::duration() const |
353 | { | 384 | { |
354 | return _wlanhdr->duration; | 385 | return _wlanhdr->duration; |
355 | } | 386 | } |
356 | 387 | ||
357 | 388 | ||
358 | OMacAddress OWaveLanPacket::macAddress1() const | 389 | OMacAddress OWaveLanPacket::macAddress1() const |
359 | { | 390 | { |
360 | return OMacAddress( _wlanhdr->mac1 ); | 391 | return OMacAddress( _wlanhdr->mac1 ); |
361 | } | 392 | } |
362 | 393 | ||
363 | 394 | ||
364 | OMacAddress OWaveLanPacket::macAddress2() const | 395 | OMacAddress OWaveLanPacket::macAddress2() const |
365 | { | 396 | { |
366 | return OMacAddress( _wlanhdr->mac2 ); | 397 | return OMacAddress( _wlanhdr->mac2 ); |
367 | } | 398 | } |
368 | 399 | ||
369 | 400 | ||
370 | OMacAddress OWaveLanPacket::macAddress3() const | 401 | OMacAddress OWaveLanPacket::macAddress3() const |
371 | { | 402 | { |
372 | return OMacAddress( _wlanhdr->mac3 ); | 403 | return OMacAddress( _wlanhdr->mac3 ); |
373 | } | 404 | } |
374 | 405 | ||
375 | 406 | ||
376 | OMacAddress OWaveLanPacket::macAddress4() const | 407 | OMacAddress OWaveLanPacket::macAddress4() const |
377 | { | 408 | { |
378 | return OMacAddress( _wlanhdr->mac4 ); | 409 | return OMacAddress( _wlanhdr->mac4 ); |
379 | } | 410 | } |
380 | 411 | ||
381 | 412 | ||
382 | int OWaveLanPacket::subType() const | 413 | int OWaveLanPacket::subType() const |
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index fe88e68..83f7115 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h | |||
@@ -94,128 +94,147 @@ class QSocketNotifier; | |||
94 | * the header must be inspected before attempting to decode the payload. Hence, the | 94 | * the header must be inspected before attempting to decode the payload. Hence, the |
95 | * encapsulation level varies and can't be deduced without actually looking into the packets. | 95 | * encapsulation level varies and can't be deduced without actually looking into the packets. |
96 | * | 96 | * |
97 | * For actually working with captured frames, it's useful to identify the packets via names and | 97 | * For actually working with captured frames, it's useful to identify the packets via names and |
98 | * insert them into a parent/child - relationship based on the encapsulation. This is why | 98 | * insert them into a parent/child - relationship based on the encapsulation. This is why |
99 | * all packet classes derive from QObject. The amount of overhead caused by the QObject is | 99 | * all packet classes derive from QObject. The amount of overhead caused by the QObject is |
100 | * not a problem in this case, because we're talking about a theoratical maximum of about | 100 | * not a problem in this case, because we're talking about a theoratical maximum of about |
101 | * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the | 101 | * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the |
102 | * QObject also cares about destroying the sub-, (child-) packets. | 102 | * QObject also cares about destroying the sub-, (child-) packets. |
103 | * | 103 | * |
104 | * This enables us to perform a simple look for packets of a certain type: | 104 | * This enables us to perform a simple look for packets of a certain type: |
105 | * @code | 105 | * @code |
106 | * OPacketCapturer* pcap = new OPacketCapturer(); | 106 | * OPacketCapturer* pcap = new OPacketCapturer(); |
107 | * pcap->open( "eth0" ); | 107 | * pcap->open( "eth0" ); |
108 | * OPacket* p = pcap->next(); | 108 | * OPacket* p = pcap->next(); |
109 | * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists | 109 | * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists |
110 | * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; | 110 | * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; |
111 | * | 111 | * |
112 | */ | 112 | */ |
113 | 113 | ||
114 | class OPacket : public QObject | 114 | class OPacket : public QObject |
115 | { | 115 | { |
116 | Q_OBJECT | 116 | Q_OBJECT |
117 | 117 | ||
118 | public: | 118 | public: |
119 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); | 119 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); |
120 | virtual ~OPacket(); | 120 | virtual ~OPacket(); |
121 | 121 | ||
122 | timevalstruct timeval() const; | 122 | timevalstruct timeval() const; |
123 | 123 | ||
124 | int caplen() const; | 124 | int caplen() const; |
125 | int len() const; | 125 | int len() const; |
126 | QString dump( int = 32 ) const; | 126 | QString dump( int = 32 ) const; |
127 | 127 | ||
128 | void updateStats( QMap<QString,int>&, QObjectList* ); | 128 | void updateStats( QMap<QString,int>&, QObjectList* ); |
129 | 129 | ||
130 | private: | 130 | private: |
131 | const packetheaderstruct _hdr; // pcap packet header | 131 | const packetheaderstruct _hdr; // pcap packet header |
132 | const unsigned char* _data; // pcap packet data | 132 | const unsigned char* _data; // pcap packet data |
133 | const unsigned char* _end; // end of pcap packet data | 133 | const unsigned char* _end; // end of pcap packet data |
134 | }; | 134 | }; |
135 | 135 | ||
136 | /*====================================================================================== | 136 | /*====================================================================================== |
137 | * OEthernetPacket - DLT_EN10MB frame | 137 | * OEthernetPacket - DLT_EN10MB frame |
138 | *======================================================================================*/ | 138 | *======================================================================================*/ |
139 | 139 | ||
140 | class OEthernetPacket : public QObject | 140 | class OEthernetPacket : public QObject |
141 | { | 141 | { |
142 | Q_OBJECT | 142 | Q_OBJECT |
143 | 143 | ||
144 | public: | 144 | public: |
145 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); | 145 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); |
146 | virtual ~OEthernetPacket(); | 146 | virtual ~OEthernetPacket(); |
147 | 147 | ||
148 | OMacAddress sourceAddress() const; | 148 | OMacAddress sourceAddress() const; |
149 | OMacAddress destinationAddress() const; | 149 | OMacAddress destinationAddress() const; |
150 | int type() const; | 150 | int type() const; |
151 | 151 | ||
152 | private: | 152 | private: |
153 | const struct ether_header* _ether; | 153 | const struct ether_header* _ether; |
154 | }; | 154 | }; |
155 | 155 | ||
156 | 156 | ||
157 | /*====================================================================================== | 157 | /*====================================================================================== |
158 | * OPrismHeaderPacket - DLT_PRISM_HEADER frame | ||
159 | *======================================================================================*/ | ||
160 | |||
161 | class OPrismHeaderPacket : public QObject | ||
162 | { | ||
163 | Q_OBJECT | ||
164 | |||
165 | public: | ||
166 | OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); | ||
167 | virtual ~OPrismHeaderPacket(); | ||
168 | |||
169 | unsigned int signalStrength() const; | ||
170 | |||
171 | private: | ||
172 | const struct prism_hdr* _header; | ||
173 | }; | ||
174 | |||
175 | |||
176 | /*====================================================================================== | ||
158 | * OWaveLanPacket - DLT_IEEE802_11 frame | 177 | * OWaveLanPacket - DLT_IEEE802_11 frame |
159 | *======================================================================================*/ | 178 | *======================================================================================*/ |
160 | 179 | ||
161 | class OWaveLanPacket : public QObject | 180 | class OWaveLanPacket : public QObject |
162 | { | 181 | { |
163 | Q_OBJECT | 182 | Q_OBJECT |
164 | 183 | ||
165 | public: | 184 | public: |
166 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); | 185 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); |
167 | virtual ~OWaveLanPacket(); | 186 | virtual ~OWaveLanPacket(); |
168 | 187 | ||
169 | int duration() const; | 188 | int duration() const; |
170 | bool fromDS() const; | 189 | bool fromDS() const; |
171 | bool toDS() const; | 190 | bool toDS() const; |
172 | virtual OMacAddress macAddress1() const; | 191 | virtual OMacAddress macAddress1() const; |
173 | virtual OMacAddress macAddress2() const; | 192 | virtual OMacAddress macAddress2() const; |
174 | virtual OMacAddress macAddress3() const; | 193 | virtual OMacAddress macAddress3() const; |
175 | virtual OMacAddress macAddress4() const; | 194 | virtual OMacAddress macAddress4() const; |
176 | bool usesPowerManagement() const; | 195 | bool usesPowerManagement() const; |
177 | int type() const; | 196 | int type() const; |
178 | int subType() const; | 197 | int subType() const; |
179 | int version() const; | 198 | int version() const; |
180 | bool usesWep() const; | 199 | bool usesWep() const; |
181 | 200 | ||
182 | private: | 201 | private: |
183 | const struct ieee_802_11_header* _wlanhdr; | 202 | const struct ieee_802_11_header* _wlanhdr; |
184 | }; | 203 | }; |
185 | 204 | ||
186 | 205 | ||
187 | /*====================================================================================== | 206 | /*====================================================================================== |
188 | * OWaveLanManagementPacket - type: management (T_MGMT) | 207 | * OWaveLanManagementPacket - type: management (T_MGMT) |
189 | *======================================================================================*/ | 208 | *======================================================================================*/ |
190 | 209 | ||
191 | class OWaveLanManagementPacket : public QObject | 210 | class OWaveLanManagementPacket : public QObject |
192 | { | 211 | { |
193 | Q_OBJECT | 212 | Q_OBJECT |
194 | 213 | ||
195 | public: | 214 | public: |
196 | OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); | 215 | OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); |
197 | virtual ~OWaveLanManagementPacket(); | 216 | virtual ~OWaveLanManagementPacket(); |
198 | 217 | ||
199 | QString managementType() const; | 218 | QString managementType() const; |
200 | 219 | ||
201 | int beaconInterval() const; | 220 | int beaconInterval() const; |
202 | int capabilities() const; // generic | 221 | int capabilities() const; // generic |
203 | 222 | ||
204 | bool canESS() const; | 223 | bool canESS() const; |
205 | bool canIBSS() const; | 224 | bool canIBSS() const; |
206 | bool canCFP() const; | 225 | bool canCFP() const; |
207 | bool canCFP_REQ() const; | 226 | bool canCFP_REQ() const; |
208 | bool canPrivacy() const; | 227 | bool canPrivacy() const; |
209 | 228 | ||
210 | private: | 229 | private: |
211 | const struct ieee_802_11_mgmt_header* _header; | 230 | const struct ieee_802_11_mgmt_header* _header; |
212 | const struct ieee_802_11_mgmt_body* _body; | 231 | const struct ieee_802_11_mgmt_body* _body; |
213 | }; | 232 | }; |
214 | 233 | ||
215 | 234 | ||
216 | /*====================================================================================== | 235 | /*====================================================================================== |
217 | * OWaveLanManagementSSID | 236 | * OWaveLanManagementSSID |
218 | *======================================================================================*/ | 237 | *======================================================================================*/ |
219 | 238 | ||
220 | class OWaveLanManagementSSID : public QObject | 239 | class OWaveLanManagementSSID : public QObject |
221 | { | 240 | { |