From: Csaba Henk <[email protected]>

- 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.
---
 doc/netconfig.txt               |   14 +++++++++++++-
 libfwnetconfig/libfwnetconfig.c |    9 ++++++---
 libfwnetconfig/libfwnetconfig.h |    1 +
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/doc/netconfig.txt b/doc/netconfig.txt
index 815732a..c46126a 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:
diff --git a/libfwnetconfig/libfwnetconfig.c b/libfwnetconfig/libfwnetconfig.c
index 52abf21..7332dda 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") && ptr)
+                                       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;
 
-- 
1.6.1

_______________________________________________
Frugalware-devel mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-devel

Reply via email to