author | mickeyl <mickeyl> | 2003-05-05 14:57:27 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-05 14:57:27 (UTC) |
commit | 29f5c6e6bcb8db0f0e26da25dbf34b2685c01526 (patch) (unidiff) | |
tree | a05e296ff11d532fd3d5fd092aade07474d1ba95 | |
parent | a5818261bec2d0a6d903fef9baeed1a7abc85275 (diff) | |
download | opie-29f5c6e6bcb8db0f0e26da25dbf34b2685c01526.zip opie-29f5c6e6bcb8db0f0e26da25dbf34b2685c01526.tar.gz opie-29f5c6e6bcb8db0f0e26da25dbf34b2685c01526.tar.bz2 |
- fix segfault on unknown linktype (thanks groucho)
- make capturing using PRISM headers optional
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 31 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 11 | ||||
-rw-r--r-- | libopie2/opienet/opcap.cpp | 2 |
3 files changed, 25 insertions, 19 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 2dfff1d..6cef5cf 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -764,245 +764,250 @@ bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | |||
764 | 764 | ||
765 | 765 | ||
766 | QString OWirelessNetworkInterface::SSID() const | 766 | QString OWirelessNetworkInterface::SSID() const |
767 | { | 767 | { |
768 | char str[IW_ESSID_MAX_SIZE]; | 768 | char str[IW_ESSID_MAX_SIZE]; |
769 | _iwr.u.essid.pointer = &str[0]; | 769 | _iwr.u.essid.pointer = &str[0]; |
770 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 770 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
771 | if ( !wioctl( SIOCGIWESSID ) ) | 771 | if ( !wioctl( SIOCGIWESSID ) ) |
772 | { | 772 | { |
773 | return "<unknown>"; | 773 | return "<unknown>"; |
774 | } | 774 | } |
775 | else | 775 | else |
776 | { | 776 | { |
777 | return str; | 777 | return str; |
778 | } | 778 | } |
779 | } | 779 | } |
780 | 780 | ||
781 | 781 | ||
782 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 782 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
783 | { | 783 | { |
784 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 784 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
785 | _iwr.u.essid.length = ssid.length(); | 785 | _iwr.u.essid.length = ssid.length(); |
786 | wioctl( SIOCSIWESSID ); | 786 | wioctl( SIOCSIWESSID ); |
787 | } | 787 | } |
788 | 788 | ||
789 | 789 | ||
790 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 790 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
791 | { | 791 | { |
792 | int result = ::ioctl( _sfd, call, &iwreq ); | 792 | int result = ::ioctl( _sfd, call, &iwreq ); |
793 | if ( result == -1 ) | 793 | if ( result == -1 ) |
794 | qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); | 794 | qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); |
795 | else | 795 | else |
796 | qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Ok.", name(), call ); | 796 | qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Ok.", name(), call ); |
797 | return ( result != -1 ); | 797 | return ( result != -1 ); |
798 | } | 798 | } |
799 | 799 | ||
800 | 800 | ||
801 | bool OWirelessNetworkInterface::wioctl( int call ) const | 801 | bool OWirelessNetworkInterface::wioctl( int call ) const |
802 | { | 802 | { |
803 | strcpy( _iwr.ifr_name, name() ); | 803 | strcpy( _iwr.ifr_name, name() ); |
804 | return wioctl( call, _iwr ); | 804 | return wioctl( call, _iwr ); |
805 | } | 805 | } |
806 | 806 | ||
807 | 807 | ||
808 | /*====================================================================================== | 808 | /*====================================================================================== |
809 | * OMonitoringInterface | 809 | * OMonitoringInterface |
810 | *======================================================================================*/ | 810 | *======================================================================================*/ |
811 | 811 | ||
812 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) | 812 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
813 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ) | 813 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) |
814 | { | 814 | { |
815 | } | 815 | } |
816 | 816 | ||
817 | 817 | ||
818 | OMonitoringInterface::~OMonitoringInterface() | 818 | OMonitoringInterface::~OMonitoringInterface() |
819 | { | 819 | { |
820 | } | 820 | } |
821 | 821 | ||
822 | 822 | ||
823 | void OMonitoringInterface::setChannel( int c ) | 823 | void OMonitoringInterface::setChannel( int c ) |
824 | { | 824 | { |
825 | // use standard WE channel switching protocol | 825 | // use standard WE channel switching protocol |
826 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); | 826 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); |
827 | _if->_iwr.u.freq.m = c; | 827 | _if->_iwr.u.freq.m = c; |
828 | _if->_iwr.u.freq.e = 0; | 828 | _if->_iwr.u.freq.e = 0; |
829 | _if->wioctl( SIOCSIWFREQ ); | 829 | _if->wioctl( SIOCSIWFREQ ); |
830 | } | 830 | } |
831 | 831 | ||
832 | 832 | ||
833 | bool OMonitoringInterface::enabled() const | 833 | bool OMonitoringInterface::enabled() const |
834 | { | 834 | { |
835 | return _if->monitorMode(); | 835 | return _if->monitorMode(); |
836 | } | 836 | } |
837 | 837 | ||
838 | 838 | ||
839 | void OMonitoringInterface::setEnabled( bool b ) | 839 | void OMonitoringInterface::setEnabled( bool b ) |
840 | { | 840 | { |
841 | } | 841 | } |
842 | 842 | ||
843 | 843 | ||
844 | /*====================================================================================== | 844 | /*====================================================================================== |
845 | * OCiscoMonitoringInterface | 845 | * OCiscoMonitoringInterface |
846 | *======================================================================================*/ | 846 | *======================================================================================*/ |
847 | 847 | ||
848 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) | 848 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
849 | :OMonitoringInterface( iface ) | 849 | :OMonitoringInterface( iface, prismHeader ) |
850 | { | 850 | { |
851 | iface->setMonitoring( this ); | 851 | iface->setMonitoring( this ); |
852 | } | 852 | } |
853 | 853 | ||
854 | 854 | ||
855 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 855 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
856 | { | 856 | { |
857 | } | 857 | } |
858 | 858 | ||
859 | 859 | ||
860 | void OCiscoMonitoringInterface::setEnabled( bool b ) | 860 | void OCiscoMonitoringInterface::setEnabled( bool b ) |
861 | { | 861 | { |
862 | QString fname; | 862 | QString fname; |
863 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 863 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
864 | QFile f( fname ); | 864 | QFile f( fname ); |
865 | if ( !f.exists() ) return; | 865 | if ( !f.exists() ) return; |
866 | 866 | ||
867 | if ( f.open( IO_WriteOnly ) ) | 867 | if ( f.open( IO_WriteOnly ) ) |
868 | { | 868 | { |
869 | QTextStream s( &f ); | 869 | QTextStream s( &f ); |
870 | s << "Mode: r"; | 870 | s << "Mode: r"; |
871 | s << "Mode: y"; | 871 | s << "Mode: y"; |
872 | s << "XmitPower: 1"; | 872 | s << "XmitPower: 1"; |
873 | } | 873 | } |
874 | 874 | ||
875 | // flushing and closing will be done automatically when f goes out of scope | 875 | // flushing and closing will be done automatically when f goes out of scope |
876 | } | 876 | } |
877 | 877 | ||
878 | 878 | ||
879 | QString OCiscoMonitoringInterface::name() const | 879 | QString OCiscoMonitoringInterface::name() const |
880 | { | 880 | { |
881 | return "cisco"; | 881 | return "cisco"; |
882 | } | 882 | } |
883 | 883 | ||
884 | 884 | ||
885 | void OCiscoMonitoringInterface::setChannel( int ) | 885 | void OCiscoMonitoringInterface::setChannel( int ) |
886 | { | 886 | { |
887 | // cisco devices automatically switch channels when in monitor mode | 887 | // cisco devices automatically switch channels when in monitor mode |
888 | } | 888 | } |
889 | 889 | ||
890 | 890 | ||
891 | /*====================================================================================== | 891 | /*====================================================================================== |
892 | * OWlanNGMonitoringInterface | 892 | * OWlanNGMonitoringInterface |
893 | *======================================================================================*/ | 893 | *======================================================================================*/ |
894 | 894 | ||
895 | 895 | ||
896 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface ) | 896 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
897 | :OMonitoringInterface( iface ) | 897 | :OMonitoringInterface( iface, prismHeader ) |
898 | { | 898 | { |
899 | iface->setMonitoring( this ); | 899 | iface->setMonitoring( this ); |
900 | } | 900 | } |
901 | 901 | ||
902 | 902 | ||
903 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() | 903 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() |
904 | { | 904 | { |
905 | } | 905 | } |
906 | 906 | ||
907 | 907 | ||
908 | void OWlanNGMonitoringInterface::setEnabled( bool b ) | 908 | void OWlanNGMonitoringInterface::setEnabled( bool b ) |
909 | { | 909 | { |
910 | //FIXME: do nothing if its already in the same mode | 910 | //FIXME: do nothing if its already in the same mode |
911 | 911 | ||
912 | QString enable = b ? "true" : "false"; | 912 | QString enable = b ? "true" : "false"; |
913 | QString prism = _prismHeader ? "true" : "false"; | ||
913 | QString cmd; | 914 | QString cmd; |
914 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); | 915 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
916 | (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); | ||
915 | system( cmd ); | 917 | system( cmd ); |
916 | } | 918 | } |
917 | 919 | ||
918 | 920 | ||
919 | QString OWlanNGMonitoringInterface::name() const | 921 | QString OWlanNGMonitoringInterface::name() const |
920 | { | 922 | { |
921 | return "wlan-ng"; | 923 | return "wlan-ng"; |
922 | } | 924 | } |
923 | 925 | ||
924 | 926 | ||
925 | void OWlanNGMonitoringInterface::setChannel( int ) | 927 | void OWlanNGMonitoringInterface::setChannel( int ) |
926 | { | 928 | { |
927 | // wlan-ng devices automatically switch channels when in monitor mode | 929 | // wlan-ng devices automatically switch channels when in monitor mode |
928 | } | 930 | } |
929 | 931 | ||
930 | 932 | ||
931 | /*====================================================================================== | 933 | /*====================================================================================== |
932 | * OHostAPMonitoringInterface | 934 | * OHostAPMonitoringInterface |
933 | *======================================================================================*/ | 935 | *======================================================================================*/ |
934 | 936 | ||
935 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) | 937 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
936 | :OMonitoringInterface( iface ) | 938 | :OMonitoringInterface( iface, prismHeader ) |
937 | { | 939 | { |
938 | iface->setMonitoring( this ); | 940 | iface->setMonitoring( this ); |
939 | } | 941 | } |
940 | 942 | ||
941 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() | 943 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() |
942 | { | 944 | { |
943 | } | 945 | } |
944 | 946 | ||
945 | void OHostAPMonitoringInterface::setEnabled( bool b ) | 947 | void OHostAPMonitoringInterface::setEnabled( bool b ) |
946 | { | 948 | { |
947 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | 949 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 |
948 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | 950 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring |
949 | 951 | ||
950 | //TODO: check wireless extensions version on runtime and use | 952 | //TODO: check wireless extensions version on runtime and use |
951 | //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15 | 953 | //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15 |
952 | 954 | ||
955 | int monitorCode = _prismHeader ? 1 : 2; | ||
956 | |||
953 | if ( b ) | 957 | if ( b ) |
954 | { | 958 | { |
955 | _if->setPrivate( "monitor", 1, 2 ); | 959 | _if->setPrivate( "monitor", 1, monitorCode ); |
956 | } | 960 | } |
957 | else | 961 | else |
958 | { | 962 | { |
959 | _if->setPrivate( "monitor", 1, 0 ); | 963 | _if->setPrivate( "monitor", 1, 0 ); |
960 | } | 964 | } |
961 | } | 965 | } |
962 | 966 | ||
963 | 967 | ||
964 | QString OHostAPMonitoringInterface::name() const | 968 | QString OHostAPMonitoringInterface::name() const |
965 | { | 969 | { |
966 | return "hostap"; | 970 | return "hostap"; |
967 | } | 971 | } |
968 | 972 | ||
969 | 973 | ||
970 | /*====================================================================================== | 974 | /*====================================================================================== |
971 | * OOrinocoNetworkInterface | 975 | * OOrinocoNetworkInterface |
972 | *======================================================================================*/ | 976 | *======================================================================================*/ |
973 | 977 | ||
974 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) | 978 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
975 | :OMonitoringInterface( iface ) | 979 | :OMonitoringInterface( iface, prismHeader ) |
976 | { | 980 | { |
977 | iface->setMonitoring( this ); | 981 | iface->setMonitoring( this ); |
978 | } | 982 | } |
979 | 983 | ||
980 | 984 | ||
981 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() | 985 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() |
982 | { | 986 | { |
983 | } | 987 | } |
984 | 988 | ||
985 | 989 | ||
986 | void OOrinocoMonitoringInterface::setChannel( int c ) | 990 | void OOrinocoMonitoringInterface::setChannel( int c ) |
987 | { | 991 | { |
988 | _if->setPrivate( "monitor", 2, 1, c ); | 992 | int monitorCode = _prismHeader ? 1 : 2; |
993 | _if->setPrivate( "monitor", 2, monitorCode, c ); | ||
989 | } | 994 | } |
990 | 995 | ||
991 | 996 | ||
992 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 997 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
993 | { | 998 | { |
994 | if ( b ) | 999 | if ( b ) |
995 | { | 1000 | { |
996 | setChannel( 1 ); | 1001 | setChannel( 1 ); |
997 | } | 1002 | } |
998 | else | 1003 | else |
999 | { | 1004 | { |
1000 | _if->setPrivate( "monitor", 2, 0, 0 ); | 1005 | _if->setPrivate( "monitor", 2, 0, 0 ); |
1001 | } | 1006 | } |
1002 | } | 1007 | } |
1003 | 1008 | ||
1004 | 1009 | ||
1005 | QString OOrinocoMonitoringInterface::name() const | 1010 | QString OOrinocoMonitoringInterface::name() const |
1006 | { | 1011 | { |
1007 | return "orinoco"; | 1012 | return "orinoco"; |
1008 | } | 1013 | } |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 1b38d02..eb9d506 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -407,132 +407,133 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
407 | * @returns true if the interface is featuring the private IOCTL @command. | 407 | * @returns true if the interface is featuring the private IOCTL @command. |
408 | */ | 408 | */ |
409 | virtual bool hasPrivate( const QString& command ); | 409 | virtual bool hasPrivate( const QString& command ); |
410 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this | 410 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this |
411 | 411 | ||
412 | virtual bool isAssociated() const {}; //FIXME: Implement and document this | 412 | virtual bool isAssociated() const {}; //FIXME: Implement and document this |
413 | /** | 413 | /** |
414 | * @returns the MAC address of the Access Point if the | 414 | * @returns the MAC address of the Access Point if the |
415 | * device is in infrastructure mode. @returns a (more or less random) CELL | 415 | * device is in infrastructure mode. @returns a (more or less random) CELL |
416 | * address if the device is in adhoc mode. | 416 | * address if the device is in adhoc mode. |
417 | */ | 417 | */ |
418 | virtual QString associatedAP() const; | 418 | virtual QString associatedAP() const; |
419 | /** | 419 | /** |
420 | * Set the @a ssid (Service Set ID) string. This is used to decide | 420 | * Set the @a ssid (Service Set ID) string. This is used to decide |
421 | * which network to associate with (use "any" to let the driver decide). | 421 | * which network to associate with (use "any" to let the driver decide). |
422 | */ | 422 | */ |
423 | virtual void setSSID( const QString& ssid ); | 423 | virtual void setSSID( const QString& ssid ); |
424 | /** | 424 | /** |
425 | * @returns the current SSID (Service Set ID). | 425 | * @returns the current SSID (Service Set ID). |
426 | */ | 426 | */ |
427 | virtual QString SSID() const; | 427 | virtual QString SSID() const; |
428 | 428 | ||
429 | protected: | 429 | protected: |
430 | void buildChannelList(); | 430 | void buildChannelList(); |
431 | void buildPrivateList(); | 431 | void buildPrivateList(); |
432 | virtual void init(); | 432 | virtual void init(); |
433 | struct iwreq& iwr() const; | 433 | struct iwreq& iwr() const; |
434 | bool wioctl( int call ) const; | 434 | bool wioctl( int call ) const; |
435 | bool wioctl( int call, struct iwreq& ) const; | 435 | bool wioctl( int call, struct iwreq& ) const; |
436 | 436 | ||
437 | protected: | 437 | protected: |
438 | mutable struct iwreq _iwr; | 438 | mutable struct iwreq _iwr; |
439 | QMap<int,int> _channels; | 439 | QMap<int,int> _channels; |
440 | 440 | ||
441 | private: | 441 | private: |
442 | OChannelHopper* _hopper; | 442 | OChannelHopper* _hopper; |
443 | }; | 443 | }; |
444 | 444 | ||
445 | 445 | ||
446 | /*====================================================================================== | 446 | /*====================================================================================== |
447 | * OMonitoringInterface | 447 | * OMonitoringInterface |
448 | *======================================================================================*/ | 448 | *======================================================================================*/ |
449 | 449 | ||
450 | 450 | ||
451 | class OMonitoringInterface | 451 | class OMonitoringInterface |
452 | { | 452 | { |
453 | public: | 453 | public: |
454 | OMonitoringInterface(); | 454 | OMonitoringInterface(); |
455 | OMonitoringInterface( ONetworkInterface* ); | 455 | OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
456 | virtual ~OMonitoringInterface(); | 456 | virtual ~OMonitoringInterface(); |
457 | 457 | ||
458 | public: | 458 | public: |
459 | virtual void setEnabled( bool ); | 459 | virtual void setEnabled( bool ); |
460 | virtual bool enabled() const; | 460 | virtual bool enabled() const; |
461 | virtual void setChannel( int ); | 461 | virtual void setChannel( int ); |
462 | 462 | ||
463 | virtual QString name() const = 0; | 463 | virtual QString name() const = 0; |
464 | 464 | ||
465 | protected: | 465 | protected: |
466 | OWirelessNetworkInterface* _if; | 466 | OWirelessNetworkInterface* _if; |
467 | bool _prismHeader; | ||
467 | 468 | ||
468 | }; | 469 | }; |
469 | 470 | ||
470 | 471 | ||
471 | /*====================================================================================== | 472 | /*====================================================================================== |
472 | * OCiscoMonitoring | 473 | * OCiscoMonitoring |
473 | *======================================================================================*/ | 474 | *======================================================================================*/ |
474 | 475 | ||
475 | 476 | ||
476 | class OCiscoMonitoringInterface : public OMonitoringInterface | 477 | class OCiscoMonitoringInterface : public OMonitoringInterface |
477 | { | 478 | { |
478 | public: | 479 | public: |
479 | OCiscoMonitoringInterface( ONetworkInterface* ); | 480 | OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
480 | virtual ~OCiscoMonitoringInterface(); | 481 | virtual ~OCiscoMonitoringInterface(); |
481 | 482 | ||
482 | virtual void setEnabled( bool ); | 483 | virtual void setEnabled( bool ); |
483 | virtual QString name() const; | 484 | virtual QString name() const; |
484 | virtual void setChannel( int ); | 485 | virtual void setChannel( int ); |
485 | 486 | ||
486 | }; | 487 | }; |
487 | 488 | ||
488 | /*====================================================================================== | 489 | /*====================================================================================== |
489 | * OWlanNGMonitoringInterface | 490 | * OWlanNGMonitoringInterface |
490 | *======================================================================================*/ | 491 | *======================================================================================*/ |
491 | 492 | ||
492 | class OWlanNGMonitoringInterface : public OMonitoringInterface | 493 | class OWlanNGMonitoringInterface : public OMonitoringInterface |
493 | { | 494 | { |
494 | public: | 495 | public: |
495 | OWlanNGMonitoringInterface( ONetworkInterface* ); | 496 | OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
496 | virtual ~OWlanNGMonitoringInterface(); | 497 | virtual ~OWlanNGMonitoringInterface(); |
497 | 498 | ||
498 | public: | 499 | public: |
499 | virtual void setEnabled( bool ); | 500 | virtual void setEnabled( bool ); |
500 | virtual QString name() const; | 501 | virtual QString name() const; |
501 | virtual void setChannel( int ); | 502 | virtual void setChannel( int ); |
502 | 503 | ||
503 | }; | 504 | }; |
504 | 505 | ||
505 | /*====================================================================================== | 506 | /*====================================================================================== |
506 | * OHostAPMonitoringInterface | 507 | * OHostAPMonitoringInterface |
507 | *======================================================================================*/ | 508 | *======================================================================================*/ |
508 | 509 | ||
509 | class OHostAPMonitoringInterface : public OMonitoringInterface | 510 | class OHostAPMonitoringInterface : public OMonitoringInterface |
510 | { | 511 | { |
511 | public: | 512 | public: |
512 | OHostAPMonitoringInterface( ONetworkInterface* ); | 513 | OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
513 | virtual ~OHostAPMonitoringInterface(); | 514 | virtual ~OHostAPMonitoringInterface(); |
514 | 515 | ||
515 | public: | 516 | public: |
516 | virtual void setEnabled( bool ); | 517 | virtual void setEnabled( bool ); |
517 | virtual QString name() const; | 518 | virtual QString name() const; |
518 | }; | 519 | }; |
519 | 520 | ||
520 | /*====================================================================================== | 521 | /*====================================================================================== |
521 | * OOrinocoMonitoringInterface | 522 | * OOrinocoMonitoringInterface |
522 | *======================================================================================*/ | 523 | *======================================================================================*/ |
523 | 524 | ||
524 | class OOrinocoMonitoringInterface : public OMonitoringInterface | 525 | class OOrinocoMonitoringInterface : public OMonitoringInterface |
525 | { | 526 | { |
526 | public: | 527 | public: |
527 | OOrinocoMonitoringInterface( ONetworkInterface* ); | 528 | OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
528 | virtual ~OOrinocoMonitoringInterface(); | 529 | virtual ~OOrinocoMonitoringInterface(); |
529 | 530 | ||
530 | public: | 531 | public: |
531 | virtual void setChannel( int ); | 532 | virtual void setChannel( int ); |
532 | virtual void setEnabled( bool ); | 533 | virtual void setEnabled( bool ); |
533 | virtual QString name() const; | 534 | virtual QString name() const; |
534 | 535 | ||
535 | }; | 536 | }; |
536 | 537 | ||
537 | #endif // ONETWORK_H | 538 | #endif // ONETWORK_H |
538 | 539 | ||
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index e2ab6d7..f6d05ea 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -26,97 +26,97 @@ | |||
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: | 68 | case DLT_PRISM_HEADER: |
69 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" ); | 69 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" ); |
70 | new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); | 70 | new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); |
71 | break; | 71 | break; |
72 | 72 | ||
73 | default: | 73 | default: |
74 | qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink '%s'!", datalink ); | 74 | qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink ); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | OPacket::~OPacket() | 79 | OPacket::~OPacket() |
80 | { | 80 | { |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | timevalstruct OPacket::timeval() const | 84 | timevalstruct OPacket::timeval() const |
85 | { | 85 | { |
86 | return _hdr.ts; | 86 | return _hdr.ts; |
87 | } | 87 | } |
88 | 88 | ||
89 | 89 | ||
90 | int OPacket::caplen() const | 90 | int OPacket::caplen() const |
91 | { | 91 | { |
92 | return _hdr.caplen; | 92 | return _hdr.caplen; |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) | 96 | void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) |
97 | { | 97 | { |
98 | if (!l) return; | 98 | if (!l) return; |
99 | QObject* o = l->first(); | 99 | QObject* o = l->first(); |
100 | while ( o ) | 100 | while ( o ) |
101 | { | 101 | { |
102 | stats[o->name()]++; | 102 | stats[o->name()]++; |
103 | updateStats( stats, const_cast<QObjectList*>( o->children() ) ); | 103 | updateStats( stats, const_cast<QObjectList*>( o->children() ) ); |
104 | o = l->next(); | 104 | o = l->next(); |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | QString OPacket::dump( int bpl ) const | 109 | QString OPacket::dump( int bpl ) const |
110 | { | 110 | { |
111 | static int index = 0; | 111 | static int index = 0; |
112 | index++; | 112 | index++; |
113 | int len = _hdr.caplen; | 113 | int len = _hdr.caplen; |
114 | QString str; | 114 | QString str; |
115 | 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 ); |
116 | str.append( "0000: " ); | 116 | str.append( "0000: " ); |
117 | QString tmp; | 117 | QString tmp; |
118 | QString bytes; | 118 | QString bytes; |
119 | QString chars; | 119 | QString chars; |
120 | 120 | ||
121 | for ( int i = 0; i < len; ++i ) | 121 | for ( int i = 0; i < len; ++i ) |
122 | { | 122 | { |