From 0ccb25c5fa5c912f0151823b50aa375bc454a6dd Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 14 Mar 2019 11:16:19 +0100 Subject: [PATCH] shared: add nm_ip_addr_is_null() helper --- shared/nm-utils/nm-shared-utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h index f48bfede7e..fae0abe828 100644 --- a/shared/nm-utils/nm-shared-utils.h +++ b/shared/nm-utils/nm-shared-utils.h @@ -126,6 +126,16 @@ typedef struct { extern const NMIPAddr nm_ip_addr_zero; +static inline gboolean +nm_ip_addr_is_null (int addr_family, gconstpointer addr) +{ + nm_assert (addr); + if (addr_family == AF_INET6) + return IN6_IS_ADDR_UNSPECIFIED ((const struct in6_addr *) addr); + nm_assert (addr_family == AF_INET); + return ((const struct in_addr *) addr)->s_addr == 0; +} + static inline void nm_ip_addr_set (int addr_family, gpointer dst, gconstpointer src) {