shared: add nm_utils_ether_addr_equal(), nm_utils_ether_addr_cmp()

This commit is contained in:
Thomas Haller 2020-06-08 13:43:47 +02:00
parent fce73b1c82
commit 39127758bd
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 24 additions and 0 deletions

View file

@ -13,6 +13,7 @@
#include <sys/syscall.h>
#include <glib-unix.h>
#include <net/if.h>
#include <net/ethernet.h>
#include "nm-errno.h"
#include "nm-str-buf.h"
@ -88,6 +89,11 @@ nm_ip_addr_set_from_untrusted (int addr_family,
/*****************************************************************************/
G_STATIC_ASSERT (ETH_ALEN == sizeof (struct ether_addr));
G_STATIC_ASSERT (ETH_ALEN == 6);
/*****************************************************************************/
gsize
nm_utils_get_next_realloc_size (gboolean true_realloc, gsize requested)
{

View file

@ -178,6 +178,24 @@ nm_ip4_addr_is_localhost (in_addr_t addr4)
/*****************************************************************************/
struct ether_addr;
static inline int
nm_utils_ether_addr_cmp (const struct ether_addr *a1, const struct ether_addr *a2)
{
nm_assert (a1);
nm_assert (a2);
return memcmp (a1, a2, 6 /*ETH_ALEN*/);
}
static inline gboolean
nm_utils_ether_addr_equal (const struct ether_addr *a1, const struct ether_addr *a2)
{
return nm_utils_ether_addr_cmp (a1, a2) == 0;
}
/*****************************************************************************/
#define NM_UTILS_INET_ADDRSTRLEN INET6_ADDRSTRLEN
static inline const char *