[RFC] [PATCH 3/7] Add WPA support to netcfg
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
dhcp.c, apoligies, *this* file removes the nested satan machine and
adds the new function for choosing wpa secured network. netcfg.patch
just adds options to netcfg.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFIEs2MV8GyuTwyskMRAlniAJoD3kshvqs+zM+h2qiJuEaR1HD9YQCeJSot
SIZMSqyFYISHql4h+LYWCE8=
=psME
-----END PGP SIGNATURE-----
diff --git a/packages/netcfg/dhcp.c b/packages/netcfg/dhcp.c
index d58119c..a898173 100644
--- a/packages/netcfg/dhcp.c
+++ b/packages/netcfg/dhcp.c
@@ -50,13 +50,17 @@ static void netcfg_write_dhcp (char *iface, char *dhostname)
fprintf(fp, "\thostname %s\n", dhostname);
}
if (is_wireless_iface(iface)) {
- fprintf(fp, "\t# wireless-* options are implemented by the wireless-tools package\n");
+ if (requested_wpa_supplicant)
+ fprintf(fp, "\twpa-conf /etc/wpa_supplicant/wpa_supplicant.conf\n");
+ else {
+ fprintf(fp, "\t# wireless-* options are implemented by the wireless-tools package\n");
fprintf(fp, "\twireless-mode %s\n",
(mode == MANAGED) ? "managed" : "ad-hoc");
fprintf(fp, "\twireless-essid %s\n",
(essid && *essid) ? essid : "any");
if (wepkey != NULL)
fprintf(fp, "\twireless-key1 %s\n", wepkey);
+ }
}
fclose(fp);
}
@@ -196,6 +200,11 @@ static int kill_dhcp_client(void)
return 0;
}
+static int kill_wpa_supplicant(void)
+{
+ system("killwpa.sh");
+ return 0;
+}
/*
* Poll the started DHCP client for netcfg/dhcp_timeout seconds (def. 15)
@@ -302,6 +311,49 @@ int ask_dhcp_options (struct debconfclient *client)
return REPLY_DONT_CONFIGURE;
}
+int reconfigure_wifi(struct debconfclient *client)
+{
+
+ enum { ABORT, ESSID, SECURITY, WEP, WPA, DONE } wifistate = ESSID;
+
+ kill_wpa_supplicant();
+ kill_dhcp_client();
+
+ for (;;) {
+ switch (wifistate) {
+ case ESSID:
+ wifistate = ( netcfg_wireless_set_essid (client, interface, "high") == GO_BACK ) ?
+ ABORT : SECURITY;
+ break;
+ case SECURITY:
+ {
+ int ret;
+ ret = netcfg_wireless_set_security (client, interface);
+ if (ret == GO_BACK)
+ wifistate = ESSID;
+ else if (ret == REPLY_WPA)
+ wifistate = WPA;
+ else
+ wifistate = WEP;
+ break;
+ }
+ case WEP:
+ wifistate = (netcfg_wireless_set_wep (client, interface) == GO_BACK) ?
+ SECURITY : DONE;
+ break;
+ case WPA:
+ wifistate = (netcfg_set_passphrase (client, interface) == GO_BACK) ?
+ SECURITY : DONE;
+ break;
+ case DONE:
+ return 0;
+ break;
+ case ABORT:
+ return 1;
+ break;
+ }
+ }
+}
/* Here comes another Satan machine. */
int netcfg_activate_dhcp (struct debconfclient *client)
@@ -472,35 +524,10 @@ int netcfg_activate_dhcp (struct debconfclient *client)
}
break;
case REPLY_RECONFIGURE_WIFI:
- {
- /* oh god - a NESTED satan machine */
- enum { ABORT, DONE, ESSID, WEP } wifistate = ESSID;
- for (;;) {
- switch (wifistate) {
- case ESSID:
- wifistate = ( netcfg_wireless_set_essid(client, interface, "high") == GO_BACK ) ?
- ABORT : WEP;
- break;
- case WEP:
- wifistate = ( netcfg_wireless_set_wep (client, interface) == GO_BACK ) ?
- ESSID : DONE;
- break;
- case ABORT:
- state = ASK_OPTIONS;
- break;
- case DONE:
- if (dhcp_pid > 0)
- state = POLL;
- else {
- kill_dhcp_client();
- state = START;
- }
- break;
- }
- if (wifistate == DONE || wifistate == ABORT)
- break;
- }
- }
+ if (!reconfigure_wifi(client))
+ state = START;
+ else
+ state = ASK_OPTIONS;
break;
}
break;
Reply to: