all/systemd: reformat ./{shared,src}/systemd/ with new clang-format style
./contrib/scripts/nm-code-format.sh -i
This commit is contained in:
@@ -10,31 +10,27 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_nm_log_enabled_impl (gboolean mt_require_locking,
|
_nm_log_enabled_impl(gboolean mt_require_locking, NMLogLevel level, NMLogDomain domain)
|
||||||
NMLogLevel level,
|
|
||||||
NMLogDomain domain)
|
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_nm_log_impl (const char *file,
|
_nm_log_impl(const char *file,
|
||||||
guint line,
|
guint line,
|
||||||
const char *func,
|
const char *func,
|
||||||
gboolean mt_require_locking,
|
gboolean mt_require_locking,
|
||||||
NMLogLevel level,
|
NMLogLevel level,
|
||||||
NMLogDomain domain,
|
NMLogDomain domain,
|
||||||
int error,
|
int error,
|
||||||
const char *ifname,
|
const char *ifname,
|
||||||
const char *con_uuid,
|
const char *con_uuid,
|
||||||
const char *fmt,
|
const char *fmt,
|
||||||
...)
|
...)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_nm_utils_monotonic_timestamp_initialized (const struct timespec *tp,
|
_nm_utils_monotonic_timestamp_initialized(const struct timespec *tp,
|
||||||
gint64 offset_sec,
|
gint64 offset_sec,
|
||||||
gboolean is_boottime)
|
gboolean is_boottime)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
@@ -22,32 +22,31 @@ const bool mempool_use_allowed = true;
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nm_sd_utils_path_equal (const char *a, const char *b)
|
nm_sd_utils_path_equal(const char *a, const char *b)
|
||||||
{
|
{
|
||||||
return path_equal (a, b);
|
return path_equal(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
nm_sd_utils_path_simplify (char *path, gboolean kill_dots)
|
nm_sd_utils_path_simplify(char *path, gboolean kill_dots)
|
||||||
{
|
{
|
||||||
return path_simplify (path, kill_dots);
|
return path_simplify(path, kill_dots);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
nm_sd_utils_path_startswith (const char *path, const char *prefix)
|
nm_sd_utils_path_startswith(const char *path, const char *prefix)
|
||||||
{
|
{
|
||||||
return path_startswith (path, prefix);
|
return path_startswith(path, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
nm_sd_utils_unbase64char (char ch, gboolean accept_padding_equal)
|
nm_sd_utils_unbase64char(char ch, gboolean accept_padding_equal)
|
||||||
{
|
{
|
||||||
if ( ch == '='
|
if (ch == '=' && accept_padding_equal)
|
||||||
&& accept_padding_equal)
|
return G_MAXINT;
|
||||||
return G_MAXINT;
|
return unbase64char(ch);
|
||||||
return unbase64char (ch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,60 +68,54 @@ nm_sd_utils_unbase64char (char ch, gboolean accept_padding_equal)
|
|||||||
* function fail.
|
* function fail.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
nm_sd_utils_unbase64mem (const char *p,
|
nm_sd_utils_unbase64mem(const char *p, size_t l, gboolean secure, guint8 **mem, size_t *len)
|
||||||
size_t l,
|
|
||||||
gboolean secure,
|
|
||||||
guint8 **mem,
|
|
||||||
size_t *len)
|
|
||||||
{
|
{
|
||||||
return unbase64mem_full (p, l, secure, (void **) mem, len);
|
return unbase64mem_full(p, l, secure, (void **) mem, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nm_sd_dns_name_to_wire_format (const char *domain,
|
int
|
||||||
guint8 *buffer,
|
nm_sd_dns_name_to_wire_format(const char *domain, guint8 *buffer, size_t len, gboolean canonical)
|
||||||
size_t len,
|
|
||||||
gboolean canonical)
|
|
||||||
{
|
{
|
||||||
return dns_name_to_wire_format (domain, buffer, len, canonical);
|
return dns_name_to_wire_format(domain, buffer, len, canonical);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nm_sd_dns_name_is_valid (const char *s)
|
int
|
||||||
|
nm_sd_dns_name_is_valid(const char *s)
|
||||||
{
|
{
|
||||||
return dns_name_is_valid (s);
|
return dns_name_is_valid(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean nm_sd_hostname_is_valid (const char *s, bool allow_trailing_dot)
|
gboolean
|
||||||
|
nm_sd_hostname_is_valid(const char *s, bool allow_trailing_dot)
|
||||||
{
|
{
|
||||||
return hostname_is_valid (s, allow_trailing_dot);
|
return hostname_is_valid(s, allow_trailing_dot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_http_url_is_valid (const char *url, gboolean only_https)
|
_http_url_is_valid(const char *url, gboolean only_https)
|
||||||
{
|
{
|
||||||
if ( !url
|
if (!url || !url[0])
|
||||||
|| !url[0])
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if ( !only_https
|
if (!only_https && NM_STR_HAS_PREFIX(url, "http://"))
|
||||||
&& NM_STR_HAS_PREFIX (url, "http://"))
|
url += NM_STRLEN("http://");
|
||||||
url += NM_STRLEN ("http://");
|
else if (NM_STR_HAS_PREFIX(url, "https://"))
|
||||||
else if (NM_STR_HAS_PREFIX (url, "https://"))
|
url += NM_STRLEN("https://");
|
||||||
url += NM_STRLEN ("https://");
|
else
|
||||||
else
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (!url[0])
|
if (!url[0])
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return !NM_STRCHAR_ANY (url, ch, (guchar) ch >= 128u);
|
return !NM_STRCHAR_ANY(url, ch, (guchar) ch >= 128u);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nm_sd_http_url_is_valid_https (const char *url)
|
nm_sd_http_url_is_valid_https(const char *url)
|
||||||
{
|
{
|
||||||
/* We use this function to verify connection:mud-url property, it must thus
|
/* We use this function to verify connection:mud-url property, it must thus
|
||||||
* not change behavior.
|
* not change behavior.
|
||||||
*
|
*
|
||||||
* Note that sd_dhcp_client_set_mud_url() and sd_dhcp6_client_set_request_mud_url()
|
* Note that sd_dhcp_client_set_mud_url() and sd_dhcp6_client_set_request_mud_url()
|
||||||
@@ -134,46 +127,46 @@ nm_sd_http_url_is_valid_https (const char *url)
|
|||||||
*
|
*
|
||||||
* We only must make sure that this is also correct in the future, when we
|
* We only must make sure that this is also correct in the future, when we
|
||||||
* re-import systemd code. */
|
* re-import systemd code. */
|
||||||
nm_assert (_http_url_is_valid (url, FALSE) == http_url_is_valid (url));
|
nm_assert(_http_url_is_valid(url, FALSE) == http_url_is_valid(url));
|
||||||
return _http_url_is_valid (url, TRUE);
|
return _http_url_is_valid(url, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
nmtst_systemd_extract_first_word_all (const char *str, char ***out_strv)
|
nmtst_systemd_extract_first_word_all(const char *str, char ***out_strv)
|
||||||
{
|
{
|
||||||
gs_unref_ptrarray GPtrArray *arr = NULL;
|
gs_unref_ptrarray GPtrArray *arr = NULL;
|
||||||
|
|
||||||
/* we implement a str split function to parse `/proc/cmdline`. This
|
/* we implement a str split function to parse `/proc/cmdline`. This
|
||||||
* code should behave like systemd, which uses extract_first_word()
|
* code should behave like systemd, which uses extract_first_word()
|
||||||
* for that.
|
* for that.
|
||||||
*
|
*
|
||||||
* As we want to unit-test our implementation to match systemd,
|
* As we want to unit-test our implementation to match systemd,
|
||||||
* expose this function for testing. */
|
* expose this function for testing. */
|
||||||
|
|
||||||
g_assert (out_strv);
|
g_assert(out_strv);
|
||||||
g_assert (!*out_strv);
|
g_assert(!*out_strv);
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
arr = g_ptr_array_new_with_free_func (g_free);
|
arr = g_ptr_array_new_with_free_func(g_free);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
gs_free char *word = NULL;
|
gs_free char *word = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = extract_first_word (&str, &word, NULL, EXTRACT_UNQUOTE | EXTRACT_RELAX);
|
r = extract_first_word(&str, &word, NULL, EXTRACT_UNQUOTE | EXTRACT_RELAX);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
break;
|
break;
|
||||||
g_ptr_array_add (arr, g_steal_pointer (&word));
|
g_ptr_array_add(arr, g_steal_pointer(&word));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ptr_array_add (arr, NULL);
|
g_ptr_array_add(arr, NULL);
|
||||||
|
|
||||||
*out_strv = (char **) g_ptr_array_free (g_steal_pointer (&arr), FALSE);
|
*out_strv = (char **) g_ptr_array_free(g_steal_pointer(&arr), FALSE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@@ -8,38 +8,32 @@
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
gboolean nm_sd_utils_path_equal (const char *a, const char *b);
|
gboolean nm_sd_utils_path_equal(const char *a, const char *b);
|
||||||
|
|
||||||
char *nm_sd_utils_path_simplify (char *path, gboolean kill_dots);
|
char *nm_sd_utils_path_simplify(char *path, gboolean kill_dots);
|
||||||
|
|
||||||
const char *nm_sd_utils_path_startswith (const char *path, const char *prefix);
|
const char *nm_sd_utils_path_startswith(const char *path, const char *prefix);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
int nm_sd_utils_unbase64char (char ch, gboolean accept_padding_equal);
|
int nm_sd_utils_unbase64char(char ch, gboolean accept_padding_equal);
|
||||||
|
|
||||||
int nm_sd_utils_unbase64mem (const char *p,
|
int nm_sd_utils_unbase64mem(const char *p, size_t l, gboolean secure, guint8 **mem, size_t *len);
|
||||||
size_t l,
|
|
||||||
gboolean secure,
|
|
||||||
guint8 **mem,
|
|
||||||
size_t *len);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
int nm_sd_dns_name_to_wire_format (const char *domain,
|
int
|
||||||
guint8 *buffer,
|
nm_sd_dns_name_to_wire_format(const char *domain, guint8 *buffer, size_t len, gboolean canonical);
|
||||||
size_t len,
|
|
||||||
gboolean canonical);
|
|
||||||
|
|
||||||
int nm_sd_dns_name_is_valid (const char *s);
|
int nm_sd_dns_name_is_valid(const char *s);
|
||||||
gboolean nm_sd_hostname_is_valid(const char *s, bool allow_trailing_dot);
|
gboolean nm_sd_hostname_is_valid(const char *s, bool allow_trailing_dot);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
gboolean nm_sd_http_url_is_valid_https (const char *url);
|
gboolean nm_sd_http_url_is_valid_https(const char *url);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
int nmtst_systemd_extract_first_word_all (const char *str, char ***out_strv);
|
int nmtst_systemd_extract_first_word_all(const char *str, char ***out_strv);
|
||||||
|
|
||||||
#endif /* __NM_SD_UTILS_SHARED_H__ */
|
#endif /* __NM_SD_UTILS_SHARED_H__ */
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/* strerror() is not thread-safe. Patch systemd-sources via a define. */
|
/* strerror() is not thread-safe. Patch systemd-sources via a define. */
|
||||||
#define strerror(errsv) nm_strerror_native (errsv)
|
#define strerror(errsv) nm_strerror_native(errsv)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
@@ -29,49 +29,91 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
_nm_log_get_max_level_realm (void)
|
_nm_log_get_max_level_realm(void)
|
||||||
{
|
{
|
||||||
/* inline function, to avoid coverity warning about constant expression. */
|
/* inline function, to avoid coverity warning about constant expression. */
|
||||||
return 7 /* LOG_DEBUG */;
|
return 7 /* LOG_DEBUG */;
|
||||||
}
|
}
|
||||||
#define log_get_max_level_realm(realm) _nm_log_get_max_level_realm ()
|
#define log_get_max_level_realm(realm) _nm_log_get_max_level_realm()
|
||||||
|
|
||||||
#define log_internal_realm(level, error, file, line, func, format, ...) \
|
#define log_internal_realm(level, error, file, line, func, format, ...) \
|
||||||
({ \
|
({ \
|
||||||
const int _nm_e = (error); \
|
const int _nm_e = (error); \
|
||||||
const NMLogLevel _nm_l = nm_log_level_from_syslog (LOG_PRI (level)); \
|
const NMLogLevel _nm_l = nm_log_level_from_syslog(LOG_PRI(level)); \
|
||||||
\
|
\
|
||||||
if (_nm_log_enabled_impl (!(NM_THREAD_SAFE_ON_MAIN_THREAD), _nm_l, LOGD_SYSTEMD)) { \
|
if (_nm_log_enabled_impl(!(NM_THREAD_SAFE_ON_MAIN_THREAD), _nm_l, LOGD_SYSTEMD)) { \
|
||||||
const char *_nm_location = strrchr ((""file), '/'); \
|
const char *_nm_location = strrchr(("" file), '/'); \
|
||||||
\
|
\
|
||||||
_nm_log_impl (_nm_location ? _nm_location + 1 : (""file), (line), (func), !(NM_THREAD_SAFE_ON_MAIN_THREAD), _nm_l, LOGD_SYSTEMD, _nm_e, NULL, NULL, ("%s"format), "libsystemd: ", ## __VA_ARGS__); \
|
_nm_log_impl(_nm_location ? _nm_location + 1 : ("" file), \
|
||||||
} \
|
(line), \
|
||||||
(_nm_e > 0 ? -_nm_e : _nm_e); \
|
(func), \
|
||||||
})
|
!(NM_THREAD_SAFE_ON_MAIN_THREAD), \
|
||||||
|
_nm_l, \
|
||||||
|
LOGD_SYSTEMD, \
|
||||||
|
_nm_e, \
|
||||||
|
NULL, \
|
||||||
|
NULL, \
|
||||||
|
("%s" format), \
|
||||||
|
"libsystemd: ", \
|
||||||
|
##__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
(_nm_e > 0 ? -_nm_e : _nm_e); \
|
||||||
|
})
|
||||||
|
|
||||||
#define log_assert_failed(text, file, line, func) \
|
#define log_assert_failed(text, file, line, func) \
|
||||||
G_STMT_START { \
|
G_STMT_START \
|
||||||
log_internal (LOG_CRIT, 0, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting.", text, file, line, func); \
|
{ \
|
||||||
g_assert_not_reached (); \
|
log_internal(LOG_CRIT, \
|
||||||
} G_STMT_END
|
0, \
|
||||||
|
file, \
|
||||||
|
line, \
|
||||||
|
func, \
|
||||||
|
"Assertion '%s' failed at %s:%u, function %s(). Aborting.", \
|
||||||
|
text, \
|
||||||
|
file, \
|
||||||
|
line, \
|
||||||
|
func); \
|
||||||
|
g_assert_not_reached(); \
|
||||||
|
} \
|
||||||
|
G_STMT_END
|
||||||
|
|
||||||
#define log_assert_failed_unreachable(text, file, line, func) \
|
#define log_assert_failed_unreachable(text, file, line, func) \
|
||||||
G_STMT_START { \
|
G_STMT_START \
|
||||||
log_internal (LOG_CRIT, 0, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting.", text, file, line, func); \
|
{ \
|
||||||
g_assert_not_reached (); \
|
log_internal(LOG_CRIT, \
|
||||||
} G_STMT_END
|
0, \
|
||||||
|
file, \
|
||||||
|
line, \
|
||||||
|
func, \
|
||||||
|
"Code should not be reached '%s' at %s:%u, function %s(). Aborting.", \
|
||||||
|
text, \
|
||||||
|
file, \
|
||||||
|
line, \
|
||||||
|
func); \
|
||||||
|
g_assert_not_reached(); \
|
||||||
|
} \
|
||||||
|
G_STMT_END
|
||||||
|
|
||||||
#define log_assert_failed_return(text, file, line, func) \
|
#define log_assert_failed_return(text, file, line, func) \
|
||||||
({ \
|
({ \
|
||||||
log_internal (LOG_DEBUG, 0, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Ignoring.", text, file, line, func); \
|
log_internal(LOG_DEBUG, \
|
||||||
g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, text); \
|
0, \
|
||||||
(void) 0; \
|
file, \
|
||||||
})
|
line, \
|
||||||
|
func, \
|
||||||
|
"Assertion '%s' failed at %s:%u, function %s(). Ignoring.", \
|
||||||
|
text, \
|
||||||
|
file, \
|
||||||
|
line, \
|
||||||
|
func); \
|
||||||
|
g_return_if_fail_warning(G_LOG_DOMAIN, G_STRFUNC, text); \
|
||||||
|
(void) 0; \
|
||||||
|
})
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#ifndef VALGRIND
|
#ifndef VALGRIND
|
||||||
#define VALGRIND 0
|
#define VALGRIND 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ENABLE_DEBUG_HASHMAP 0
|
#define ENABLE_DEBUG_HASHMAP 0
|
||||||
@@ -83,68 +125,71 @@ G_STMT_START { \
|
|||||||
|
|
||||||
#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD
|
#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD
|
||||||
|
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#define ENABLE_GSHADOW FALSE
|
#define ENABLE_GSHADOW FALSE
|
||||||
|
|
||||||
#define HAVE_SECCOMP 0
|
#define HAVE_SECCOMP 0
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/* systemd cannot be compiled with "-Wdeclaration-after-statement". In particular
|
/* systemd cannot be compiled with "-Wdeclaration-after-statement". In particular
|
||||||
* in combination with assert_cc(). */
|
* in combination with assert_cc(). */
|
||||||
NM_PRAGMA_WARNING_DISABLE ("-Wdeclaration-after-statement")
|
NM_PRAGMA_WARNING_DISABLE("-Wdeclaration-after-statement")
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static inline pid_t
|
static inline pid_t
|
||||||
raw_getpid (void) {
|
raw_getpid(void)
|
||||||
#if defined(__alpha__)
|
{
|
||||||
return (pid_t) syscall (__NR_getxpid);
|
#if defined(__alpha__)
|
||||||
#else
|
return (pid_t) syscall(__NR_getxpid);
|
||||||
return (pid_t) syscall (__NR_getpid);
|
#else
|
||||||
#endif
|
return (pid_t) syscall(__NR_getpid);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline pid_t _nm_gettid(void) {
|
static inline pid_t
|
||||||
return (pid_t) syscall(SYS_gettid);
|
_nm_gettid(void)
|
||||||
|
{
|
||||||
|
return (pid_t) syscall(SYS_gettid);
|
||||||
}
|
}
|
||||||
#define gettid() _nm_gettid ()
|
#define gettid() _nm_gettid()
|
||||||
|
|
||||||
/* we build with C11 and thus <uchar.h> provides char32_t,char16_t. */
|
/* we build with C11 and thus <uchar.h> provides char32_t,char16_t. */
|
||||||
#define HAVE_CHAR32_T 1
|
#define HAVE_CHAR32_T 1
|
||||||
#define HAVE_CHAR16_T 1
|
#define HAVE_CHAR16_T 1
|
||||||
|
|
||||||
#if defined(HAVE_DECL_REALLOCARRAY) && HAVE_DECL_REALLOCARRAY == 1
|
#if defined(HAVE_DECL_REALLOCARRAY) && HAVE_DECL_REALLOCARRAY == 1
|
||||||
#define HAVE_REALLOCARRAY 1
|
#define HAVE_REALLOCARRAY 1
|
||||||
#else
|
#else
|
||||||
#define HAVE_REALLOCARRAY 0
|
#define HAVE_REALLOCARRAY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_DECL_EXPLICIT_BZERO) && HAVE_DECL_EXPLICIT_BZERO == 1
|
#if defined(HAVE_DECL_EXPLICIT_BZERO) && HAVE_DECL_EXPLICIT_BZERO == 1
|
||||||
#define HAVE_EXPLICIT_BZERO 1
|
#define HAVE_EXPLICIT_BZERO 1
|
||||||
#else
|
#else
|
||||||
#define HAVE_EXPLICIT_BZERO 0
|
#define HAVE_EXPLICIT_BZERO 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_DECL_PIDFD_OPEN) && HAVE_DECL_PIDFD_OPEN == 1
|
#if defined(HAVE_DECL_PIDFD_OPEN) && HAVE_DECL_PIDFD_OPEN == 1
|
||||||
#define HAVE_PIDFD_OPEN 1
|
#define HAVE_PIDFD_OPEN 1
|
||||||
#else
|
#else
|
||||||
#define HAVE_PIDFD_OPEN 0
|
#define HAVE_PIDFD_OPEN 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_DECL_PIDFD_SEND_SIGNAL) && HAVE_DECL_PIDFD_SEND_SIGNAL == 1
|
#if defined(HAVE_DECL_PIDFD_SEND_SIGNAL) && HAVE_DECL_PIDFD_SEND_SIGNAL == 1
|
||||||
#define HAVE_PIDFD_SEND_SIGNAL 1
|
#define HAVE_PIDFD_SEND_SIGNAL 1
|
||||||
#else
|
#else
|
||||||
#define HAVE_PIDFD_SEND_SIGNAL 0
|
#define HAVE_PIDFD_SEND_SIGNAL 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_DECL_RT_SIGQUEUEINFO) && HAVE_DECL_RT_SIGQUEUEINFO == 1
|
#if defined(HAVE_DECL_RT_SIGQUEUEINFO) && HAVE_DECL_RT_SIGQUEUEINFO == 1
|
||||||
#define HAVE_RT_SIGQUEUEINFO 1
|
#define HAVE_RT_SIGQUEUEINFO 1
|
||||||
#else
|
#else
|
||||||
#define HAVE_RT_SIGQUEUEINFO 0
|
#define HAVE_RT_SIGQUEUEINFO 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD */
|
#endif /* (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD */
|
||||||
|
|
||||||
|
@@ -16,12 +16,12 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
NMUuid *
|
NMUuid *
|
||||||
nm_sd_utils_id128_get_machine (NMUuid *out_uuid)
|
nm_sd_utils_id128_get_machine(NMUuid *out_uuid)
|
||||||
{
|
{
|
||||||
g_assert (out_uuid);
|
g_assert(out_uuid);
|
||||||
|
|
||||||
G_STATIC_ASSERT_EXPR (sizeof (*out_uuid) == sizeof (sd_id128_t));
|
G_STATIC_ASSERT_EXPR(sizeof(*out_uuid) == sizeof(sd_id128_t));
|
||||||
if (sd_id128_get_machine ((sd_id128_t *) out_uuid) < 0)
|
if (sd_id128_get_machine((sd_id128_t *) out_uuid) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return out_uuid;
|
return out_uuid;
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
struct _NMUuid;
|
struct _NMUuid;
|
||||||
|
|
||||||
struct _NMUuid *nm_sd_utils_id128_get_machine (struct _NMUuid *out_uuid);
|
struct _NMUuid *nm_sd_utils_id128_get_machine(struct _NMUuid *out_uuid);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
@@ -11,30 +11,31 @@
|
|||||||
#include "src/libsystemd-network/dhcp-lease-internal.h"
|
#include "src/libsystemd-network/dhcp-lease-internal.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
nm_sd_dhcp_lease_get_private_options (sd_dhcp_lease *lease, nm_sd_dhcp_option **out_options)
|
nm_sd_dhcp_lease_get_private_options(sd_dhcp_lease *lease, nm_sd_dhcp_option **out_options)
|
||||||
{
|
{
|
||||||
struct sd_dhcp_raw_option *raw_option;
|
struct sd_dhcp_raw_option *raw_option;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
g_return_val_if_fail (lease, -EINVAL);
|
g_return_val_if_fail(lease, -EINVAL);
|
||||||
g_return_val_if_fail (out_options, -EINVAL);
|
g_return_val_if_fail(out_options, -EINVAL);
|
||||||
g_return_val_if_fail (*out_options == NULL, -EINVAL);
|
g_return_val_if_fail(*out_options == NULL, -EINVAL);
|
||||||
|
|
||||||
if (lease->private_options == NULL)
|
if (lease->private_options == NULL)
|
||||||
return -ENODATA;
|
return -ENODATA;
|
||||||
|
|
||||||
LIST_FOREACH (options, raw_option, lease->private_options)
|
LIST_FOREACH(options, raw_option, lease->private_options)
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
*out_options = g_new (nm_sd_dhcp_option, cnt);
|
*out_options = g_new(nm_sd_dhcp_option, cnt);
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
|
|
||||||
LIST_FOREACH (options, raw_option, lease->private_options) {
|
LIST_FOREACH(options, raw_option, lease->private_options)
|
||||||
(*out_options)[cnt].code = raw_option->tag;
|
{
|
||||||
(*out_options)[cnt].data = raw_option->data;
|
(*out_options)[cnt].code = raw_option->tag;
|
||||||
(*out_options)[cnt].data_len = raw_option->length;
|
(*out_options)[cnt].data = raw_option->data;
|
||||||
cnt++;
|
(*out_options)[cnt].data_len = raw_option->length;
|
||||||
}
|
cnt++;
|
||||||
|
}
|
||||||
|
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
@@ -9,12 +9,11 @@
|
|||||||
#include "nm-sd.h"
|
#include "nm-sd.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t code;
|
uint8_t code;
|
||||||
uint8_t data_len;
|
uint8_t data_len;
|
||||||
void *data;
|
void * data;
|
||||||
} nm_sd_dhcp_option;
|
} nm_sd_dhcp_option;
|
||||||
|
|
||||||
int
|
int nm_sd_dhcp_lease_get_private_options(sd_dhcp_lease *lease, nm_sd_dhcp_option **out_options);
|
||||||
nm_sd_dhcp_lease_get_private_options (sd_dhcp_lease *lease, nm_sd_dhcp_option **out_options);
|
|
||||||
|
|
||||||
#endif /* __NETWORKMANAGER_DHCP_SYSTEMD_UTILS_H__ */
|
#endif /* __NETWORKMANAGER_DHCP_SYSTEMD_UTILS_H__ */
|
||||||
|
@@ -15,94 +15,92 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
typedef struct SDEventSource {
|
typedef struct SDEventSource {
|
||||||
GSource source;
|
GSource source;
|
||||||
GPollFD pollfd;
|
GPollFD pollfd;
|
||||||
sd_event *event;
|
sd_event *event;
|
||||||
} SDEventSource;
|
} SDEventSource;
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
event_prepare (GSource *source, int *timeout_)
|
event_prepare(GSource *source, int *timeout_)
|
||||||
{
|
{
|
||||||
return sd_event_prepare (((SDEventSource *) source)->event) > 0;
|
return sd_event_prepare(((SDEventSource *) source)->event) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
event_check (GSource *source)
|
event_check(GSource *source)
|
||||||
{
|
{
|
||||||
return sd_event_wait (((SDEventSource *) source)->event, 0) > 0;
|
return sd_event_wait(((SDEventSource *) source)->event, 0) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
event_dispatch (GSource *source, GSourceFunc callback, gpointer user_data)
|
event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data)
|
||||||
{
|
{
|
||||||
return sd_event_dispatch (((SDEventSource *) source)->event) > 0;
|
return sd_event_dispatch(((SDEventSource *) source)->event) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
event_finalize (GSource *source)
|
event_finalize(GSource *source)
|
||||||
{
|
{
|
||||||
SDEventSource *s = (SDEventSource *) source;
|
SDEventSource *s = (SDEventSource *) source;
|
||||||
|
|
||||||
sd_event_unref (s->event);
|
sd_event_unref(s->event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDEventSource *
|
static SDEventSource *
|
||||||
event_create_source (sd_event *event)
|
event_create_source(sd_event *event)
|
||||||
{
|
{
|
||||||
static const GSourceFuncs event_funcs = {
|
static const GSourceFuncs event_funcs = {
|
||||||
.prepare = event_prepare,
|
.prepare = event_prepare,
|
||||||
.check = event_check,
|
.check = event_check,
|
||||||
.dispatch = event_dispatch,
|
.dispatch = event_dispatch,
|
||||||
.finalize = event_finalize,
|
.finalize = event_finalize,
|
||||||
};
|
};
|
||||||
SDEventSource *source;
|
SDEventSource *source;
|
||||||
gboolean is_default_event = FALSE;
|
gboolean is_default_event = FALSE;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!event) {
|
if (!event) {
|
||||||
is_default_event = TRUE;
|
is_default_event = TRUE;
|
||||||
r = sd_event_default (&event);
|
r = sd_event_default(&event);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
g_return_val_if_reached (NULL);
|
g_return_val_if_reached(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
source = (SDEventSource *) g_source_new ((GSourceFuncs *) &event_funcs, sizeof (SDEventSource));
|
source = (SDEventSource *) g_source_new((GSourceFuncs *) &event_funcs, sizeof(SDEventSource));
|
||||||
|
|
||||||
source->event = is_default_event
|
source->event = is_default_event ? g_steal_pointer(&event) : sd_event_ref(event);
|
||||||
? g_steal_pointer (&event)
|
|
||||||
: sd_event_ref (event);
|
|
||||||
|
|
||||||
source->pollfd = (GPollFD) {
|
source->pollfd = (GPollFD){
|
||||||
.fd = sd_event_get_fd (source->event),
|
.fd = sd_event_get_fd(source->event),
|
||||||
.events = G_IO_IN | G_IO_HUP | G_IO_ERR,
|
.events = G_IO_IN | G_IO_HUP | G_IO_ERR,
|
||||||
};
|
};
|
||||||
|
|
||||||
g_source_add_poll (&source->source, &source->pollfd);
|
g_source_add_poll(&source->source, &source->pollfd);
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
event_attach (sd_event *event, GMainContext *context)
|
event_attach(sd_event *event, GMainContext *context)
|
||||||
{
|
{
|
||||||
SDEventSource *source;
|
SDEventSource *source;
|
||||||
guint id;
|
guint id;
|
||||||
|
|
||||||
source = event_create_source (event);
|
source = event_create_source(event);
|
||||||
|
|
||||||
g_return_val_if_fail (source, 0);
|
g_return_val_if_fail(source, 0);
|
||||||
|
|
||||||
id = g_source_attach ((GSource *) source, context);
|
id = g_source_attach((GSource *) source, context);
|
||||||
g_source_unref ((GSource *) source);
|
g_source_unref((GSource *) source);
|
||||||
|
|
||||||
nm_assert (id != 0);
|
nm_assert(id != 0);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
nm_sd_event_attach_default (void)
|
nm_sd_event_attach_default(void)
|
||||||
{
|
{
|
||||||
return event_attach (NULL, NULL);
|
return event_attach(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -113,4 +111,3 @@ nm_sd_event_attach_default (void)
|
|||||||
#include "dhcp-lease-internal.h"
|
#include "dhcp-lease-internal.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
guint nm_sd_event_attach_default (void);
|
guint nm_sd_event_attach_default(void);
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* expose internal systemd API
|
* expose internal systemd API
|
||||||
@@ -27,4 +27,3 @@ int dhcp_lease_save(struct sd_dhcp_lease *lease, const char *lease_file);
|
|||||||
int dhcp_lease_load(struct sd_dhcp_lease **ret, const char *lease_file);
|
int dhcp_lease_load(struct sd_dhcp_lease **ret, const char *lease_file);
|
||||||
|
|
||||||
#endif /* __NM_SD_H__ */
|
#endif /* __NM_SD_H__ */
|
||||||
|
|
||||||
|
@@ -12,10 +12,10 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
asynchronous_close (int fd) {
|
asynchronous_close(int fd)
|
||||||
safe_close (fd);
|
{
|
||||||
return -1;
|
safe_close(fd);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
#include "systemd/sd-adapt-shared/nm-sd-adapt-shared.h"
|
#include "systemd/sd-adapt-shared/nm-sd-adapt-shared.h"
|
||||||
|
|
||||||
#ifndef HAVE_SYS_AUXV_H
|
#ifndef HAVE_SYS_AUXV_H
|
||||||
#define HAVE_SYS_AUXV_H 0
|
#define HAVE_SYS_AUXV_H 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
@@ -25,62 +25,61 @@
|
|||||||
|
|
||||||
#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD
|
#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <elf.h>
|
#include <elf.h>
|
||||||
#ifdef HAVE_SYS_AUXV_H
|
#ifdef HAVE_SYS_AUXV_H
|
||||||
#include <sys/auxv.h>
|
#include <sys/auxv.h>
|
||||||
#endif
|
#endif
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
/* Missing in Linux 3.2.0, in Ubuntu 12.04 */
|
/* Missing in Linux 3.2.0, in Ubuntu 12.04 */
|
||||||
#ifndef BPF_XOR
|
#ifndef BPF_XOR
|
||||||
#define BPF_XOR 0xa0
|
#define BPF_XOR 0xa0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ETHERTYPE_LLDP
|
#ifndef ETHERTYPE_LLDP
|
||||||
#define ETHERTYPE_LLDP 0x88cc
|
#define ETHERTYPE_LLDP 0x88cc
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SECURE_GETENV
|
#ifndef HAVE_SECURE_GETENV
|
||||||
# ifdef HAVE___SECURE_GETENV
|
#ifdef HAVE___SECURE_GETENV
|
||||||
# define secure_getenv __secure_getenv
|
#define secure_getenv __secure_getenv
|
||||||
# else
|
#else
|
||||||
# error neither secure_getenv nor __secure_getenv is available
|
#error neither secure_getenv nor __secure_getenv is available
|
||||||
# endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
sd_notify (int unset_environment, const char *state)
|
sd_notify(int unset_environment, const char *state)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Can't include both net/if.h and linux/if.h; so have to define this here */
|
/* Can't include both net/if.h and linux/if.h; so have to define this here */
|
||||||
#ifndef IF_NAMESIZE
|
#ifndef IF_NAMESIZE
|
||||||
#define IF_NAMESIZE 16
|
#define IF_NAMESIZE 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IFNAMSIZ
|
#ifndef IFNAMSIZ
|
||||||
#define IFNAMSIZ IF_NAMESIZE
|
#define IFNAMSIZ IF_NAMESIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MAX_HANDLE_SZ
|
#ifndef MAX_HANDLE_SZ
|
||||||
#define MAX_HANDLE_SZ 128
|
#define MAX_HANDLE_SZ 128
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "sd-id128.h"
|
#include "sd-id128.h"
|
||||||
#include "sparse-endian.h"
|
#include "sparse-endian.h"
|
||||||
#include "async.h"
|
#include "async.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#endif /* (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD */
|
#endif /* (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD */
|
||||||
|
|
||||||
#endif /* __NM_SD_ADAPT_CORE_H__ */
|
#endif /* __NM_SD_ADAPT_CORE_H__ */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user