summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-04-01 21:29:51 +0200
committerThomas Haller <thaller@redhat.com>2022-05-03 10:05:59 +0200
commit3a9d6e56495a86edfa44c3e64d566f4e86061ae9 (patch)
tree8f796d416336ca43e4ce52acba63c275fbcf1ec0
parent9bd3451afe64619ac278522ef54105c09a028034 (diff)
glib-aux: move ip address utils in "nm-shared-utils.h" header
Some were duplicated. Drop those. Some function were in an order where they required forward declarations. Reorder. (cherry picked from commit d7990b359b421ebc4a8bde7fdd6614773d157153)
-rw-r--r--src/libnm-glib-aux/nm-shared-utils.h54
1 files changed, 22 insertions, 32 deletions
diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h
index b9b16950fa..3cf9fcc59d 100644
--- a/src/libnm-glib-aux/nm-shared-utils.h
+++ b/src/libnm-glib-aux/nm-shared-utils.h
@@ -389,6 +389,10 @@ gboolean nm_utils_get_ipv6_interface_identifier(NMLinkType link_type,
/*****************************************************************************/
+in_addr_t _nm_utils_ip4_prefix_to_netmask(guint32 prefix);
+guint32 _nm_utils_ip4_get_default_prefix0(in_addr_t ip);
+guint32 _nm_utils_ip4_get_default_prefix(in_addr_t ip);
+
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);
@@ -408,6 +412,20 @@ int nm_utils_ip6_address_same_prefix_cmp(const struct in6_addr *addr_a,
const struct in6_addr *addr_b,
guint8 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 int
nm_utils_ip_address_same_prefix_cmp(int addr_family,
gconstpointer addr_a,
@@ -428,20 +446,6 @@ nm_utils_ip_address_same_prefix_cmp(int addr_family,
}
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,
@@ -458,6 +462,10 @@ nm_utils_ip_address_same_prefix(int addr_family,
/*****************************************************************************/
+gboolean nm_utils_ip_is_site_local(int addr_family, const void *address);
+
+/*****************************************************************************/
+
#define NM_IPV4LL_NETWORK ((in_addr_t) (htonl(0xA9FE0000lu)))
#define NM_IPV4LL_NETMASK ((in_addr_t) (htonl(0xFFFF0000lu)))
@@ -974,24 +982,6 @@ nm_utils_escaped_tokens_options_escape_val(const char *val, char **out_to_free)
/*****************************************************************************/
-guint32 _nm_utils_ip4_prefix_to_netmask(guint32 prefix);
-guint32 _nm_utils_ip4_get_default_prefix0(in_addr_t ip);
-guint32 _nm_utils_ip4_get_default_prefix(in_addr_t ip);
-
-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);
-int nm_utils_ip6_address_same_prefix_cmp(const struct in6_addr *addr_a,
- const struct in6_addr *addr_b,
- guint8 plen);
-
-gboolean nm_utils_ip_is_site_local(int addr_family, const void *address);
-
-/*****************************************************************************/
-
gboolean nm_utils_parse_inaddr_bin_full(int addr_family,
gboolean accept_legacy,
const char *text,