author | mickeyl <mickeyl> | 2005-05-10 10:14:38 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-05-10 10:14:38 (UTC) |
commit | ff1d0ce627f64fb757df48d4c4998cb82a024dbc (patch) (unidiff) | |
tree | 332d07f028d216564ee287ddd2b642e0d314234e /noncore | |
parent | ce515e60ba66d4b1540879b17b2b31b5fac627d3 (diff) | |
download | opie-ff1d0ce627f64fb757df48d4c4998cb82a024dbc.zip opie-ff1d0ce627f64fb757df48d4c4998cb82a024dbc.tar.gz opie-ff1d0ce627f64fb757df48d4c4998cb82a024dbc.tar.bz2 |
improve WEP key handling and add wlan-ng support. patch courtesy Dirk Opfer, thanks!
4 files changed, 142 insertions, 5 deletions
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index 8a9db66..64d8752 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp | |||
@@ -71,2 +71,3 @@ QString WExtensions::essid(){ | |||
71 | const char* buffer[200]; | 71 | const char* buffer[200]; |
72 | memset(buffer,0x00,200); | ||
72 | iwr.u.data.pointer = (caddr_t) buffer; | 73 | iwr.u.data.pointer = (caddr_t) buffer; |
@@ -75,2 +76,4 @@ QString WExtensions::essid(){ | |||
75 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ | 76 | if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ |
77 | if (iwr.u.essid.length > IW_ESSID_MAX_SIZE) | ||
78 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | ||
76 | buffer[(unsigned int) iwr.u.essid.length] = '\0'; | 79 | buffer[(unsigned int) iwr.u.essid.length] = '\0'; |
diff --git a/noncore/settings/networksettings/wlan/wlan.pro b/noncore/settings/networksettings/wlan/wlan.pro index eb9dd4f..3a064d3 100644 --- a/noncore/settings/networksettings/wlan/wlan.pro +++ b/noncore/settings/networksettings/wlan/wlan.pro | |||
@@ -10,3 +10,3 @@ INTERFACES = wlan.ui info.ui | |||
10 | TARGET = wlan | 10 | TARGET = wlan |
11 | VERSION = 1.0.1 | 11 | VERSION = 1.0.2 |
12 | 12 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index 11dfe74..2fd97c3 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp | |||
@@ -81,3 +81,3 @@ void WLANImp::parseOpts() { | |||
81 | bool error; | 81 | bool error; |
82 | QString opt; | 82 | QString opt,key; |
83 | 83 | ||
@@ -86,3 +86,2 @@ void WLANImp::parseOpts() { | |||
86 | 86 | ||
87 | |||
88 | opt = interfaces->getInterfaceOption("wireless_essid", error); | 87 | opt = interfaces->getInterfaceOption("wireless_essid", error); |
@@ -111,7 +110,62 @@ void WLANImp::parseOpts() { | |||
111 | 110 | ||
112 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); | 111 | opt = interfaces->getInterfaceOption("wireless_type", error).simplifyWhiteSpace(); |
113 | if (opt.isNull()) | 112 | |
113 | if ( opt == "wlan-ng") { | ||
114 | |||
115 | //FIXME:Handle wlan_ng_priv_genstr | ||
116 | |||
117 | // get default key_id | ||
118 | opt = interfaces->getInterfaceOption("wlan_ng_default_key_id", error).simplifyWhiteSpace(); | ||
119 | |||
120 | if (opt == "0") | ||
121 | keyRadio0->setChecked(true); | ||
122 | if (opt == "1") | ||
123 | keyRadio1->setChecked(true); | ||
124 | if (opt == "2") | ||
125 | keyRadio2->setChecked(true); | ||
126 | if (opt == "3") | ||
127 | keyRadio3->setChecked(true); | ||
128 | |||
129 | // get key0 | ||
130 | key = interfaces->getInterfaceOption("wlan_ng_key0", error).simplifyWhiteSpace(); | ||
131 | key.replace(QString(":"),QString("")); | ||
132 | keyLineEdit0->setText(key); | ||
133 | |||
134 | // get key1 | ||
135 | key = interfaces->getInterfaceOption("wlan_ng_key1", error).simplifyWhiteSpace(); | ||
136 | key.replace(QString(":"),QString("")); | ||
137 | keyLineEdit1->setText(key); | ||
138 | |||
139 | // get key2 | ||
140 | key = interfaces->getInterfaceOption("wlan_ng_key2", error).simplifyWhiteSpace(); | ||
141 | key.replace(QString(":"),QString("")); | ||
142 | keyLineEdit2->setText(key); | ||
143 | |||
144 | // get key3 | ||
145 | key = interfaces->getInterfaceOption("wlan_ng_key3", error).simplifyWhiteSpace(); | ||
146 | key.replace(QString(":"),QString("")); | ||
147 | keyLineEdit3->setText(key); | ||
148 | |||
114 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); | 149 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); |
150 | |||
151 | // encryption on? | ||
152 | if(opt == "on"){ | ||
153 | wepEnabled->setChecked(true); | ||
154 | } else { | ||
155 | wepEnabled->setChecked(false); | ||
156 | } | ||
157 | |||
158 | opt = interfaces->getInterfaceOption("wireless_keymode", error).simplifyWhiteSpace(); | ||
159 | |||
160 | if(opt == "restricted"){ | ||
161 | // restricted mode, only accept encrypted packets | ||
162 | rejectNonEnc->setChecked(true); | ||
163 | } | ||
164 | } | ||
165 | else { | ||
166 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); | ||
167 | |||
115 | parseKeyStr(opt); | 168 | parseKeyStr(opt); |
116 | } | 169 | } |
170 | } | ||
117 | 171 | ||
@@ -228,3 +282,23 @@ void WLANImp::accept() { | |||
228 | 282 | ||
283 | QString WLANImp::formatKey(QString input) | ||
284 | { | ||
285 | int len,r=0; | ||
286 | |||
287 | len = input.length(); | ||
288 | |||
289 | if (!len) | ||
290 | return input; | ||
291 | |||
292 | for(int i=1;i<len/2;i++) | ||
293 | { | ||
294 | input.insert(r+i*2,QString(":")); | ||
295 | r++; | ||
296 | } | ||
297 | |||
298 | return input; | ||
299 | } | ||
300 | |||
229 | void WLANImp::writeOpts() { | 301 | void WLANImp::writeOpts() { |
302 | QString para, devicetype; | ||
303 | |||
230 | // eh can't really do anything about it other then return. :-D | 304 | // eh can't really do anything about it other then return. :-D |
@@ -255,2 +329,60 @@ void WLANImp::writeOpts() { | |||
255 | 329 | ||
330 | devicetype = interfaces->getInterfaceOption("wireless_type", error).simplifyWhiteSpace(); | ||
331 | |||
332 | if ( devicetype == "wlan-ng") { | ||
333 | |||
334 | // wlan-ng style | ||
335 | interfaces->removeInterfaceOption(QString("wireless_key")); | ||
336 | |||
337 | if (wepEnabled->isChecked()) { | ||
338 | |||
339 | interfaces->setInterfaceOption(QString("wireless_enc"),"on"); | ||
340 | |||
341 | if (! keyLineEdit0->text().isNull()) { | ||
342 | interfaces->setInterfaceOption(QString("wlan_ng_key0"), formatKey(keyLineEdit0->text())); | ||
343 | } else | ||
344 | interfaces->removeInterfaceOption(QString("wlan_ng_key0")); | ||
345 | if (! keyLineEdit1->text().isNull()) { | ||
346 | interfaces->setInterfaceOption(QString("wlan_ng_key1"), formatKey(keyLineEdit1->text())); | ||
347 | } else | ||
348 | interfaces->removeInterfaceOption(QString("wlan_ng_key1")); | ||
349 | if (! keyLineEdit2->text().isNull()) { | ||
350 | interfaces->setInterfaceOption(QString("wlan_ng_key2"), formatKey(keyLineEdit2->text())); | ||
351 | } else | ||
352 | interfaces->removeInterfaceOption(QString("wlan_ng_key2")); | ||
353 | if (! keyLineEdit3->text().isNull()) { | ||
354 | interfaces->setInterfaceOption(QString("wlan_ng_key3"), formatKey(keyLineEdit3->text())); | ||
355 | } else | ||
356 | interfaces->removeInterfaceOption(QString("wlan_ng_key3")); | ||
357 | |||
358 | if (acceptNonEnc->isChecked()) | ||
359 | interfaces->removeInterfaceOption(QString("wireless_keymode")); | ||
360 | else | ||
361 | interfaces->setInterfaceOption(QString("wireless_keymode"),"restricted"); | ||
362 | |||
363 | para = ""; | ||
364 | if (keyRadio0->isChecked()) { | ||
365 | para = "0"; | ||
366 | } else if (keyRadio1->isChecked()) { | ||
367 | para = "1"; | ||
368 | } else if (keyRadio2->isChecked()) { | ||
369 | para = "2"; | ||
370 | } else if (keyRadio3->isChecked()) { | ||
371 | para = "3"; | ||
372 | } | ||
373 | |||
374 | interfaces->setInterfaceOption(QString("wlan_ng_default_key_id"), para); | ||
375 | |||
376 | } else { | ||
377 | // No wep, remove all previous keys | ||
378 | interfaces->removeInterfaceOption(QString("wireless_enc")); | ||
379 | interfaces->removeInterfaceOption(QString("wlan_ng_default_key_id")); | ||
380 | interfaces->removeInterfaceOption(QString("wlan_ng_key0")); | ||
381 | interfaces->removeInterfaceOption(QString("wlan_ng_key1")); | ||
382 | interfaces->removeInterfaceOption(QString("wlan_ng_key2")); | ||
383 | interfaces->removeInterfaceOption(QString("wlan_ng_key3")); | ||
384 | } | ||
385 | |||
386 | } else { | ||
387 | // This is the old style | ||
256 | if (wepEnabled->isChecked()) { | 388 | if (wepEnabled->isChecked()) { |
@@ -295,2 +427,3 @@ void WLANImp::writeOpts() { | |||
295 | interfaces->removeInterfaceOption(QString("wireless_enc")); | 427 | interfaces->removeInterfaceOption(QString("wireless_enc")); |
428 | } | ||
296 | 429 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.h b/noncore/settings/networksettings/wlan/wlanimp2.h index c3d1eee..0e8d533 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.h +++ b/noncore/settings/networksettings/wlan/wlanimp2.h | |||
@@ -39,2 +39,3 @@ private: | |||
39 | void parseKeyStr(QString keystr); | 39 | void parseKeyStr(QString keystr); |
40 | QString formatKey(QString input); | ||
40 | 41 | ||