summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-02-03 09:23:09 +0200
committerHanoh Haim <hhaim@cisco.com>2016-02-03 09:23:09 +0200
commit2e8a6255330ae7babdd0ace9889fa89796ac3687 (patch)
tree90d41cff6fc84403638f3a8043a15bbe9daf89a4
parenta1cc404d690f7c1b875c364f247062be1178e202 (diff)
add fixup offset
-rw-r--r--scripts/automation/regression/unit_tests/functional_tests/scapy_pkt_builder_test.py24
-rw-r--r--scripts/automation/trex_control_plane/client_utils/scapy_packet_builder.py6
2 files changed, 28 insertions, 2 deletions
diff --git a/scripts/automation/regression/unit_tests/functional_tests/scapy_pkt_builder_test.py b/scripts/automation/regression/unit_tests/functional_tests/scapy_pkt_builder_test.py
index 98102dba..ee80e6d8 100644
--- a/scripts/automation/regression/unit_tests/functional_tests/scapy_pkt_builder_test.py
+++ b/scripts/automation/regression/unit_tests/functional_tests/scapy_pkt_builder_test.py
@@ -140,6 +140,30 @@ class CTRexPktBuilderSanitySCapy_Test(pkt_bld_general_test.CGeneralPktBld_Test):
assert_equal(p_utl.get_field_offet_by_str("IPv6.src"),(38,16));
+ def test_simple_vm2(self):
+ raw1 = CTRexScRaw( [ CTRexVmDescFlowVar(name="my_valn",min_val=0,max_val=10,init_val=2,size=1,op="inc"),
+ CTRexVmDescWrFlowVar (fv_name="my_valn",pkt_offset= "802|1Q.vlan" ,offset_fixup=3) # fix the offset as valn is bitfield and not supported right now
+ ]
+ );
+
+ pkt_builder = CScapyTRexPktBuilder();
+
+ py='5'*128
+ pkt=Ether()/ \
+ Dot1Q(vlan=12)/ \
+ IP(src="16.0.0.1",dst="48.0.0.1")/ \
+ UDP(dport=12,sport=1025)/IP()/py
+
+ # set packet
+ pkt_builder.set_packet(pkt);
+ pkt_builder.add_command ( raw1 )
+ pkt_builder.compile();
+
+
+ d= pkt_builder.get_vm_data()
+ assert_equal(d['instructions'][1]['pkt_offset'],17)
+
+
def tearDown(self):
pass
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 62abe2ee..fda77cf7 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
@@ -508,10 +508,12 @@ 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);
@@ -519,7 +521,7 @@ class CTRexVmDescWrFlowVar(CTRexVmDescBase):
assert(type(is_big)==bool);
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: