Move qinq out of simple_tcp_packet
diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py
index 50316b7..f088532 100644
--- a/src/python/oftest/testutils.py
+++ b/src/python/oftest/testutils.py
@@ -56,8 +56,6 @@
def simple_tcp_packet(pktlen=100,
dl_dst='00:01:02:03:04:05',
dl_src='00:06:07:08:09:0a',
- dl_qinq_enable=False,
- dl_vlan_outer=20,
dl_vlan_enable=False,
dl_vlan=0,
dl_vlan_pcp=0,
@@ -77,8 +75,6 @@
@param len Length of packet in bytes w/o CRC
@param dl_dst Destinatino MAC
@param dl_src Source MAC
- @param dl_qinq_enable True if the packet is double vlan tags
- @param dl_vlan_outer Outer VLAN ID
@param dl_vlan_enable True if the packet is with vlan, False otherwise
@param dl_vlan VLAN ID
@param dl_vlan_pcp VLAN priority
@@ -97,13 +93,7 @@
pktlen = MINSIZE
# Note Dot1Q.id is really CFI
- if (dl_qinq_enable):
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
- scapy.Dot1Q(prio=0, id=0, vlan=dl_vlan_outer)/ \
- scapy.Dot1Q(prio=dl_vlan_pcp, id=dl_vlan_cfi, vlan=dl_vlan)/ \
- scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ihl=ip_ihl)/ \
- scapy.TCP(sport=tcp_sport, dport=tcp_dport)
- elif (dl_vlan_enable):
+ if (dl_vlan_enable):
pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
scapy.Dot1Q(prio=dl_vlan_pcp, id=dl_vlan_cfi, vlan=dl_vlan)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ihl=ip_ihl)/ \
@@ -244,6 +234,61 @@
return pkt
+def qinq_tcp_packet(pktlen=100,
+ dl_dst='00:01:02:03:04:05',
+ dl_src='00:06:07:08:09:0a',
+ dl_vlan_outer=20,
+ dl_vlan_pcp_outer=0,
+ dl_vlan_cfi_outer=0,
+ dl_vlan=10,
+ dl_vlan_pcp=0,
+ dl_vlan_cfi=0,
+ ip_src='192.168.0.1',
+ ip_dst='192.168.0.2',
+ ip_tos=0,
+ tcp_sport=1234,
+ tcp_dport=80,
+ ip_ihl=None,
+ ip_options=False
+ ):
+ """
+ Return a doubly tagged dataplane TCP packet
+
+ Supports a few parameters:
+ @param len Length of packet in bytes w/o CRC
+ @param dl_dst Destinatino MAC
+ @param dl_src Source MAC
+ @param dl_vlan_outer Outer VLAN ID
+ @param dl_vlan_pcp_outer Outer VLAN priority
+ @param dl_vlan_cfi_outer Outer VLAN cfi bit
+ @param dl_vlan Inner VLAN ID
+ @param dl_vlan_pcp VLAN priority
+ @param dl_vlan_cfi VLAN cfi bit
+ @param ip_src IP source
+ @param ip_dst IP destination
+ @param ip_tos IP ToS
+ @param tcp_dport TCP destination port
+ @param ip_sport TCP source port
+
+ Generates a TCP request. Users
+ shouldn't assume anything about this packet other than that
+ it is a valid ethernet/IP/TCP frame.
+ """
+
+ if MINSIZE > pktlen:
+ pktlen = MINSIZE
+
+ # Note Dot1Q.id is really CFI
+ pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Dot1Q(prio=dl_vlan_pcp_outer, id=dl_vlan_cfi_outer, vlan=dl_vlan_outer)/ \
+ scapy.Dot1Q(prio=dl_vlan_pcp, id=dl_vlan_cfi, vlan=dl_vlan)/ \
+ scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ihl=ip_ihl)/ \
+ scapy.TCP(sport=tcp_sport, dport=tcp_dport)
+
+ pkt = pkt/("D" * (pktlen - len(pkt)))
+
+ return pkt
+
def do_barrier(ctrl, timeout=-1):
"""
Do a barrier command