summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-02-20 20:00:01 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-02-20 20:00:01 +0200
commit4145ff0ff4b8fbc9c376ab80cb02a8bab34c28bb (patch)
tree49fc492f76c400b61e9c5915286bbb49f6b950b0 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
parent7f6543835444bd0a1b3e344363fc2705ce02b84b (diff)
hlt updates: split by cores, direction
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.py23
1 files changed, 15 insertions, 8 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 24a7301b..fc4750c3 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
@@ -28,17 +28,24 @@ class CTRexPacketBuildException(Exception):
################################################################################################
-def ipv4_str_to_num (ipv4_buffer):
+def _buffer_to_num(str_buffer):
+ assert type(str_buffer)==str, 'type of str_buffer is not str'
+ res=0
+ for i in str_buffer:
+ res = res << 8
+ res += ord(i)
+ return res
+
+def ipv4_str_to_num (ipv4_buffer):
assert type(ipv4_buffer)==str, 'type of ipv4_buffer is not str'
assert len(ipv4_buffer)==4, 'size of ipv4_buffer is not 4'
- res=0
- shift=24
- for i in ipv4_buffer:
- res = res + (ord(i)<<shift);
- shift =shift -8
- return res
+ return _buffer_to_num(ipv4_buffer)
+def mac_str_to_num (mac_buffer):
+ assert type(mac_buffer)==str, 'type of mac_buffer is not str'
+ assert len(mac_buffer)==6, 'size of mac_buffer is not 6'
+ return _buffer_to_num(mac_buffer)
def is_valid_ipv4(ip_addr):
@@ -588,7 +595,7 @@ class CTRexVmDescWrMaskFlowVar(CTRexVmDescBase):
self.pkt_offset =pkt_offset
self.pkt_cast_size =pkt_cast_size
assert type(pkt_cast_size)==int,'type of pkt_cast_size is not int'
- if not (pkt_cast_size in [1,2,4]):
+ if not (pkt_cast_size in [1,2,4,8]):
raise CTRexPacketBuildException(-10,"not valid cast size");
self.mask = mask