Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalwareutils.git;a=commitdiff;h=db55720275c5f446306bec3b85a61ae3ea62d9df

commit db55720275c5f446306bec3b85a61ae3ea62d9df
Author: Csaba Henk <[email protected]>
Date:   Tue Dec 30 02:08:07 2008 +0100

libfwnetconfig: allow hand-written /etc/wpa_supplicant.conf usage

- add a "wpa_supplicant = yes|no" network directive
- when starting interfaces, if "wpa_supplicant = yes" is present,
call wpa_supplicant using the existing /etc/wpa_supplicant.conf
without modifying it.

diff --git a/doc/netconfig.txt b/doc/netconfig.txt
index 815732a..e52f1df 100644
--- a/doc/netconfig.txt
+++ b/doc/netconfig.txt
@@ -118,12 +118,24 @@ be used. If using DHCP, then this directive is ignored.

key = <key>::
Used to manipulate encryption or scrambling keys and security mode for
-       wireless networks. Use this for WEP only, use `wpa_psk` for WPA.
+       wireless networks. Use this for WEP only, use `wpa_psk` or
+       `wpa_supplicant` for WPA.

wpa_psk = <passphrase>::
If this directive is specified, then wpa_supplicant will be invoked to
initialize WPA encryption before setting any other parameter (like ESSID).

+wpa_supplicant = yes|no::
+       If this directive is enabled, then wpa_supplicant will be invoked to
+       initialize WPA encryption before setting any other parameter, but will
+       not do anything else. It is intended to use instead of the `essid` and
+       `wpa_psk` directives if you prefer to write a wpa_supplicant.conf
+       manually.
++
+NOTE: In case you use WPA encryption only with your wireless card, then
+this method has the advantage of not having different network profiles
+for each WPA network, as long as each network has a different essid.
+
wpa_driver = <driver>::
The driver to be used by wpa_supplicant. The default is `wext`. Possible drivers
are:
@@ -199,11 +211,10 @@ the first, and this post_down should be the last one.
=== Using wpa_supplicant

If you want to use wpa_supplicant instead of the simple encryption (using
-key = secret), then use the following pre_up and post_down lines:
+key = secret), then enable this by setting:

----
-pre_up = wpa_supplicant -Dwext -iwlan0 -c /etc/wpa_supplicant.conf -w -B
-post_down = killall wpa_supplicant
+wpa_supplicant = yes
----

You also need to edit `/etc/wpa_supplicant.conf`. A possible correct setup is:
diff --git a/libfwnetconfig/libfwnetconfig.c b/libfwnetconfig/libfwnetconfig.c
index 52abf21..dd79890 100644
--- a/libfwnetconfig/libfwnetconfig.c
+++ b/libfwnetconfig/libfwnetconfig.c
@@ -196,6 +196,8 @@ fwnet_profile_t *fwnet_parseprofile(char *fn)
strncpy(iface->wpa_psk, ptr, PATH_MAX);
if(!strcmp(var, "WPA_DRIVER") && !strlen(iface->wpa_driver))
strncpy(iface->wpa_driver, ptr, PATH_MAX);
+                               if(!strcmp(var, "WPA_SUPPLICANT"))
+                                       iface->wpa_supplicant = (toupper(*ptr) 
== 'Y');
if(!strcmp(var, "GATEWAY") && !strlen(iface->gateway))
strncpy(iface->gateway, ptr, FWNET_GW_MAX_SIZE);
}
@@ -311,7 +313,7 @@ int fwnet_ifdown(fwnet_interface_t *iface, fwnet_profile_t 
*profile)
fwutil_system(ptr);
FWUTIL_FREE(ptr);
}
-       if(strlen(iface->wpa_psk))
+       if(strlen(iface->wpa_psk) || iface->wpa_supplicant)
{
ptr = g_strdup("killall wpa_supplicant");
fwutil_system(ptr);
@@ -426,9 +428,10 @@ int fwnet_ifup(fwnet_interface_t *iface, fwnet_profile_t 
*profile)

dhcp = fwnet_is_dhcp(iface);
// initialize the device
-       if(strlen(iface->wpa_psk))
+       if(strlen(iface->wpa_psk) || iface->wpa_supplicant)
{
-               update_wpa_conf(iface->essid, iface->wpa_psk);
+               if(strlen(iface->wpa_psk))
+                       update_wpa_conf(iface->essid, iface->wpa_psk);
if(strlen(iface->wpa_driver))
ptr = g_strdup_printf("wpa_supplicant -i%s -D%s -c /etc/wpa_supplicant.conf -w 
-B", iface->name, iface->wpa_driver);
else
diff --git a/libfwnetconfig/libfwnetconfig.h b/libfwnetconfig/libfwnetconfig.h
index 2144bcd..b760f5d 100644
--- a/libfwnetconfig/libfwnetconfig.h
+++ b/libfwnetconfig/libfwnetconfig.h
@@ -51,6 +51,7 @@ typedef struct __fwnet_interface_t {
char key[FWNET_ENCODING_TOKEN_MAX+1];
char wpa_psk[PATH_MAX+1];
char wpa_driver[PATH_MAX+1];
+       int wpa_supplicant;
char gateway[FWNET_GW_MAX_SIZE+1];
} fwnet_interface_t;
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to