summaryrefslogtreecommitdiff
path: root/libnm/nm-device-ethernet.c
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-06-16 11:30:47 -0400
committerDan Winship <danw@gnome.org>2014-08-07 15:34:50 -0400
commit44b9a8708b07626266456922c0bc89836a1cdc38 (patch)
tree04659ce54ea307efecf49abd08f0494c248648c4 /libnm/nm-device-ethernet.c
parent357efd26e4da4d6dacf2f0c58b41c136b098a253 (diff)
downloadNetworkManager-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-ethernet.c')
-rw-r--r--libnm/nm-device-ethernet.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libnm/nm-device-ethernet.c b/libnm/nm-device-ethernet.c
index 4dfdcd840b..65906913ff 100644
--- a/libnm/nm-device-ethernet.c
+++ b/libnm/nm-device-ethernet.c
@@ -169,21 +169,20 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
if (s_wired) {
const GByteArray *mac;
- const char *perm_str;
- guint8 perm_mac[ETH_ALEN];
+ const char *perm_addr;
/* FIXME: filter using s390 subchannels when they are exported over the bus */
/* Check MAC address */
- perm_str = nm_device_ethernet_get_permanent_hw_address (NM_DEVICE_ETHERNET (device));
- if (perm_str) {
- if (!nm_utils_hwaddr_aton (perm_str, perm_mac, ETH_ALEN)) {
+ perm_addr = nm_device_ethernet_get_permanent_hw_address (NM_DEVICE_ETHERNET (device));
+ if (perm_addr) {
+ if (!nm_utils_hwaddr_valid (perm_addr, ETH_ALEN)) {
g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_INVALID_DEVICE_MAC,
"Invalid device MAC address.");
return FALSE;
}
mac = nm_setting_wired_get_mac_address (s_wired);
- if (mac && memcmp (mac->data, perm_mac, ETH_ALEN)) {
+ if (mac && !nm_utils_hwaddr_matches (mac->data, mac->len, perm_addr, -1)) {
g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH,
"The MACs of the device and the connection didn't match.");
return FALSE;