1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#ifndef __NM_CLOUD_SETUP_UTILS_H__
#define __NM_CLOUD_SETUP_UTILS_H__
#include "nm-glib-aux/nm-logging-fwd.h"
/*****************************************************************************/
/* mark names for variables that can be used as configuration. Search
* for NMCS_ENV_VARIABLE() to find all honored environment variables. */
#define NMCS_ENV_VARIABLE(var) "" var ""
/*****************************************************************************/
extern volatile NMLogLevel _nm_logging_configured_level;
static inline gboolean
nm_logging_enabled(NMLogLevel level)
{
return level >= _nm_logging_configured_level;
}
void _nm_logging_enabled_init(const char *level_str);
void _nm_log_impl_cs(NMLogLevel level, const char *fmt, ...) _nm_printf(2, 3);
#define _nm_log(level, ...) _nm_log_impl_cs((level), __VA_ARGS__);
#define _NMLOG(level, ...) \
G_STMT_START \
{ \
const NMLogLevel _level = (level); \
\
if (nm_logging_enabled(_level)) { \
_nm_log(_level, __VA_ARGS__); \
} \
} \
G_STMT_END
/*****************************************************************************/
#ifndef NM_DIST_VERSION
#define NM_DIST_VERSION VERSION
#endif
/*****************************************************************************/
gpointer nmcs_wait_for_objects_register(gpointer target);
gboolean nmcs_wait_for_objects_iterate_until_done(GMainContext *context, int timeout_msec);
/*****************************************************************************/
typedef void (*NMCSUtilsPollProbeStartFcn)(GCancellable * cancellable,
gpointer probe_user_data,
GAsyncReadyCallback callback,
gpointer user_data);
typedef gboolean (*NMCSUtilsPollProbeFinishFcn)(GObject * source,
GAsyncResult *result,
gpointer probe_user_data,
GError ** error);
void nmcs_utils_poll(int poll_timeout_ms,
int ratelimit_timeout_ms,
int sleep_timeout_ms,
NMCSUtilsPollProbeStartFcn probe_start_fcn,
NMCSUtilsPollProbeFinishFcn probe_finish_fcn,
gpointer probe_user_data,
GCancellable * cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean nmcs_utils_poll_finish(GAsyncResult *result, gpointer *probe_user_data, GError **error);
/*****************************************************************************/
char *nmcs_utils_hwaddr_normalize(const char *hwaddr, gssize len);
/*****************************************************************************/
const char *nmcs_utils_parse_memmem(GBytes *mem, const char *needle);
const char *nmcs_utils_parse_get_full_line(GBytes *mem, const char *needle);
/*****************************************************************************/
char *nmcs_utils_uri_build_concat_v(const char *base, const char **components, gsize n_components);
#define nmcs_utils_uri_build_concat(base, ...) \
nmcs_utils_uri_build_concat_v(base, ((const char *[]){__VA_ARGS__}), NM_NARG(__VA_ARGS__))
/*****************************************************************************/
gboolean nmcs_setting_ip_replace_ipv4_addresses(NMSettingIPConfig *s_ip,
NMIPAddress ** entries_arr,
guint entries_len);
gboolean nmcs_setting_ip_replace_ipv4_routes(NMSettingIPConfig *s_ip,
NMIPRoute ** entries_arr,
guint entries_len);
gboolean nmcs_setting_ip_replace_ipv4_rules(NMSettingIPConfig *s_ip,
NMIPRoutingRule ** entries_arr,
guint entries_len);
/*****************************************************************************/
NMConnection *nmcs_device_get_applied_connection(NMDevice * device,
GCancellable *cancellable,
guint64 * version_id,
GError ** error);
gboolean nmcs_device_reapply(NMDevice * device,
GCancellable *sigterm_cancellable,
NMConnection *connection,
guint64 version_id,
gboolean * out_version_id_changed,
GError ** error);
#endif /* __NM_CLOUD_SETUP_UTILS_H__ */
|