2 var conf_wired
= false;
4 function configure_os()
6 var os
= document
.os_driver
.os
.value
;
7 document
.os_driver
.driver
.disabled
= false;
8 document
.os_driver
.driver
[0] = new Option("Select your driver", "select");
10 document
.os_driver
.driver
[1] = new Option("madwifi", "madwifi");
11 document
.os_driver
.driver
[2] = new Option("Host AP (Prism2/2.5/3)", "hostap");
12 document
.os_driver
.driver
[3] = new Option("Intel ipw2100/2200", "ipw");
13 document
.os_driver
.driver
[4] = new Option("Any wired Ethernet driver", "linux_wired");
14 document
.os_driver
.driver
[5] = new Option("Other", "other linux");
15 } else if (os
== "windows") {
16 document
.os_driver
.driver
[1] = new Option("Any wireless NDIS driver", "ndis_wireless");
17 document
.os_driver
.driver
[2] = new Option("Any wired (Ethernet) NDIS driver", "ndis_wired");
22 function configure_driver()
24 var drv
= document
.os_driver
.driver
.value
;
25 var t
= document
.getElementById("os_desc");
28 t
.style
.visibility
= "hidden";
30 if (drv
== "ndis_wireless") {
32 t
.innerHTML
= "All wireless Windows NDIS drivers support AP selection " +
33 "and roaming, so in most cases, configuring the driver to take care " +
34 "of this by setting ap_scan=2 is the recommended configuration for " +
36 t
.style
.visibility
= "visible";
37 } else if (drv
== "ndis_wired" || drv
== "linux_wired") {
47 function update_encr()
49 var auth
= document
.authmode
.auth
.value
;
50 var t
= document
.getElementById("encr_desc");
52 for (i
= 0; i
< 6; i
++)
53 document
.encrmode
.encr
[i
] = null;
55 document
.encrmode
.encr
[0] = new Option("None (unencrypted open network)", "none");
56 document
.encrmode
.encr
.selectedIndex
= 0;
57 t
.innerHTML
= "Based on the selected authentication mode (open network), only 'None' is an allowed encryption mode.";
58 t
.style
.visibility
= "visible";
59 } else if (auth
== "wep") {
60 document
.encrmode
.encr
[0] = new Option("WEP (Wired Equivalent Privacy)", "wep");
61 document
.encrmode
.encr
.selectedIndex
= 0;
62 t
.innerHTML
= "Based on the selected authentication mode (WEP), only 'WEP' is an allowed encryption mode.";
63 t
.style
.visibility
= "visible";
64 } else if (auth
== "ieee8021x") {
65 document
.encrmode
.encr
[0] = new Option("None (unencrypted open network)", "none");
66 document
.encrmode
.encr
[1] = new Option("WEP (Wired Equivalent Privacy)", "wep");
67 document
.encrmode
.encr
.selectedIndex
= conf_wired
? 0 : 1;
68 t
.innerHTML
= "Based on the selected authentication mode (IEEE 802.1X), either 'None' or 'WEP' can be selected. In wireless networks, this is most likely going to be 'WEP' and in wired networks, only 'None' is allowed.";
69 t
.style
.visibility
= "visible";
70 } else if (auth
== "wpa-psk" || auth
== "wpa-eap") {
71 document
.encrmode
.encr
[0] = new Option("TKIP (Temporal Key Integrity Protocol)", "tkip");
72 document
.encrmode
.encr
[1] = new Option("CCMP (AES Counter-Mode/CBC-MAC Protocol)", "ccmp");
73 document
.encrmode
.encr
.selectedIndex
= (document
.authmode
.auth2
.value
== "wpa1") ? 0 : 1;
74 t
.innerHTML
= "Based on the selected authentication mode (WPA/WPA2), either 'TKIP' or 'CCMP' can be selected. Most WPA networks are using TKIP whereas WPA2 defaults to CCMP.";
75 t
.style
.visibility
= "visible";
78 t
.style
.visibility
= "hidden";
83 function update_cred()
85 var auth
= document
.authmode
.auth
.value
;
88 t
= document
.getElementById("cred_unknown");
89 t
.style
.display
= "none";
90 t
= document
.getElementById("cred_open");
91 t
.style
.display
= "none";
92 t
= document
.getElementById("cred_wep");
93 t
.style
.display
= "none";
94 t
= document
.getElementById("cred_psk");
95 t
.style
.display
= "none";
96 t
= document
.getElementById("cred_eap");
97 t
.style
.display
= "none";
100 t
= document
.getElementById("cred_open");
101 t
.style
.display
= "block";
102 } else if (auth
== "wep") {
103 t
= document
.getElementById("cred_wep");
104 t
.style
.display
= "block";
105 } else if (auth
== "wpa-psk") {
106 t
= document
.getElementById("cred_psk");
107 t
.style
.display
= "block";
108 } else if (auth
== "ieee8021x" || auth
== "wpa-eap") {
109 t
= document
.getElementById("cred_eap");
110 t
.style
.display
= "block";
112 t
= document
.getElementById("cred_unknown");
113 t
.style
.display
= "block";
118 function configure_auth()
120 var auth
= document
.authmode
.auth
.value
;
122 document
.authmode
.auth2
[0] = null;
123 document
.authmode
.auth2
[1] = null;
124 document
.authmode
.auth2
.disabled
= true;
126 document
.authmode
.auth2
[0] = new Option("Open System authentication", "open");
127 document
.authmode
.auth2
[1] = new Option("Shared Key authentication", "shared");
128 document
.authmode
.auth2
.disabled
= false;
129 } else if (auth
== "wpa-psk" || auth
== "wpa-eap") {
130 document
.authmode
.auth2
[0] = new Option("WPA (version 1)", "wpa1");
131 document
.authmode
.auth2
[1] = new Option("WPA2 (IEEE 802.11i)", "wpa2");
132 document
.authmode
.auth2
.disabled
= false;
141 function configure_auth2()
148 function configure_encr()
154 function configure_passphrase()
156 var passphrase
= document
.cred_psk_form
.passphrase
.value
;
157 var psk
= document
.cred_psk_form
.psk
.value
;
158 var t
= document
.getElementById("cred_desc");
160 if (psk
.length
&& (psk
.length
!= 64 || !is_hex(psk
))) {
161 t
.innerHTML
= "<p class=\"error\">Note: Invalid PSK</p>";
162 t
.style
.visibility
= "visible";
163 } else if (psk
.length
== 0 && passphrase
.length
&&
164 (passphrase
.length
< 8 || passphrase
.length
> 63)) {
165 t
.innerHTML
= "<p class=\"error\">Note: Invalid passphrase</p>";
166 t
.style
.visibility
= "visible";
169 t
.style
.visibility
= "hidden";
173 document
.cred_psk_form
.passphrase
.disabled
= true;
174 document
.cred_psk_form
.psk
.disabled
= false;
175 } else if (passphrase
.length
) {
176 document
.cred_psk_form
.passphrase
.disabled
= false;
177 document
.cred_psk_form
.psk
.disabled
= true;
179 document
.cred_psk_form
.passphrase
.disabled
= false;
180 document
.cred_psk_form
.psk
.disabled
= false;
192 for (i
= 0; i
< s
.length
; i
++) {
193 if (s
[i
] >= 'a' && s
[i
] <= 'f')
195 if (s
[i
] >= 'A' && s
[i
] <= 'F')
197 if (s
[i
] >= '0' && s
[i
] <= '9')
206 function valid_wep_key(key
)
212 if (key
[key
.length
- 1] != '"')
214 return (key
.length
== 5 + 2 || key
.length
== 13 + 2 ||
215 key
.length
== 16 + 2);
218 return (is_hex(key
) &&
219 (key
.length
== 10 || key
.length
== 26 || key
.length
== 32));
223 function configure_wep()
225 var t
= document
.getElementById("cred_desc");
229 wep
= document
.cred_wep_form
.wep0
.value
;
230 if (!valid_wep_key(wep
))
231 txt
+= "<p class=\"error\">Note: Invalid WEP key: " + wep
+ "</p>\n";
232 wep
= document
.cred_wep_form
.wep1
.value
;
233 if (!valid_wep_key(wep
))
234 txt
+= "<p class=\"error\">Note: Invalid WEP key: " + wep
+ "</p>\n";
235 wep
= document
.cred_wep_form
.wep2
.value
;
236 if (!valid_wep_key(wep
))
237 txt
+= "<p class=\"error\">Note: Invalid WEP key: " + wep
+ "</p>\n";
238 wep
= document
.cred_wep_form
.wep3
.value
;
239 if (!valid_wep_key(wep
))
240 txt
+= "<p class=\"error\">Note: Invalid WEP key: " + wep
+ "</p>\n";
244 t
.style
.visibility
= "visible";
245 } else if (t
.style
.visibility
!= "hidden")
246 t
.style
.visibility
= "hidden";
252 function update_eap()
254 var eap
= document
.cred_eap_form
.eap
.value
;
257 if (eap
== "PEAP" || eap
== "TTLS" || eap
== "FAST") {
258 document
.cred_eap_form
.phase2
[n
++] = new Option("EAP-MSCHAPv2", "MSCHAPV2");
259 document
.cred_eap_form
.phase2
.selectedIndex
= n
- 1;
261 document
.cred_eap_form
.phase2
[n
++] = new Option("EAP-GTC", "GTC");
262 document
.cred_eap_form
.phase2
[n
++] = new Option("EAP-MD5", "MD5");
263 document
.cred_eap_form
.phase2
[n
++] = new Option("EAP-TLS", "TLS");
264 document
.cred_eap_form
.phase2
[n
++] = new Option("EAP-OTP", "OTP");
267 document
.cred_eap_form
.phase2
[n
++] = new Option("MSCHAPv2", "_MSCHAPV2");
268 document
.cred_eap_form
.phase2
.selectedIndex
= n
- 1;
269 document
.cred_eap_form
.phase2
[n
++] = new Option("MSCHAP", "_MSCHAP");
270 document
.cred_eap_form
.phase2
[n
++] = new Option("PAP", "_PAP");
271 document
.cred_eap_form
.phase2
[n
++] = new Option("CHAP", "_CHAP");
273 document
.cred_eap_form
.phase2
.disabled
= false;
275 document
.cred_eap_form
.phase2
.disabled
= true;
278 for (i
= 20; i
>= n
; i
--)
279 document
.cred_eap_form
.phase2
[i
] = null;
285 function update_eap2()
287 var eap
= document
.cred_eap_form
.eap
.value
;
288 var password
= false;
290 var user_cert
= false;
292 if (eap
== "PEAP" || eap
== "TTLS") {
294 if (document
.cred_eap_form
.phase2
.value
== "TLS")
298 } else if (eap
== "FAST") {
300 } else if (eap
== "GTC") {
302 } else if (eap
== "LEAP" || eap
== "MD5" || eap
== "MSCHAPV2") {
304 } else if (eap
== "TLS") {
310 document
.cred_eap_form
.anon_identity
.disabled
= false;
311 document
.cred_eap_form
.anon_identity
.value
= "anonymous";
312 } else if (eap
== "FAST") {
313 document
.cred_eap_form
.anon_identity
.disabled
= false;
314 document
.cred_eap_form
.anon_identity
.value
= "FAST-000000000000";
316 document
.cred_eap_form
.anon_identity
.disabled
= true;
318 document
.cred_eap_form
.password
.disabled
= !password
;
320 document
.cred_eap_form
.ca_cert
.disabled
= false;
321 if (document
.cred_eap_form
.ca_cert
.value
.length
== 0)
322 document
.cred_eap_form
.ca_cert
.value
= "/etc/ca.pem";
324 document
.cred_eap_form
.ca_cert
.disabled
= true;
326 document
.cred_eap_form
.client_cert
.disabled
= !user_cert
;
327 document
.cred_eap_form
.private_key
.disabled
= !user_cert
;
328 document
.cred_eap_form
.private_key_passwd
.disabled
= !user_cert
;
331 document
.cred_eap_form
.pac_file
.disabled
= false;
332 if (document
.cred_eap_form
.pac_file
.value
.length
== 0)
333 document
.cred_eap_form
.pac_file
.value
= "/etc/fast.pac";
335 document
.cred_eap_form
.pac_file
.disabled
= true;
342 function configure_eap()
348 function update_conf()
350 var t
= document
.getElementById("exampleconf");
352 var indent
= " ";
353 var ap_scan
= conf_ap_scan
;
354 var drv
= document
.os_driver
.driver
.value
;
358 if (document
.network
.hidden_ssid
.checked
&& ap_scan
== 1 &&
359 drv
!= "hostap" && drv
!= "madwifi") {
360 /* if the selected driver does not support scan_ssid, must use
361 * ap_scan=2 mode with hidden SSIDs */
362 txt
+= "# this driver requires ap_scan=2 mode when using hidden SSIDs<br>\n";
368 txt
+= "# example configuration will be generated here<br>\n";
371 txt
+= "# wired drivers do not use scanning<br>\n" +
372 "ap_scan=0<br><br>\n";
375 txt
+= "# request AP scanning and decide which AP to use<br>\n" +
376 "ap_scan=1<br><br>\n";
379 txt
+= "# request driver to take care of AP selection and roaming<br>\n" +
380 "ap_scan=2<br><br>\n";
384 if (document
.os_driver
.os
.value
== "windows") {
385 txt
+= "# enable control interface using local UDP socket<br>\n" +
386 "ctrl_interface=udp<br>\n";
388 txt
+= "# enable control interface using UNIX domain sockets<br>\n" +
389 "ctrl_interface=/var/run/wpa_supplicant<br>\n";
393 "# you can include one or more network blocks here<br>\n" +
397 txt
+= indent
+ "# wired network - must not configure SSID here<br>\n";
399 if (document
.network
.ssid
.value
.length
== 0)
400 txt
+= indent
+ "# must configure SSID here (Step 2)<br>\n";
401 txt
+= indent
+ "ssid=\"" + document
.network
.ssid
.value
+ "\"<br>\n";
402 if (ap_scan
== 1 && document
.network
.hidden_ssid
.checked
)
403 txt
+= indent
+ "scan_ssid=1<br>\n";
406 var auth
= document
.authmode
.auth
.value
;
407 var auth2
= document
.authmode
.auth2
.value
;
409 if (auth
== "open" || auth
== "wep")
410 txt
+= indent
+ "key_mgmt=NONE<br>\n";
411 else if (auth
== "ieee8021x")
412 txt
+= indent
+ "key_mgmt=IEEE8021X<br>\n";
413 else if (auth
== "wpa-psk")
414 txt
+= indent
+ "key_mgmt=WPA-PSK<br>\n";
415 else if (auth
== "wpa-eap")
416 txt
+= indent
+ "key_mgmt=WPA-EAP<br>\n";
418 txt
+= indent
+ "# must set key_mgmt here (Step 3)<br>\n";
422 txt
+= indent
+ "auth_alg=OPEN<br>\n";
423 else if (auth2
== "shared")
424 txt
+= indent
+ "auth_alg=SHARED<br>\n";
425 } else if (auth
== "wpa-psk" || auth
== "wpa-eap") {
427 txt
+= indent
+ "proto=WPA<br>\n";
428 else if (auth2
== "wpa2")
429 txt
+= indent
+ "proto=WPA2<br>\n";
431 txt
+= indent
+ "# WPA proto (v1/v2) should be configured here (Step 3)<br>\n";
435 if (auth
== "wpa-psk" || auth
== "wpa-eap") {
436 var encr
= document
.encrmode
.encr
.value
;
438 txt
+= indent
+ "pairwise=TKIP<br>\n";
439 else if (encr
== "ccmp")
440 txt
+= indent
+ "pairwise=CCMP<br>\n";
442 txt
+= indent
+ "# should configure pairwise encryption cipher (Step 4)<br>\n";
447 wep
= document
.cred_wep_form
.wep0
.value
;
449 txt
+= indent
+ "wep_key0=" + wep
+ "<br>\n";
450 wep
= document
.cred_wep_form
.wep1
.value
;
452 txt
+= indent
+ "wep_key1=" + wep
+ "<br>\n";
453 wep
= document
.cred_wep_form
.wep2
.value
;
455 txt
+= indent
+ "wep_key2=" + wep
+ "<br>\n";
456 wep
= document
.cred_wep_form
.wep3
.value
;
458 txt
+= indent
+ "wep_key3=" + wep
+ "<br>\n";
459 txt
+= indent
+ "wep_tx_keyidx=" + document
.cred_wep_form
.wep_tx_idx
.value
+ "<br>\n";
460 } else if (auth
== "wpa-psk") {
461 var passphrase
= document
.cred_psk_form
.passphrase
.value
;
462 var psk
= document
.cred_psk_form
.psk
.value
;
464 if (psk
.length
!= 64)
465 txt
+= indent
+ "# WPA PSK 64-character hex string<br>\n";
466 txt
+= indent
+ "psk=" + psk
+ "<br>\n";
468 if (passphrase
.length
< 8)
469 txt
+= indent
+ "# WPA passphrase must be at least 8 characters long<br>\n";
470 if (passphrase
.length
> 63)
471 txt
+= indent
+ "# WPA passphrase must be at most 63 characters long<br>\n";
472 txt
+= indent
+ "psk=\"" + passphrase
+ "\"<br>\n";
474 } else if (auth
== "ieee8021x" || auth
== "wpa-eap") {
475 var eap
= document
.cred_eap_form
.eap
.value
;
477 txt
+= indent
+ "# EAP method needs to be selected (Step 5)<br>\n";
479 txt
+= indent
+ "eap=" + eap
+ "<br>\n";
481 var phase2
= document
.cred_eap_form
.phase2
;
482 var eap2
= phase2
.value
;
483 if (eap
== "PEAP" || eap
== "TTLS" || eap
== "FAST") {
484 txt
+= indent
+ "phase2=\"auth";
486 if (eap2
[0] == '_') {
487 eap2
= eap2
.substring(1);
491 txt
+= "=" + eap2
+ "\"<br>\n";
494 var identity
= document
.cred_eap_form
.identity
.value
;
496 txt
+= indent
+ "identity=\"" + identity
+ "\"<br>\n";
498 var anon
= document
.cred_eap_form
.anon_identity
;
499 if (!anon
.disabled
&& anon
.value
.length
)
500 txt
+= indent
+ "anonymous_identity=\"" + anon
.value
+ "\"<br>\n";
502 var password
= document
.cred_eap_form
.password
;
503 if (!password
.disabled
&& password
.value
.length
)
504 txt
+= indent
+ "password=\"" + password
.value
+ "\"<br>\n";
506 var ca_cert
= document
.cred_eap_form
.ca_cert
;
507 if (!ca_cert
.disabled
) {
508 txt
+= indent
+ "ca_cert=\"" + ca_cert
.value
+ "\"<br>\n";
509 if (!phase2
.disabled
&& eap2
== "TLS")
510 txt
+= indent
+ "ca_cert2=\"" + ca_cert
.value
+ "\"<br>\n";
513 var client_cert
= document
.cred_eap_form
.client_cert
;
514 if (!client_cert
.disabled
) {
516 if (!phase2
.disabled
&& eap2
== "TLS")
519 if (client_cert
.value
.length
)
520 txt
+= indent
+ "client_cert" + e
+ "=\"" + client_cert
.value
+ "\"<br>\n";
522 var key
= document
.cred_eap_form
.private_key
.value
;
524 txt
+= indent
+ "private_key" + e
+ "=\"" + key
+ "\"<br>\n";
526 var passwd
= document
.cred_eap_form
.private_key_passwd
.value
;
528 txt
+= indent
+ "private_key_passwd" + e
+ "=\"" + passwd
+ "\"<br>\n";
531 var pac
= document
.cred_eap_form
.pac_file
;
532 if (!pac
.disabled
&& pac
.value
.length
)
533 txt
+= indent
+ "pac_file=\"" + pac
.value
+ "\"<br>\n";
535 txt
+= indent
+ "phase1=\"fast_provisioning=1\"<br>\n";