2020-12-23 22:21:36 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2019-09-25 13:13:40 +02:00
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 2004 - 2016 Red Hat, Inc.
|
|
|
|
|
* Copyright (C) 2005 - 2008 Novell, Inc.
|
2016-03-01 09:56:51 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __NM_CORE_UTILS_H__
|
|
|
|
|
#define __NM_CORE_UTILS_H__
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <arpa/inet.h>
|
2022-01-18 17:30:14 +01:00
|
|
|
#include <sys/types.h>
|
2016-03-01 09:56:51 +01:00
|
|
|
|
|
|
|
|
#include "nm-connection.h"
|
|
|
|
|
|
2021-02-18 17:37:47 +01:00
|
|
|
#include "libnm-glib-aux/nm-time-utils.h"
|
2018-10-17 14:09:13 +02:00
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define NM_DEFINE_SINGLETON_INSTANCE(TYPE) static TYPE *singleton_instance
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
#define NM_DEFINE_SINGLETON_REGISTER(TYPE) \
|
|
|
|
|
NM_DEFINE_SINGLETON_INSTANCE(TYPE); \
|
|
|
|
|
static void _singleton_instance_weak_ref_cb(gpointer data, GObject *where_the_object_was) \
|
|
|
|
|
{ \
|
2019-05-05 15:40:04 +02:00
|
|
|
nm_log_dbg(LOGD_CORE, \
|
|
|
|
|
"disposing %s singleton (" NM_HASH_OBFUSCATE_PTR_FMT ")", \
|
|
|
|
|
G_STRINGIFY(TYPE), \
|
|
|
|
|
NM_HASH_OBFUSCATE_PTR(singleton_instance)); \
|
2016-03-01 09:56:51 +01:00
|
|
|
singleton_instance = NULL; \
|
|
|
|
|
} \
|
|
|
|
|
static inline void nm_singleton_instance_register(void) \
|
|
|
|
|
{ \
|
|
|
|
|
g_object_weak_ref(G_OBJECT(singleton_instance), _singleton_instance_weak_ref_cb, NULL); \
|
|
|
|
|
_nm_singleton_instance_register_destruction(G_OBJECT(singleton_instance)); \
|
2020-07-19 12:15:39 +02:00
|
|
|
} \
|
|
|
|
|
_NM_DUMMY_STRUCT_FOR_TRAILING_SEMICOLON
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
void _nm_singleton_instance_register_destruction(GObject *instance);
|
|
|
|
|
|
|
|
|
|
/* By default, the getter will assert that the singleton will be created only once. You can
|
|
|
|
|
* change this by redefining NM_DEFINE_SINGLETON_ALLOW_MULTIPLE. */
|
|
|
|
|
#ifndef NM_DEFINE_SINGLETON_ALLOW_MULTIPLE
|
2021-07-09 08:48:48 +02:00
|
|
|
#define NM_DEFINE_SINGLETON_ALLOW_MULTIPLE FALSE
|
2016-03-01 09:56:51 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define NM_DEFINE_SINGLETON_GETTER(TYPE, GETTER, GTYPE, ...) \
|
|
|
|
|
NM_DEFINE_SINGLETON_INSTANCE(TYPE); \
|
|
|
|
|
NM_DEFINE_SINGLETON_REGISTER(TYPE); \
|
2018-10-24 10:52:42 +02:00
|
|
|
static char _already_created_##GETTER = FALSE; \
|
2021-11-09 13:28:54 +01:00
|
|
|
TYPE *GETTER(void) \
|
2016-03-01 09:56:51 +01:00
|
|
|
{ \
|
|
|
|
|
if (G_UNLIKELY(!singleton_instance)) { \
|
2018-10-24 10:52:42 +02:00
|
|
|
g_assert(!(_already_created_##GETTER) || (NM_DEFINE_SINGLETON_ALLOW_MULTIPLE)); \
|
|
|
|
|
(_already_created_##GETTER) = TRUE; \
|
2021-02-08 16:55:35 +01:00
|
|
|
singleton_instance = g_object_new(GTYPE, ##__VA_ARGS__, NULL); \
|
2016-03-01 09:56:51 +01:00
|
|
|
g_assert(singleton_instance); \
|
|
|
|
|
nm_singleton_instance_register(); \
|
2019-05-05 15:40:04 +02:00
|
|
|
nm_log_dbg(LOGD_CORE, \
|
|
|
|
|
"create %s singleton (" NM_HASH_OBFUSCATE_PTR_FMT ")", \
|
|
|
|
|
G_STRINGIFY(TYPE), \
|
|
|
|
|
NM_HASH_OBFUSCATE_PTR(singleton_instance)); \
|
2016-03-01 09:56:51 +01:00
|
|
|
} \
|
|
|
|
|
return singleton_instance; \
|
2018-10-24 10:52:42 +02:00
|
|
|
} \
|
|
|
|
|
_nm_unused static void _nmtst_##GETTER##_reset(TYPE *instance) \
|
|
|
|
|
{ \
|
|
|
|
|
/* usually, the singleton can only be created once (and further instantiations
|
|
|
|
|
* are guarded by an assert). For testing, we need to reset the singleton to
|
|
|
|
|
* allow multiple instantiations. */ \
|
|
|
|
|
g_assert(G_IS_OBJECT(instance)); \
|
|
|
|
|
g_assert(instance == singleton_instance); \
|
|
|
|
|
g_assert(_already_created_##GETTER); \
|
|
|
|
|
g_object_unref(instance); \
|
|
|
|
|
\
|
|
|
|
|
/* require that the last unref also destroyed the singleton. If this fails,
|
|
|
|
|
* somebody still keeps a reference. Fix your test! */ \
|
|
|
|
|
g_assert(!singleton_instance); \
|
|
|
|
|
_already_created_##GETTER = FALSE; \
|
2016-03-01 09:56:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* attach @instance to the data or @owner. @owner owns a reference
|
|
|
|
|
* to @instance thus the lifetime of @instance is at least as long
|
|
|
|
|
* as that of @owner. Use this when @owner depends on @instance. */
|
|
|
|
|
#define NM_UTILS_KEEP_ALIVE(owner, instance, unique_token) \
|
|
|
|
|
G_STMT_START \
|
|
|
|
|
{ \
|
|
|
|
|
g_object_set_data_full(G_OBJECT(owner), \
|
|
|
|
|
".nm-utils-keep-alive-" unique_token "", \
|
|
|
|
|
g_object_ref(instance), \
|
|
|
|
|
g_object_unref); \
|
|
|
|
|
} \
|
|
|
|
|
G_STMT_END
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-11-19 11:20:19 +01:00
|
|
|
gboolean nm_ether_addr_is_valid(const NMEtherAddr *addr);
|
|
|
|
|
gboolean nm_ether_addr_is_valid_str(const char *str);
|
2016-03-01 09:56:51 +01:00
|
|
|
|
2017-10-13 14:00:22 +02:00
|
|
|
static inline void
|
|
|
|
|
nm_hash_update_in6addr(NMHashState *h, const struct in6_addr *addr)
|
2017-07-26 10:50:23 +02:00
|
|
|
{
|
2017-10-16 12:38:16 +02:00
|
|
|
nm_assert(addr);
|
|
|
|
|
|
|
|
|
|
nm_hash_update(h, addr, sizeof(*addr));
|
2017-07-26 10:50:23 +02:00
|
|
|
}
|
|
|
|
|
|
2017-10-13 14:00:22 +02:00
|
|
|
static inline void
|
|
|
|
|
nm_hash_update_in6addr_prefix(NMHashState *h, const struct in6_addr *addr, guint8 plen)
|
2017-07-26 10:50:23 +02:00
|
|
|
{
|
|
|
|
|
struct in6_addr a;
|
|
|
|
|
|
2017-10-16 12:38:16 +02:00
|
|
|
nm_assert(addr);
|
2017-10-13 14:00:22 +02:00
|
|
|
|
glib-aux: rename IP address related helpers from "nm-inet-utils.h"
- name things related to `in_addr_t`, `struct in6_addr`, `NMIPAddr` as
`nm_ip4_addr_*()`, `nm_ip6_addr_*()`, `nm_ip_addr_*()`, respectively.
- we have a wrapper `nm_inet_ntop()` for `inet_ntop()`. This name
of our wrapper is chosen to be familiar with the libc underlying
function. With this, also name functions that are about string
representations of addresses `nm_inet_*()`, `nm_inet4_*()`,
`nm_inet6_*()`. For example, `nm_inet_parse_str()`,
`nm_inet_is_normalized()`.
<<<<
R() {
git grep -l "$1" | xargs sed -i "s/\<$1\>/$2/g"
}
R NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX NM_CMP_DIRECT_IP4_ADDR_SAME_PREFIX
R NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX
R NM_UTILS_INET_ADDRSTRLEN NM_INET_ADDRSTRLEN
R _nm_utils_inet4_ntop nm_inet4_ntop
R _nm_utils_inet6_ntop nm_inet6_ntop
R _nm_utils_ip4_get_default_prefix nm_ip4_addr_get_default_prefix
R _nm_utils_ip4_get_default_prefix0 nm_ip4_addr_get_default_prefix0
R _nm_utils_ip4_netmask_to_prefix nm_ip4_addr_netmask_to_prefix
R _nm_utils_ip4_prefix_to_netmask nm_ip4_addr_netmask_from_prefix
R nm_utils_inet4_ntop_dup nm_inet4_ntop_dup
R nm_utils_inet6_ntop_dup nm_inet6_ntop_dup
R nm_utils_inet_ntop nm_inet_ntop
R nm_utils_inet_ntop_dup nm_inet_ntop_dup
R nm_utils_ip4_address_clear_host_address nm_ip4_addr_clear_host_address
R nm_utils_ip4_address_is_link_local nm_ip4_addr_is_link_local
R nm_utils_ip4_address_is_loopback nm_ip4_addr_is_loopback
R nm_utils_ip4_address_is_zeronet nm_ip4_addr_is_zeronet
R nm_utils_ip4_address_same_prefix nm_ip4_addr_same_prefix
R nm_utils_ip4_address_same_prefix_cmp nm_ip4_addr_same_prefix_cmp
R nm_utils_ip6_address_clear_host_address nm_ip6_addr_clear_host_address
R nm_utils_ip6_address_same_prefix nm_ip6_addr_same_prefix
R nm_utils_ip6_address_same_prefix_cmp nm_ip6_addr_same_prefix_cmp
R nm_utils_ip6_is_ula nm_ip6_addr_is_ula
R nm_utils_ip_address_same_prefix nm_ip_addr_same_prefix
R nm_utils_ip_address_same_prefix_cmp nm_ip_addr_same_prefix_cmp
R nm_utils_ip_is_site_local nm_ip_addr_is_site_local
R nm_utils_ipaddr_is_normalized nm_inet_is_normalized
R nm_utils_ipaddr_is_valid nm_inet_is_valid
R nm_utils_ipx_address_clear_host_address nm_ip_addr_clear_host_address
R nm_utils_parse_inaddr nm_inet_parse_str
R nm_utils_parse_inaddr_bin nm_inet_parse_bin
R nm_utils_parse_inaddr_bin_full nm_inet_parse_bin_full
R nm_utils_parse_inaddr_prefix nm_inet_parse_with_prefix_str
R nm_utils_parse_inaddr_prefix_bin nm_inet_parse_with_prefix_bin
R test_nm_utils_ip6_address_same_prefix test_nm_ip_addr_same_prefix
./contrib/scripts/nm-code-format.sh -F
2022-08-19 13:15:20 +02:00
|
|
|
nm_ip6_addr_clear_host_address(&a, addr, plen);
|
2017-07-26 10:50:23 +02:00
|
|
|
/* we don't hash plen itself. The caller may want to do that.*/
|
2017-10-13 14:00:22 +02:00
|
|
|
nm_hash_update_in6addr(h, &a);
|
2017-07-26 10:50:23 +02:00
|
|
|
}
|
|
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
/**
|
|
|
|
|
* nm_utils_ip6_route_metric_normalize:
|
|
|
|
|
* @metric: the route metric
|
|
|
|
|
*
|
2020-07-03 15:25:51 +02:00
|
|
|
* For IPv6 route, when adding a route via netlink, kernel treats the value 0 as IP6_RT_PRIO_USER (1024).
|
|
|
|
|
* So, user space cannot add routes with such a metric, and 0 gets "normalized"
|
|
|
|
|
* to NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6.
|
|
|
|
|
*
|
|
|
|
|
* Note that kernel itself can add IPv6 routes with metric zero. Also, you can delete
|
|
|
|
|
* them, but mostly because with `ip -6 route delete ... metric 0` the 0 acts as a wildcard
|
|
|
|
|
* and kills the first matching route.
|
2016-03-01 09:56:51 +01:00
|
|
|
*
|
|
|
|
|
* Returns: @metric, if @metric is not zero, otherwise 1024.
|
|
|
|
|
*/
|
|
|
|
|
static inline guint32
|
|
|
|
|
nm_utils_ip6_route_metric_normalize(guint32 metric)
|
|
|
|
|
{
|
2018-04-24 11:20:03 +02:00
|
|
|
return metric ?: 1024 /*NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6*/;
|
2016-03-01 09:56:51 +01:00
|
|
|
}
|
|
|
|
|
|
2017-08-30 19:10:59 +02:00
|
|
|
static inline guint32
|
|
|
|
|
nm_utils_ip_route_metric_normalize(int addr_family, guint32 metric)
|
|
|
|
|
{
|
2020-10-30 12:13:18 +01:00
|
|
|
return NM_IS_IPv4(addr_family) ? metric : nm_utils_ip6_route_metric_normalize(metric);
|
2017-08-30 19:10:59 +02:00
|
|
|
}
|
|
|
|
|
|
2017-10-04 15:21:21 +02:00
|
|
|
static inline guint32
|
2020-07-03 15:25:51 +02:00
|
|
|
nm_utils_ip_route_metric_penalize(guint32 metric, guint32 penalty)
|
2017-10-04 15:21:21 +02:00
|
|
|
{
|
|
|
|
|
if (metric < G_MAXUINT32 - penalty)
|
|
|
|
|
return metric + penalty;
|
|
|
|
|
return G_MAXUINT32;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
void nm_utils_kill_process_sync(pid_t pid,
|
|
|
|
|
guint64 start_time,
|
|
|
|
|
int sig,
|
core: fix enum argument in prototype of nm_utils_kill_process_sync(), etc.
This avoids a new compiler warning with gcc 13.0.0-0.9.fc38:
../src/core/nm-core-utils.c:482:1: error: conflicting types for 'nm_utils_kill_child_async' due to enum/integer mismatch; have 'void(pid_t, int, NMLogDomain, const char *, guint32, void (*)(pid_t, gboolean, int, void *), void *)' {aka 'void(int, int, NMLogDomain, const char *, unsigned int, void (*)(int, int, int, void *), void *)'} [-Werror=enum-int-mismatch]
482 | nm_utils_kill_child_async(pid_t pid,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/core/nm-core-utils.c:9:
Fixes: 067202b34e5a ('core: use explict NMLogDomain enum instead of int')
2023-01-18 16:19:09 +01:00
|
|
|
NMLogDomain log_domain,
|
2016-03-01 09:56:51 +01:00
|
|
|
const char *log_name,
|
|
|
|
|
guint32 wait_before_kill_msec,
|
|
|
|
|
guint32 sleep_duration_msec,
|
|
|
|
|
guint32 max_wait_msec);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
typedef void (*NMUtilsKillChildAsyncCb)(pid_t pid,
|
|
|
|
|
gboolean success,
|
|
|
|
|
int child_status,
|
2021-11-09 13:28:54 +01:00
|
|
|
void *user_data);
|
2016-03-01 09:56:51 +01:00
|
|
|
void nm_utils_kill_child_async(pid_t pid,
|
|
|
|
|
int sig,
|
core: fix enum argument in prototype of nm_utils_kill_process_sync(), etc.
This avoids a new compiler warning with gcc 13.0.0-0.9.fc38:
../src/core/nm-core-utils.c:482:1: error: conflicting types for 'nm_utils_kill_child_async' due to enum/integer mismatch; have 'void(pid_t, int, NMLogDomain, const char *, guint32, void (*)(pid_t, gboolean, int, void *), void *)' {aka 'void(int, int, NMLogDomain, const char *, unsigned int, void (*)(int, int, int, void *), void *)'} [-Werror=enum-int-mismatch]
482 | nm_utils_kill_child_async(pid_t pid,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/core/nm-core-utils.c:9:
Fixes: 067202b34e5a ('core: use explict NMLogDomain enum instead of int')
2023-01-18 16:19:09 +01:00
|
|
|
NMLogDomain log_domain,
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *log_name,
|
2016-03-01 09:56:51 +01:00
|
|
|
guint32 wait_before_kill_msec,
|
|
|
|
|
NMUtilsKillChildAsyncCb callback,
|
2021-11-09 13:28:54 +01:00
|
|
|
void *user_data);
|
2016-03-01 09:56:51 +01:00
|
|
|
gboolean nm_utils_kill_child_sync(pid_t pid,
|
|
|
|
|
int sig,
|
core: fix enum argument in prototype of nm_utils_kill_process_sync(), etc.
This avoids a new compiler warning with gcc 13.0.0-0.9.fc38:
../src/core/nm-core-utils.c:482:1: error: conflicting types for 'nm_utils_kill_child_async' due to enum/integer mismatch; have 'void(pid_t, int, NMLogDomain, const char *, guint32, void (*)(pid_t, gboolean, int, void *), void *)' {aka 'void(int, int, NMLogDomain, const char *, unsigned int, void (*)(int, int, int, void *), void *)'} [-Werror=enum-int-mismatch]
482 | nm_utils_kill_child_async(pid_t pid,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/core/nm-core-utils.c:9:
Fixes: 067202b34e5a ('core: use explict NMLogDomain enum instead of int')
2023-01-18 16:19:09 +01:00
|
|
|
NMLogDomain log_domain,
|
2016-03-01 09:56:51 +01:00
|
|
|
const char *log_name,
|
2021-11-09 13:28:54 +01:00
|
|
|
int *child_status,
|
2016-03-01 09:56:51 +01:00
|
|
|
guint32 wait_before_kill_msec,
|
|
|
|
|
guint32 sleep_duration_msec);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
const char *nm_utils_find_helper(const char *progname, const char *try_first, GError **error);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2016-04-27 14:47:59 +02:00
|
|
|
char *nm_utils_read_link_absolute(const char *link_file, GError **error);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2019-07-18 15:37:55 +02:00
|
|
|
#define NM_MATCH_SPEC_MAC_TAG "mac:"
|
|
|
|
|
#define NM_MATCH_SPEC_S390_SUBCHANNELS_TAG "s390-subchannels:"
|
|
|
|
|
#define NM_MATCH_SPEC_INTERFACE_NAME_TAG "interface-name:"
|
|
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
typedef enum {
|
|
|
|
|
NM_MATCH_SPEC_NO_MATCH = 0,
|
|
|
|
|
NM_MATCH_SPEC_MATCH = 1,
|
|
|
|
|
NM_MATCH_SPEC_NEG_MATCH = 2,
|
|
|
|
|
} NMMatchSpecMatchType;
|
|
|
|
|
|
2023-06-08 14:35:46 +02:00
|
|
|
int nm_match_spec_match_type_to_bool(NMMatchSpecMatchType m, int no_match_value);
|
|
|
|
|
|
2023-06-08 17:01:01 +02:00
|
|
|
typedef struct _NMMatchSpecDeviceData {
|
|
|
|
|
const char *interface_name;
|
|
|
|
|
const char *device_type;
|
|
|
|
|
const char *driver;
|
|
|
|
|
const char *driver_version;
|
|
|
|
|
const char *dhcp_plugin;
|
|
|
|
|
const char *hwaddr;
|
|
|
|
|
const char *s390_subchannels;
|
|
|
|
|
} NMMatchSpecDeviceData;
|
|
|
|
|
|
|
|
|
|
NMMatchSpecMatchType nm_match_spec_device(const GSList *specs, const NMMatchSpecDeviceData *data);
|
|
|
|
|
|
core: refactor evaluation of device's match-spec
Previously, we would have different functions like
- nm_match_spec_device_type()
- nm_match_spec_hwaddr()
- nm_match_spec_s390_subchannels()
- nm_match_spec_interface_name()
which all would handle one type of match-spec.
So, to get the overall result whether the arguments
match or not, nm_device_spec_match_list() had to stich
them together and iterate the list multiple times.
Refactor the code to have one nm_match_spec_device()
function that gets all relevant paramters.
The upside is:
- the logic how to evaluate the match-spec is all at one place
(match_device_eval()) instead of spread over multiple
functions.
- It requires iterating the list at most twice. Twice, because
we do a fast pre-search for "*".
One downside could be, that we have to pass all 4 arguments
for the evaluation, even if the might no be needed. That is,
because "nm-core-utils.c" shall be independend from NMDevice, it
cannot receive a device instance to get the parameters as needed.
As we would add new match-types, the argument list would grow.
However, all arguments are cached and fetching them from the
device's private data is very cheap.
(cherry picked from commit b957403efd53ff7d826ac7a4f80487032c03824b)
2017-01-20 19:50:25 +01:00
|
|
|
NMMatchSpecMatchType nm_match_spec_config(const GSList *specs, guint nm_version, const char *env);
|
2021-11-09 13:28:54 +01:00
|
|
|
GSList *nm_match_spec_split(const char *value);
|
|
|
|
|
char *nm_match_spec_join(GSList *specs);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2018-08-09 09:29:51 +02:00
|
|
|
gboolean nm_wildcard_match_check(const char *str, const char *const *patterns, guint num_patterns);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2020-06-23 08:39:04 +02:00
|
|
|
gboolean nm_utils_kernel_cmdline_match_check(const char *const *proc_cmdline,
|
|
|
|
|
const char *const *patterns,
|
|
|
|
|
guint num_patterns,
|
2021-11-09 13:28:54 +01:00
|
|
|
GError **error);
|
2020-06-23 08:39:04 +02:00
|
|
|
|
2021-06-03 09:01:18 +02:00
|
|
|
int nm_utils_connection_match_spec_list(NMConnection *connection,
|
|
|
|
|
const GSList *specs,
|
|
|
|
|
int no_match_value);
|
|
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-08-30 19:17:29 +02:00
|
|
|
gboolean nm_utils_connection_has_default_route(NMConnection *connection,
|
|
|
|
|
int addr_family,
|
2021-11-09 13:28:54 +01:00
|
|
|
gboolean *out_is_never_default);
|
2017-08-30 19:17:29 +02:00
|
|
|
|
2017-02-03 15:38:58 +01:00
|
|
|
int nm_utils_cmp_connection_by_autoconnect_priority(NMConnection *a, NMConnection *b);
|
2016-03-01 09:56:51 +01:00
|
|
|
|
2018-03-29 11:47:52 +02:00
|
|
|
void nm_utils_log_connection_diff(NMConnection *connection,
|
|
|
|
|
NMConnection *diff_base,
|
|
|
|
|
guint32 level,
|
|
|
|
|
guint64 domain,
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *name,
|
|
|
|
|
const char *prefix,
|
|
|
|
|
const char *dbus_path);
|
2016-03-01 09:56:51 +01:00
|
|
|
|
|
|
|
|
gboolean nm_utils_is_specific_hostname(const char *name);
|
2022-03-04 08:09:39 +01:00
|
|
|
gboolean nm_utils_shorten_hostname(const char *hostname, char **shortened);
|
2016-03-01 09:56:51 +01:00
|
|
|
|
core: refactor loading machine-id and cache it
Previously, whenever we needed /etc/machine-id we would re-load it
from file. The are 3 downsides of that:
- the smallest downside is the runtime overhead of repeatedly
reading the file and parse it.
- as we read it multiple times, it may change anytime. Most
code in NetworkManager does not expect or handle a change of
the machine-id.
Generally, the admin should make sure that the machine-id is properly
initialized before NetworkManager starts, and not change it. As such,
a change of the machine-id should never happen in practice.
But if it would change, we would get odd behaviors. Note for example
how generate_duid_from_machine_id() already cached the generated DUID
and only read it once.
It's better to pick the machine-id once, and rely to use the same
one for the remainder of the program.
If the admin wants to change the machine-id, NetworkManager must be
restarted as well (in case the admin cares).
Also, as we now only load it once, it makes sense to log an error
(once) when we fail to read the machine-id.
- previously, loading the machine-id could fail each time. And we
have to somehow handle that error. It seems, the best thing what we
anyway can do, is to log an error once and continue with a fake
machine-id. Here we add a fake machine-id based on the secret-key
or the boot-id. Now obtaining a machine-id can no longer fail
and error handling is no longer necessary.
Also, ensure that a machine-id of all zeros is not valid.
Technically, a machine-id is not an RFC 4122 UUID. But it's
the same size, so we also use NMUuid data structure for it.
While at it, also refactor caching of the boot-id and the secret
key. In particular, fix the thread-safety of the double-checked
locking implementations.
2018-10-30 14:07:11 +01:00
|
|
|
struct _NMUuid;
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *nm_utils_machine_id_str(void);
|
core: refactor loading machine-id and cache it
Previously, whenever we needed /etc/machine-id we would re-load it
from file. The are 3 downsides of that:
- the smallest downside is the runtime overhead of repeatedly
reading the file and parse it.
- as we read it multiple times, it may change anytime. Most
code in NetworkManager does not expect or handle a change of
the machine-id.
Generally, the admin should make sure that the machine-id is properly
initialized before NetworkManager starts, and not change it. As such,
a change of the machine-id should never happen in practice.
But if it would change, we would get odd behaviors. Note for example
how generate_duid_from_machine_id() already cached the generated DUID
and only read it once.
It's better to pick the machine-id once, and rely to use the same
one for the remainder of the program.
If the admin wants to change the machine-id, NetworkManager must be
restarted as well (in case the admin cares).
Also, as we now only load it once, it makes sense to log an error
(once) when we fail to read the machine-id.
- previously, loading the machine-id could fail each time. And we
have to somehow handle that error. It seems, the best thing what we
anyway can do, is to log an error once and continue with a fake
machine-id. Here we add a fake machine-id based on the secret-key
or the boot-id. Now obtaining a machine-id can no longer fail
and error handling is no longer necessary.
Also, ensure that a machine-id of all zeros is not valid.
Technically, a machine-id is not an RFC 4122 UUID. But it's
the same size, so we also use NMUuid data structure for it.
While at it, also refactor caching of the boot-id and the secret
key. In particular, fix the thread-safety of the double-checked
locking implementations.
2018-10-30 14:07:11 +01:00
|
|
|
const struct _NMUuid *nm_utils_machine_id_bin(void);
|
|
|
|
|
gboolean nm_utils_machine_id_is_fake(void);
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *nm_utils_boot_id_str(void);
|
2018-12-12 10:14:51 +01:00
|
|
|
const struct _NMUuid *nm_utils_boot_id_bin(void);
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *nm_utils_proc_cmdline(void);
|
|
|
|
|
const char *const *nm_utils_proc_cmdline_split(void);
|
2016-04-25 21:18:06 +02:00
|
|
|
|
2018-12-12 10:10:38 +01:00
|
|
|
gboolean nm_utils_host_id_get(const guint8 **out_host_id, gsize *out_host_id_len);
|
2022-03-11 09:39:07 +01:00
|
|
|
gint64 nm_utils_host_id_get_timestamp_nsec(void);
|
2016-04-25 18:14:25 +02:00
|
|
|
|
2021-09-07 09:34:43 +02:00
|
|
|
void nmtst_utils_host_id_push(const guint8 *host_id,
|
|
|
|
|
gssize host_id_len,
|
|
|
|
|
gboolean is_good,
|
|
|
|
|
const gint64 *timestamp_ns);
|
|
|
|
|
|
|
|
|
|
void nmtst_utils_host_id_pop(void);
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
_nmtst_auto_utils_host_id_context_pop(const char *const *unused)
|
|
|
|
|
{
|
|
|
|
|
nmtst_utils_host_id_pop();
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
#define _NMTST_UTILS_HOST_ID_CONTEXT(uniq, host_id) \
|
|
|
|
|
_nm_unused nm_auto(_nmtst_auto_utils_host_id_context_pop) \
|
|
|
|
|
const char *const NM_UNIQ_T(_host_id_context_, uniq) = ({ \
|
|
|
|
|
const gint64 _timestamp_ns = 1631000672; \
|
|
|
|
|
\
|
|
|
|
|
nmtst_utils_host_id_push((const guint8 *) "" host_id "", \
|
|
|
|
|
NM_STRLEN(host_id), \
|
|
|
|
|
TRUE, \
|
|
|
|
|
&_timestamp_ns); \
|
|
|
|
|
"" host_id ""; \
|
|
|
|
|
})
|
2021-09-07 09:34:43 +02:00
|
|
|
|
|
|
|
|
#define NMTST_UTILS_HOST_ID_CONTEXT(host_id) _NMTST_UTILS_HOST_ID_CONTEXT(NM_UNIQ, host_id)
|
|
|
|
|
|
2018-12-20 08:38:05 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-12-20 08:50:07 +01:00
|
|
|
int nm_utils_arp_type_detect_from_hwaddrlen(gsize hwaddr_len);
|
2018-12-14 08:45:09 +01:00
|
|
|
|
2018-12-20 08:38:05 +01:00
|
|
|
gboolean nm_utils_arp_type_validate_hwaddr(int arp_type, const guint8 *hwaddr, gsize hwaddr_len);
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_utils_arp_type_get_hwaddr_relevant_part(int arp_type, const guint8 **hwaddr, gsize *hwaddr_len);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-12-18 14:03:38 +01:00
|
|
|
typedef enum {
|
|
|
|
|
/* The stable type. Note that this value is encoded in the
|
|
|
|
|
* generated addresses, thus the numbers MUST not change.
|
|
|
|
|
*
|
|
|
|
|
* Also note, if we ever allocate ID 255, we must take care
|
|
|
|
|
* that nm_utils_ipv6_addr_set_stable_privacy() extends the
|
|
|
|
|
* uint8 encoding of this value. */
|
2016-12-18 13:54:26 +01:00
|
|
|
NM_UTILS_STABLE_TYPE_UUID = 0,
|
2016-06-21 18:07:56 +02:00
|
|
|
NM_UTILS_STABLE_TYPE_STABLE_ID = 1,
|
2016-12-18 13:54:26 +01:00
|
|
|
NM_UTILS_STABLE_TYPE_GENERATED = 2,
|
|
|
|
|
NM_UTILS_STABLE_TYPE_RANDOM = 3,
|
2016-06-21 18:07:56 +02:00
|
|
|
} NMUtilsStableType;
|
|
|
|
|
|
2024-04-05 08:20:02 +02:00
|
|
|
#define NM_UTILS_STABLE_TYPE_NONE ((NMUtilsStableType) - 1)
|
2021-08-25 11:30:35 +02:00
|
|
|
|
2016-12-18 13:54:26 +01:00
|
|
|
NMUtilsStableType nm_utils_stable_id_parse(const char *stable_id,
|
2018-05-22 18:35:43 +02:00
|
|
|
const char *deviceid,
|
2018-11-02 12:07:09 +01:00
|
|
|
const char *hwaddr,
|
2016-12-18 13:54:26 +01:00
|
|
|
const char *bootid,
|
2018-05-22 18:35:43 +02:00
|
|
|
const char *uuid,
|
2023-11-14 10:12:10 +01:00
|
|
|
GBytes *ssid,
|
2021-11-09 13:28:54 +01:00
|
|
|
char **out_generated);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2023-12-06 11:09:15 +01:00
|
|
|
NMUtilsStableType nm_utils_stable_id_parse_network_ssid(GBytes *ssid,
|
|
|
|
|
const char *uuid,
|
|
|
|
|
gboolean complete,
|
|
|
|
|
char **out_stable_id);
|
2023-11-14 13:07:50 +01:00
|
|
|
|
2016-12-18 13:54:26 +01:00
|
|
|
char *nm_utils_stable_id_random(void);
|
|
|
|
|
char *nm_utils_stable_id_generated_complete(const char *msg);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2021-08-25 15:13:36 +02:00
|
|
|
#define NM_STABLE_PRIVACY_RFC7217_IDGEN_RETRIES 3
|
|
|
|
|
|
|
|
|
|
void nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NMUtilsStableType stable_type,
|
2021-11-09 13:28:54 +01:00
|
|
|
struct in6_addr *addr,
|
|
|
|
|
const char *ifname,
|
|
|
|
|
const char *network_id,
|
2021-08-25 15:13:36 +02:00
|
|
|
guint32 dad_counter,
|
2021-11-09 13:28:54 +01:00
|
|
|
const guint8 *host_id,
|
2021-08-25 15:13:36 +02:00
|
|
|
gsize host_id_len);
|
|
|
|
|
|
|
|
|
|
void nm_utils_ipv6_addr_set_stable_privacy(NMUtilsStableType stable_type,
|
2021-11-09 13:28:54 +01:00
|
|
|
struct in6_addr *addr,
|
|
|
|
|
const char *ifname,
|
|
|
|
|
const char *network_id,
|
2021-08-25 15:13:36 +02:00
|
|
|
guint32 dad_counter);
|
|
|
|
|
|
|
|
|
|
gboolean nm_utils_ipv6_addr_set_stable_privacy_may_fail(NMUtilsStableType stable_type,
|
2021-11-09 13:28:54 +01:00
|
|
|
struct in6_addr *addr,
|
|
|
|
|
const char *ifname,
|
|
|
|
|
const char *network_id,
|
2021-08-25 15:13:36 +02:00
|
|
|
guint32 dad_counter,
|
2021-11-09 13:28:54 +01:00
|
|
|
GError **error);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
all: make MAC address randomization algorithm configurable
For the per-connection settings "ethernet.cloned-mac-address"
and "wifi.cloned-mac-address", and for the per-device setting
"wifi.scan-rand-mac-address", we may generate MAC addresses using
either the "random" or "stable" algorithm.
Add new properties "generate-mac-address-mask" that allow to configure
which bits of the MAC address will be scrambled.
By default, the "random" and "stable" algorithms scamble all bits
of the MAC address, including the OUI part and generate a locally-
administered, unicast address.
By specifying a MAC address mask, we can now configure to perserve
parts of the current MAC address of the device. For example, setting
"FF:FF:FF:00:00:00" will preserve the first 3 octects of the current
MAC address.
One can also explicitly specify a MAC address to use instead of the
current MAC address. For example, "FF:FF:FF:00:00:00 68:F7:28:00:00:00"
sets the OUI part of the MAC address to "68:F7:28" while scrambling
the last 3 octects.
Similarly, "02:00:00:00:00:00 00:00:00:00:00:00" will scamble
all bits of the MAC address, except clearing the second-least
significant bit. Thus, creating a burned-in address, globally
administered.
One can also supply a list of MAC addresses like
"FF:FF:FF:00:00:00 68:F7:28:00:00:00 00:0C:29:00:00:00 ..." in which
case a MAC address is choosen randomly.
To fully scamble the MAC address one can configure
"02:00:00:00:00:00 00:00:00:00:00:00 02:00:00:00:00:00".
which also randomly creates either a locally or globally administered
address.
With this, the following macchanger options can be implemented:
`macchanger --random`
This is the default if no mask is configured.
-> ""
while is the same as:
-> "00:00:00:00:00:00"
-> "02:00:00:00:00:00 02:00:00:00:00:00"
`macchanger --random --bia`
-> "02:00:00:00:00:00 00:00:00:00:00:00"
`macchanger --ending`
This option cannot be fully implemented, because macchanger
uses the current MAC address but also implies --bia.
-> "FF:FF:FF:00:00:00"
This would yields the same result only if the current MAC address
is already a burned-in address too. Otherwise, it has not the same
effect as --ending.
-> "FF:FF:FF:00:00:00 <MAC_ADDR>"
Alternatively, instead of using the current MAC address,
spell the OUI part out. But again, that is not really the
same as macchanger does because you explictly have to name
the OUI part to use.
`machanger --another`
`machanger --another_any`
-> "FF:FF:FF:00:00:00 <MAC_ADDR> <MAC_ADDR> ..."
"$(printf "FF:FF:FF:00:00:00 %s\n" "$(sed -n 's/^\([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) .*/\1:\2:\3:00:00:00/p' /usr/share/macchanger/wireless.list | xargs)")"
2016-06-22 20:31:39 +02:00
|
|
|
char *nm_utils_hw_addr_gen_random_eth(const char *current_mac_address,
|
|
|
|
|
const char *generate_mac_address_mask);
|
2016-10-18 11:54:58 +02:00
|
|
|
char *nm_utils_hw_addr_gen_stable_eth_impl(NMUtilsStableType stable_type,
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *stable_id,
|
|
|
|
|
const guint8 *host_id,
|
2018-12-12 10:10:38 +01:00
|
|
|
gsize host_id_len,
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *ifname,
|
|
|
|
|
const char *current_mac_address,
|
|
|
|
|
const char *generate_mac_address_mask);
|
device: extend MAC address handling including randomization for ethernet and wifi
Extend the "ethernet.cloned-mac-address" and "wifi.cloned-mac-address"
settings. Instead of specifying an explicit MAC address, the additional
special values "permanent", "preserve", "random", "random-bia", "stable" and
"stable-bia" are supported.
"permanent" means to use the permanent hardware address. Previously that
was the default if no explict cloned-mac-address was set. The default is
thus still "permanent", but it can be overwritten by global
configuration.
"preserve" means not to configure the MAC address when activating the
device. That was actually the default behavior before introducing MAC
address handling with commit 1b49f941a69af910b0e68530be7339e8053068e5.
"random" and "random-bia" use a randomized MAC address for each
connection. "stable" and "stable-bia" use a generated, stable
address based on some token. The "bia" suffix says to generate a
burned-in address. The stable method by default uses as token the
connection UUID, but the token can be explicitly choosen via
"stable:<TOKEN>" and "stable-bia:<TOKEN>".
On a D-Bus level, the "cloned-mac-address" is a bytestring and thus
cannot express the new forms. It is replaced by the new
"assigned-mac-address" field. For the GObject property, libnm's API,
nmcli, keyfile, etc. the old name "cloned-mac-address" is still used.
Deprecating the old field seems more complicated then just extending
the use of the existing "cloned-mac-address" field, although the name
doesn't match well with the extended meaning.
There is some overlap with the "wifi.mac-address-randomization" setting.
https://bugzilla.gnome.org/show_bug.cgi?id=705545
https://bugzilla.gnome.org/show_bug.cgi?id=708820
https://bugzilla.gnome.org/show_bug.cgi?id=758301
2016-05-24 15:57:16 +02:00
|
|
|
char *nm_utils_hw_addr_gen_stable_eth(NMUtilsStableType stable_type,
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *stable_id,
|
|
|
|
|
const char *ifname,
|
|
|
|
|
const char *current_mac_address,
|
|
|
|
|
const char *generate_mac_address_mask);
|
device: extend MAC address handling including randomization for ethernet and wifi
Extend the "ethernet.cloned-mac-address" and "wifi.cloned-mac-address"
settings. Instead of specifying an explicit MAC address, the additional
special values "permanent", "preserve", "random", "random-bia", "stable" and
"stable-bia" are supported.
"permanent" means to use the permanent hardware address. Previously that
was the default if no explict cloned-mac-address was set. The default is
thus still "permanent", but it can be overwritten by global
configuration.
"preserve" means not to configure the MAC address when activating the
device. That was actually the default behavior before introducing MAC
address handling with commit 1b49f941a69af910b0e68530be7339e8053068e5.
"random" and "random-bia" use a randomized MAC address for each
connection. "stable" and "stable-bia" use a generated, stable
address based on some token. The "bia" suffix says to generate a
burned-in address. The stable method by default uses as token the
connection UUID, but the token can be explicitly choosen via
"stable:<TOKEN>" and "stable-bia:<TOKEN>".
On a D-Bus level, the "cloned-mac-address" is a bytestring and thus
cannot express the new forms. It is replaced by the new
"assigned-mac-address" field. For the GObject property, libnm's API,
nmcli, keyfile, etc. the old name "cloned-mac-address" is still used.
Deprecating the old field seems more complicated then just extending
the use of the existing "cloned-mac-address" field, although the name
doesn't match well with the extended meaning.
There is some overlap with the "wifi.mac-address-randomization" setting.
https://bugzilla.gnome.org/show_bug.cgi?id=705545
https://bugzilla.gnome.org/show_bug.cgi?id=708820
https://bugzilla.gnome.org/show_bug.cgi?id=758301
2016-05-24 15:57:16 +02:00
|
|
|
|
2018-10-30 08:37:48 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-12-20 08:38:05 +01:00
|
|
|
GBytes *nm_utils_dhcp_client_id_mac(int arp_type, const guint8 *hwaddr, gsize hwaddr_len);
|
|
|
|
|
|
2018-11-23 13:00:07 +01:00
|
|
|
guint32 nm_utils_create_dhcp_iaid(gboolean legacy_unstable_byteorder,
|
|
|
|
|
const guint8 *interface_id,
|
|
|
|
|
gsize interface_id_len);
|
|
|
|
|
|
2021-01-04 17:32:47 +01:00
|
|
|
GBytes *nm_utils_dhcp_client_id_duid(guint32 iaid, const guint8 *duid, gsize duid_len);
|
|
|
|
|
|
2019-12-02 11:29:13 +01:00
|
|
|
GBytes *nm_utils_dhcp_client_id_systemd_node_specific_full(guint32 iaid,
|
2018-10-30 08:37:48 +01:00
|
|
|
const guint8 *machine_id,
|
|
|
|
|
gsize machine_id_len);
|
|
|
|
|
|
2019-12-02 11:29:13 +01:00
|
|
|
GBytes *nm_utils_dhcp_client_id_systemd_node_specific(guint32 iaid);
|
2018-10-30 08:37:48 +01:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-09-10 12:46:53 +02:00
|
|
|
/* RFC 3315 defines the epoch for the DUID-LLT time field on Jan 1st 2000. */
|
|
|
|
|
#define NM_UTILS_EPOCH_DATETIME_200001010000 946684800
|
|
|
|
|
|
|
|
|
|
struct _NMUuid;
|
|
|
|
|
|
|
|
|
|
GBytes *
|
|
|
|
|
nm_utils_generate_duid_llt(int arp_type, const guint8 *hwaddr, gsize hwaddr_len, gint64 time);
|
|
|
|
|
|
|
|
|
|
GBytes *nm_utils_generate_duid_ll(int arp_type, const guint8 *hwaddr, gsize hwaddr_len);
|
|
|
|
|
|
|
|
|
|
GBytes *nm_utils_generate_duid_uuid(const struct _NMUuid *uuid);
|
|
|
|
|
|
|
|
|
|
GBytes *nm_utils_generate_duid_from_machine_id(void);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
void nm_utils_array_remove_at_indexes(GArray *array, const guint *indexes_to_delete, gsize len);
|
|
|
|
|
|
|
|
|
|
void nm_utils_setpgid(gpointer unused);
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
NM_UTILS_TEST_NONE = 0,
|
|
|
|
|
|
|
|
|
|
/* Internal flag, marking that either nm_utils_get_testing() or _nm_utils_set_testing() was called. */
|
|
|
|
|
_NM_UTILS_TEST_INITIALIZED = (1LL << 0),
|
|
|
|
|
|
|
|
|
|
/* Indicate that test mode is enabled in general. Explicitly calling _nm_utils_set_testing() will always set this flag. */
|
|
|
|
|
_NM_UTILS_TEST_GENERAL = (1LL << 1),
|
|
|
|
|
|
|
|
|
|
/* Don't check the owner of keyfiles during testing. */
|
|
|
|
|
NM_UTILS_TEST_NO_KEYFILE_OWNER_CHECK = (1LL << 2),
|
|
|
|
|
|
|
|
|
|
_NM_UTILS_TEST_LAST,
|
|
|
|
|
NM_UTILS_TEST_ALL = (((_NM_UTILS_TEST_LAST - 1) << 1) - 1) & ~(_NM_UTILS_TEST_INITIALIZED),
|
|
|
|
|
} NMUtilsTestFlags;
|
|
|
|
|
|
|
|
|
|
gboolean nm_utils_get_testing_initialized(void);
|
|
|
|
|
NMUtilsTestFlags nm_utils_get_testing(void);
|
|
|
|
|
void _nm_utils_set_testing(NMUtilsTestFlags flags);
|
|
|
|
|
|
|
|
|
|
void nm_utils_g_value_set_strv(GValue *value, GPtrArray *strings);
|
|
|
|
|
|
2020-07-22 18:28:12 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-06-02 19:17:35 +02:00
|
|
|
const char *nm_utils_dnsmasq_status_to_string(int status, char *dest, gsize size);
|
2016-05-01 22:24:41 +02:00
|
|
|
|
2020-11-20 20:08:37 +01:00
|
|
|
void nm_utils_get_reverse_dns_domains_ip_4(guint32 ip, guint8 plen, GPtrArray *domains);
|
2016-06-03 22:07:42 +02:00
|
|
|
void
|
2020-11-20 20:08:37 +01:00
|
|
|
nm_utils_get_reverse_dns_domains_ip_6(const struct in6_addr *ip, guint8 plen, GPtrArray *domains);
|
2016-06-03 22:07:38 +02:00
|
|
|
|
2020-11-20 20:10:57 +01:00
|
|
|
static inline void
|
|
|
|
|
nm_utils_get_reverse_dns_domains_ip(int addr_family,
|
|
|
|
|
gconstpointer addr,
|
|
|
|
|
guint8 plen,
|
2021-11-09 13:28:54 +01:00
|
|
|
GPtrArray *domains)
|
2020-11-20 20:10:57 +01:00
|
|
|
{
|
|
|
|
|
if (NM_IS_IPv4(addr_family))
|
|
|
|
|
nm_utils_get_reverse_dns_domains_ip_4(*((const in_addr_t *) addr), plen, domains);
|
|
|
|
|
else
|
|
|
|
|
nm_utils_get_reverse_dns_domains_ip_6(addr, plen, domains);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-17 09:56:16 +01:00
|
|
|
struct stat;
|
|
|
|
|
|
|
|
|
|
gboolean nm_utils_validate_plugin(const char *path, struct stat *stat, GError **error);
|
2021-11-09 13:28:54 +01:00
|
|
|
char **nm_utils_read_plugin_paths(const char *dirname, const char *prefix);
|
|
|
|
|
char *nm_utils_format_con_diff_for_audit(GHashTable *diff);
|
2017-03-03 23:59:16 +01:00
|
|
|
|
2017-10-09 11:56:51 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-07 11:04:36 +01:00
|
|
|
const char *nm_activation_type_to_string(NMActivationType activation_type);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-01-10 11:23:33 +01:00
|
|
|
const char *nm_utils_parse_dns_domain(const char *domain, gboolean *is_routing);
|
|
|
|
|
|
2019-02-09 11:46:47 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-01-27 20:16:22 +01:00
|
|
|
void nm_wifi_utils_parse_ies(const guint8 *bytes,
|
|
|
|
|
gsize len,
|
2021-11-09 13:28:54 +01:00
|
|
|
guint32 *out_max_rate,
|
2023-07-27 16:15:47 +02:00
|
|
|
guint32 *out_bandwidth,
|
2021-11-09 13:28:54 +01:00
|
|
|
gboolean *out_metered,
|
|
|
|
|
gboolean *out_owe_transition_mode);
|
2020-01-27 20:16:22 +01:00
|
|
|
|
2020-01-27 19:31:23 +01:00
|
|
|
guint8 nm_wifi_utils_level_to_quality(int val);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-02-09 11:46:47 +01:00
|
|
|
#define NM_VPN_ROUTE_METRIC_DEFAULT 50
|
|
|
|
|
|
2019-09-04 10:18:56 +02:00
|
|
|
#define NM_UTILS_ERROR_MSG_REQ_AUTH_FAILED "Unable to authenticate the request"
|
|
|
|
|
#define NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN "Unable to determine UID of the request"
|
|
|
|
|
#define NM_UTILS_ERROR_MSG_INSUFF_PRIV "Insufficient privileges"
|
|
|
|
|
|
2021-05-24 21:49:35 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
void nm_utils_spawn_helper(const char *const *args,
|
|
|
|
|
GCancellable *cancellable,
|
2021-05-24 21:49:35 +02:00
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
|
gpointer cb_data);
|
|
|
|
|
|
|
|
|
|
char *nm_utils_spawn_helper_finish(GAsyncResult *result, GError **error);
|
|
|
|
|
|
2022-01-18 17:30:14 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
uid_t nm_utils_get_nm_uid(void);
|
|
|
|
|
|
|
|
|
|
gid_t nm_utils_get_nm_gid(void);
|
|
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
#endif /* __NM_CORE_UTILS_H__ */
|