summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/wlan/wextensions.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/wlan/wextensions.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/wextensions.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp
index 6335ebc..16654bb 100644
--- a/noncore/settings/networksettings/wlan/wextensions.cpp
+++ b/noncore/settings/networksettings/wlan/wextensions.cpp
@@ -70,50 +70,73 @@ QString WExtensions::essid(){
70 70
71/** 71/**
72 * @return QString the mode of interface 72 * @return QString the mode of interface
73 */ 73 */
74QString WExtensions::mode(){ 74QString 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 */
86double WExtensions::frequency(){ 86double 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/**
95 * Get the channel that the interface is running at.
96 * @return int the channel that the interfacae is running at.
97 */
98int WExtensions::channel(){
99 if(!hasWirelessExtensions)
100 return 0;
101 if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr ))
102 return 0;
103 double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000);
104 double left = 2.401;
105 double right = 2.416;
106 for(int channel = 1; channel<= 15; channel++){
107 if( num >= left && num <= right )
108 return channel;
109 left += 0.005;
110 right += 0.005;
111 }
112 qDebug(QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1());
113 return -1;
114}
115
94/*** 116/***
95 * Get the current rate that the card is transmiting at. 117 * Get the current rate that the card is transmiting at.
118 * @return double the rate, 0 if error.
96 */ 119 */
97double WExtensions::rate(){ 120double WExtensions::rate(){
98 if(!hasWirelessExtensions) 121 if(!hasWirelessExtensions)
99 return 0; 122 return 0;
100 if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ 123 if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){
101 return ((double)iwr.u.bitrate.value)/1000000; 124 return ((double)iwr.u.bitrate.value)/1000000;
102 } 125 }
103 return 0; 126 return 0;
104} 127}
105 128
106 129
107/** 130/**
108 * @return QString the AccessPoint that the interface is connected to. 131 * @return QString the AccessPoint that the interface is connected to.
109 */ 132 */
110QString WExtensions::ap(){ 133QString WExtensions::ap(){
111 if(!hasWirelessExtensions) 134 if(!hasWirelessExtensions)
112 return QString(); 135 return QString();
113 if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ 136 if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){
114 QString ap; 137 QString ap;
115 ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", 138 ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
116 iwr.u.ap_addr.sa_data[0]&0xff, 139 iwr.u.ap_addr.sa_data[0]&0xff,
117 iwr.u.ap_addr.sa_data[1]&0xff, 140 iwr.u.ap_addr.sa_data[1]&0xff,
118 iwr.u.ap_addr.sa_data[2]&0xff, 141 iwr.u.ap_addr.sa_data[2]&0xff,
119 iwr.u.ap_addr.sa_data[3]&0xff, 142 iwr.u.ap_addr.sa_data[3]&0xff,