Expand parameters for simple_tcp_packet
diff --git a/tests/testutils.py b/tests/testutils.py
index df7831e..862571f 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -35,8 +35,12 @@
def simple_tcp_packet(pktlen=100,
dl_dst='00:01:02:03:04:05',
dl_src='00:06:07:08:09:0a',
+ dl_vlan_enable=False,
+ dl_vlan=0,
+ dl_vlan_pcp=0,
ip_src='192.168.0.1',
ip_dst='192.168.0.2',
+ ip_tos=0,
tcp_sport=1234,
tcp_dport=80
):
@@ -47,8 +51,12 @@
@param len Length of packet in bytes w/o CRC
@param dl_dst Destinatino MAC
@param dl_src Source MAC
+ @param dl_vlan_enable True if the packet is with vlan, False otherwise
+ @param dl_vlan VLAN ID
+ @param dl_vlan_pcp VLAN priority
@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
@@ -56,9 +64,16 @@
shouldn't assume anything about this packet other than that
it is a valid ethernet/IP/TCP frame.
"""
- pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
- scapy.IP(src=ip_src, dst=ip_dst)/ \
- scapy.TCP(sport=tcp_sport, dport=tcp_dport)
+ if (dl_vlan_enable):
+ pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.Dot1Q(prio=dl_vlan_pcp, id=0, vlan=dl_vlan)/ \
+ scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos)/ \
+ scapy.TCP(sport=tcp_sport, dport=tcp_dport)
+ else:
+ pkt = scapy.Ether(dst=dl_dst, src=dl_src)/ \
+ scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos)/ \
+ scapy.TCP(sport=tcp_sport, dport=tcp_dport)
+
pkt = pkt/("D" * (pktlen - len(pkt)))
return pkt