summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/client_utils/packet_builder.py
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-01-27 13:03:51 +0200
committerHanoh Haim <hhaim@cisco.com>2016-01-27 13:03:51 +0200
commitc581c5bb6314b5f80d315c23354f8866ed2a71ff (patch)
tree8e1e4e041e027f3c14a542730ffd688882c69522 /scripts/automation/trex_control_plane/client_utils/packet_builder.py
parent52f599e870f0a3d98cebdf4d49607a6f50cf3380 (diff)
parent1e69b27f272fef2e3124693b865521a4927418f5 (diff)
Merge to latest
Diffstat (limited to 'scripts/automation/trex_control_plane/client_utils/packet_builder.py')
-rwxr-xr-xscripts/automation/trex_control_plane/client_utils/packet_builder.py10
1 files changed, 5 insertions, 5 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 fe96789e..c7d3308e 100755
--- a/scripts/automation/trex_control_plane/client_utils/packet_builder.py
+++ b/scripts/automation/trex_control_plane/client_utils/packet_builder.py
@@ -12,7 +12,7 @@ import re
import itertools
from abc import ABCMeta, abstractmethod
from collections import namedtuple
-
+import base64
class CTRexPktBuilder(object):
"""
@@ -332,6 +332,7 @@ class CTRexPktBuilder(object):
def load_packet_from_byte_list(self, byte_list):
# convert byte array into buffer
+ byte_list = [ord(c) for c in base64.b64decode(byte_list)]
buf = struct.pack('B'*len(byte_list), *byte_list)
# thn, load it based on dpkt parsing
@@ -480,11 +481,10 @@ class CTRexPktBuilder(object):
"""
if self._packet is None:
raise CTRexPktBuilder.EmptyPacketError()
- pkt_in_hex = binascii.hexlify(str(self._packet))
- return {"binary": [int(pkt_in_hex[i:i+2], 16)
- for i in range(0, len(pkt_in_hex), 2)],
+
+ return {"binary": base64.b64encode(str(self._packet)),
"meta": self.metadata}
- # return [pkt_in_hex[i:i+2] for i in range(0, len(pkt_in_hex), 2)]
+
def dump_pkt_to_pcap(self, file_path, ts=None):
"""