diff options
author | imarom <imarom@cisco.com> | 2016-05-10 15:36:33 +0300 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-05-10 15:37:42 +0300 |
commit | 63bf6aba10075a03fe6609369c1c7008afb85ba7 (patch) | |
tree | 8ab016390f9fb07cc29d500120a039b226a0798e /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py | |
parent | 6daea438c392fda4c765d2afa46a34d691799bd7 (diff) |
PCAP API - added packet hook
example is much simpler now
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py')
-rwxr-xr-x | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py | 10 |
1 files changed, 8 insertions, 2 deletions
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 92598312..a7fd3026 100755 --- 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 @@ -928,7 +928,7 @@ class STLProfile(object): # loop_count = 0 means loop forever @staticmethod - def load_pcap (pcap_file, ipg_usec = None, speedup = 1.0, loop_count = 1, vm = None): + def load_pcap (pcap_file, ipg_usec = None, speedup = 1.0, loop_count = 1, vm = None, packet_hook = None): """ Convert a pcap file with a number of packets to a list of connected streams. packet1->packet2->packet3 etc @@ -950,6 +950,9 @@ class STLProfile(object): vm : list List of Field engine instructions + packet_hook : Callable or function + will be applied to every packet + :return: STLProfile """ @@ -973,7 +976,10 @@ class STLProfile(object): except Scapy_Exception as e: raise STLError("failed to open PCAP file '{0}'".format(pcap_file)) - + if packet_hook: + pkts = [(packet_hook(cap), meta) for (cap, meta) in pkts] + + for i, (cap, meta) in enumerate(pkts, start = 1): # IPG - if not provided, take from cap if ipg_usec == None: |