platform: add nm_linux_platform_lookup()

Give a direct access to the cache to lookup values there. This is only
useful for testing.
This commit is contained in:
Thomas Haller
2016-04-13 19:17:11 +02:00
parent d933164087
commit aaa28d4d40
3 changed files with 19 additions and 2 deletions

View File

@@ -3728,6 +3728,16 @@ cache_lookup_link (NMPlatform *platform, int ifindex)
return obj_cache;
}
const NMPlatformObject *const*
nm_linux_platform_lookup (NMPlatform *platform, const NMPCacheId *cache_id, guint *out_len)
{
g_return_val_if_fail (NM_IS_LINUX_PLATFORM (platform), NULL);
g_return_val_if_fail (cache_id, NULL);
return nmp_cache_lookup_multi (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache,
cache_id, out_len);
}
static GArray *
link_get_all (NMPlatform *platform)
{

View File

@@ -52,4 +52,10 @@ NMPlatform *nm_linux_platform_new (gboolean netns_support);
void nm_linux_platform_setup (void);
struct _NMPCacheId;
const NMPlatformObject *const *nm_linux_platform_lookup (NMPlatform *platform,
const struct _NMPCacheId *cache_id,
guint *out_len);
#endif /* __NETWORKMANAGER_LINUX_PLATFORM_H__ */

View File

@@ -95,8 +95,9 @@ typedef enum { /*< skip >*/
} NMPCacheIdType;
typedef struct _NMPObject NMPObject;
typedef struct _NMPCacheId NMPCacheId;
typedef struct {
struct _NMPCacheId {
union {
NMMultiIndexId base;
guint8 _id_type; /* NMPCacheIdType as guint8 */
@@ -136,7 +137,7 @@ typedef struct {
struct in6_addr _misaligned_network;
} routes_by_destination_ip6;
};
} NMPCacheId;
};
extern NMPCacheId _nmp_cache_id_static;
#define NMP_CACHE_ID_STATIC (&_nmp_cache_id_static)