device: renew dhcp leases on awake for software devices
[NetworkManager.git] / shared / nm-test-libnm-utils.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /*
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the
15  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  * Boston, MA 02110-1301 USA.
17  *
18  * Copyright 2014 - 2015 Red Hat, Inc.
19  */
20
21 #include "NetworkManager.h"
22
23 #include "nm-test-utils.h"
24
25 /*****************************************************************************/
26
27 typedef struct {
28         GDBusConnection *bus;
29         GDBusProxy *proxy;
30         GPid pid;
31         int keepalive_fd;
32 #if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
33         struct {
34                 DBusGConnection *bus;
35         } libdbus;
36 #endif
37 } NMTstcServiceInfo;
38
39 NMTstcServiceInfo *nmtstc_service_init (void);
40 void nmtstc_service_cleanup (NMTstcServiceInfo *info);
41
42 static inline void _nmtstc_auto_service_cleanup (NMTstcServiceInfo **info)
43 {
44         if (info && *info) {
45                 nmtstc_service_cleanup (*info);
46                 *info = NULL;
47         }
48 }
49
50 #define NMTSTC_SERVICE_INFO_SETUP(sinfo) \
51         NM_PRAGMA_WARNING_DISABLE ("-Wunused-variable") \
52         __attribute__ ((cleanup(_nmtstc_auto_service_cleanup))) NMTstcServiceInfo *sinfo = nmtstc_service_init (); \
53         NM_PRAGMA_WARNING_REENABLE
54
55 /*****************************************************************************/
56
57 #if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB)
58
59 NMDevice *nmtstc_service_add_device (NMTstcServiceInfo *info,
60                                      NMClient *client,
61                                      const char *method,
62                                      const char *ifname);
63
64 NMDevice * nmtstc_service_add_wired_device (NMTstcServiceInfo *sinfo,
65                                             NMClient *client,
66                                             const char *ifname,
67                                             const char *hwaddr,
68                                             const char **subchannels);
69
70 #endif /* NM_NETWORKMANAGER_COMPILATION_LIB */
71
72 #if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
73
74 #include "nm-client.h"
75 #include "nm-remote-settings.h"
76
77 NMClient *nmtstc_nm_client_new (void);
78 NMRemoteSettings *nmtstc_nm_remote_settings_new (void);
79
80 #endif /* NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY */
81
82 void nmtstc_service_add_connection (NMTstcServiceInfo *sinfo,
83                                     NMConnection *connection,
84                                     gboolean verify_connection,
85                                     char **out_path);
86
87 void nmtstc_service_add_connection_variant (NMTstcServiceInfo *sinfo,
88                                             GVariant *connection,
89                                             gboolean verify_connection,
90                                             char **out_path);
91
92 void nmtstc_service_update_connection (NMTstcServiceInfo *sinfo,
93                                        const char *path,
94                                        NMConnection *connection,
95                                        gboolean verify_connection);
96
97 void nmtstc_service_update_connection_variant (NMTstcServiceInfo *sinfo,
98                                                const char *path,
99                                                GVariant *connection,
100                                                gboolean verify_connection);
101