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-bt.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-bt.c')
-rw-r--r-- | libnm/nm-device-bt.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/libnm/nm-device-bt.c b/libnm/nm-device-bt.c index 988811076e..40fc767097 100644 --- a/libnm/nm-device-bt.c +++ b/libnm/nm-device-bt.c @@ -147,8 +147,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro NMSettingBluetooth *s_bt; const char *ctype; const GByteArray *mac; - const char *hw_str; - guint8 hw_mac[ETH_ALEN]; + const char *hw_addr; NMBluetoothCapabilities dev_caps; NMBluetoothCapabilities bt_type; @@ -170,15 +169,15 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro } /* Check BT address */ - hw_str = nm_device_bt_get_hw_address (NM_DEVICE_BT (device)); - if (hw_str) { - if (!nm_utils_hwaddr_aton (hw_str, hw_mac, ETH_ALEN)) { + hw_addr = nm_device_bt_get_hw_address (NM_DEVICE_BT (device)); + if (hw_addr) { + if (!nm_utils_hwaddr_valid (hw_addr, ETH_ALEN)) { g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_INVALID_DEVICE_MAC, "Invalid device MAC address."); return FALSE; } mac = nm_setting_bluetooth_get_bdaddr (s_bt); - 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_BT_ERROR, NM_DEVICE_BT_ERROR_MAC_MISMATCH, "The MACs of the device and the connection didn't match."); return FALSE; |