diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2019-03-26 18:34:53 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2019-03-27 10:16:39 +0100 |
commit | a66ab735b672aa3593b5926016e8af9cb4ac40db (patch) | |
tree | 6c2390f32423d9e319b781cc4f774ac00e0ef1cf | |
parent | 579373a5dfc98b0d39deaf1c12a1b492ac6c4e40 (diff) | |
download | NetworkManager-a66ab735b672aa3593b5926016e8af9cb4ac40db.tar.gz |
lldp: drop _access* macros
Use unaligned access functions instead where needed.
-rw-r--r-- | src/devices/nm-lldp-listener.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/src/devices/nm-lldp-listener.c b/src/devices/nm-lldp-listener.c index cb3b5907da..378ee3e3ea 100644 --- a/src/devices/nm-lldp-listener.c +++ b/src/devices/nm-lldp-listener.c @@ -25,6 +25,7 @@ #include <net/ethernet.h> #include "platform/nm-platform.h" +#include "nm-utils/unaligned.h" #include "nm-utils.h" #include "systemd/nm-sd.h" @@ -155,21 +156,6 @@ ether_addr_equal (const struct ether_addr *a1, const struct ether_addr *a2) return memcmp (a1, a2, ETH_ALEN) == 0; } -static guint32 -_access_uint8 (const void *data) -{ - return *((const guint8 *) data); -} - -static guint32 -_access_uint16 (const void *data) -{ - guint16 v; - - memcpy (&v, data, sizeof (v)); - return ntohs (v); -} - /*****************************************************************************/ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_lldp_attr_id_to_name, LldpAttrId, @@ -514,15 +500,15 @@ lldp_neighbor_new (sd_lldp_neighbor *neighbor_sd, GError **error) if (len != 2) continue; _lldp_attr_set_uint32 (neigh->attrs, LLDP_ATTR_ID_IEEE_802_1_PVID, - _access_uint16 (data8)); + unaligned_read_be16 (data8)); break; case SD_LLDP_OUI_802_1_SUBTYPE_PORT_PROTOCOL_VLAN_ID: if (len != 3) continue; _lldp_attr_set_uint32 (neigh->attrs, LLDP_ATTR_ID_IEEE_802_1_PPVID_FLAGS, - _access_uint8 (&data8[0])); + data8[0]); _lldp_attr_set_uint32 (neigh->attrs, LLDP_ATTR_ID_IEEE_802_1_PPVID, - _access_uint16 (&data8[1])); + unaligned_read_be16 (&data8[1])); break; case SD_LLDP_OUI_802_1_SUBTYPE_VLAN_NAME: { int l; @@ -537,7 +523,7 @@ lldp_neighbor_new (sd_lldp_neighbor *neighbor_sd, GError **error) continue; _lldp_attr_set_uint32 (neigh->attrs, LLDP_ATTR_ID_IEEE_802_1_VID, - _access_uint16 (&data8[0])); + unaligned_read_be16 (&data8[0])); _lldp_attr_set_str_ptr (neigh->attrs, LLDP_ATTR_ID_IEEE_802_1_VLAN_NAME, &data8[3], l); break; |