[RFC] [PATCH 1/7] Add WPA support to netcfg
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello list,
Here is a new patchset that is hopefully easier for people to
digest and thus comment on, broken down per file. Nothing much has
changed since the last patch except a couple of cleanups and
suggestions from the last patch.
netcfg, remove the nested satan machine, add reconfigure-wifi function
and add wpa options during configuration.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFIEsxZV8GyuTwyskMRAq5lAJ4xCe6gi1JO7G22JZ6VVRRuZqvh7ACfQZCF
Sd5xs7sH5nc/0OIecL2dhhA=
=lGTB
-----END PGP SIGNATURE-----
diff --git a/packages/netcfg/netcfg.c b/packages/netcfg/netcfg.c
index 710327b..1e5745a 100644
--- a/packages/netcfg/netcfg.c
+++ b/packages/netcfg/netcfg.c
@@ -33,6 +33,7 @@
#endif
#include "netcfg.h"
+int requested_wpa_supplicant = 0;
static method_t netcfg_method = DHCP;
response_t netcfg_get_method(struct debconfclient *client)
@@ -61,7 +62,21 @@ response_t netcfg_get_method(struct debconfclient *client)
int main(int argc, char *argv[])
{
int num_interfaces = 0;
- enum { BACKUP, GET_INTERFACE, GET_HOSTNAME_ONLY, GET_METHOD, GET_DHCP, GET_STATIC, WCONFIG, WCONFIG_ESSID, WCONFIG_WEP, QUIT } state = GET_INTERFACE;
+ enum { BACKUP, \
+ GET_INTERFACE, \
+ GET_HOSTNAME_ONLY, \
+ GET_METHOD, \
+ GET_DHCP, \
+ GET_STATIC, \
+ WCONFIG, \
+ WCONFIG_ESSID, \
+ WCONFIG_SECURITY, \
+ WCONFIG_WEP, \
+ WCONFIG_WPA, \
+ QUIT }
+
+ state = GET_INTERFACE;
+
static struct debconfclient *client;
static int requested_wireless_tools = 0;
char **ifaces;
@@ -237,23 +252,49 @@ int main(int argc, char *argv[])
}
state = WCONFIG_ESSID;
break;
-
+
case WCONFIG_ESSID:
- if (netcfg_wireless_set_essid (client, interface, NULL) == GO_BACK)
+ if (netcfg_wireless_set_essid(client, interface, "high") == GO_BACK)
state = BACKUP;
else
- state = WCONFIG_WEP;
+ state = WCONFIG_SECURITY;
break;
+ case WCONFIG_SECURITY:
+ {
+ int ret;
+ ret = netcfg_wireless_set_security(client, interface);
+ if (ret == GO_BACK)
+ state = WCONFIG_ESSID;
+ else if (ret == REPLY_WPA)
+ state = WCONFIG_WPA;
+ else
+ state = WCONFIG_WEP;
+ break;
+ }
+
case WCONFIG_WEP:
- if (netcfg_wireless_set_wep (client, interface) == GO_BACK)
- state = WCONFIG_ESSID;
+ if (netcfg_wireless_set_wep(client, interface) == GO_BACK)
+ state = WCONFIG_SECURITY;
else
state = GET_METHOD;
break;
-
+
+ case WCONFIG_WPA:
+ if (requested_wpa_supplicant == 0) {
+ di_exec_shell_log("apt-install wpasupplicant");
+ requested_wpa_supplicant = 1;
+ }
+
+ if (netcfg_set_passphrase(client, interface) == GO_BACK)
+ state = WCONFIG_SECURITY;
+ else
+ state = GET_METHOD;
+ break;
+
case QUIT:
return 0;
}
}
}
+
diff --git a/packages/netcfg/netcfg.h b/packages/netcfg/netcfg.h
index 5016870..f2aeccb 100644
--- a/packages/netcfg/netcfg.h
+++ b/packages/netcfg/netcfg.h
@@ -10,11 +10,15 @@
#define DHCLIENT3_CONF "/etc/dhcp3/dhclient.conf"
#define DOMAIN_FILE "/tmp/domain_name"
#define NTP_SERVER_FILE "/tmp/dhcp-ntp-servers"
+#define WPASUPP_FILE "/etc/wpa_supplicant/wpa_supplicant.conf"
#define DEVNAMES "/etc/network/devnames"
#define DEVHOTPLUG "/etc/network/devhotplug"
#define STAB "/var/run/stab"
+#define WPA_MIN 8
+#define WPA_MAX 64
+
#define _GNU_SOURCE
#include <sys/types.h>
@@ -41,7 +45,7 @@
"ff02::2 ip6-allrouters\n" \
"ff02::3 ip6-allhosts\n"
-typedef enum { NOT_ASKED = 30, GO_BACK } response_t;
+typedef enum { NOT_ASKED = 30, GO_BACK, REPLY_WEP, REPLY_WPA } response_t;
typedef enum { DHCP, STATIC, DUNNO } method_t;
typedef enum { ADHOC = 1, MANAGED = 2 } wifimode_t;
@@ -49,6 +53,7 @@ extern int netcfg_progress_displayed;
extern int wfd, skfd;
extern int input_result;
extern int have_domain;
+extern int requested_wpa_supplicant;
/* network config */
extern char *interface;
@@ -64,7 +69,7 @@ extern struct in_addr gateway;
extern struct in_addr pointopoint;
/* wireless */
-extern char *essid, *wepkey;
+extern char *essid, *wepkey, *passphrase;
extern wifimode_t mode;
/* common functions */
@@ -111,7 +116,11 @@ extern int is_wireless_iface (const char* iface);
extern int netcfg_wireless_set_essid (struct debconfclient *client, char* iface, char* priority);
extern int netcfg_wireless_set_wep (struct debconfclient *client, char* iface);
+extern int netcfg_wireless_set_security (struct debconfclient *client, char* iface);
+extern int netcfg_set_passphrase (struct debconfclient *client, char* iface);
+extern int netcfg_write_wpa (char *essid, char *passphrase);
+extern int start_wpa_supplicant (struct debconfclient *client);
extern int iface_is_hotpluggable(const char *iface);
extern short find_in_stab (const char *iface);
extern void deconfigure_network(void);
Reply to: