summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-03-23 09:19:46 +0200
committerimarom <imarom@cisco.com>2016-03-23 13:01:08 +0200
commit5e727474efe18b3800df6130c068e668fadd2e0b (patch)
tree1c9bce9e6367b892830df6a49798cd14bbe434d8 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
parent46f110d0c728ba9299156cf92a59c27c2d0348fa (diff)
Python 3 - another drop (package fixups)
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
index f4a056f8..a7064853 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
@@ -1136,7 +1136,7 @@ class STLPktBuilder(CTrexPktBuilderInterface):
pkt : string,
Scapy or pcap file filename a scapy packet
- pkt_buffer : string
+ pkt_buffer : bytes
a packet as buffer
vm : list or base on :class:`trex_stl_lib.trex_stl_packet_builder_scapy.STLScVmRaw`
@@ -1156,6 +1156,9 @@ class STLPktBuilder(CTrexPktBuilderInterface):
"""
super(STLPktBuilder, self).__init__()
+ validate_type('pkt', pkt, (type(None), str, Packet))
+ validate_type('pkt_buffer', pkt_buffer, (type(None), bytes))
+
self.pkt = None # as input
self.pkt_raw = None # from raw pcap file
self.vm_scripts = [] # list of high level instructions
@@ -1232,7 +1235,6 @@ class STLPktBuilder(CTrexPktBuilderInterface):
"""
pkt_buf = self._get_pkt_as_str()
-
return {'binary': base64.b64encode(pkt_buf).decode() if encode else pkt_buf,
'meta': self.metadata}
@@ -1266,7 +1268,7 @@ class STLPktBuilder(CTrexPktBuilderInterface):
def set_pkt_as_str (self, pkt_buffer):
- validate_type('pkt_buffer', pkt_buffer, str)
+ validate_type('pkt_buffer', pkt_buffer, bytes)
self.pkt_raw = pkt_buffer
@@ -1288,7 +1290,7 @@ class STLPktBuilder(CTrexPktBuilderInterface):
for pkt in p:
was_set=True;
- self.pkt_raw = str(pkt[0])
+ self.pkt_raw = pkt[0]
break
if not was_set :
raise CTRexPacketBuildException(-14, "no buffer inside the pcap file {0}".format(f_path))