diff --git a/monitor/main.c b/monitor/main.c index 3a5031ad..0cc4cb7e 100644 --- a/monitor/main.c +++ b/monitor/main.c @@ -459,11 +459,8 @@ static int analyze_pcap(const char *pathname) continue; } - arphrd_type = L_GET_UNALIGNED((const uint16_t *) (buf + 2)); - arphrd_type = L_BE16_TO_CPU(arphrd_type); - - proto_type = L_GET_UNALIGNED((const uint16_t *) (buf + 14)); - proto_type = L_BE16_TO_CPU(proto_type); + arphrd_type = l_get_be16(buf + 2); + proto_type = l_get_be16(buf + 14); switch (arphrd_type) { case ARPHRD_ETHER: @@ -603,14 +600,9 @@ static int process_pcap(struct pcap *pcap, uint16_t id) continue; } - pkt_type = L_GET_UNALIGNED((const uint16_t *) buf); - pkt_type = L_BE16_TO_CPU(pkt_type); - - arphrd_type = L_GET_UNALIGNED((const uint16_t *) (buf + 2)); - arphrd_type = L_BE16_TO_CPU(arphrd_type); - - proto_type = L_GET_UNALIGNED((const uint16_t *) (buf + 14)); - proto_type = L_BE16_TO_CPU(proto_type); + pkt_type = l_get_be16(buf); + arphrd_type = l_get_be16(buf + 2); + proto_type = l_get_be16(buf + 14); switch (arphrd_type) { case ARPHRD_ETHER: diff --git a/monitor/nlmon.c b/monitor/nlmon.c index 3ffa6b2d..c83a65a1 100644 --- a/monitor/nlmon.c +++ b/monitor/nlmon.c @@ -4049,14 +4049,9 @@ static void store_packet(struct nlmon *nlmon, const struct timeval *tv, memset(sll_hdr, 0, sizeof(sll_hdr)); - pkt_type = L_CPU_TO_BE16(pkt_type); - L_PUT_UNALIGNED(pkt_type, (uint16_t *) buf); - - arphrd_type = L_CPU_TO_BE16(arphrd_type); - L_PUT_UNALIGNED(arphrd_type, (uint16_t *) (buf + 2)); - - proto_type = L_CPU_TO_BE16(proto_type); - L_PUT_UNALIGNED(proto_type, (uint16_t *) (buf + 14)); + l_put_be16(pkt_type, buf); + l_put_be16(arphrd_type, buf + 2); + l_put_be16(proto_type, buf + 14); pcap_write(nlmon->pcap, tv, &sll_hdr, sizeof(sll_hdr), data, size); }