-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.cpp | 3 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.cpp | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp index 16654bb..827d075 100644 --- a/noncore/net/networksetup/wlan/wextensions.cpp +++ b/noncore/net/networksetup/wlan/wextensions.cpp | |||
@@ -71,64 +71,67 @@ QString WExtensions::essid(){ | |||
71 | /** | 71 | /** |
72 | * @return QString the mode of interface | 72 | * @return QString the mode of interface |
73 | */ | 73 | */ |
74 | QString WExtensions::mode(){ | 74 | QString WExtensions::mode(){ |
75 | if(!hasWirelessExtensions) | 75 | if(!hasWirelessExtensions) |
76 | return QString(); | 76 | return QString(); |
77 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) | 77 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) |
78 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); | 78 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); |
79 | return QString(); | 79 | return QString(); |
80 | } | 80 | } |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Get the frequency that the interface is running at. | 83 | * Get the frequency that the interface is running at. |
84 | * @return int the frequency that the interfacae is running at. | 84 | * @return int the frequency that the interfacae is running at. |
85 | */ | 85 | */ |
86 | double WExtensions::frequency(){ | 86 | double WExtensions::frequency(){ |
87 | if(!hasWirelessExtensions) | 87 | if(!hasWirelessExtensions) |
88 | return 0; | 88 | return 0; |
89 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) | 89 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) |
90 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 90 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
91 | return 0; | 91 | return 0; |
92 | } | 92 | } |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Get the channel that the interface is running at. | 95 | * Get the channel that the interface is running at. |
96 | * @return int the channel that the interfacae is running at. | 96 | * @return int the channel that the interfacae is running at. |
97 | */ | 97 | */ |
98 | int WExtensions::channel(){ | 98 | int WExtensions::channel(){ |
99 | if(!hasWirelessExtensions) | 99 | if(!hasWirelessExtensions) |
100 | return 0; | 100 | return 0; |
101 | if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) | 101 | if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) |
102 | return 0; | 102 | return 0; |
103 | |||
104 | // http://www.elanix.com/pdf/an137e.pdf | ||
105 | |||
103 | double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 106 | double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
104 | double left = 2.401; | 107 | double left = 2.401; |
105 | double right = 2.416; | 108 | double right = 2.416; |
106 | for(int channel = 1; channel<= 15; channel++){ | 109 | for(int channel = 1; channel<= 15; channel++){ |
107 | if( num >= left && num <= right ) | 110 | if( num >= left && num <= right ) |
108 | return channel; | 111 | return channel; |
109 | left += 0.005; | 112 | left += 0.005; |
110 | right += 0.005; | 113 | right += 0.005; |
111 | } | 114 | } |
112 | qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1()); | 115 | qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1()); |
113 | return -1; | 116 | return -1; |
114 | } | 117 | } |
115 | 118 | ||
116 | /*** | 119 | /*** |
117 | * Get the current rate that the card is transmiting at. | 120 | * Get the current rate that the card is transmiting at. |
118 | * @return double the rate, 0 if error. | 121 | * @return double the rate, 0 if error. |
119 | */ | 122 | */ |
120 | double WExtensions::rate(){ | 123 | double WExtensions::rate(){ |
121 | if(!hasWirelessExtensions) | 124 | if(!hasWirelessExtensions) |
122 | return 0; | 125 | return 0; |
123 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ | 126 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ |
124 | return ((double)iwr.u.bitrate.value)/1000000; | 127 | return ((double)iwr.u.bitrate.value)/1000000; |
125 | } | 128 | } |
126 | return 0; | 129 | return 0; |
127 | } | 130 | } |
128 | 131 | ||
129 | 132 | ||
130 | /** | 133 | /** |
131 | * @return QString the AccessPoint that the interface is connected to. | 134 | * @return QString the AccessPoint that the interface is connected to. |
132 | */ | 135 | */ |
133 | QString WExtensions::ap(){ | 136 | QString WExtensions::ap(){ |
134 | if(!hasWirelessExtensions) | 137 | if(!hasWirelessExtensions) |
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index 16654bb..827d075 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp | |||
@@ -71,64 +71,67 @@ QString WExtensions::essid(){ | |||
71 | /** | 71 | /** |
72 | * @return QString the mode of interface | 72 | * @return QString the mode of interface |
73 | */ | 73 | */ |
74 | QString WExtensions::mode(){ | 74 | QString WExtensions::mode(){ |
75 | if(!hasWirelessExtensions) | 75 | if(!hasWirelessExtensions) |
76 | return QString(); | 76 | return QString(); |
77 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) | 77 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) |
78 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); | 78 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); |
79 | return QString(); | 79 | return QString(); |
80 | } | 80 | } |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Get the frequency that the interface is running at. | 83 | * Get the frequency that the interface is running at. |
84 | * @return int the frequency that the interfacae is running at. | 84 | * @return int the frequency that the interfacae is running at. |
85 | */ | 85 | */ |
86 | double WExtensions::frequency(){ | 86 | double WExtensions::frequency(){ |
87 | if(!hasWirelessExtensions) | 87 | if(!hasWirelessExtensions) |
88 | return 0; | 88 | return 0; |
89 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) | 89 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) |
90 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 90 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
91 | return 0; | 91 | return 0; |
92 | } | 92 | } |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Get the channel that the interface is running at. | 95 | * Get the channel that the interface is running at. |
96 | * @return int the channel that the interfacae is running at. | 96 | * @return int the channel that the interfacae is running at. |
97 | */ | 97 | */ |
98 | int WExtensions::channel(){ | 98 | int WExtensions::channel(){ |
99 | if(!hasWirelessExtensions) | 99 | if(!hasWirelessExtensions) |
100 | return 0; | 100 | return 0; |
101 | if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) | 101 | if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) |
102 | return 0; | 102 | return 0; |
103 | |||
104 | // http://www.elanix.com/pdf/an137e.pdf | ||
105 | |||
103 | double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 106 | double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
104 | double left = 2.401; | 107 | double left = 2.401; |
105 | double right = 2.416; | 108 | double right = 2.416; |
106 | for(int channel = 1; channel<= 15; channel++){ | 109 | for(int channel = 1; channel<= 15; channel++){ |
107 | if( num >= left && num <= right ) | 110 | if( num >= left && num <= right ) |
108 | return channel; | 111 | return channel; |
109 | left += 0.005; | 112 | left += 0.005; |
110 | right += 0.005; | 113 | right += 0.005; |
111 | } | 114 | } |
112 | qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1()); | 115 | qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1()); |
113 | return -1; | 116 | return -1; |
114 | } | 117 | } |
115 | 118 | ||
116 | /*** | 119 | /*** |
117 | * Get the current rate that the card is transmiting at. | 120 | * Get the current rate that the card is transmiting at. |
118 | * @return double the rate, 0 if error. | 121 | * @return double the rate, 0 if error. |
119 | */ | 122 | */ |
120 | double WExtensions::rate(){ | 123 | double WExtensions::rate(){ |
121 | if(!hasWirelessExtensions) | 124 | if(!hasWirelessExtensions) |
122 | return 0; | 125 | return 0; |
123 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ | 126 | if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ |
124 | return ((double)iwr.u.bitrate.value)/1000000; | 127 | return ((double)iwr.u.bitrate.value)/1000000; |
125 | } | 128 | } |
126 | return 0; | 129 | return 0; |
127 | } | 130 | } |
128 | 131 | ||
129 | 132 | ||
130 | /** | 133 | /** |
131 | * @return QString the AccessPoint that the interface is connected to. | 134 | * @return QString the AccessPoint that the interface is connected to. |
132 | */ | 135 | */ |
133 | QString WExtensions::ap(){ | 136 | QString WExtensions::ap(){ |
134 | if(!hasWirelessExtensions) | 137 | if(!hasWirelessExtensions) |