changeset 4275:9b00b7b02e72 draft

arp: clarify that we check ar_hln in the BPF filter While here, re-arrange it a little to match the structure.
author Roy Marples <roy@marples.name>
date Sun, 06 May 2018 16:26:11 +0100
parents b31c71090afa
children 0780bdeb5e75
files src/arp.c
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/arp.c	Sun May 06 10:11:44 2018 +0100
+++ b/src/arp.c	Sun May 06 16:26:11 2018 +0100
@@ -128,13 +128,16 @@
 	/* Protocol must be IP. */
 	if (ar.ar_pro != htons(ETHERTYPE_IP))
 		continue;
+	/* 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;
-	/* Protocol length must match in_addr_t */
-	if (ar.ar_pln != sizeof(arm.sip.s_addr))
-		return;
 #endif
 
 	/* Get pointers to the hardware addresses */