Add packet parsing/matching verification
New tests that deal with parsing and matching of valid and
corrupted packets. Current coverage includes corrupted IP
and TCP headers, valid and corrupted LLC (with and without
SNAP), basic ARP and basic VLAN.
diff --git a/src/python/oftest/parse.py b/src/python/oftest/parse.py
index 8826c0c..a3421a1 100644
--- a/src/python/oftest/parse.py
+++ b/src/python/oftest/parse.py
@@ -245,8 +245,10 @@
except:
icmp = None
- # @todo arp is not yet supported
- arp = None
+ try:
+ arp = ether[scapy.ARP]
+ except:
+ arp = None
return (dot1q, ip, tcp, udp, icmp, arp)
def packet_to_flow_match(packet, pkt_format="L2"):
@@ -328,7 +330,14 @@
match.nw_proto = 1
match.tp_src = icmp.type
match.tp_dst = icmp.code
+ match.wildcards &= ~OFPFW_NW_PROTO
- #@todo Implement ARP fields
+ if arp:
+ match.nw_proto = arp.op
+ match.wildcards &= ~OFPFW_NW_PROTO
+ match.nw_src = parse_ip(arp.psrc)
+ match.wildcards &= ~OFPFW_NW_SRC_MASK
+ match.nw_dst = parse_ip(arp.pdst)
+ match.wildcards &= ~OFPFW_NW_DST_MASK
return match