summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetwork.cpp
Unidiff
Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 171a2bc..591681c 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -789,105 +789,105 @@ void OWirelessNetworkInterface::setNickName( const QString& nickname )
789 789
790 790
791QString OWirelessNetworkInterface::nickName() const 791QString OWirelessNetworkInterface::nickName() const
792{ 792{
793 char str[IW_ESSID_MAX_SIZE]; 793 char str[IW_ESSID_MAX_SIZE];
794 _iwr.u.data.pointer = &str[0]; 794 _iwr.u.data.pointer = &str[0];
795 _iwr.u.data.length = IW_ESSID_MAX_SIZE; 795 _iwr.u.data.length = IW_ESSID_MAX_SIZE;
796 if ( !wioctl( SIOCGIWNICKN ) ) 796 if ( !wioctl( SIOCGIWNICKN ) )
797 { 797 {
798 return "<unknown>"; 798 return "<unknown>";
799 } 799 }
800 else 800 else
801 { 801 {
802 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string 802 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string
803 return str; 803 return str;
804 } 804 }
805} 805}
806 806
807 807
808void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) 808void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... )
809{ 809{
810 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); 810 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) );
811 if ( !priv ) 811 if ( !priv )
812 { 812 {
813 owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() 813 owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name()
814 << "' does not support private ioctl '" << call << "'" << oendl; 814 << "' does not support private ioctl '" << call << "'" << oendl;
815 return; 815 return;
816 } 816 }
817 if ( priv->numberSetArgs() != numargs ) 817 if ( priv->numberSetArgs() != numargs )
818 { 818 {
819 owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" 819 owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '"
820 << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; 820 << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl;
821 return; 821 return;
822 } 822 }
823 823
824 odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; 824 odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl;
825 memset( &_iwr, 0, sizeof _iwr ); 825 memset( &_iwr, 0, sizeof _iwr );
826 va_list argp; 826 va_list argp;
827 va_start( argp, numargs ); 827 va_start( argp, numargs );
828 for ( int i = 0; i < numargs; ++i ) 828 for ( int i = 0; i < numargs; ++i )
829 { 829 {
830 priv->setParameter( i, va_arg( argp, int ) ); 830 priv->setParameter( i, va_arg( argp, int ) );
831 } 831 }
832 va_end( argp ); 832 va_end( argp );
833 priv->invoke(); 833 priv->invoke();
834} 834}
835 835
836 836
837void OWirelessNetworkInterface::getPrivate( const QString& call ) 837void OWirelessNetworkInterface::getPrivate( const QString& )
838{ 838{
839 oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; 839 oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl;
840} 840}
841 841
842 842
843bool OWirelessNetworkInterface::hasPrivate( const QString& call ) 843bool OWirelessNetworkInterface::hasPrivate( const QString& call )
844{ 844{
845 return child( (const char*) call ); 845 return child( call.local8Bit() );
846} 846}
847 847
848 848
849QString OWirelessNetworkInterface::SSID() const 849QString OWirelessNetworkInterface::SSID() const
850{ 850{
851 char str[IW_ESSID_MAX_SIZE]; 851 char str[IW_ESSID_MAX_SIZE];
852 _iwr.u.essid.pointer = &str[0]; 852 _iwr.u.essid.pointer = &str[0];
853 _iwr.u.essid.length = IW_ESSID_MAX_SIZE; 853 _iwr.u.essid.length = IW_ESSID_MAX_SIZE;
854 if ( !wioctl( SIOCGIWESSID ) ) 854 if ( !wioctl( SIOCGIWESSID ) )
855 { 855 {
856 return "<unknown>"; 856 return "<unknown>";
857 } 857 }
858 else 858 else
859 { 859 {
860 return str; 860 return str;
861 } 861 }
862} 862}
863 863
864 864
865void OWirelessNetworkInterface::setSSID( const QString& ssid ) 865void OWirelessNetworkInterface::setSSID( const QString& ssid )
866{ 866{
867 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); 867 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid );
868 _iwr.u.essid.length = ssid.length(); 868 _iwr.u.essid.length = ssid.length();
869 wioctl( SIOCSIWESSID ); 869 wioctl( SIOCSIWESSID );
870} 870}
871 871
872 872
873OStationList* OWirelessNetworkInterface::scanNetwork() 873OStationList* OWirelessNetworkInterface::scanNetwork()
874{ 874{
875 _iwr.u.param.flags = IW_SCAN_DEFAULT; 875 _iwr.u.param.flags = IW_SCAN_DEFAULT;
876 _iwr.u.param.value = 0; 876 _iwr.u.param.value = 0;
877 if ( !wioctl( SIOCSIWSCAN ) ) 877 if ( !wioctl( SIOCSIWSCAN ) )
878 { 878 {
879 return 0; 879 return 0;
880 } 880 }
881 881
882 OStationList* stations = new OStationList(); 882 OStationList* stations = new OStationList();
883 883
884 int timeout = 1000000; 884 int timeout = 1000000;
885 885
886 odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; 886 odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl;
887 887
888 bool results = false; 888 bool results = false;
889 struct timeval tv; 889 struct timeval tv;
890 tv.tv_sec = 0; 890 tv.tv_sec = 0;
891 tv.tv_usec = 250000; // initial timeout ~ 250ms 891 tv.tv_usec = 250000; // initial timeout ~ 250ms
892 char buffer[IW_SCAN_MAX_DATA]; 892 char buffer[IW_SCAN_MAX_DATA];
893 893
@@ -967,177 +967,177 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
967 } 967 }
968 case SIOCGIWESSID: 968 case SIOCGIWESSID:
969 { 969 {
970 odebug << "SIOCGIWESSID" << oendl; 970 odebug << "SIOCGIWESSID" << oendl;
971 stations->last()->ssid = static_cast<const char*>( we->u.essid.pointer ); 971 stations->last()->ssid = static_cast<const char*>( we->u.essid.pointer );
972 break; 972 break;
973 } 973 }
974 case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; 974 case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break;
975 case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break; 975 case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break;
976 case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ 976 case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */
977 case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */ 977 case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */
978 case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ 978 case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */
979 case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ 979 case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */
980 case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ 980 case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */
981 default: odebug << "unhandled event" << oendl; 981 default: odebug << "unhandled event" << oendl;
982 } 982 }
983 983
984 offset += we->len; 984 offset += we->len;
985 we = (struct iw_event*) &buffer[offset]; 985 we = (struct iw_event*) &buffer[offset];
986 } 986 }
987 return stations; 987 return stations;
988 988
989 return stations; 989 return stations;
990 990
991 } 991 }
992 else 992 else
993 { 993 {
994 odebug << " - no results (timeout) :(" << oendl; 994 odebug << " - no results (timeout) :(" << oendl;
995 return stations; 995 return stations;
996 } 996 }
997} 997}
998 998
999 999
1000int OWirelessNetworkInterface::signalStrength() const 1000int OWirelessNetworkInterface::signalStrength() const
1001{ 1001{
1002 iw_statistics stat; 1002 iw_statistics stat;
1003 ::memset( &stat, 0, sizeof stat ); 1003 ::memset( &stat, 0, sizeof stat );
1004 _iwr.u.data.pointer = (char*) &stat; 1004 _iwr.u.data.pointer = (char*) &stat;
1005 _iwr.u.data.flags = 0; 1005 _iwr.u.data.flags = 0;
1006 _iwr.u.data.length = sizeof stat; 1006 _iwr.u.data.length = sizeof stat;
1007 1007
1008 if ( !wioctl( SIOCGIWSTATS ) ) 1008 if ( !wioctl( SIOCGIWSTATS ) )
1009 { 1009 {
1010 return -1; 1010 return -1;
1011 } 1011 }
1012 1012
1013 int max = _range.max_qual.qual; 1013 int max = _range.max_qual.qual;
1014 int cur = stat.qual.qual; 1014 int cur = stat.qual.qual;
1015 int lev = stat.qual.level; //FIXME: Do something with them? 1015// int lev = stat.qual.level; //FIXME: Do something with them?
1016 int noi = stat.qual.noise; //FIXME: Do something with them? 1016// int noi = stat.qual.noise; //FIXME: Do something with them?
1017 1017
1018 1018
1019 return max != 0 ? cur*100/max: -1; 1019 return max != 0 ? cur*100/max: -1;
1020} 1020}
1021 1021
1022 1022
1023bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const 1023bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
1024{ 1024{
1025 #ifndef NODEBUG 1025 #ifndef NODEBUG
1026 int result = ::ioctl( _sfd, call, &iwreq ); 1026 int result = ::ioctl( _sfd, call, &iwreq );
1027 1027
1028 if ( result == -1 ) 1028 if ( result == -1 )
1029 odebug << "ONetworkInterface::wioctl (" << name() << ") call '" 1029 odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
1030 << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; 1030 << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
1031 else 1031 else
1032 odebug << "ONetworkInterface::wioctl (" << name() << ") call '" 1032 odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
1033 << debugmapper->map( call ) << "' - Status: Ok." << oendl; 1033 << debugmapper->map( call ) << "' - Status: Ok." << oendl;
1034 1034
1035 return ( result != -1 ); 1035 return ( result != -1 );
1036 #else 1036 #else
1037 return ::ioctl( _sfd, call, &iwreq ) != -1; 1037 return ::ioctl( _sfd, call, &iwreq ) != -1;
1038 #endif 1038 #endif
1039} 1039}
1040 1040
1041 1041
1042bool OWirelessNetworkInterface::wioctl( int call ) const 1042bool OWirelessNetworkInterface::wioctl( int call ) const
1043{ 1043{
1044 strcpy( _iwr.ifr_name, name() ); 1044 strcpy( _iwr.ifr_name, name() );
1045 return wioctl( call, _iwr ); 1045 return wioctl( call, _iwr );
1046} 1046}
1047 1047
1048 1048
1049/*====================================================================================== 1049/*======================================================================================
1050 * OMonitoringInterface 1050 * OMonitoringInterface
1051 *======================================================================================*/ 1051 *======================================================================================*/
1052 1052
1053OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1053OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1054 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) 1054 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader )
1055{ 1055{
1056} 1056}
1057 1057
1058 1058
1059OMonitoringInterface::~OMonitoringInterface() 1059OMonitoringInterface::~OMonitoringInterface()
1060{ 1060{
1061} 1061}
1062 1062
1063 1063
1064void OMonitoringInterface::setChannel( int c ) 1064void OMonitoringInterface::setChannel( int c )
1065{ 1065{
1066 // use standard WE channel switching protocol 1066 // use standard WE channel switching protocol
1067 memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); 1067 memset( &_if->_iwr, 0, sizeof( struct iwreq ) );
1068 _if->_iwr.u.freq.m = c; 1068 _if->_iwr.u.freq.m = c;
1069 _if->_iwr.u.freq.e = 0; 1069 _if->_iwr.u.freq.e = 0;
1070 _if->wioctl( SIOCSIWFREQ ); 1070 _if->wioctl( SIOCSIWFREQ );
1071} 1071}
1072 1072
1073 1073
1074void OMonitoringInterface::setEnabled( bool b ) 1074void OMonitoringInterface::setEnabled( bool )
1075{ 1075{
1076} 1076}
1077 1077
1078 1078
1079/*====================================================================================== 1079/*======================================================================================
1080 * OCiscoMonitoringInterface 1080 * OCiscoMonitoringInterface
1081 *======================================================================================*/ 1081 *======================================================================================*/
1082 1082
1083OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1083OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1084 :OMonitoringInterface( iface, prismHeader ) 1084 :OMonitoringInterface( iface, prismHeader )
1085{ 1085{
1086 iface->setMonitoring( this ); 1086 iface->setMonitoring( this );
1087} 1087}
1088 1088
1089 1089
1090OCiscoMonitoringInterface::~OCiscoMonitoringInterface() 1090OCiscoMonitoringInterface::~OCiscoMonitoringInterface()
1091{ 1091{
1092} 1092}
1093 1093
1094 1094
1095void OCiscoMonitoringInterface::setEnabled( bool b ) 1095void OCiscoMonitoringInterface::setEnabled( bool /*b*/ )
1096{ 1096{
1097 QString fname; 1097 QString fname;
1098 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); 1098 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() );
1099 QFile f( fname ); 1099 QFile f( fname );
1100 if ( !f.exists() ) return; 1100 if ( !f.exists() ) return;
1101 1101
1102 if ( f.open( IO_WriteOnly ) ) 1102 if ( f.open( IO_WriteOnly ) )
1103 { 1103 {
1104 QTextStream s( &f ); 1104 QTextStream s( &f );
1105 s << "Mode: r"; 1105 s << "Mode: r";
1106 s << "Mode: y"; 1106 s << "Mode: y";
1107 s << "XmitPower: 1"; 1107 s << "XmitPower: 1";
1108 } 1108 }
1109 1109
1110 // flushing and closing will be done automatically when f goes out of scope 1110 // flushing and closing will be done automatically when f goes out of scope
1111} 1111}
1112 1112
1113 1113
1114QString OCiscoMonitoringInterface::name() const 1114QString OCiscoMonitoringInterface::name() const
1115{ 1115{
1116 return "cisco"; 1116 return "cisco";
1117} 1117}
1118 1118
1119 1119
1120void OCiscoMonitoringInterface::setChannel( int ) 1120void OCiscoMonitoringInterface::setChannel( int )
1121{ 1121{
1122 // cisco devices automatically switch channels when in monitor mode 1122 // cisco devices automatically switch channels when in monitor mode
1123} 1123}
1124 1124
1125 1125
1126/*====================================================================================== 1126/*======================================================================================
1127 * OWlanNGMonitoringInterface 1127 * OWlanNGMonitoringInterface
1128 *======================================================================================*/ 1128 *======================================================================================*/
1129 1129
1130 1130
1131OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1131OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1132 :OMonitoringInterface( iface, prismHeader ) 1132 :OMonitoringInterface( iface, prismHeader )
1133{ 1133{
1134 iface->setMonitoring( this ); 1134 iface->setMonitoring( this );
1135} 1135}
1136 1136
1137 1137
1138OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() 1138OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface()
1139{ 1139{
1140} 1140}
1141 1141
1142 1142
1143void OWlanNGMonitoringInterface::setEnabled( bool b ) 1143void OWlanNGMonitoringInterface::setEnabled( bool b )