summaryrefslogtreecommitdiffstats
path: root/regress/sys/netinet/arp/arp_request.py
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2015-11-05 01:49:12 +0000
committerbluhm <bluhm@openbsd.org>2015-11-05 01:49:12 +0000
commita13597fa25002793552843f1ed3bf5cb23f04645 (patch)
treeb1f6cc6ab3c8ba04fed7a6658bdf536007f80d2f /regress/sys/netinet/arp/arp_request.py
parentRemove an alias for a macro. (diff)
downloadwireguard-openbsd-a13597fa25002793552843f1ed3bf5cb23f04645.tar.xz
wireguard-openbsd-a13597fa25002793552843f1ed3bf5cb23f04645.zip
Add regression tests for the ARP implementation in the kernel. Send
multiple ARP packets to a remote machine with Scapy. Check ARP replies, table entries and log messages. All log messages in in_arpinput() are generated. Proxy ARP is also tested.
Diffstat (limited to 'regress/sys/netinet/arp/arp_request.py')
-rw-r--r--regress/sys/netinet/arp/arp_request.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/regress/sys/netinet/arp/arp_request.py b/regress/sys/netinet/arp/arp_request.py
new file mode 100644
index 00000000000..d974c6330c2
--- /dev/null
+++ b/regress/sys/netinet/arp/arp_request.py
@@ -0,0 +1,50 @@
+#!/usr/local/bin/python2.7
+# send Address Resolution Protocol Request
+# expect Address Resolution Protocol response and check all fields
+# RFC 826 An Ethernet Address Resolution Protocol
+# Packet Generation
+
+import os
+from addr import *
+from scapy.all import *
+
+arp=ARP(op='who-has', hwsrc=LOCAL_MAC, psrc=LOCAL_ADDR,
+ hwdst="ff:ff:ff:ff:ff:ff", pdst=REMOTE_ADDR)
+eth=Ether(src=LOCAL_MAC, dst="ff:ff:ff:ff:ff:ff")/arp
+
+e=srp1(eth, iface=LOCAL_IF, timeout=2)
+
+if e and e.type == ETH_P_ARP:
+ a=e.payload
+ if a.hwtype != ARPHDR_ETHER:
+ print "HWTYPE=%#0.4x != ARPHDR_ETHER" % (a.hwtype)
+ exit(1)
+ if a.ptype != ETH_P_IP:
+ print "PTYPE=%#0.4x != ETH_P_IP" % (a.ptype)
+ exit(1)
+ if a.hwlen != 6:
+ print "HWLEN=%d != 6" % (a.hwlen)
+ exit(1)
+ if a.plen != 4:
+ print "PLEN=%d != 4" % (a.plen)
+ exit(1)
+ if a.op != 2:
+ print "OP=%s != is-at" % (a.op)
+ exit(1)
+ if a.hwsrc != REMOTE_MAC:
+ print "HWLOCAL=%s != REMOTE_MAC" % (a.hwsrc)
+ exit(1)
+ if a.psrc != REMOTE_ADDR:
+ print "PLOCAL=%s != REMOTE_ADDR" % (a.psrc)
+ exit(1)
+ if a.hwdst != LOCAL_MAC:
+ print "HWREMOTE=%s != LOCAL_MAC" % (a.hwdst)
+ exit(1)
+ if a.pdst != LOCAL_ADDR:
+ print "PREMOTE=%s != LOCAL_ADDR" % (a.pdst)
+ exit(1)
+ print "arp reply"
+ exit(0)
+
+print "NO ARP REPLY"
+exit(2)