From 03b7f6f101cf1a62cb36755a515884751d8df480 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sun, 6 May 2018 16:26:11 +0100 Subject: [PATCH] arp: clarify that we check ar_hln in the BPF filter While here, re-arrange it a little to match the structure. --- src/arp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/arp.c b/src/arp.c index 3949ca4a..f8bff87a 100644 --- a/src/arp.c +++ b/src/arp.c @@ -128,13 +128,16 @@ arp_packet(struct interface *ifp, uint8_t *data, size_t len) /* Protocol must be IP. */ if (ar.ar_pro != htons(ETHERTYPE_IP)) continue; - /* Only these types are recognised */ - if (ar.ar_op != htons(ARPOP_REPLY) && - ar.ar_op != htons(ARPOP_REQUEST)) + /* lladdr length matches */ + if (ar.ar_hln != ifp->hwlen) continue; /* Protocol length must match in_addr_t */ if (ar.ar_pln != sizeof(arm.sip.s_addr)) return; + /* Only these types are recognised */ + if (ar.ar_op != htons(ARPOP_REPLY) && + ar.ar_op != htons(ARPOP_REQUEST)) + continue; #endif /* Get pointers to the hardware addresses */ -- 2.47.2