diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index ffaa094cb9..2a461543b0 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -286,30 +286,6 @@ is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) /*****************************************************************************/ -static gboolean -match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr) -{ - NMSettingWired *s_wired; - NMDevice *parent_device; - const char *setting_mac; - const char *parent_mac; - - s_wired = nm_connection_get_setting_wired (connection); - if (!s_wired) - return !fail_if_no_hwaddr; - - setting_mac = nm_setting_wired_get_mac_address (s_wired); - if (!setting_mac) - return !fail_if_no_hwaddr; - - parent_device = nm_device_parent_get_device (device); - if (!parent_device) - return !fail_if_no_hwaddr; - - parent_mac = nm_device_get_permanent_hw_address (parent_device); - return parent_mac && nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1); -} - static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) { @@ -343,7 +319,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) return FALSE; } else { /* Parent could be a MAC address in an NMSettingWired */ - if (!match_hwaddr (device, connection, TRUE)) + if (!nm_device_match_hwaddr (device, connection, TRUE)) return FALSE; } } @@ -380,7 +356,7 @@ complete_connection (NMDevice *device, * settings, then there's not enough information to complete the setting. */ if ( !nm_setting_macvlan_get_parent (s_macvlan) - && !match_hwaddr (device, connection, TRUE)) { + && !nm_device_match_hwaddr (device, connection, TRUE)) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, "The 'macvlan' setting had no interface name, parent, or hardware address."); return FALSE; diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h index f3c301d48e..416ae845c8 100644 --- a/src/devices/nm-device-private.h +++ b/src/devices/nm-device-private.h @@ -133,5 +133,8 @@ gboolean _nm_device_hash_check_invalid_keys (GHashTable *hash, const char *setti _nm_device_hash_check_invalid_keys (hash, setting_name, error, ((const char *[]) { __VA_ARGS__, NULL })) gboolean nm_device_match_parent (NMDevice *device, const char *parent); +gboolean nm_device_match_hwaddr (NMDevice *device, + NMConnection *connection, + gboolean fail_if_no_hwaddr); #endif /* NM_DEVICE_PRIVATE_H */ diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 0badfd2852..06f19c408c 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -314,30 +314,6 @@ is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) /*****************************************************************************/ -static gboolean -match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr) -{ - NMSettingWired *s_wired; - NMDevice *parent_device; - const char *setting_mac; - const char *parent_mac; - - s_wired = nm_connection_get_setting_wired (connection); - if (!s_wired) - return !fail_if_no_hwaddr; - - setting_mac = nm_setting_wired_get_mac_address (s_wired); - if (!setting_mac) - return !fail_if_no_hwaddr; - - parent_device = nm_device_parent_get_device (device); - if (!parent_device) - return !fail_if_no_hwaddr; - - parent_mac = nm_device_get_permanent_hw_address (parent_device); - return parent_mac && nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1); -} - static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) { @@ -364,7 +340,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) return FALSE; } else { /* Parent could be a MAC address in an NMSettingWired */ - if (!match_hwaddr (device, connection, TRUE)) + if (!nm_device_match_hwaddr (device, connection, TRUE)) return FALSE; } } @@ -413,7 +389,7 @@ complete_connection (NMDevice *device, * settings, then there's not enough information to complete the setting. */ if ( !nm_setting_vlan_get_parent (s_vlan) - && !match_hwaddr (device, connection, TRUE)) { + && !nm_device_match_hwaddr (device, connection, TRUE)) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, "The 'vlan' setting had no interface name, parent, or hardware address."); return FALSE; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 76b7e28b40..71cdead330 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4422,6 +4422,32 @@ nm_device_match_parent (NMDevice *self, const char *parent) return TRUE; } +gboolean +nm_device_match_hwaddr (NMDevice *device, + NMConnection *connection, + gboolean fail_if_no_hwaddr) +{ + NMSettingWired *s_wired; + NMDevice *parent_device; + const char *setting_mac; + const char *parent_mac; + + s_wired = nm_connection_get_setting_wired (connection); + if (!s_wired) + return !fail_if_no_hwaddr; + + setting_mac = nm_setting_wired_get_mac_address (s_wired); + if (!setting_mac) + return !fail_if_no_hwaddr; + + parent_device = nm_device_parent_get_device (device); + if (!parent_device) + return !fail_if_no_hwaddr; + + parent_mac = nm_device_get_permanent_hw_address (parent_device); + return parent_mac && nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1); +} + static gboolean check_connection_compatible (NMDevice *self, NMConnection *connection) {