summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.se>2015-12-07 21:36:24 +0000
committerThomas Habets <thomas@habets.se>2015-12-07 21:36:29 +0000
commit18966752d251e1f0c9a14d6da380f204bf2f2941 (patch)
treef924a2dc058cfd38716c4b94d16395199b662a00
parente29991fbeb872c07c5805f842b82a3229d089bb9 (diff)
downloadarping-18966752d251e1f0c9a14d6da380f204bf2f2941.tar.gz
Fix packet testing script.
-rwxr-xr-xextra/packets.exp49
1 files changed, 27 insertions, 22 deletions
diff --git a/extra/packets.exp b/extra/packets.exp
index a881109..6d66f8c 100755
--- a/extra/packets.exp
+++ b/extra/packets.exp
@@ -1,6 +1,6 @@
#!/usr/bin/expect -f
#
-# Usage: packets.exp <path to arping>
+# Usage: packets.exp <path to arping> <my mac>
#
# Uses dummy0 interface on linux to verify that packets are byte-perfect
# when they're sent out from arping.
@@ -17,18 +17,23 @@
#
set bin [lindex $argv 0]
set DEV "dummy0"
+set my_mac "52:2b:c8:01:02:03"
set PACKETDUMP "packetdump.pcap"
proc dotest {name count filter cmd lines} {
upvar DEV DEV
upvar PACKETDUMP PACKETDUMP
upvar bin bin
+ upvar my_mac my_mac
send_user -- "----------- $name -----------\n"
send_user -- "Command: $cmd\n"
spawn ip a a 192.0.2.100/24 dev "$DEV"
expect eof
+ spawn ip l set dev "$DEV" address "$my_mac"
+ expect eof
+
spawn ip l set up "$DEV"
expect eof
@@ -46,55 +51,55 @@ proc dotest {name count filter cmd lines} {
wait
spawn -noecho tcpdump -etnXXr "${PACKETDUMP}" "${filter}"
- log_user 0
+ #log_user 0
foreach l $lines {
- puts "Expecting $l..."
+ puts "Expecting: $l"
expect "$l\r"
}
expect eof
- log_user 1
+ #log_user 1
}
dotest "Simple" 1 "arp" {-c 1 -i "$DEV" 192.0.2.1} {
- "52:2b:c8:eb:1e:4e > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.1 tell 192.0.2.100, length 28"
- "\t0x0000: ffff ffff ffff 522b c8eb 1e4e 0806 0001 ......R+...N...."
- "\t0x0010: 0800 0604 0001 522b c8eb 1e4e c000 0264 ......R+...N...d"
+ "52:2b:c8:01:02:03 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.1 tell 192.0.2.100, length 28"
+ "\t0x0000: ffff ffff ffff 522b c801 0203 0806 0001 ......R+........"
+ "\t0x0010: 0800 0604 0001 522b c801 0203 c000 0264 ......R+.......d"
"\t0x0020: 0000 0000 0000 c000 0201 .........."
}
dotest "SrcIP 0 -0" 1 "arp" {-0 -c 1 -i "$DEV" 192.0.2.1} {
- "52:2b:c8:eb:1e:4e > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.1 tell 0.0.0.0, length 28"
- "\t0x0000: ffff ffff ffff 522b c8eb 1e4e 0806 0001 ......R+...N...."
- "\t0x0010: 0800 0604 0001 522b c8eb 1e4e 0000 0000 ......R+...N...."
+ "52:2b:c8:01:02:03 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.1 tell 0.0.0.0, length 28"
+ "\t0x0000: ffff ffff ffff 522b c801 0203 0806 0001 ......R+........"
+ "\t0x0010: 0800 0604 0001 522b c801 0203 0000 0000 ......R+........"
"\t0x0020: 0000 0000 0000 c000 0201 .........."
}
dotest "SrcIP bc -b" 1 "arp" {-b -c 1 -i "$DEV" 192.0.2.1} {
- "52:2b:c8:eb:1e:4e > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.1 tell 255.255.255.255, length 28"
- "\t0x0000: ffff ffff ffff 522b c8eb 1e4e 0806 0001 ......R+...N...."
- "\t0x0010: 0800 0604 0001 522b c8eb 1e4e ffff ffff ......R+...N...."
+ "52:2b:c8:01:02:03 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.1 tell 255.255.255.255, length 28"
+ "\t0x0000: ffff ffff ffff 522b c801 0203 0806 0001 ......R+........"
+ "\t0x0010: 0800 0604 0001 522b c801 0203 ffff ffff ......R+........"
"\t0x0020: 0000 0000 0000 c000 0201 .........."
}
dotest "SrcIP bc manual" 1 "arp" {-S 255.255.255.255 -c 1 -i "$DEV" 192.0.2.1} {
- "52:2b:c8:eb:1e:4e > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.1 tell 255.255.255.255, length 28"
- "\t0x0000: ffff ffff ffff 522b c8eb 1e4e 0806 0001 ......R+...N...."
- "\t0x0010: 0800 0604 0001 522b c8eb 1e4e ffff ffff ......R+...N...."
+ "52:2b:c8:01:02:03 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.1 tell 255.255.255.255, length 28"
+ "\t0x0000: ffff ffff ffff 522b c801 0203 0806 0001 ......R+........"
+ "\t0x0010: 0800 0604 0001 522b c801 0203 ffff ffff ......R+........"
"\t0x0020: 0000 0000 0000 c000 0201 .........."
}
dotest "SrcIP other manual" 1 "arp" {-S 61.62.63.64 -c 1 -i "$DEV" 192.0.2.1} {
- "52:2b:c8:eb:1e:4e > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.1 tell 61.62.63.64, length 28"
- "\t0x0000: ffff ffff ffff 522b c8eb 1e4e 0806 0001 ......R+...N...."
- "\t0x0010: 0800 0604 0001 522b c8eb 1e4e 3d3e 3f40 ......R+...N=>?@"
+ "52:2b:c8:01:02:03 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.1 tell 61.62.63.64, length 28"
+ "\t0x0000: ffff ffff ffff 522b c801 0203 0806 0001 ......R+........"
+ "\t0x0010: 0800 0604 0001 522b c801 0203 3d3e 3f40 ......R+....=>?@"
"\t0x0020: 0000 0000 0000 c000 0201 .........."
}
dotest "Finddup" 1 "arp" {-c 1 -d -i "$DEV"} {
- "52:2b:c8:eb:1e:4e > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.100 tell 192.0.2.100, length 28"
- "\t0x0000: ffff ffff ffff 522b c8eb 1e4e 0806 0001 ......R+...N...."
- "\t0x0010: 0800 0604 0001 522b c8eb 1e4e c000 0264 ......R+...N...d"
+ "52:2b:c8:01:02:03 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 192.0.2.100 tell 192.0.2.100, length 28"
+ "\t0x0000: ffff ffff ffff 522b c801 0203 0806 0001 ......R+........"
+ "\t0x0010: 0800 0604 0001 522b c801 0203 c000 0264 ......R+.......d"
"\t0x0020: 0000 0000 0000 c000 0264 .........d"
}