NetworkManager r3686 - in trunk: . src/supplicant-manager



Author: dcbw
Date: Fri May 23 10:23:17 2008
New Revision: 3686
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3686&view=rev

Log:
2008-05-23  Dan Williams  <dcbw redhat com>

	* src/supplicant-manager/nm-supplicant-settings-verify.c
		- Switch 'bssid' from bytes to keyword type
		- (validate_type_keyword): allow NULL keyword lists

	* src/supplicant-manager/nm-supplicant-config.c
		- (nm_supplicant_config_add_setting_wireless): convert the bssid from
			a byte array to string form, which is what the supplicant expects



Modified:
   trunk/ChangeLog
   trunk/src/supplicant-manager/nm-supplicant-config.c
   trunk/src/supplicant-manager/nm-supplicant-settings-verify.c

Modified: trunk/src/supplicant-manager/nm-supplicant-config.c
==============================================================================
--- trunk/src/supplicant-manager/nm-supplicant-config.c	(original)
+++ trunk/src/supplicant-manager/nm-supplicant-config.c	Fri May 23 10:23:17 2008
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <glib.h>
+#include <netinet/ether.h>
 #include <dbus/dbus-glib.h>
 
 #include "nm-supplicant-config.h"
@@ -323,6 +324,9 @@
 	return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->blobs;
 }
 
+#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
+#define MAC_ARG(x) ((guint8*)(x))[0],((guint8*)(x))[1],((guint8*)(x))[2],((guint8*)(x))[3],((guint8*)(x))[4],((guint8*)(x))[5]
+
 gboolean
 nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
                                            NMSettingWireless * setting,
@@ -383,14 +387,18 @@
 			return FALSE;
 	}
 
-	if (setting->bssid) {
+	if (setting->bssid && setting->bssid->len) {
+		char *str_bssid;
+
+		str_bssid = g_strdup_printf (MAC_FMT, MAC_ARG (setting->bssid->data));
 		if (!nm_supplicant_config_add_option (self, "bssid",
-						      (char *) setting->bssid->data,
-						      setting->bssid->len,
-	 	                                     FALSE)) {
+		                                      str_bssid, strlen (str_bssid),
+		                                      FALSE)) {
+			g_free (str_bssid);
 			nm_warning ("Error adding BSSID to supplicant config.");
 			return FALSE;
 		}
+		g_free (str_bssid);
 	}
 
 	// FIXME: band & channel config items

Modified: trunk/src/supplicant-manager/nm-supplicant-settings-verify.c
==============================================================================
--- trunk/src/supplicant-manager/nm-supplicant-settings-verify.c	(original)
+++ trunk/src/supplicant-manager/nm-supplicant-settings-verify.c	Fri May 23 10:23:17 2008
@@ -83,7 +83,7 @@
 
 static const struct Opt opt_table[] = {
 	{ "ssid",               TYPE_BYTES,   0, 32,FALSE,  NULL },
-	{ "bssid",              TYPE_BYTES,   0, 6, FALSE,  NULL },
+	{ "bssid",              TYPE_KEYWORD, 0, 0, FALSE,  NULL },
 	{ "scan_ssid",          TYPE_INT,     0, 1, FALSE,  NULL },
 	{ "mode",               TYPE_INT,     0, 1, FALSE,  NULL },
 	{ "frequency",          TYPE_INT,     2412, 5825, FALSE,  NULL },
@@ -177,6 +177,10 @@
 	g_return_val_if_fail (opt != NULL, FALSE);
 	g_return_val_if_fail (value != NULL, FALSE);
 
+	/* Allow everything */
+	if (!opt->str_allowed)
+		return TRUE;
+
 	candidates = g_strsplit (value, " ", 0);
 	if (!candidates)
 		goto out;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]