2007-08-14 Dan Williams <dcbw@redhat.com>

* src/NetworkManagerUtils.c
		- (nm_utils_escape_ssid): add "ignore_trailing_null" parameter which
			ignores trailing nulls in the SSID to work around mismatches in
			expectations between WEXT and what the info-daemon passes back.  The
			info-daemon would pass back the correct length, but due to the
			ESSID length issues with WEXT 22 and greater and wpa_supplicant,
			the device would always have an SSID + 1 depending on what versions
			of wpa_supplicant, the kernel, and NM you have.  This was most often
			visible by just quitting the applet and relaunching, which caused
			NM to reassociated to the same network over again when reloading
			the save networks.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2685 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2007-08-15 01:56:02 +00:00
parent 66c11dd988
commit ccb13f0bdd
5 changed files with 29 additions and 13 deletions

View File

@@ -174,7 +174,7 @@ nm_ap_list_remove_ap_by_ssid (NMAccessPointList *list, const GByteArray * ssid)
for (elt = list->ap_list; elt; elt = g_slist_next (elt)) { for (elt = list->ap_list; elt; elt = g_slist_next (elt)) {
NMAccessPoint * list_ap = (NMAccessPoint *) elt->data; NMAccessPoint * list_ap = (NMAccessPoint *) elt->data;
if (nm_utils_same_ssid (nm_ap_get_ssid (list_ap), ssid)) { if (nm_utils_same_ssid (nm_ap_get_ssid (list_ap), ssid, TRUE)) {
list->ap_list = g_slist_remove_link (list->ap_list, elt); list->ap_list = g_slist_remove_link (list->ap_list, elt);
g_object_unref (list_ap); g_object_unref (list_ap);
g_slist_free (elt); g_slist_free (elt);
@@ -209,7 +209,7 @@ void nm_ap_list_remove_duplicate_ssids (NMAccessPointList *list)
NMAccessPoint * list_ap_j = (NMAccessPoint *) elt_j->data; NMAccessPoint * list_ap_j = (NMAccessPoint *) elt_j->data;
const GByteArray * list_ap_j_ssid = nm_ap_get_ssid (list_ap_j); const GByteArray * list_ap_j_ssid = nm_ap_get_ssid (list_ap_j);
if ((found = nm_utils_same_ssid (list_ap_i_ssid, list_ap_j_ssid))) if ((found = nm_utils_same_ssid (list_ap_i_ssid, list_ap_j_ssid, TRUE)))
break; break;
} }
@@ -225,7 +225,7 @@ void nm_ap_list_remove_duplicate_ssids (NMAccessPointList *list)
const GByteArray * list_ap_j_ssid = nm_ap_get_ssid (list_ap_j); const GByteArray * list_ap_j_ssid = nm_ap_get_ssid (list_ap_j);
strengthj = nm_ap_get_strength (list_ap_j); strengthj = nm_ap_get_strength (list_ap_j);
if (nm_utils_same_ssid (list_ap_i_ssid, list_ap_j_ssid)) { if (nm_utils_same_ssid (list_ap_i_ssid, list_ap_j_ssid, TRUE)) {
if (strengthj > max_strength) { if (strengthj > max_strength) {
removal_list = g_slist_append (removal_list, list_ap_max); removal_list = g_slist_append (removal_list, list_ap_max);
list_ap_max = list_ap_j; list_ap_max = list_ap_j;
@@ -267,7 +267,7 @@ nm_ap_list_get_ap_by_ssid (NMAccessPointList *list, const GByteArray * ssid)
while ((ap = nm_ap_list_iter_next (iter))) { while ((ap = nm_ap_list_iter_next (iter))) {
const GByteArray * ap_ssid = nm_ap_get_ssid (ap); const GByteArray * ap_ssid = nm_ap_get_ssid (ap);
if (ap_ssid && nm_utils_same_ssid (ap_ssid, ssid)) { if (ap_ssid && nm_utils_same_ssid (ap_ssid, ssid, TRUE)) {
found_ap = ap; found_ap = ap;
break; break;
} }

View File

@@ -322,7 +322,7 @@ nm_policy_device_change_check (gpointer user_data)
* link to the old access point. We don't switch away * link to the old access point. We don't switch away
* from Ad-Hoc APs either. * from Ad-Hoc APs either.
*/ */
gboolean same_ssid = nm_utils_same_ssid (old_ssid, new_ssid); gboolean same_ssid = nm_utils_same_ssid (old_ssid, new_ssid, TRUE);
/* If the "best" AP's SSID is the same as the current activation /* If the "best" AP's SSID is the same as the current activation
* request's SSID, but the current activation request isn't * request's SSID, but the current activation request isn't

View File

@@ -625,14 +625,28 @@ nm_utils_escape_ssid (const char * ssid, guint32 len)
} }
gboolean gboolean
nm_utils_same_ssid (const GByteArray * ssid1, const GByteArray * ssid2) nm_utils_same_ssid (const GByteArray * ssid1,
const GByteArray * ssid2,
gboolean ignore_trailing_null)
{ {
guint32 ssid1_len, ssid2_len;
if (ssid1 == ssid2) if (ssid1 == ssid2)
return TRUE; return TRUE;
if ((ssid1 && !ssid2) || (!ssid1 && ssid2)) if ((ssid1 && !ssid2) || (!ssid1 && ssid2))
return FALSE; return FALSE;
if (ssid1->len != ssid2->len)
ssid1_len = ssid1->len;
ssid2_len = ssid2->len;
if (ssid1_len && ssid2_len && ignore_trailing_null) {
if (ssid1->data[ssid1_len - 1] == '\0')
ssid1_len--;
if (ssid2->data[ssid2_len - 1] == '\0')
ssid2_len--;
}
if (ssid1_len != ssid2_len)
return FALSE; return FALSE;
return memcmp (ssid1->data, ssid2->data, ssid1->len) == 0 ? TRUE : FALSE; return memcmp (ssid1->data, ssid2->data, ssid1_len) == 0 ? TRUE : FALSE;
} }

View File

@@ -109,6 +109,8 @@ int nm_utils_ip4_netmask_to_prefix (guint32 ip4_netmask);
gboolean nm_utils_is_empty_ssid (const char * ssid, int len); gboolean nm_utils_is_empty_ssid (const char * ssid, int len);
const char * nm_utils_escape_ssid (const char *ssid, guint32 len); const char * nm_utils_escape_ssid (const char *ssid, guint32 len);
gboolean nm_utils_same_ssid (const GByteArray * ssid1, const GByteArray * ssid2); gboolean nm_utils_same_ssid (const GByteArray * ssid1,
const GByteArray * ssid2,
gboolean ignore_trailing_null);
#endif #endif

View File

@@ -224,7 +224,7 @@ nm_device_802_11_wireless_update_bssid (NMDevice80211Wireless *self,
if ( nm_ethernet_address_is_valid (&new_bssid) if ( nm_ethernet_address_is_valid (&new_bssid)
&& nm_ethernet_address_is_valid (old_bssid) && nm_ethernet_address_is_valid (old_bssid)
&& !nm_ethernet_addresses_are_equal (&new_bssid, old_bssid) && !nm_ethernet_addresses_are_equal (&new_bssid, old_bssid)
&& nm_utils_same_ssid (old_ssid, new_ssid)) && nm_utils_same_ssid (old_ssid, new_ssid, TRUE))
{ {
gboolean automatic; gboolean automatic;
gchar new_addr[20]; gchar new_addr[20];
@@ -729,7 +729,7 @@ link_to_specific_ap (NMDevice80211Wireless *self,
const GByteArray * dev_ssid = nm_device_802_11_wireless_get_ssid (self); const GByteArray * dev_ssid = nm_device_802_11_wireless_get_ssid (self);
const GByteArray * ap_ssid = nm_ap_get_ssid (ap); const GByteArray * ap_ssid = nm_ap_get_ssid (ap);
if (dev_ssid && ap_ssid && nm_utils_same_ssid (dev_ssid, ap_ssid)) { if (dev_ssid && ap_ssid && nm_utils_same_ssid (dev_ssid, ap_ssid, TRUE)) {
self->priv->failed_link_count = 0; self->priv->failed_link_count = 0;
have_link = TRUE; have_link = TRUE;
} }
@@ -1936,7 +1936,7 @@ merge_scanned_ap (NMDevice80211Wireless *dev,
/* Did the AP's name change? */ /* Did the AP's name change? */
if ( !devlist_ssid if ( !devlist_ssid
|| !merge_ssid || !merge_ssid
|| !nm_utils_same_ssid (devlist_ssid, merge_ssid)) { || !nm_utils_same_ssid (devlist_ssid, merge_ssid, TRUE)) {
network_removed (dev, list_ap); network_removed (dev, list_ap);
nm_ap_set_ssid (list_ap, merge_ssid); nm_ap_set_ssid (list_ap, merge_ssid);
network_added (dev, list_ap); network_added (dev, list_ap);
@@ -2011,7 +2011,7 @@ cull_scan_list (NMDevice80211Wireless * self)
/* Don't ever prune the AP we're currently associated with */ /* Don't ever prune the AP we're currently associated with */
ssid = nm_ap_get_ssid (outdated_ap); ssid = nm_ap_get_ssid (outdated_ap);
cur_ssid = cur_ap ? nm_ap_get_ssid (cur_ap) : NULL; cur_ssid = cur_ap ? nm_ap_get_ssid (cur_ap) : NULL;
if (ssid && nm_utils_same_ssid (cur_ssid, ssid)) if (ssid && nm_utils_same_ssid (cur_ssid, ssid, TRUE))
keep_around = TRUE; keep_around = TRUE;
prune_interval_s = SCAN_INTERVAL_MAX * 3; prune_interval_s = SCAN_INTERVAL_MAX * 3;