diff options
| author | Michael Biebl <biebl@debian.org> | 2017-12-12 15:53:07 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-12-12 15:53:07 +0100 |
| commit | afcd268ea7b1149fbfb66bce4eca659b675da0a2 (patch) | |
| tree | c3fca2203ad17434daf3ccf576582bd66aa41ab2 /shared/nm-utils/nm-shared-utils.h | |
| parent | 417f6015c3dc8c47cf27daa59f64e0e36c521b9c (diff) | |
New upstream version 1.10.2 upstream/1.10.2
Diffstat (limited to 'shared/nm-utils/nm-shared-utils.h')
| -rw-r--r-- | shared/nm-utils/nm-shared-utils.h | 77 |
1 files changed, 60 insertions, 17 deletions
diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h index 96aab534..d6d829cd 100644 --- a/shared/nm-utils/nm-shared-utils.h +++ b/shared/nm-utils/nm-shared-utils.h @@ -26,23 +26,6 @@ /*****************************************************************************/ -typedef struct { - union { - guint8 addr_ptr[1]; - in_addr_t addr4; - struct in6_addr addr6; - - /* NMIPAddr is really a union for IP addresses. - * However, as ethernet addresses fit in here nicely, use - * it also for an ethernet MAC address. */ - guint8 addr_eth[6 /*ETH_ALEN*/]; - }; -} NMIPAddr; - -extern const NMIPAddr nm_ip_addr_zero; - -/*****************************************************************************/ - static inline char nm_utils_addr_family_to_char (int addr_family) { @@ -68,6 +51,36 @@ nm_utils_addr_family_to_size (int addr_family) /*****************************************************************************/ +typedef struct { + union { + guint8 addr_ptr[1]; + in_addr_t addr4; + struct in6_addr addr6; + + /* NMIPAddr is really a union for IP addresses. + * However, as ethernet addresses fit in here nicely, use + * it also for an ethernet MAC address. */ + guint8 addr_eth[6 /*ETH_ALEN*/]; + }; +} NMIPAddr; + +extern const NMIPAddr nm_ip_addr_zero; + +static inline void +nm_ip_addr_set (int addr_family, gpointer dst, const NMIPAddr *src) +{ + nm_assert_addr_family (addr_family); + nm_assert (dst); + nm_assert (src); + + if (addr_family != AF_INET6) + *((in_addr_t *) dst) = src->addr4; + else + *((struct in6_addr *) dst) = src->addr6; +} + +/*****************************************************************************/ + #define NM_CMP_RETURN(c) \ G_STMT_START { \ const int _cc = (c); \ @@ -373,6 +386,16 @@ gboolean nm_g_object_set_property (GObject *object, const GValue *value, GError **error); +gboolean nm_g_object_set_property_boolean (GObject *object, + const gchar *property_name, + gboolean value, + GError **error); + +gboolean nm_g_object_set_property_uint (GObject *object, + const gchar *property_name, + guint value, + GError **error); + GParamSpec *nm_g_object_class_find_property_from_gtype (GType gtype, const char *property_name); @@ -394,6 +417,26 @@ char *nm_utils_str_utf8safe_escape_take (char *str, NMUtilsStrUtf8SafeFlags flag /*****************************************************************************/ +typedef struct { + const char *name; +} NMUtilsNamedEntry; + +typedef struct { + union { + NMUtilsNamedEntry named_entry; + const char *name; + }; + union { + const char *value_str; + gconstpointer value_ptr; + }; +} NMUtilsNamedValue; + +#define nm_utils_named_entry_cmp nm_strcmp_p +#define nm_utils_named_entry_cmp_with_data nm_strcmp_p_with_data + +/*****************************************************************************/ + #define NM_UTILS_NS_PER_SECOND ((gint64) 1000000000) #define NM_UTILS_NS_PER_MSEC ((gint64) 1000000) #define NM_UTILS_NS_TO_MSEC_CEIL(nsec) (((nsec) + (NM_UTILS_NS_PER_MSEC - 1)) / NM_UTILS_NS_PER_MSEC) |