2019-09-10 11:19:01 +02:00
|
|
|
// SPDX-License-Identifier: LGPL-2.1+
|
2014-07-31 13:32:10 -04:00
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 2014 - 2015 Red Hat, Inc.
|
2014-07-31 13:32:10 -04:00
|
|
|
*/
|
|
|
|
|
|
2020-05-06 23:06:36 +02:00
|
|
|
#ifndef __NM_TEST_LIBNM_UTILS_H__
|
|
|
|
|
#define __NM_TEST_LIBNM_UTILS_H__
|
|
|
|
|
|
2015-12-21 10:22:33 +01:00
|
|
|
#include "NetworkManager.h"
|
2014-07-31 13:32:10 -04:00
|
|
|
|
2016-06-15 15:29:10 +02:00
|
|
|
#include "nm-utils/nm-test-utils.h"
|
2015-12-20 21:59:13 +01:00
|
|
|
|
2014-07-31 13:32:10 -04:00
|
|
|
typedef struct {
|
2020-09-28 16:03:33 +02:00
|
|
|
GDBusConnection *bus;
|
|
|
|
|
GDBusProxy * proxy;
|
|
|
|
|
GPid pid;
|
|
|
|
|
int keepalive_fd;
|
2015-12-21 10:22:33 +01:00
|
|
|
} NMTstcServiceInfo;
|
2014-07-31 13:32:10 -04:00
|
|
|
|
2020-09-28 16:03:33 +02:00
|
|
|
NMTstcServiceInfo *nmtstc_service_init(void);
|
|
|
|
|
void nmtstc_service_cleanup(NMTstcServiceInfo *info);
|
|
|
|
|
NMTstcServiceInfo *nmtstc_service_available(NMTstcServiceInfo *info);
|
2015-12-20 16:43:01 +01:00
|
|
|
|
2020-09-28 16:03:33 +02:00
|
|
|
static inline void
|
|
|
|
|
_nmtstc_auto_service_cleanup(NMTstcServiceInfo **info)
|
2015-12-21 10:55:38 +01:00
|
|
|
{
|
2020-09-28 16:03:33 +02:00
|
|
|
nmtstc_service_cleanup(g_steal_pointer(info));
|
2015-12-21 10:55:38 +01:00
|
|
|
}
|
2018-06-25 11:28:50 +02:00
|
|
|
#define nmtstc_auto_service_cleanup nm_auto(_nmtstc_auto_service_cleanup)
|
|
|
|
|
|
2020-09-28 16:03:33 +02:00
|
|
|
#define NMTSTC_SERVICE_INFO_SETUP(sinfo) \
|
|
|
|
|
NM_PRAGMA_WARNING_DISABLE("-Wunused-variable") \
|
|
|
|
|
nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = ({ \
|
|
|
|
|
NMTstcServiceInfo *_sinfo; \
|
|
|
|
|
\
|
|
|
|
|
_sinfo = nmtstc_service_init(); \
|
|
|
|
|
if (!nmtstc_service_available(_sinfo)) \
|
|
|
|
|
return; \
|
|
|
|
|
_sinfo; \
|
|
|
|
|
}); \
|
|
|
|
|
NM_PRAGMA_WARNING_REENABLE
|
|
|
|
|
|
|
|
|
|
NMDevice *nmtstc_service_add_device(NMTstcServiceInfo *info,
|
|
|
|
|
NMClient * client,
|
|
|
|
|
const char * method,
|
|
|
|
|
const char * ifname);
|
|
|
|
|
|
|
|
|
|
NMDevice *nmtstc_service_add_wired_device(NMTstcServiceInfo *sinfo,
|
|
|
|
|
NMClient * client,
|
|
|
|
|
const char * ifname,
|
|
|
|
|
const char * hwaddr,
|
|
|
|
|
const char ** subchannels);
|
|
|
|
|
|
|
|
|
|
void nmtstc_service_add_connection(NMTstcServiceInfo *sinfo,
|
|
|
|
|
NMConnection * connection,
|
|
|
|
|
gboolean verify_connection,
|
|
|
|
|
char ** out_path);
|
|
|
|
|
|
|
|
|
|
void nmtstc_service_add_connection_variant(NMTstcServiceInfo *sinfo,
|
|
|
|
|
GVariant * connection,
|
|
|
|
|
gboolean verify_connection,
|
|
|
|
|
char ** out_path);
|
|
|
|
|
|
|
|
|
|
void nmtstc_service_update_connection(NMTstcServiceInfo *sinfo,
|
|
|
|
|
const char * path,
|
|
|
|
|
NMConnection * connection,
|
|
|
|
|
gboolean verify_connection);
|
|
|
|
|
|
|
|
|
|
void nmtstc_service_update_connection_variant(NMTstcServiceInfo *sinfo,
|
|
|
|
|
const char * path,
|
|
|
|
|
GVariant * connection,
|
|
|
|
|
gboolean verify_connection);
|
|
|
|
|
|
|
|
|
|
gpointer nmtstc_context_object_new_valist(GType gtype,
|
|
|
|
|
gboolean allow_iterate_main_context,
|
|
|
|
|
const char *first_property_name,
|
|
|
|
|
va_list var_args);
|
|
|
|
|
|
|
|
|
|
gpointer nmtstc_context_object_new(GType gtype,
|
|
|
|
|
gboolean allow_iterate_main_context,
|
|
|
|
|
const char *first_property_name,
|
|
|
|
|
...);
|
2020-01-03 08:34:20 +01:00
|
|
|
|
|
|
|
|
static inline NMClient *
|
2020-09-28 16:03:33 +02:00
|
|
|
nmtstc_client_new(gboolean allow_iterate_main_context)
|
2020-01-03 08:34:20 +01:00
|
|
|
{
|
2020-09-28 16:03:33 +02:00
|
|
|
return nmtstc_context_object_new(NM_TYPE_CLIENT, allow_iterate_main_context, NULL);
|
2020-01-03 08:34:20 +01:00
|
|
|
}
|
2020-05-06 23:06:36 +02:00
|
|
|
|
|
|
|
|
#endif /* __NM_TEST_LIBNM_UTILS_H__ */
|