add vxlan
diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py
old mode 100644
new mode 100755
index 6e67604..2903a5e
--- a/src/python/oftest/testutils.py
+++ b/src/python/oftest/testutils.py
@@ -239,6 +239,66 @@
return pkt
+def simple_vxlan_packet(eth_dst='00:01:02:03:04:05',
+ eth_src='00:06:07:08:09:0a',
+ dl_vlan_enable=False,
+ vlan_vid=0,
+ vlan_pcp=0,
+ dl_vlan_cfi=0,
+ ip_src='192.168.0.1',
+ ip_dst='192.168.0.2',
+ ip_tos=0,
+ ip_ttl=64,
+ udp_sport=1234,
+ udp_dport=4789,
+ vnid=1,
+ inner_pyload=None,
+ ip_ihl=None,
+ ip_options=False
+ ):
+ """
+ Return a simple dataplane UDP packet
+
+ Supports a few parameters:
+ @param len Length of packet in bytes w/o CRC
+ @param eth_dst Destination MAC
+ @param eth_src Source MAC
+ @param dl_vlan_enable True if the packet is with vlan, False otherwise
+ @param vlan_vid VLAN ID
+ @param vlan_pcp VLAN priority
+ @param ip_src IP source
+ @param ip_dst IP destination
+ @param ip_tos IP ToS
+ @param ip_ttl IP TTL
+ @param udp_dport UDP destination port
+ @param udp_sport UDP source port
+ @param inner_pyload inner pacekt content
+ Generates a simple UDP packet. Users shouldn't assume anything about
+ this packet other than that it is a valid ethernet/IP/UDP frame.
+ """
+
+ # Note Dot1Q.id is really CFI
+ if (dl_vlan_enable):
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
+ scapy.Dot1Q(prio=vlan_pcp, id=dl_vlan_cfi, vlan=vlan_vid)/ \
+ scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
+ scapy.UDP(sport=udp_sport, dport=udp_dport)
+ else:
+ if not ip_options:
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
+ scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
+ scapy.UDP(sport=udp_sport, dport=udp_dport)
+ else:
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
+ scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl, options=ip_options)/ \
+ scapy.UDP(sport=udp_sport, dport=udp_dport)
+ #add vxlan header
+ pkt = pkt/scapy.VXLAN(vni=vnid)
+ #add innder payload
+ pkt=pkt/inner_pyload
+
+ return pkt
+
def simple_udpv6_packet(pktlen=100,
eth_dst='00:01:02:03:04:05',
eth_src='00:06:07:08:09:0a',
@@ -1640,7 +1700,8 @@
logging.debug("Checking for pkt on port %r", ofport)
(rcv_port, rcv_pkt, pkt_time) = test.dataplane.poll(port_number=ofport, exp_pkt=str(pkt))
test.assertTrue(rcv_pkt != None, "Did not receive pkt on %r" % ofport)
-
+ return (rcv_port, rcv_pkt, pkt_time)
+
def verify_no_packet(test, pkt, ofport):
"""
Check that a particular packet is not received