From e74c568b07b50b97873fb4ee1d776dedefbd54d6 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Fri, 1 Oct 2021 23:05:04 +0200 Subject: New upstream version 1.32.12 --- src/core/nm-core-utils.h | 189 ++++------------------------------------------- 1 file changed, 14 insertions(+), 175 deletions(-) (limited to 'src/core/nm-core-utils.h') diff --git a/src/core/nm-core-utils.h b/src/core/nm-core-utils.h index 5dc4d432..76c340d1 100644 --- a/src/core/nm-core-utils.h +++ b/src/core/nm-core-utils.h @@ -12,12 +12,10 @@ #include "nm-connection.h" -#include "nm-glib-aux/nm-time-utils.h" +#include "libnm-glib-aux/nm-time-utils.h" /*****************************************************************************/ -#define NM_PLATFORM_LIFETIME_PERMANENT G_MAXUINT32 - #define NM_DEFINE_SINGLETON_INSTANCE(TYPE) static TYPE *singleton_instance #define NM_DEFINE_SINGLETON_REGISTER(TYPE) \ @@ -98,73 +96,6 @@ void _nm_singleton_instance_register_destruction(GObject *instance); gboolean nm_ether_addr_is_valid(const NMEtherAddr *addr); gboolean nm_ether_addr_is_valid_str(const char *str); -gconstpointer -nm_utils_ipx_address_clear_host_address(int family, gpointer dst, gconstpointer src, guint8 plen); -in_addr_t nm_utils_ip4_address_clear_host_address(in_addr_t addr, guint8 plen); -const struct in6_addr *nm_utils_ip6_address_clear_host_address(struct in6_addr * dst, - const struct in6_addr *src, - guint8 plen); - -static inline int -nm_utils_ip4_address_same_prefix_cmp(in_addr_t addr_a, in_addr_t addr_b, guint8 plen) -{ - NM_CMP_DIRECT(htonl(nm_utils_ip4_address_clear_host_address(addr_a, plen)), - htonl(nm_utils_ip4_address_clear_host_address(addr_b, plen))); - return 0; -} - -int nm_utils_ip6_address_same_prefix_cmp(const struct in6_addr *addr_a, - const struct in6_addr *addr_b, - guint8 plen); - -static inline int -nm_utils_ip_address_same_prefix_cmp(int addr_family, - gconstpointer addr_a, - gconstpointer addr_b, - guint8 plen) -{ - nm_assert_addr_family(addr_family); - - NM_CMP_SELF(addr_a, addr_b); - - if (NM_IS_IPv4(addr_family)) { - return nm_utils_ip4_address_same_prefix_cmp(*((const in_addr_t *) addr_a), - *((const in_addr_t *) addr_b), - plen); - } - - return nm_utils_ip6_address_same_prefix_cmp(addr_a, addr_b, plen); -} - -static inline gboolean -nm_utils_ip4_address_same_prefix(in_addr_t addr_a, in_addr_t addr_b, guint8 plen) -{ - return nm_utils_ip4_address_same_prefix_cmp(addr_a, addr_b, plen) == 0; -} - -static inline gboolean -nm_utils_ip6_address_same_prefix(const struct in6_addr *addr_a, - const struct in6_addr *addr_b, - guint8 plen) -{ - return nm_utils_ip6_address_same_prefix_cmp(addr_a, addr_b, plen) == 0; -} - -static inline gboolean -nm_utils_ip_address_same_prefix(int addr_family, - gconstpointer addr_a, - gconstpointer addr_b, - guint8 plen) -{ - return nm_utils_ip_address_same_prefix_cmp(addr_family, addr_a, addr_b, plen) == 0; -} - -#define NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX(a, b, plen) \ - NM_CMP_RETURN(nm_utils_ip4_address_same_prefix_cmp((a), (b), (plen))) - -#define NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX(a, b, plen) \ - NM_CMP_RETURN(nm_utils_ip6_address_same_prefix_cmp((a), (b), (plen))) - static inline void nm_hash_update_in6addr(NMHashState *h, const struct in6_addr *addr) { @@ -185,8 +116,6 @@ nm_hash_update_in6addr_prefix(NMHashState *h, const struct in6_addr *addr, guint nm_hash_update_in6addr(h, &a); } -double nm_utils_exp10(gint16 e); - /** * nm_utils_ip6_route_metric_normalize: * @metric: the route metric @@ -221,9 +150,6 @@ nm_utils_ip_route_metric_penalize(guint32 metric, guint32 penalty) return G_MAXUINT32; } -int nm_utils_modprobe(GError **error, gboolean suppress_error_loggin, const char *arg1, ...) - G_GNUC_NULL_TERMINATED; - void nm_utils_kill_process_sync(pid_t pid, guint64 start_time, int sig, @@ -285,15 +211,16 @@ gboolean nm_utils_kernel_cmdline_match_check(const char *const *proc_cmdline, guint num_patterns, GError ** error); +int nm_utils_connection_match_spec_list(NMConnection *connection, + const GSList *specs, + int no_match_value); + /*****************************************************************************/ gboolean nm_utils_connection_has_default_route(NMConnection *connection, int addr_family, gboolean * out_is_never_default); -char * nm_utils_new_vlan_name(const char *parent_iface, guint32 vlan_id); -const char *nm_utils_new_infiniband_name(char *name, const char *parent_name, int p_key); - int nm_utils_cmp_connection_by_autoconnect_priority(NMConnection *a, NMConnection *b); void nm_utils_log_connection_diff(NMConnection *connection, @@ -304,19 +231,6 @@ void nm_utils_log_connection_diff(NMConnection *connection, const char * prefix, const char * dbus_path); -gboolean nm_utils_is_valid_path_component(const char *name); -const char *NM_ASSERT_VALID_PATH_COMPONENT(const char *name); - -#define NM_UTILS_SYSCTL_IP_CONF_PATH_BUFSIZE 100 - -const char * -nm_utils_sysctl_ip_conf_path(int addr_family, char *buf, const char *ifname, const char *property); - -gboolean nm_utils_sysctl_ip_conf_is_path(int addr_family, - const char *path, - const char *ifname, - const char *property); - gboolean nm_utils_is_specific_hostname(const char *name); struct _NMUuid; @@ -344,49 +258,6 @@ nm_utils_arp_type_get_hwaddr_relevant_part(int arp_type, const guint8 **hwaddr, /*****************************************************************************/ -/* IPv6 Interface Identifier helpers */ - -/** - * NMUtilsIPv6IfaceId: - * @id: convenience member for validity checking; never use directly - * @id_u8: the 64-bit Interface Identifier - * - * Holds a 64-bit IPv6 Interface Identifier. The IID is a sequence of bytes - * and should not normally be treated as a %guint64, but this is done for - * convenience of validity checking and initialization. - */ -struct _NMUtilsIPv6IfaceId { - union { - guint64 id; - guint8 id_u8[8]; - }; -}; - -#define NM_UTILS_IPV6_IFACE_ID_INIT \ - { \ - { \ - .id = 0 \ - } \ - } - -void nm_utils_ipv6_addr_set_interface_identifier(struct in6_addr * addr, - const NMUtilsIPv6IfaceId iid); - -void nm_utils_ipv6_interface_identifier_get_from_addr(NMUtilsIPv6IfaceId * iid, - const struct in6_addr *addr); - -gboolean nm_utils_ipv6_interface_identifier_get_from_token(NMUtilsIPv6IfaceId *iid, - const char * token); - -const char *nm_utils_inet6_interface_identifier_to_token(NMUtilsIPv6IfaceId iid, - char buf[static INET6_ADDRSTRLEN]); - -gboolean nm_utils_get_ipv6_interface_identifier(NMLinkType link_type, - const guint8 * hwaddr, - guint len, - guint dev_id, - NMUtilsIPv6IfaceId *out_iid); - typedef enum { /* The stable type. Note that this value is encoded in the * generated addresses, thus the numbers MUST not change. @@ -501,33 +372,6 @@ void _nm_utils_set_testing(NMUtilsTestFlags flags); void nm_utils_g_value_set_strv(GValue *value, GPtrArray *strings); -guint32 -nm_utils_lifetime_rebase_relative_time_on_now(guint32 timestamp, guint32 duration, gint32 now); - -guint32 nm_utils_lifetime_get(guint32 timestamp, - guint32 lifetime, - guint32 preferred, - gint32 now, - guint32 *out_preferred); - -/*****************************************************************************/ - -#define NM_IPV4LL_NETWORK ((in_addr_t)(htonl(0xA9FE0000lu))) -#define NM_IPV4LL_NETMASK ((in_addr_t)(htonl(0xFFFF0000lu))) - -static inline gboolean -nm_utils_ip4_address_is_link_local(in_addr_t addr) -{ - return (addr & NM_IPV4LL_NETMASK) == NM_IPV4LL_NETWORK; -} - -static inline gboolean -nm_utils_ip4_address_is_zeronet(in_addr_t network) -{ - /* Same as ipv4_is_zeronet() from kernel's include/linux/in.h. */ - return (network & htonl(0xFF000000u)) == htonl(0x00000000u); -} - /*****************************************************************************/ const char *nm_utils_dnsmasq_status_to_string(int status, char *dest, gsize size); @@ -556,20 +400,6 @@ char * nm_utils_format_con_diff_for_audit(GHashTable *diff); /*****************************************************************************/ -/* this enum is compatible with ICMPV6_ROUTER_PREF_* (from , - * the values for netlink attribute RTA_PREF) and "enum ndp_route_preference" - * from . */ -typedef enum _nm_packed { - NM_ICMPV6_ROUTER_PREF_MEDIUM = 0x0, /* ICMPV6_ROUTER_PREF_MEDIUM */ - NM_ICMPV6_ROUTER_PREF_LOW = 0x3, /* ICMPV6_ROUTER_PREF_LOW */ - NM_ICMPV6_ROUTER_PREF_HIGH = 0x1, /* ICMPV6_ROUTER_PREF_HIGH */ - NM_ICMPV6_ROUTER_PREF_INVALID = 0x2, /* ICMPV6_ROUTER_PREF_INVALID */ -} NMIcmpv6RouterPref; - -const char *nm_icmpv6_router_pref_to_string(NMIcmpv6RouterPref pref, char *buf, gsize len); - -/*****************************************************************************/ - const char *nm_activation_type_to_string(NMActivationType activation_type); /*****************************************************************************/ @@ -594,4 +424,13 @@ guint8 nm_wifi_utils_level_to_quality(int val); #define NM_UTILS_ERROR_MSG_REQ_UID_UKNOWN "Unable to determine UID of the request" #define NM_UTILS_ERROR_MSG_INSUFF_PRIV "Insufficient privileges" +/*****************************************************************************/ + +void nm_utils_spawn_helper(const char *const * args, + GCancellable * cancellable, + GAsyncReadyCallback callback, + gpointer cb_data); + +char *nm_utils_spawn_helper_finish(GAsyncResult *result, GError **error); + #endif /* __NM_CORE_UTILS_H__ */ -- cgit 1.3.0-6-gf8a5 From 88c227d90a6b7b388c5c85d72802a0ca8f05ed5c Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Thu, 13 Jan 2022 22:30:39 +0100 Subject: New upstream version 1.34.0 --- src/core/nm-core-utils.h | 68 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 16 deletions(-) (limited to 'src/core/nm-core-utils.h') diff --git a/src/core/nm-core-utils.h b/src/core/nm-core-utils.h index 76c340d1..38f56adc 100644 --- a/src/core/nm-core-utils.h +++ b/src/core/nm-core-utils.h @@ -40,7 +40,7 @@ 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 - #define NM_DEFINE_SINGLETON_ALLOW_MULTIPLE FALSE +#define NM_DEFINE_SINGLETON_ALLOW_MULTIPLE FALSE #endif #define NM_DEFINE_SINGLETON_GETTER(TYPE, GETTER, GTYPE, ...) \ @@ -247,6 +247,33 @@ const char *const * nm_utils_proc_cmdline_split(void); gboolean nm_utils_host_id_get(const guint8 **out_host_id, gsize *out_host_id_len); gint64 nm_utils_host_id_get_timestamp_ns(void); +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(); +} + +#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 ""; \ + }) + +#define NMTST_UTILS_HOST_ID_CONTEXT(host_id) _NMTST_UTILS_HOST_ID_CONTEXT(NM_UNIQ, host_id) + /*****************************************************************************/ int nm_utils_arp_type_detect_from_hwaddrlen(gsize hwaddr_len); @@ -271,6 +298,8 @@ typedef enum { NM_UTILS_STABLE_TYPE_RANDOM = 3, } NMUtilsStableType; +#define NM_UTILS_STABLE_TYPE_NONE ((NMUtilsStableType) -1) + NMUtilsStableType nm_utils_stable_id_parse(const char *stable_id, const char *deviceid, const char *hwaddr, @@ -281,21 +310,28 @@ NMUtilsStableType nm_utils_stable_id_parse(const char *stable_id, char *nm_utils_stable_id_random(void); char *nm_utils_stable_id_generated_complete(const char *msg); -gboolean nm_utils_ipv6_addr_set_stable_privacy_impl(NMUtilsStableType stable_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, - guint32 dad_counter, - guint8 * host_id, - gsize host_id_len, - GError ** error); - -gboolean nm_utils_ipv6_addr_set_stable_privacy(NMUtilsStableType id_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, - guint32 dad_counter, - GError ** error); +#define NM_STABLE_PRIVACY_RFC7217_IDGEN_RETRIES 3 + +void nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NMUtilsStableType stable_type, + struct in6_addr * addr, + const char * ifname, + const char * network_id, + guint32 dad_counter, + const guint8 * host_id, + gsize host_id_len); + +void nm_utils_ipv6_addr_set_stable_privacy(NMUtilsStableType stable_type, + struct in6_addr * addr, + const char * ifname, + const char * network_id, + guint32 dad_counter); + +gboolean nm_utils_ipv6_addr_set_stable_privacy_may_fail(NMUtilsStableType stable_type, + struct in6_addr * addr, + const char * ifname, + const char * network_id, + guint32 dad_counter, + GError ** error); char *nm_utils_hw_addr_gen_random_eth(const char *current_mac_address, const char *generate_mac_address_mask); -- cgit 1.3.0-6-gf8a5