paltform: add type argument to nm_platform_link_get_by_address()

Devices of different link types can actually have the same MAC address.
We'll want to use this to find a device of a particular type by its
hardware address.
This commit is contained in:
Lubomir Rintel
2018-05-24 15:03:40 +02:00
parent 6371f399ae
commit 732b63ffb7
2 changed files with 5 additions and 4 deletions

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Copyright (C) 2012 - 2017 Red Hat, Inc. * Copyright (C) 2012 - 2018 Red Hat, Inc.
*/ */
#include "nm-default.h" #include "nm-default.h"
@@ -807,6 +807,7 @@ _nm_platform_link_get_by_address_match_link (const NMPObject *obj, struct _nm_pl
**/ **/
const NMPlatformLink * const NMPlatformLink *
nm_platform_link_get_by_address (NMPlatform *self, nm_platform_link_get_by_address (NMPlatform *self,
NMLinkType link_type,
gconstpointer address, gconstpointer address,
size_t length) size_t length)
{ {
@@ -827,7 +828,7 @@ nm_platform_link_get_by_address (NMPlatform *self,
g_return_val_if_reached (NULL); g_return_val_if_reached (NULL);
obj = nmp_cache_lookup_link_full (nm_platform_get_cache (self), obj = nmp_cache_lookup_link_full (nm_platform_get_cache (self),
0, NULL, TRUE, NM_LINK_TYPE_NONE, 0, NULL, TRUE, link_type,
(NMPObjectMatchFn) _nm_platform_link_get_by_address_match_link, &d); (NMPObjectMatchFn) _nm_platform_link_get_by_address_match_link, &d);
return NMP_OBJECT_CAST_LINK (obj); return NMP_OBJECT_CAST_LINK (obj);
} }

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Copyright (C) 2009 - 2017 Red Hat, Inc. * Copyright (C) 2009 - 2018 Red Hat, Inc.
*/ */
#ifndef __NETWORKMANAGER_PLATFORM_H__ #ifndef __NETWORKMANAGER_PLATFORM_H__
@@ -1079,7 +1079,7 @@ const NMPObject *nm_platform_link_get_obj (NMPlatform *self,
gboolean visible_only); gboolean visible_only);
const NMPlatformLink *nm_platform_link_get (NMPlatform *self, int ifindex); const NMPlatformLink *nm_platform_link_get (NMPlatform *self, int ifindex);
const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const char *ifname); const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const char *ifname);
const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, gconstpointer address, size_t length); const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, NMLinkType link_type, gconstpointer address, size_t length);
GPtrArray *nm_platform_link_get_all (NMPlatform *self, gboolean sort_by_name); GPtrArray *nm_platform_link_get_all (NMPlatform *self, gboolean sort_by_name);
NMPlatformError nm_platform_link_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link); NMPlatformError nm_platform_link_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);