summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-06-08 13:47:21 +0200
committerThomas Haller <thaller@redhat.com>2020-06-11 16:51:50 +0200
commite7955f577e668e2f3214c1f187ae179a4adbdd47 (patch)
treeb8071f28168d5a65251913039cea2b95f6610c92
parent0d41abea2ee24192647df9545ef210a99fd977b6 (diff)
downloadNetworkManager-e7955f577e668e2f3214c1f187ae179a4adbdd47.tar.gz
lldp: use nm_utils_ether_addr_equal() instead of re-implementation
-rw-r--r--src/devices/nm-lldp-listener.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/devices/nm-lldp-listener.c b/src/devices/nm-lldp-listener.c
index ee443d002c..6db59d47e8 100644
--- a/src/devices/nm-lldp-listener.c
+++ b/src/devices/nm-lldp-listener.c
@@ -19,9 +19,9 @@
#define MAX_NEIGHBORS 128
#define MIN_UPDATE_INTERVAL_NSEC (2 * NM_UTILS_NSEC_PER_SEC)
-#define LLDP_MAC_NEAREST_BRIDGE ((const struct ether_addr *) ((uint8_t[ETH_ALEN]) { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e }))
-#define LLDP_MAC_NEAREST_NON_TPMR_BRIDGE ((const struct ether_addr *) ((uint8_t[ETH_ALEN]) { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03 }))
-#define LLDP_MAC_NEAREST_CUSTOMER_BRIDGE ((const struct ether_addr *) ((uint8_t[ETH_ALEN]) { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 }))
+#define LLDP_MAC_NEAREST_BRIDGE (&((struct ether_addr) { .ether_addr_octet = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e } }))
+#define LLDP_MAC_NEAREST_NON_TPMR_BRIDGE (&((struct ether_addr) { .ether_addr_octet = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03 } }))
+#define LLDP_MAC_NEAREST_CUSTOMER_BRIDGE (&((struct ether_addr) { .ether_addr_octet = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 } }))
/*****************************************************************************/
@@ -102,18 +102,6 @@ typedef struct {
/*****************************************************************************/
-static gboolean
-ether_addr_equal (const struct ether_addr *a1, const struct ether_addr *a2)
-{
- nm_assert (a1);
- nm_assert (a2);
-
- G_STATIC_ASSERT_EXPR (sizeof (*a1) == ETH_ALEN);
- return memcmp (a1, a2, ETH_ALEN) == 0;
-}
-
-/*****************************************************************************/
-
static void
lldp_neighbor_get_raw (LldpNeighbor *neigh,
const guint8 **out_raw_data,
@@ -216,7 +204,7 @@ lldp_neighbor_equal (LldpNeighbor *a, LldpNeighbor *b)
nm_assert ( !equal
|| ( a->chassis_id_type == b->chassis_id_type
&& a->port_id_type == b->port_id_type
- && ether_addr_equal (&a->destination_address, &b->destination_address)
+ && nm_utils_ether_addr_equal (&a->destination_address, &b->destination_address)
&& nm_streq0 (a->chassis_id, b->chassis_id)
&& nm_streq0 (a->port_id, b->port_id)));
return equal;
@@ -413,11 +401,11 @@ lldp_neighbor_to_variant (LldpNeighbor *neigh)
nm_g_variant_builder_add_sv_uint32 (&builder, NM_LLDP_ATTR_PORT_ID_TYPE, neigh->port_id_type);
nm_g_variant_builder_add_sv_str (&builder, NM_LLDP_ATTR_PORT_ID, neigh->port_id);
- if (ether_addr_equal (&neigh->destination_address, LLDP_MAC_NEAREST_BRIDGE))
+ if (nm_utils_ether_addr_equal (&neigh->destination_address, LLDP_MAC_NEAREST_BRIDGE))
str = NM_LLDP_DEST_NEAREST_BRIDGE;
- else if (ether_addr_equal (&neigh->destination_address, LLDP_MAC_NEAREST_NON_TPMR_BRIDGE))
+ else if (nm_utils_ether_addr_equal (&neigh->destination_address, LLDP_MAC_NEAREST_NON_TPMR_BRIDGE))
str = NM_LLDP_DEST_NEAREST_NON_TPMR_BRIDGE;
- else if (ether_addr_equal (&neigh->destination_address, LLDP_MAC_NEAREST_CUSTOMER_BRIDGE))
+ else if (nm_utils_ether_addr_equal (&neigh->destination_address, LLDP_MAC_NEAREST_CUSTOMER_BRIDGE))
str = NM_LLDP_DEST_NEAREST_CUSTOMER_BRIDGE;
else
str = NULL;