mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-20 00:21:29 +00:00
core: simplify nm_device_spec_match_list()
Since NMDevice has a generic get_hw_address() method now, it can do nm_device_spec_match_list() itself (for everything except ethernet, which needs to match against s390 subchannels too). https://bugzilla.gnome.org/show_bug.cgi?id=693684
This commit is contained in:
parent
1a8790b2a0
commit
a3f6af817b
|
@ -223,20 +223,6 @@ complete_connection (NMDevice *device,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
spec_match_list (NMDevice *device, const GSList *specs)
|
||||
{
|
||||
NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE (device);
|
||||
char *hwaddr;
|
||||
gboolean matched;
|
||||
|
||||
hwaddr = nm_utils_hwaddr_ntoa (priv->hw_addr, nm_utils_hwaddr_type (priv->hw_addr_len));
|
||||
matched = nm_match_spec_hwaddr (specs, hwaddr);
|
||||
g_free (hwaddr);
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
bond_match_config (NMDevice *self, NMConnection *connection)
|
||||
{
|
||||
|
@ -462,7 +448,6 @@ nm_device_bond_class_init (NMDeviceBondClass *klass)
|
|||
parent_class->check_connection_compatible = check_connection_compatible;
|
||||
parent_class->complete_connection = complete_connection;
|
||||
|
||||
parent_class->spec_match_list = spec_match_list;
|
||||
parent_class->connection_match_config = connection_match_config;
|
||||
|
||||
parent_class->act_stage1_prepare = act_stage1_prepare;
|
||||
|
|
|
@ -225,20 +225,6 @@ complete_connection (NMDevice *device,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
spec_match_list (NMDevice *device, const GSList *specs)
|
||||
{
|
||||
NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (device);
|
||||
char *hwaddr;
|
||||
gboolean matched;
|
||||
|
||||
hwaddr = nm_utils_hwaddr_ntoa (priv->hw_addr, nm_utils_hwaddr_type (priv->hw_addr_len));
|
||||
matched = nm_match_spec_hwaddr (specs, hwaddr);
|
||||
g_free (hwaddr);
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
bridge_match_config (NMDevice *self, NMConnection *connection)
|
||||
{
|
||||
|
@ -518,7 +504,6 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass)
|
|||
parent_class->check_connection_compatible = check_connection_compatible;
|
||||
parent_class->complete_connection = complete_connection;
|
||||
|
||||
parent_class->spec_match_list = spec_match_list;
|
||||
parent_class->connection_match_config = connection_match_config;
|
||||
|
||||
parent_class->act_stage1_prepare = act_stage1_prepare;
|
||||
|
|
|
@ -1352,17 +1352,11 @@ static gboolean
|
|||
spec_match_list (NMDevice *device, const GSList *specs)
|
||||
{
|
||||
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
|
||||
char *hwaddr;
|
||||
gboolean matched;
|
||||
|
||||
hwaddr = nm_utils_hwaddr_ntoa (&priv->perm_hw_addr, ARPHRD_ETHER);
|
||||
matched = nm_match_spec_hwaddr (specs, hwaddr);
|
||||
g_free (hwaddr);
|
||||
if (priv->subchannels && nm_match_spec_s390_subchannels (specs, priv->subchannels))
|
||||
return TRUE;
|
||||
|
||||
if (!matched && priv->subchannels)
|
||||
matched = nm_match_spec_s390_subchannels (specs, priv->subchannels);
|
||||
|
||||
return matched;
|
||||
return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->spec_match_list (device, specs);
|
||||
}
|
||||
|
||||
static NMConnection *
|
||||
|
|
|
@ -332,20 +332,6 @@ complete_connection (NMDevice *device,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
spec_match_list (NMDevice *device, const GSList *specs)
|
||||
{
|
||||
NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (device);
|
||||
char *hwaddr;
|
||||
gboolean matched;
|
||||
|
||||
hwaddr = nm_utils_hwaddr_ntoa (priv->hw_addr, ARPHRD_INFINIBAND);
|
||||
matched = nm_match_spec_hwaddr (specs, hwaddr);
|
||||
g_free (hwaddr);
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
infiniband_match_config (NMDevice *self, NMConnection *connection)
|
||||
{
|
||||
|
@ -476,7 +462,6 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass)
|
|||
|
||||
parent_class->act_stage1_prepare = act_stage1_prepare;
|
||||
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
||||
parent_class->spec_match_list = spec_match_list;
|
||||
parent_class->connection_match_config = connection_match_config;
|
||||
parent_class->hwaddr_matches = hwaddr_matches;
|
||||
|
||||
|
|
|
@ -354,21 +354,6 @@ complete_connection (NMDevice *device,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
spec_match_list (NMDevice *device, const GSList *specs)
|
||||
{
|
||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
|
||||
char *hwaddr;
|
||||
gboolean matched;
|
||||
int itype = nm_utils_hwaddr_type (priv->hw_addr_len);
|
||||
|
||||
hwaddr = nm_utils_hwaddr_ntoa (priv->hw_addr, itype);
|
||||
matched = nm_match_spec_hwaddr (specs, hwaddr);
|
||||
g_free (hwaddr);
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
vlan_match_config (NMDevice *device, NMConnection *connection)
|
||||
{
|
||||
|
@ -673,7 +658,6 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
|
|||
parent_class->get_best_auto_connection = get_best_auto_connection;
|
||||
parent_class->check_connection_compatible = check_connection_compatible;
|
||||
parent_class->complete_connection = complete_connection;
|
||||
parent_class->spec_match_list = spec_match_list;
|
||||
parent_class->connection_match_config = connection_match_config;
|
||||
|
||||
/* properties */
|
||||
|
|
|
@ -3427,20 +3427,6 @@ get_type_capabilities (NMDevice *dev)
|
|||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
spec_match_list (NMDevice *device, const GSList *specs)
|
||||
{
|
||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
|
||||
char *hwaddr;
|
||||
gboolean matched;
|
||||
|
||||
hwaddr = nm_utils_hwaddr_ntoa (&priv->perm_hw_addr, ARPHRD_ETHER);
|
||||
matched = nm_match_spec_hwaddr (specs, hwaddr);
|
||||
g_free (hwaddr);
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
hwaddr_matches (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
|
@ -3779,7 +3765,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
|
|||
parent_class->act_stage4_ip6_config_timeout = act_stage4_ip6_config_timeout;
|
||||
parent_class->deactivate = deactivate;
|
||||
parent_class->can_interrupt_activation = can_interrupt_activation;
|
||||
parent_class->spec_match_list = spec_match_list;
|
||||
parent_class->hwaddr_matches = hwaddr_matches;
|
||||
|
||||
parent_class->state_changed = device_state_changed;
|
||||
|
|
|
@ -284,6 +284,8 @@ static gboolean nm_device_activate_ip6_config_commit (gpointer user_data);
|
|||
|
||||
static gboolean check_connection_available (NMDevice *device, NMConnection *connection);
|
||||
|
||||
static gboolean spec_match_list (NMDevice *device, const GSList *specs);
|
||||
|
||||
static void _clear_available_connections (NMDevice *device, gboolean do_signal);
|
||||
|
||||
static void dhcp4_cleanup (NMDevice *self, gboolean stop, gboolean release);
|
||||
|
@ -4745,6 +4747,7 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
klass->act_stage4_ip6_config_timeout = act_stage4_ip6_config_timeout;
|
||||
klass->have_any_ready_slaves = have_any_ready_slaves;
|
||||
|
||||
klass->spec_match_list = spec_match_list;
|
||||
klass->check_connection_available = check_connection_available;
|
||||
klass->hw_is_up = hw_is_up;
|
||||
klass->hw_bring_up = hw_bring_up;
|
||||
|
@ -5470,6 +5473,22 @@ nm_device_spec_match_list (NMDevice *device, const GSList *specs)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
spec_match_list (NMDevice *device, const GSList *specs)
|
||||
{
|
||||
const guint8 *hwaddr;
|
||||
guint hwaddr_len = 0;
|
||||
char *hwaddr_str;
|
||||
gboolean matched;
|
||||
|
||||
hwaddr = nm_device_get_hw_address (device, &hwaddr_len);
|
||||
hwaddr_str = nm_utils_hwaddr_ntoa (hwaddr, nm_utils_hwaddr_type (hwaddr_len));
|
||||
matched = nm_match_spec_hwaddr (specs, hwaddr_str);
|
||||
g_free (hwaddr_str);
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ip4_match_config (NMDevice *self, NMConnection *connection)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue