-rw-r--r-- | libopie2/opienet/onetwork.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 36f409b..915814d 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -816,410 +816,413 @@ void OWirelessNetworkInterface::getPrivate( const QString& call ) | |||
816 | 816 | ||
817 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | 817 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) |
818 | { | 818 | { |
819 | return child( (const char*) call ); | 819 | return child( (const char*) call ); |
820 | } | 820 | } |
821 | 821 | ||
822 | 822 | ||
823 | QString OWirelessNetworkInterface::SSID() const | 823 | QString OWirelessNetworkInterface::SSID() const |
824 | { | 824 | { |
825 | char str[IW_ESSID_MAX_SIZE]; | 825 | char str[IW_ESSID_MAX_SIZE]; |
826 | _iwr.u.essid.pointer = &str[0]; | 826 | _iwr.u.essid.pointer = &str[0]; |
827 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 827 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
828 | if ( !wioctl( SIOCGIWESSID ) ) | 828 | if ( !wioctl( SIOCGIWESSID ) ) |
829 | { | 829 | { |
830 | return "<unknown>"; | 830 | return "<unknown>"; |
831 | } | 831 | } |
832 | else | 832 | else |
833 | { | 833 | { |
834 | return str; | 834 | return str; |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | 838 | ||
839 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 839 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
840 | { | 840 | { |
841 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 841 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
842 | _iwr.u.essid.length = ssid.length(); | 842 | _iwr.u.essid.length = ssid.length(); |
843 | wioctl( SIOCSIWESSID ); | 843 | wioctl( SIOCSIWESSID ); |
844 | } | 844 | } |
845 | 845 | ||
846 | 846 | ||
847 | OStationList* OWirelessNetworkInterface::scanNetwork() | 847 | OStationList* OWirelessNetworkInterface::scanNetwork() |
848 | { | 848 | { |
849 | _iwr.u.param.flags = IW_SCAN_DEFAULT; | 849 | _iwr.u.param.flags = IW_SCAN_DEFAULT; |
850 | _iwr.u.param.value = 0; | 850 | _iwr.u.param.value = 0; |
851 | if ( !wioctl( SIOCSIWSCAN ) ) | 851 | if ( !wioctl( SIOCSIWSCAN ) ) |
852 | { | 852 | { |
853 | return 0; | 853 | return 0; |
854 | } | 854 | } |
855 | 855 | ||
856 | OStationList* stations = new OStationList(); | 856 | OStationList* stations = new OStationList(); |
857 | 857 | ||
858 | int timeout = 1000000; | 858 | int timeout = 1000000; |
859 | 859 | ||
860 | odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; | 860 | odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; |
861 | 861 | ||
862 | bool results = false; | 862 | bool results = false; |
863 | struct timeval tv; | 863 | struct timeval tv; |
864 | tv.tv_sec = 0; | 864 | tv.tv_sec = 0; |
865 | tv.tv_usec = 250000; // initial timeout ~ 250ms | 865 | tv.tv_usec = 250000; // initial timeout ~ 250ms |
866 | char buffer[IW_SCAN_MAX_DATA]; | 866 | char buffer[IW_SCAN_MAX_DATA]; |
867 | 867 | ||
868 | while ( !results && timeout > 0 ) | 868 | while ( !results && timeout > 0 ) |
869 | { | 869 | { |
870 | timeout -= tv.tv_usec; | 870 | timeout -= tv.tv_usec; |
871 | select( 0, 0, 0, 0, &tv ); | 871 | select( 0, 0, 0, 0, &tv ); |
872 | 872 | ||
873 | _iwr.u.data.pointer = &buffer[0]; | 873 | _iwr.u.data.pointer = &buffer[0]; |
874 | _iwr.u.data.flags = 0; | 874 | _iwr.u.data.flags = 0; |
875 | _iwr.u.data.length = sizeof buffer; | 875 | _iwr.u.data.length = sizeof buffer; |
876 | if ( wioctl( SIOCGIWSCAN ) ) | 876 | if ( wioctl( SIOCGIWSCAN ) ) |
877 | { | 877 | { |
878 | results = true; | 878 | results = true; |
879 | continue; | 879 | continue; |
880 | } | 880 | } |
881 | else if ( errno == EAGAIN) | 881 | else if ( errno == EAGAIN) |
882 | { | 882 | { |
883 | odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; | 883 | odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; |
884 | #if 0 | 884 | #if 0 |
885 | if ( qApp ) | 885 | if ( qApp ) |
886 | { | 886 | { |
887 | qApp->processEvents( 100 ); | 887 | qApp->processEvents( 100 ); |
888 | continue; | 888 | continue; |
889 | } | 889 | } |
890 | #endif | 890 | #endif |
891 | tv.tv_sec = 0; | 891 | tv.tv_sec = 0; |
892 | tv.tv_usec = 100000; | 892 | tv.tv_usec = 100000; |
893 | continue; | 893 | continue; |
894 | } | 894 | } |
895 | } | 895 | } |
896 | 896 | ||
897 | odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; | 897 | odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; |
898 | 898 | ||
899 | if ( results ) | 899 | if ( results ) |
900 | { | 900 | { |
901 | odebug << " - result length = " << _iwr.u.data.length << oendl; | 901 | odebug << " - result length = " << _iwr.u.data.length << oendl; |
902 | if ( !_iwr.u.data.length ) | 902 | if ( !_iwr.u.data.length ) |
903 | { | 903 | { |
904 | odebug << " - no results (empty neighbourhood)" << oendl; | 904 | odebug << " - no results (empty neighbourhood)" << oendl; |
905 | return stations; | 905 | return stations; |
906 | } | 906 | } |
907 | 907 | ||
908 | odebug << " - results are in!" << oendl; | 908 | odebug << " - results are in!" << oendl; |
909 | dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); | 909 | dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); |
910 | 910 | ||
911 | // parse results | 911 | // parse results |
912 | 912 | ||
913 | int offset = 0; | 913 | int offset = 0; |
914 | struct iw_event* we = (struct iw_event*) &buffer[0]; | 914 | struct iw_event* we = (struct iw_event*) &buffer[0]; |
915 | 915 | ||
916 | while ( offset < _iwr.u.data.length ) | 916 | while ( offset < _iwr.u.data.length ) |
917 | { | 917 | { |
918 | //const char* cmd = *(*_ioctlmap)[we->cmd]; | 918 | //const char* cmd = *(*_ioctlmap)[we->cmd]; |
919 | //if ( !cmd ) cmd = "<unknown>"; | 919 | //if ( !cmd ) cmd = "<unknown>"; |
920 | odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; | 920 | odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; |
921 | switch (we->cmd) | 921 | switch (we->cmd) |
922 | { | 922 | { |
923 | case SIOCGIWAP: | 923 | case SIOCGIWAP: |
924 | { | 924 | { |
925 | odebug << "SIOCGIWAP" << oendl; | 925 | odebug << "SIOCGIWAP" << oendl; |
926 | stations->append( new OStation() ); | 926 | stations->append( new OStation() ); |
927 | stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; | 927 | stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; |
928 | break; | 928 | break; |
929 | } | 929 | } |
930 | case SIOCGIWMODE: | 930 | case SIOCGIWMODE: |
931 | { | 931 | { |
932 | odebug << "SIOCGIWMODE" << oendl; | 932 | odebug << "SIOCGIWMODE" << oendl; |
933 | stations->last()->type = modeToString( we->u.mode ); | 933 | stations->last()->type = modeToString( we->u.mode ); |
934 | break; | 934 | break; |
935 | } | 935 | } |
936 | case SIOCGIWFREQ: | 936 | case SIOCGIWFREQ: |
937 | { | 937 | { |
938 | odebug << "SIOCGIWFREQ" << oendl; | 938 | odebug << "SIOCGIWFREQ" << oendl; |
939 | stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; | 939 | stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; |
940 | break; | 940 | break; |
941 | } | 941 | } |
942 | case SIOCGIWESSID: | 942 | case SIOCGIWESSID: |
943 | { | 943 | { |
944 | odebug << "SIOCGIWESSID" << oendl; | 944 | odebug << "SIOCGIWESSID" << oendl; |
945 | stations->last()->ssid = we->u.essid.pointer; | 945 | stations->last()->ssid = we->u.essid.pointer; |
946 | break; | 946 | break; |
947 | } | 947 | } |
948 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; | 948 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; |
949 | case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break; | 949 | case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break; |
950 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ | 950 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ |
951 | case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */ | 951 | case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */ |
952 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ | 952 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ |
953 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ | 953 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ |
954 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ | 954 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ |
955 | default: odebug << "unhandled event" << oendl; | 955 | default: odebug << "unhandled event" << oendl; |
956 | } | 956 | } |
957 | 957 | ||
958 | offset += we->len; | 958 | offset += we->len; |
959 | we = (struct iw_event*) &buffer[offset]; | 959 | we = (struct iw_event*) &buffer[offset]; |
960 | } | 960 | } |
961 | return stations; | 961 | return stations; |
962 | 962 | ||
963 | return stations; | 963 | return stations; |
964 | 964 | ||
965 | } | 965 | } |
966 | else | 966 | else |
967 | { | 967 | { |
968 | odebug << " - no results (timeout) :(" << oendl; | 968 | odebug << " - no results (timeout) :(" << oendl; |
969 | return stations; | 969 | return stations; |
970 | } | 970 | } |
971 | } | 971 | } |
972 | 972 | ||
973 | 973 | ||
974 | int OWirelessNetworkInterface::signalStrength() const | 974 | int OWirelessNetworkInterface::signalStrength() const |
975 | { | 975 | { |
976 | iw_statistics stat; | 976 | iw_statistics stat; |
977 | ::memset( &stat, 0, sizeof stat ); | 977 | ::memset( &stat, 0, sizeof stat ); |
978 | _iwr.u.data.pointer = (char*) &stat; | 978 | _iwr.u.data.pointer = (char*) &stat; |
979 | _iwr.u.data.flags = 0; | 979 | _iwr.u.data.flags = 0; |
980 | _iwr.u.data.length = sizeof stat; | 980 | _iwr.u.data.length = sizeof stat; |
981 | 981 | ||
982 | if ( !wioctl( SIOCGIWSTATS ) ) | 982 | if ( !wioctl( SIOCGIWSTATS ) ) |
983 | { | 983 | { |
984 | return -1; | 984 | return -1; |
985 | } | 985 | } |
986 | 986 | ||
987 | int max = _range.max_qual.qual; | 987 | int max = _range.max_qual.qual; |
988 | int cur = stat.qual.qual; | 988 | int cur = stat.qual.qual; |
989 | int lev = stat.qual.level; //FIXME: Do something with them? | 989 | int lev = stat.qual.level; //FIXME: Do something with them? |
990 | int noi = stat.qual.noise; //FIXME: Do something with them? | 990 | int noi = stat.qual.noise; //FIXME: Do something with them? |
991 | 991 | ||
992 | return cur*100/max; | 992 | return cur*100/max; |
993 | } | 993 | } |
994 | 994 | ||
995 | 995 | ||
996 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 996 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
997 | { | 997 | { |
998 | #ifndef NODEBUG | 998 | #ifndef NODEBUG |
999 | int result = ::ioctl( _sfd, call, &iwreq ); | 999 | int result = ::ioctl( _sfd, call, &iwreq ); |
1000 | 1000 | ||
1001 | if ( result == -1 ) | 1001 | if ( result == -1 ) |
1002 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" | 1002 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" |
1003 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; | 1003 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; |
1004 | else | 1004 | else |
1005 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" | 1005 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" |
1006 | << debugmapper->map( call ) << "' - Status: Ok." << oendl; | 1006 | << debugmapper->map( call ) << "' - Status: Ok." << oendl; |
1007 | 1007 | ||
1008 | return ( result != -1 ); | 1008 | return ( result != -1 ); |
1009 | #else | 1009 | #else |
1010 | return ::ioctl( _sfd, call, &iwreq ) != -1; | 1010 | return ::ioctl( _sfd, call, &iwreq ) != -1; |
1011 | #endif | 1011 | #endif |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | 1014 | ||
1015 | bool OWirelessNetworkInterface::wioctl( int call ) const | 1015 | bool OWirelessNetworkInterface::wioctl( int call ) const |
1016 | { | 1016 | { |
1017 | strcpy( _iwr.ifr_name, name() ); | 1017 | strcpy( _iwr.ifr_name, name() ); |
1018 | return wioctl( call, _iwr ); | 1018 | return wioctl( call, _iwr ); |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | 1021 | ||
1022 | /*====================================================================================== | 1022 | /*====================================================================================== |
1023 | * OMonitoringInterface | 1023 | * OMonitoringInterface |
1024 | *======================================================================================*/ | 1024 | *======================================================================================*/ |
1025 | 1025 | ||
1026 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1026 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1027 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) | 1027 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) |
1028 | { | 1028 | { |
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | 1031 | ||
1032 | OMonitoringInterface::~OMonitoringInterface() | 1032 | OMonitoringInterface::~OMonitoringInterface() |
1033 | { | 1033 | { |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | 1036 | ||
1037 | void OMonitoringInterface::setChannel( int c ) | 1037 | void OMonitoringInterface::setChannel( int c ) |
1038 | { | 1038 | { |
1039 | // use standard WE channel switching protocol | 1039 | // use standard WE channel switching protocol |
1040 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); | 1040 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); |
1041 | _if->_iwr.u.freq.m = c; | 1041 | _if->_iwr.u.freq.m = c; |
1042 | _if->_iwr.u.freq.e = 0; | 1042 | _if->_iwr.u.freq.e = 0; |
1043 | _if->wioctl( SIOCSIWFREQ ); | 1043 | _if->wioctl( SIOCSIWFREQ ); |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | 1046 | ||
1047 | void OMonitoringInterface::setEnabled( bool b ) | 1047 | void OMonitoringInterface::setEnabled( bool b ) |
1048 | { | 1048 | { |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | 1051 | ||
1052 | /*====================================================================================== | 1052 | /*====================================================================================== |
1053 | * OCiscoMonitoringInterface | 1053 | * OCiscoMonitoringInterface |
1054 | *======================================================================================*/ | 1054 | *======================================================================================*/ |
1055 | 1055 | ||
1056 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1056 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1057 | :OMonitoringInterface( iface, prismHeader ) | 1057 | :OMonitoringInterface( iface, prismHeader ) |
1058 | { | 1058 | { |
1059 | iface->setMonitoring( this ); | 1059 | iface->setMonitoring( this ); |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | 1062 | ||
1063 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 1063 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
1064 | { | 1064 | { |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | 1067 | ||
1068 | void OCiscoMonitoringInterface::setEnabled( bool b ) | 1068 | void OCiscoMonitoringInterface::setEnabled( bool b ) |
1069 | { | 1069 | { |
1070 | QString fname; | 1070 | QString fname; |
1071 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 1071 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
1072 | QFile f( fname ); | 1072 | QFile f( fname ); |
1073 | if ( !f.exists() ) return; | 1073 | if ( !f.exists() ) return; |
1074 | 1074 | ||
1075 | if ( f.open( IO_WriteOnly ) ) | 1075 | if ( f.open( IO_WriteOnly ) ) |
1076 | { | 1076 | { |
1077 | QTextStream s( &f ); | 1077 | QTextStream s( &f ); |
1078 | s << "Mode: r"; | 1078 | s << "Mode: r"; |
1079 | s << "Mode: y"; | 1079 | s << "Mode: y"; |
1080 | s << "XmitPower: 1"; | 1080 | s << "XmitPower: 1"; |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | // flushing and closing will be done automatically when f goes out of scope | 1083 | // flushing and closing will be done automatically when f goes out of scope |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | 1086 | ||
1087 | QString OCiscoMonitoringInterface::name() const | 1087 | QString OCiscoMonitoringInterface::name() const |
1088 | { | 1088 | { |
1089 | return "cisco"; | 1089 | return "cisco"; |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | 1092 | ||
1093 | void OCiscoMonitoringInterface::setChannel( int ) | 1093 | void OCiscoMonitoringInterface::setChannel( int ) |
1094 | { | 1094 | { |
1095 | // cisco devices automatically switch channels when in monitor mode | 1095 | // cisco devices automatically switch channels when in monitor mode |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | 1098 | ||
1099 | /*====================================================================================== | 1099 | /*====================================================================================== |
1100 | * OWlanNGMonitoringInterface | 1100 | * OWlanNGMonitoringInterface |
1101 | *======================================================================================*/ | 1101 | *======================================================================================*/ |
1102 | 1102 | ||
1103 | 1103 | ||
1104 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1104 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1105 | :OMonitoringInterface( iface, prismHeader ) | 1105 | :OMonitoringInterface( iface, prismHeader ) |
1106 | { | 1106 | { |
1107 | iface->setMonitoring( this ); | 1107 | iface->setMonitoring( this ); |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | 1110 | ||
1111 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() | 1111 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() |
1112 | { | 1112 | { |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | 1115 | ||
1116 | void OWlanNGMonitoringInterface::setEnabled( bool b ) | 1116 | void OWlanNGMonitoringInterface::setEnabled( bool b ) |
1117 | { | 1117 | { |
1118 | //FIXME: do nothing if its already in the same mode | 1118 | //FIXME: do nothing if its already in the same mode |
1119 | 1119 | ||
1120 | QString enable = b ? "true" : "false"; | 1120 | QString enable = b ? "true" : "false"; |
1121 | QString prism = _prismHeader ? "true" : "false"; | 1121 | QString prism = _prismHeader ? "true" : "false"; |
1122 | QString cmd; | 1122 | QString cmd; |
1123 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", | 1123 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
1124 | (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); | 1124 | (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); |
1125 | system( cmd ); | 1125 | system( cmd ); |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | 1128 | ||
1129 | QString OWlanNGMonitoringInterface::name() const | 1129 | QString OWlanNGMonitoringInterface::name() const |
1130 | { | 1130 | { |
1131 | return "wlan-ng"; | 1131 | return "wlan-ng"; |
1132 | } | 1132 | } |
1133 | 1133 | ||
1134 | 1134 | ||
1135 | void OWlanNGMonitoringInterface::setChannel( int c ) | 1135 | void OWlanNGMonitoringInterface::setChannel( int c ) |
1136 | { | 1136 | { |
1137 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. | 1137 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. |
1138 | 1138 | ||
1139 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; | 1139 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; |
1140 | QString prism = _prismHeader ? "true" : "false"; | 1140 | QString prism = _prismHeader ? "true" : "false"; |
1141 | QString cmd; | 1141 | QString cmd; |
1142 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", | 1142 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
1143 | (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); | 1143 | (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); |
1144 | system( cmd ); | 1144 | system( cmd ); |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | 1147 | ||
1148 | /*====================================================================================== | 1148 | /*====================================================================================== |
1149 | * OHostAPMonitoringInterface | 1149 | * OHostAPMonitoringInterface |
1150 | *======================================================================================*/ | 1150 | *======================================================================================*/ |
1151 | 1151 | ||
1152 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1152 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1153 | :OMonitoringInterface( iface, prismHeader ) | 1153 | :OMonitoringInterface( iface, prismHeader ) |
1154 | { | 1154 | { |
1155 | iface->setMonitoring( this ); | 1155 | iface->setMonitoring( this ); |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() | 1158 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() |
1159 | { | 1159 | { |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | void OHostAPMonitoringInterface::setEnabled( bool b ) | 1162 | void OHostAPMonitoringInterface::setEnabled( bool b ) |
1163 | { | 1163 | { |
1164 | int monitorCode = _prismHeader ? 1 : 2; | 1164 | int monitorCode = _prismHeader ? 1 : 2; |
1165 | if ( b ) | 1165 | if ( b ) |
1166 | { | 1166 | { |
1167 | _if->setPrivate( "monitor", 1, monitorCode ); | 1167 | _if->setPrivate( "monitor", 1, monitorCode ); |
1168 | } | 1168 | } |
1169 | else | 1169 | else |
1170 | { | 1170 | { |
1171 | _if->setPrivate( "monitor", 1, 0 ); | 1171 | _if->setPrivate( "monitor", 1, 0 ); |
1172 | } | 1172 | } |
1173 | } | 1173 | } |
1174 | 1174 | ||
1175 | 1175 | ||
1176 | QString OHostAPMonitoringInterface::name() const | 1176 | QString OHostAPMonitoringInterface::name() const |
1177 | { | 1177 | { |
1178 | return "hostap"; | 1178 | return "hostap"; |
1179 | } | 1179 | } |
1180 | 1180 | ||
1181 | 1181 | ||
1182 | /*====================================================================================== | 1182 | /*====================================================================================== |
1183 | * OOrinocoNetworkInterface | 1183 | * OOrinocoNetworkInterface |
1184 | *======================================================================================*/ | 1184 | *======================================================================================*/ |
1185 | 1185 | ||
1186 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1186 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1187 | :OMonitoringInterface( iface, prismHeader ) | 1187 | :OMonitoringInterface( iface, prismHeader ) |
1188 | { | 1188 | { |
1189 | iface->setMonitoring( this ); | 1189 | iface->setMonitoring( this ); |
1190 | } | 1190 | } |
1191 | 1191 | ||
1192 | 1192 | ||
1193 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() | 1193 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() |
1194 | { | 1194 | { |
1195 | } | 1195 | } |
1196 | 1196 | ||
1197 | 1197 | ||
1198 | void OOrinocoMonitoringInterface::setChannel( int c ) | 1198 | void OOrinocoMonitoringInterface::setChannel( int c ) |
1199 | { | 1199 | { |
1200 | int monitorCode = _prismHeader ? 1 : 2; | 1200 | if ( !_if->hasPrivate( "monitor" ) ) |
1201 | _if->setPrivate( "monitor", 2, monitorCode, c ); | 1201 | { |
1202 | this->OMonitoringInterface::setChannel( c ); | ||
1203 | } | ||
1204 | else | ||
1205 | { | ||
1206 | int monitorCode = _prismHeader ? 1 : 2; | ||
1207 | _if->setPrivate( "monitor", 2, monitorCode, c ); | ||
1208 | } | ||
1202 | } | 1209 | } |
1203 | 1210 | ||
1204 | 1211 | ||
1205 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 1212 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
1206 | { | 1213 | { |
1207 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | ||
1208 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | ||
1209 | // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported | ||
1210 | |||
1211 | if ( b ) | 1214 | if ( b ) |
1212 | { | 1215 | { |
1213 | setChannel( 1 ); | 1216 | setChannel( 1 ); |
1214 | } | 1217 | } |
1215 | else | 1218 | else |
1216 | { | 1219 | { |
1217 | _if->setPrivate( "monitor", 2, 0, 0 ); | 1220 | _if->setPrivate( "monitor", 2, 0, 0 ); |
1218 | } | 1221 | } |
1219 | } | 1222 | } |
1220 | 1223 | ||
1221 | 1224 | ||
1222 | QString OOrinocoMonitoringInterface::name() const | 1225 | QString OOrinocoMonitoringInterface::name() const |
1223 | { | 1226 | { |
1224 | return "orinoco"; | 1227 | return "orinoco"; |
1225 | } | 1228 | } |