summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-12-13 20:02:45 +0200
committerimarom <imarom@cisco.com>2016-12-13 20:02:45 +0200
commitac1c2d18f699c40b974d314df3db835ec26bc0bd (patch)
tree44b73dacf0be5809817d5d675a2be8a6d85ce357 /scripts/automation/trex_control_plane/stl/trex_stl_lib/utils
parent603bd7a4d9dcb8058812633ac60a75598578cb83 (diff)
parentfe755604ec04ed7f8622394f99f0048901dad4e1 (diff)
Merge branch 'master' into rx_phase_2
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/utils')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/zipmsg.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/zipmsg.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/zipmsg.py
index 397ada16..a2a47927 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/zipmsg.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/zipmsg.py
@@ -6,7 +6,7 @@ class ZippedMsg:
MSG_COMPRESS_THRESHOLD = 256
MSG_COMPRESS_HEADER_MAGIC = 0xABE85CEA
- def check_threshold (self, msg):
+ def check_threshold(self, msg):
return len(msg) >= self.MSG_COMPRESS_THRESHOLD
def compress (self, msg):
@@ -16,7 +16,7 @@ class ZippedMsg:
return new_msg
- def decompress (self, msg):
+ def decompress(self, msg):
if len(msg) < 8:
return None
@@ -30,3 +30,15 @@ class ZippedMsg:
return x
+
+ def is_compressed(self, msg):
+ if len(msg) < 8:
+ return False
+
+ t = struct.unpack(">II", msg[:8])
+ if (t[0] != self.MSG_COMPRESS_HEADER_MAGIC):
+ return False
+
+ return True
+
+