summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/client_utils/packet_builder.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/client_utils/packet_builder.py')
-rwxr-xr-xscripts/automation/trex_control_plane/client_utils/packet_builder.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/scripts/automation/trex_control_plane/client_utils/packet_builder.py b/scripts/automation/trex_control_plane/client_utils/packet_builder.py
index e2a1b116..5ad6cd7a 100755
--- a/scripts/automation/trex_control_plane/client_utils/packet_builder.py
+++ b/scripts/automation/trex_control_plane/client_utils/packet_builder.py
@@ -32,7 +32,6 @@ class CTRexPktBuilder(object):
self._pkt_by_hdr = {}
self._pkt_top_layer = None
self._max_pkt_size = max_pkt_size
- self.payload_gen = CTRexPktBuilder.CTRexPayloadGen(self._packet, self._max_pkt_size)
self.vm = CTRexPktBuilder.CTRexVM()
self.metadata = ""
@@ -481,12 +480,15 @@ class CTRexPktBuilder(object):
def get_vm_data(self):
return self.vm.dump()
- def dump_pkt(self):
+ def dump_pkt(self, encode = True):
"""
Dumps the packet as a decimal array of bytes (each item x gets value between 0-255)
:parameters:
- None
+ encode : bool
+ Encode using base64. (disable for debug)
+
+ Default: **True**
:return:
+ packet representation as array of bytes
@@ -498,7 +500,10 @@ class CTRexPktBuilder(object):
if self._packet is None:
raise CTRexPktBuilder.EmptyPacketError()
- return {"binary": base64.b64encode(str(self._packet)),
+ if encode:
+ return {"binary": base64.b64encode(str(self._packet)),
+ "meta": self.metadata}
+ return {"binary": str(self._packet),
"meta": self.metadata}
@@ -629,6 +634,10 @@ class CTRexPktBuilder(object):
layer_name))
return
+ @property
+ def payload_gen(self):
+ return CTRexPktBuilder.CTRexPayloadGen(self._packet, self._max_pkt_size)
+
@staticmethod
def _decode_mac_addr(mac_addr):
"""