summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-02-15 18:01:09 +0200
committerHanoh Haim <hhaim@cisco.com>2016-02-15 18:01:09 +0200
commit1e98c58d91673ae56d4eb0943d619ddb77a21a33 (patch)
treefdc78e2ea1121ecbd5c5626414e0ae5016ebb2f0 /scripts/automation/trex_control_plane/stl
parent0c28aadfe1490c0ec44c94690f4c6d64f2e76e41 (diff)
add scapy layer for default mac
Diffstat (limited to 'scripts/automation/trex_control_plane/stl')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py16
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py44
2 files changed, 57 insertions, 3 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 f1462ede..1e2286c5 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
@@ -751,7 +751,21 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
else:
raise CTRexPacketBuildException(-14, "bad packet" )
-
+ def is_def_src_mac (self):
+ p = self.pkt
+ if isinstance(p, Packet):
+ if isinstance(p,Ether):
+ if 'src' in p.fields :
+ return False
+ return True
+
+ def is_def_dst_mac (self):
+ p = self.pkt
+ if isinstance(p, Packet):
+ if isinstance(p,Ether):
+ if 'dst' in p.fields :
+ return False
+ return True
def compile (self):
self.vm_low_level=CTRexVmEngine()
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
index efeb5c8a..68f8f694 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
@@ -93,6 +93,11 @@ class STLTXMultiBurst(STLTXMode):
def __str__ (self):
return "Multi Burst"
+STLStreamDstMAC_CFG_FILE=0
+STLStreamDstMAC_PKT =1
+STLStreamDstMAC_ARP =2
+
+
class STLStream(object):
@@ -105,7 +110,11 @@ class STLStream(object):
isg = 0.0,
rx_stats = None,
next = None,
- stream_id = None):
+ stream_id = None,
+ action_count =0,
+ mac_src_override_by_pkt=None,
+ mac_dst_override_mode=None #see STLStreamDstMAC_xx
+ ):
# type checking
if not isinstance(mode, STLTXMode):
@@ -134,8 +143,35 @@ class STLStream(object):
self.set_id(stream_id)
self.set_next_id(None)
+
self.fields = {}
+ int_mac_src_override_by_pkt = 0;
+ int_mac_dst_override_mode = 0;
+
+
+ if mac_src_override_by_pkt == None:
+ int_mac_src_override_by_pkt=0
+ if packet :
+ if packet.is_def_src_mac ()==False:
+ int_mac_src_override_by_pkt=1
+
+ else:
+ int_mac_src_override_by_pkt = int(mac_src_override_by_pkt);
+
+ if mac_dst_override_mode == None:
+ int_mac_dst_override_mode = 0;
+ if packet :
+ if packet.is_def_dst_mac ()==False:
+ int_mac_dst_override_mode=STLStreamDstMAC_PKT
+ else:
+ int_mac_dst_override_mode = int(mac_dst_override_mode);
+
+
+ self.fields['flags'] = (int_mac_src_override_by_pkt&1) + ((int_mac_dst_override_mode&3)<<1)
+
+ self.fields['action_count'] = action_count
+
# basic fields
self.fields['enabled'] = enabled
self.fields['self_start'] = self_start
@@ -327,7 +363,11 @@ class YAMLLoader(object):
self_start = s_obj.get('self_start', defaults.fields['self_start']),
isg = s_obj.get('isg', defaults.fields['isg']),
rx_stats = s_obj.get('rx_stats', defaults.fields['rx_stats']),
- next = yaml_object.get('next'))
+ next = yaml_object.get('next'),
+ action_count = s_obj.get('action_count', defaults.fields['action_count']),
+ mac_src_override_by_pkt = s_obj.get('mac_src_override_by_pkt', 0),
+ mac_dst_override_mode = s_obj.get('mac_src_override_by_pkt', 0)
+ )
# hack the VM fields for now
if 'vm' in s_obj: