author | kergoth <kergoth> | 2003-04-15 00:38:36 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-04-15 00:38:36 (UTC) |
commit | 54c3c91b776f277fdcf2e78621a28e98cc55ab5b (patch) (unidiff) | |
tree | 1941fc77e46a47b745380388a6b12c0924524c81 | |
parent | 02f76303f1b134c26b13c30f97295e78ffca051b (diff) | |
download | opie-54c3c91b776f277fdcf2e78621a28e98cc55ab5b.zip opie-54c3c91b776f277fdcf2e78621a28e98cc55ab5b.tar.gz opie-54c3c91b776f277fdcf2e78621a28e98cc55ab5b.tar.bz2 |
BUGFIX: Dont cut off the last character of the ESSID.
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index 827d075..bd7cf93 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp | |||
@@ -17,97 +17,97 @@ | |||
17 | * Constructor. Sets hasWirelessExtensions | 17 | * Constructor. Sets hasWirelessExtensions |
18 | */ | 18 | */ |
19 | WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) { | 19 | WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) { |
20 | fd = socket( AF_INET, SOCK_DGRAM, 0 ); | 20 | fd = socket( AF_INET, SOCK_DGRAM, 0 ); |
21 | if(fd == -1) | 21 | if(fd == -1) |
22 | return; | 22 | return; |
23 | 23 | ||
24 | const char* buffer[200]; | 24 | const char* buffer[200]; |
25 | memset( &iwr, 0, sizeof( iwr ) ); | 25 | memset( &iwr, 0, sizeof( iwr ) ); |
26 | iwr.u.essid.pointer = (caddr_t) buffer; | 26 | iwr.u.essid.pointer = (caddr_t) buffer; |
27 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 27 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
28 | iwr.u.essid.flags = 0; | 28 | iwr.u.essid.flags = 0; |
29 | 29 | ||
30 | // check if it is an IEEE 802.11 standard conform | 30 | // check if it is an IEEE 802.11 standard conform |
31 | // wireless device by sending SIOCGIWESSID | 31 | // wireless device by sending SIOCGIWESSID |
32 | // which also gives back the Extended Service Set ID | 32 | // which also gives back the Extended Service Set ID |
33 | // (see IEEE 802.11 for more information) | 33 | // (see IEEE 802.11 for more information) |
34 | 34 | ||
35 | const char* iname = interface.latin1(); | 35 | const char* iname = interface.latin1(); |
36 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); | 36 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); |
37 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) | 37 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) |
38 | hasWirelessExtensions = true; | 38 | hasWirelessExtensions = true; |
39 | } | 39 | } |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * @return QString the station name of the access point. | 42 | * @return QString the station name of the access point. |
43 | */ | 43 | */ |
44 | QString WExtensions::station(){ | 44 | QString WExtensions::station(){ |
45 | if(!hasWirelessExtensions) | 45 | if(!hasWirelessExtensions) |
46 | return QString(); | 46 | return QString(); |
47 | const char* buffer[200]; | 47 | const char* buffer[200]; |
48 | iwr.u.data.pointer = (caddr_t) buffer; | 48 | iwr.u.data.pointer = (caddr_t) buffer; |
49 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | 49 | iwr.u.data.length = IW_ESSID_MAX_SIZE; |
50 | iwr.u.data.flags = 0; | 50 | iwr.u.data.flags = 0; |
51 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ | 51 | if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ |
52 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | 52 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; |
53 | return QString(iwr.u.data.pointer); | 53 | return QString(iwr.u.data.pointer); |
54 | } | 54 | } |
55 | return QString(); | 55 | return QString(); |
56 | } | 56 | } |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * @return QString the essid of the host 802.11 access point. | 59 | * @return QString the essid of the host 802.11 access point. |
60 | */ | 60 | */ |
61 | QString WExtensions::essid(){ | 61 | QString WExtensions::essid(){ |
62 | if(!hasWirelessExtensions) | 62 | if(!hasWirelessExtensions) |
63 | return QString(); | 63 | return QString(); |
64 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ | 64 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ |
65 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; | 65 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length] = '\0'; |
66 | return QString(iwr.u.essid.pointer); | 66 | return QString(iwr.u.essid.pointer); |
67 | } | 67 | } |
68 | return QString(); | 68 | return QString(); |
69 | } | 69 | } |
70 | 70 | ||
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 | 103 | ||
104 | // http://www.elanix.com/pdf/an137e.pdf | 104 | // http://www.elanix.com/pdf/an137e.pdf |
105 | 105 | ||
106 | 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); |
107 | double left = 2.401; | 107 | double left = 2.401; |
108 | double right = 2.416; | 108 | double right = 2.416; |
109 | for(int channel = 1; channel<= 15; channel++){ | 109 | for(int channel = 1; channel<= 15; channel++){ |
110 | if( num >= left && num <= right ) | 110 | if( num >= left && num <= right ) |
111 | return channel; | 111 | return channel; |
112 | left += 0.005; | 112 | left += 0.005; |
113 | right += 0.005; | 113 | right += 0.005; |