-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index fe21f02..8a9db66 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp | |||
@@ -35,65 +35,69 @@ WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), i | |||
35 | iwr.u.essid.flags = 0; | 35 | iwr.u.essid.flags = 0; |
36 | 36 | ||
37 | // check if it is an IEEE 802.11 standard conform | 37 | // check if it is an IEEE 802.11 standard conform |
38 | // wireless device by sending SIOCGIWESSID | 38 | // wireless device by sending SIOCGIWESSID |
39 | // which also gives back the Extended Service Set ID | 39 | // which also gives back the Extended Service Set ID |
40 | // (see IEEE 802.11 for more information) | 40 | // (see IEEE 802.11 for more information) |
41 | 41 | ||
42 | const char* iname = interface.latin1(); | 42 | const char* iname = interface.latin1(); |
43 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); | 43 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); |
44 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) | 44 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) |
45 | hasWirelessExtensions = true; | 45 | hasWirelessExtensions = true; |
46 | } | 46 | } |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * @return QString the station name of the access point. | 49 | * @return QString the station name of the access point. |
50 | */ | 50 | */ |
51 | QString WExtensions::station(){ | 51 | QString WExtensions::station(){ |
52 | if(!hasWirelessExtensions) | 52 | if(!hasWirelessExtensions) |
53 | return QString(); | 53 | return QString(); |
54 | const char* buffer[200]; | 54 | const char* buffer[200]; |
55 | iwr.u.data.pointer = (caddr_t) buffer; | 55 | iwr.u.data.pointer = (caddr_t) buffer; |
56 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | 56 | iwr.u.data.length = IW_ESSID_MAX_SIZE; |
57 | iwr.u.data.flags = 0; | 57 | iwr.u.data.flags = 0; |
58 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ | 58 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ |
59 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | 59 | buffer[(unsigned int) iwr.u.data.length-1] = '\0'; |
60 | return QString(iwr.u.data.pointer); | 60 | return (const char*) buffer; |
61 | } | 61 | } |
62 | return QString(); | 62 | return QString::null; |
63 | } | 63 | } |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * @return QString the essid of the host 802.11 access point. | 66 | * @return QString the essid of the host 802.11 access point. |
67 | */ | 67 | */ |
68 | QString WExtensions::essid(){ | 68 | QString WExtensions::essid(){ |
69 | if(!hasWirelessExtensions) | 69 | if(!hasWirelessExtensions) |
70 | return QString(); | 70 | return QString(); |
71 | const char* buffer[200]; | ||
72 | iwr.u.data.pointer = (caddr_t) buffer; | ||
73 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | ||
74 | iwr.u.data.flags = 0; | ||
71 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ | 75 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ |
72 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length] = '\0'; | 76 | buffer[(unsigned int) iwr.u.essid.length] = '\0'; |
73 | return QString(iwr.u.essid.pointer); | 77 | return (const char*) buffer; |
74 | } | 78 | } |
75 | return QString(); | 79 | return QString::null; |
76 | } | 80 | } |
77 | 81 | ||
78 | /** | 82 | /** |
79 | * @return QString the mode of interface | 83 | * @return QString the mode of interface |
80 | */ | 84 | */ |
81 | QString WExtensions::mode(){ | 85 | QString WExtensions::mode(){ |
82 | if(!hasWirelessExtensions) | 86 | if(!hasWirelessExtensions) |
83 | return QString(); | 87 | return QString(); |
84 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) | 88 | if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) |
85 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); | 89 | return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); |
86 | return QString(); | 90 | return QString(); |
87 | } | 91 | } |
88 | 92 | ||
89 | /** | 93 | /** |
90 | * Get the frequency that the interface is running at. | 94 | * Get the frequency that the interface is running at. |
91 | * @return int the frequency that the interfacae is running at. | 95 | * @return int the frequency that the interfacae is running at. |
92 | */ | 96 | */ |
93 | double WExtensions::frequency(){ | 97 | double WExtensions::frequency(){ |
94 | if(!hasWirelessExtensions) | 98 | if(!hasWirelessExtensions) |
95 | return 0; | 99 | return 0; |
96 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) | 100 | if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) |
97 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); | 101 | return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); |
98 | return 0; | 102 | return 0; |
99 | } | 103 | } |