Commit 207c0f5f authored by Thomas Haller's avatar Thomas Haller
Browse files

platform: add nm_platform_link_can_assume()

parent a6fb37ba
......@@ -5128,6 +5128,49 @@ wifi_indicate_addressing_running (NMPlatform *platform, int ifindex, gboolean ru
/******************************************************************/
static gboolean
link_can_assume (NMPlatform *platform, int ifindex)
{
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
NMPCacheId cache_id;
const NMPlatformObject *const *objs;
guint i, len;
const NMPObject *link;
if (ifindex <= 0)
return FALSE;
link = cache_lookup_link (platform, ifindex);
if (!link)
return FALSE;
if (!NM_FLAGS_HAS (link->link.n_ifi_flags, IFF_UP))
return FALSE;
if (link->link.master > 0)
return TRUE;
if (nmp_cache_lookup_multi (priv->cache,
nmp_cache_id_init_addrroute_visible_by_ifindex (&cache_id, NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex),
NULL))
return TRUE;
objs = nmp_cache_lookup_multi (priv->cache,
nmp_cache_id_init_addrroute_visible_by_ifindex (&cache_id, NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex),
&len);
if (objs) {
for (i = 0; i < len; i++) {
const NMPlatformIP6Address *a = (NMPlatformIP6Address *) objs[i];
if (!IN6_IS_ADDR_LINKLOCAL (&a->address))
return TRUE;
}
}
return FALSE;
}
/******************************************************************/
static guint32
mesh_get_channel (NMPlatform *platform, int ifindex)
{
......@@ -6218,6 +6261,8 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
platform_class->link_enslave = link_enslave;
platform_class->link_release = link_release;
platform_class->link_can_assume = link_can_assume;
platform_class->vlan_add = vlan_add;
platform_class->link_vlan_change = link_vlan_change;
platform_class->link_vxlan_add = link_vxlan_add;
......
......@@ -1378,6 +1378,18 @@ nm_platform_link_get_master (NMPlatform *self, int slave)
/*****************************************************************************/
gboolean
nm_platform_link_can_assume (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
if (klass->link_can_assume)
return klass->link_can_assume (self, ifindex);
g_return_val_if_reached (FALSE);
}
/*****************************************************************************/
/**
* nm_platform_link_get_lnk:
* @self: the platform instance
......
......@@ -528,6 +528,8 @@ typedef struct {
gboolean (*link_enslave) (NMPlatform *, int master, int slave);
gboolean (*link_release) (NMPlatform *, int master, int slave);
gboolean (*link_can_assume) (NMPlatform *, int ifindex);
gboolean (*vlan_add) (NMPlatform *, const char *name, int parent, int vlanid, guint32 vlanflags, const NMPlatformLink **out_link);
gboolean (*link_vlan_change) (NMPlatform *self,
int ifindex,
......@@ -717,6 +719,8 @@ gboolean nm_platform_link_get_user_ipv6ll_enabled (NMPlatform *self, int ifindex
gconstpointer nm_platform_link_get_address (NMPlatform *self, int ifindex, size_t *length);
int nm_platform_link_get_master (NMPlatform *self, int slave);
gboolean nm_platform_link_can_assume (NMPlatform *self, int ifindex);
gboolean nm_platform_link_get_unmanaged (NMPlatform *self, int ifindex, gboolean *unmanaged);
gboolean nm_platform_link_supports_slaves (NMPlatform *self, int ifindex);
const char *nm_platform_link_get_type_name (NMPlatform *self, int ifindex);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment