diff options
author | Thomas Haller <thaller@redhat.com> | 2020-01-28 11:38:51 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-01-28 11:43:22 +0100 |
commit | 228519fe792afd7c17509e3a179a31aabf663579 (patch) | |
tree | f5d69a63a70a9f1a425d4c875bc4c4d7aecd2772 | |
parent | b9c5c07c4d756c4d0f4c0fda38cf4862b1b5c09e (diff) | |
download | NetworkManager-228519fe792afd7c17509e3a179a31aabf663579.tar.gz |
shared: add nm_ip_addr_cmp()/nm_ip_addr_equal() helpers
-rw-r--r-- | shared/nm-glib-aux/nm-shared-utils.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h index e835a1efa3..ebb526152a 100644 --- a/shared/nm-glib-aux/nm-shared-utils.h +++ b/shared/nm-glib-aux/nm-shared-utils.h @@ -124,6 +124,22 @@ typedef struct { extern const NMIPAddr nm_ip_addr_zero; +static inline int +nm_ip_addr_cmp (int addr_family, gconstpointer a, gconstpointer b) +{ + nm_assert_addr_family (addr_family); + nm_assert (a); + nm_assert (b); + + return memcmp (a, b, nm_utils_addr_family_to_size (addr_family)); +} + +static inline gboolean +nm_ip_addr_equal (int addr_family, gconstpointer a, gconstpointer b) +{ + return nm_ip_addr_cmp (addr_family, a, b) == 0; +} + static inline gboolean nm_ip_addr_is_null (int addr_family, gconstpointer addr) { |