network-manager-applet r439 - in trunk: . src src/utils



Author: dcbw
Date: Fri Jan 11 22:19:16 2008
New Revision: 439
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=439&view=rev

Log:
2008-01-11  Dan Williams  <dcbw redhat com>

	* src/utils/utils.c
	  src/utils/utils.h
		- (utils_ether_addr_valid): new function

	* src/applet.c
		- (add_seen_bssid): ensure BSSID is valid before saving it



Modified:
   trunk/ChangeLog
   trunk/src/applet.c
   trunk/src/utils/utils.c
   trunk/src/utils/utils.h

Modified: trunk/src/applet.c
==============================================================================
--- trunk/src/applet.c	(original)
+++ trunk/src/applet.c	Fri Jan 11 22:19:16 2008
@@ -2888,7 +2888,7 @@
 		return FALSE;
 
 	bssid = nm_access_point_get_hw_address (ap);
-	if (!bssid)
+	if (!bssid || !utils_ether_addr_valid (ether_aton (bssid)))
 		return FALSE;
 
 	lower_bssid = g_ascii_strdown (bssid, -1);

Modified: trunk/src/utils/utils.c
==============================================================================
--- trunk/src/utils/utils.c	(original)
+++ trunk/src/utils/utils.c	Fri Jan 11 22:19:16 2008
@@ -414,3 +414,38 @@
 	return 0;
 }
 
+/*
+ * utils_ether_addr_valid
+ *
+ * Compares an Ethernet address against known invalid addresses.
+ *
+ */
+gboolean
+utils_ether_addr_valid (const struct ether_addr *test_addr)
+{
+	guint8 invalid_addr1[ETH_ALEN] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+	guint8 invalid_addr2[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+	guint8 invalid_addr3[ETH_ALEN] = {0x44, 0x44, 0x44, 0x44, 0x44, 0x44};
+	guint8 invalid_addr4[ETH_ALEN] = {0x00, 0x30, 0xb4, 0x00, 0x00, 0x00}; /* prism54 dummy MAC */
+
+	g_return_val_if_fail (test_addr != NULL, FALSE);
+
+	/* Compare the AP address the card has with invalid ethernet MAC addresses. */
+	if (!memcmp (test_addr->ether_addr_octet, &invalid_addr1, ETH_ALEN))
+		return FALSE;
+
+	if (!memcmp (test_addr->ether_addr_octet, &invalid_addr2, ETH_ALEN))
+		return FALSE;
+
+	if (!memcmp (test_addr->ether_addr_octet, &invalid_addr3, ETH_ALEN))
+		return FALSE;
+
+	if (!memcmp (test_addr->ether_addr_octet, &invalid_addr4, ETH_ALEN))
+		return FALSE;
+
+	if (test_addr->ether_addr_octet[0] & 1)			/* Multicast addresses */
+		return FALSE;
+	
+	return TRUE;
+}
+

Modified: trunk/src/utils/utils.h
==============================================================================
--- trunk/src/utils/utils.h	(original)
+++ trunk/src/utils/utils.h	Fri Jan 11 22:19:16 2008
@@ -25,6 +25,7 @@
 #include <glib.h>
 #include <nm-connection.h>
 #include <nm-device.h>
+#include <net/ethernet.h>
 
 char * utils_bin2hexstr (const char *bytes, int len, int final_len);
 
@@ -45,5 +46,7 @@
 guint32 utils_channel_to_freq (guint32 channel, char *band);
 guint32 utils_find_next_channel (guint32 channel, int direction, char *band);
 
+gboolean utils_ether_addr_valid (const struct ether_addr *test_addr);
+
 #endif /* UTILS_H */
 



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