NetworkManager r3451 - in trunk: . src



Author: dcbw
Date: Thu Mar 13 20:52:23 2008
New Revision: 3451
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3451&view=rev

Log:
2008-03-13  Dan Williams  <dcbw redhat com>

	* src/NetworkManagerUtils.c
	  src/NetworkManagerUtils.h
		- (nm_ether_ntop): replacement for iw_ether_ntop()

	* src/NetworkManagerAP.c
	  src/nm-device-802-11-wireless.c
	  src/nm-device-802-3-ethernet.c
		- s/iw_ether_ntop/nm_ether_ntop/g



Modified:
   trunk/ChangeLog
   trunk/src/NetworkManagerAP.c
   trunk/src/NetworkManagerUtils.c
   trunk/src/NetworkManagerUtils.h
   trunk/src/nm-device-802-11-wireless.c
   trunk/src/nm-device-802-3-ethernet.c

Modified: trunk/src/NetworkManagerAP.c
==============================================================================
--- trunk/src/NetworkManagerAP.c	(original)
+++ trunk/src/NetworkManagerAP.c	Thu Mar 13 20:52:23 2008
@@ -162,7 +162,6 @@
 			  GValue *value, GParamSpec *pspec)
 {
 	NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object);
-	char hw_addr_buf[20];
 	GArray * ssid;
 	int len;
 	int i;
@@ -189,9 +188,7 @@
 		g_value_set_uint (value, priv->freq);
 		break;
 	case PROP_HW_ADDRESS:
-		memset (hw_addr_buf, 0, 20);
-		iw_ether_ntop (&priv->address, hw_addr_buf);
-		g_value_set_string (value, &hw_addr_buf[0]);
+		g_value_take_string (value, nm_ether_ntop (&priv->address));
 		break;
 	case PROP_MODE:
 		g_value_set_int (value, priv->mode);

Modified: trunk/src/NetworkManagerUtils.c
==============================================================================
--- trunk/src/NetworkManagerUtils.c	(original)
+++ trunk/src/NetworkManagerUtils.c	Thu Mar 13 20:52:23 2008
@@ -351,3 +351,14 @@
 }
 
 /* End from hostap */
+
+char *
+nm_ether_ntop (const struct ether_addr *mac)
+{
+	/* we like leading zeros */
+	return g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
+	                        mac->ether_addr_octet[0], mac->ether_addr_octet[1],
+	                        mac->ether_addr_octet[2], mac->ether_addr_octet[3],
+	                        mac->ether_addr_octet[4], mac->ether_addr_octet[5]);
+}
+

Modified: trunk/src/NetworkManagerUtils.h
==============================================================================
--- trunk/src/NetworkManagerUtils.h	(original)
+++ trunk/src/NetworkManagerUtils.h	Thu Mar 13 20:52:23 2008
@@ -50,5 +50,7 @@
 
 char *          nm_utils_hexstr2bin (const char *hex, size_t len);
 
+char *nm_ether_ntop (const struct ether_addr *mac);
+
 #endif
 

Modified: trunk/src/nm-device-802-11-wireless.c
==============================================================================
--- trunk/src/nm-device-802-11-wireless.c	(original)
+++ trunk/src/nm-device-802-11-wireless.c	Thu Mar 13 20:52:23 2008
@@ -610,28 +610,27 @@
 		const GByteArray *new_ssid = NULL;
 		const struct ether_addr *old_bssid = NULL;
 		const GByteArray *old_ssid = NULL;
-		gchar new_addr[20];
-		gchar old_addr[20];
+		char *old_addr = NULL, *new_addr = NULL;
 
-		memset (new_addr, '\0', sizeof (new_addr));
 		if (new_ap) {
 			new_bssid = nm_ap_get_address (new_ap);
-			iw_ether_ntop (new_bssid, new_addr);
+			new_addr = nm_ether_ntop (new_bssid);
 			new_ssid = nm_ap_get_ssid (new_ap);
 		}
 
-		memset (old_addr, '\0', sizeof (old_addr));
 		if (priv->current_ap) {
 			old_bssid = nm_ap_get_address (priv->current_ap);
-			iw_ether_ntop (old_bssid, old_addr);
+			old_addr = nm_ether_ntop (old_bssid);
 			old_ssid = nm_ap_get_ssid (priv->current_ap);
 		}
 
 		nm_debug ("Roamed from BSSID %s (%s) to %s (%s)",
-		          old_bssid ? old_addr : "(none)",
+		          old_addr ? old_addr : "(none)",
 		          old_ssid ? nm_utils_escape_ssid (old_ssid->data, old_ssid->len) : "(none)",
-		          new_bssid ? new_addr : "(none)",
+		          new_addr ? new_addr : "(none)",
 		          new_ssid ? nm_utils_escape_ssid (new_ssid->data, new_ssid->len) : "(none)");
+		g_free (old_addr);
+		g_free (new_addr);
 
 		set_current_ap (self, new_ap);
 	}
@@ -2942,14 +2941,11 @@
 	NMDevice80211Wireless *device = NM_DEVICE_802_11_WIRELESS (object);
 	NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (device);
 	struct ether_addr hw_addr;
-	char hw_addr_buf[20];
 
 	switch (prop_id) {
 	case PROP_HW_ADDRESS:
-		memset (hw_addr_buf, 0, 20);
 		nm_device_802_11_wireless_get_address (device, &hw_addr);
-		iw_ether_ntop (&hw_addr, hw_addr_buf);
-		g_value_set_string (value, &hw_addr_buf[0]);
+		g_value_take_string (value, nm_ether_ntop (&hw_addr));
 		break;
 	case PROP_MODE:
 		g_value_set_int (value, nm_device_802_11_wireless_get_mode (device));

Modified: trunk/src/nm-device-802-3-ethernet.c
==============================================================================
--- trunk/src/nm-device-802-3-ethernet.c	(original)
+++ trunk/src/nm-device-802-3-ethernet.c	Thu Mar 13 20:52:23 2008
@@ -714,14 +714,11 @@
 {
 	NMDevice8023Ethernet *device = NM_DEVICE_802_3_ETHERNET (object);
 	struct ether_addr hw_addr;
-	char hw_addr_buf[20];
 
 	switch (prop_id) {
 	case PROP_HW_ADDRESS:
-		memset (hw_addr_buf, 0, 20);
 		nm_device_802_3_ethernet_get_address (device, &hw_addr);
-		iw_ether_ntop (&hw_addr, hw_addr_buf);
-		g_value_set_string (value, &hw_addr_buf[0]);
+		g_value_take_string (value, nm_ether_ntop (&hw_addr));
 		break;
 	case PROP_SPEED:
 		g_value_set_uint (value, nm_device_802_3_ethernet_get_speed (device));



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