summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane')
-rw-r--r--scripts/automation/trex_control_plane/client_utils/scapy_packet_builder.py36
1 files changed, 29 insertions, 7 deletions
diff --git a/scripts/automation/trex_control_plane/client_utils/scapy_packet_builder.py b/scripts/automation/trex_control_plane/client_utils/scapy_packet_builder.py
index 5ee4a044..79616ad7 100644
--- a/scripts/automation/trex_control_plane/client_utils/scapy_packet_builder.py
+++ b/scripts/automation/trex_control_plane/client_utils/scapy_packet_builder.py
@@ -354,10 +354,13 @@ class CTRexScapyPktUtl(object):
"""
return layer offset by string
+ :parameters:
+
IP:0
IP:1
return offset
+
"""
l1=layer_des.split(":")
layer=""
@@ -377,13 +380,14 @@ class CTRexScapyPktUtl(object):
"""
return field_des (offset,size) layer:cnt.field
for example
-
+ 802|1Q.vlan get 802.1Q->valn replace | with .
IP.src
IP:0.src (first IP.src like IP.src)
for example IP:1.src for internal IP
return (offset, size) as tuple
+
"""
s=field_des.split(".");
@@ -391,7 +395,7 @@ class CTRexScapyPktUtl(object):
raise CTRexPacketBuildException(-11,("field desription should be layer:cnt.field e.g IP.src or IP:1.src "));
- layer_ex = s[0]
+ layer_ex = s[0].replace("|",".")
field = s[1]
l1=layer_ex.split(":")
@@ -437,6 +441,12 @@ class CTRexVmDescBase(object):
print yaml.dump(self.get_json(), default_flow_style=False)
+ def get_var_ref (self):
+ '''
+ virtual function return a ref var name
+ '''
+ return None
+
def get_var_name(self):
'''
virtual function return the varible name if exists
@@ -504,18 +514,23 @@ class CTRexVmDescFixIpv4(CTRexVmDescBase):
self.offset = parent._pkt_layer_offset(self.offset);
class CTRexVmDescWrFlowVar(CTRexVmDescBase):
- def __init__(self,fv_name,pkt_offset,add_val=0,is_big=True):
+ def __init__(self,fv_name,pkt_offset,offset_fixup=0,add_val=0,is_big=True):
super(CTRexVmDescWrFlowVar, self).__init__()
self.name =fv_name
assert(type(fv_name)==str);
+ self.offset_fixup =offset_fixup
+ assert(type(offset_fixup)==int);
self.pkt_offset =pkt_offset
self.add_val =add_val
assert(type(add_val)==int);
self.is_big =is_big;
assert(type(is_big)==bool);
+ def get_var_ref (self):
+ return self.name
+
def get_obj (self):
- return CTRexVmInsWrFlowVar(self.name,self.pkt_offset,self.add_val,self.is_big)
+ return CTRexVmInsWrFlowVar(self.name,self.pkt_offset+self.offset_fixup,self.add_val,self.is_big)
def compile(self,parent):
if type(self.pkt_offset)==str:
@@ -616,15 +631,22 @@ class CScapyTRexPktBuilder(object):
# make sure we have varibles once
vars={};
+
+ # add it add var to dit
for desc in obj.commands:
- print desc.__dict__
var_name = desc.get_var_name()
- print var_name
if var_name :
if vars.has_key(var_name):
- raise CTRexPacketBuildException(-11,("varible %s define twice ") % (var_name) );
+ raise CTRexPacketBuildException(-11,("variable %s define twice ") % (var_name) );
else:
vars[var_name]=1
+
+ # check that all write exits
+ for desc in obj.commands:
+ var_name = desc.get_var_ref()
+ if var_name :
+ if not vars.has_key(var_name):
+ raise CTRexPacketBuildException(-11,("variable %s does not exists ") % (var_name) );
desc.compile(self);
for desc in obj.commands: