Commit a66ab735 authored by Beniamino Galvani's avatar Beniamino Galvani

lldp: drop _access* macros

Use unaligned access functions instead where needed.
parent 579373a5
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment