diff options
author | Dan Winship <danw@gnome.org> | 2014-06-16 11:30:47 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-08-07 15:34:50 -0400 |
commit | 44b9a8708b07626266456922c0bc89836a1cdc38 (patch) | |
tree | 04659ce54ea307efecf49abd08f0494c248648c4 /libnm/nm-device-wimax.c | |
parent | 357efd26e4da4d6dacf2f0c58b41c136b098a253 (diff) | |
download | NetworkManager-44b9a8708b07626266456922c0bc89836a1cdc38.tar.gz |
libnm-core, etc: add nm_utils_hwaddr_matches()
Add nm_utils_hwaddr_matches(), for comparing hardware addresses for
equality, allowing either binary or ASCII hardware addresses to be
passed, and handling the special rules for InfiniBand hardware
addresses automatically. Update code to use it.
Diffstat (limited to 'libnm/nm-device-wimax.c')
-rw-r--r-- | libnm/nm-device-wimax.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/libnm/nm-device-wimax.c b/libnm/nm-device-wimax.c index 95e17e35ba..f842b83c89 100644 --- a/libnm/nm-device-wimax.c +++ b/libnm/nm-device-wimax.c @@ -323,8 +323,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro NMSettingWimax *s_wimax; const char *ctype; const GByteArray *mac; - const char *hw_str; - guint8 hw_mac[ETH_ALEN]; + const char *hw_addr; s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); @@ -344,15 +343,15 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro } /* Check MAC address */ - hw_str = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device)); - if (hw_str) { - if (!nm_utils_hwaddr_aton (hw_str, hw_mac, ETH_ALEN)) { + hw_addr = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device)); + if (hw_addr) { + if (!nm_utils_hwaddr_valid (hw_addr, ETH_ALEN)) { g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC, "Invalid device MAC address."); return FALSE; } mac = nm_setting_wimax_get_mac_address (s_wimax); - if (mac && memcmp (mac->data, hw_mac, ETH_ALEN)) { + if (mac && !nm_utils_hwaddr_matches (mac->data, mac->len, hw_addr, -1)) { g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH, "The MACs of the device and the connection didn't match."); return FALSE; |