diff options
author | imarom <imarom@cisco.com> | 2016-11-13 17:17:36 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-11-13 17:17:36 +0200 |
commit | 6e1919c3aebabc0977a8ab40b5c60cbd0e7114d0 (patch) | |
tree | 502aa78527ee4de1723e4a32c291dfcdb71cea23 /scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py | |
parent | ab28fccc187c6134eeb0400ce0b113a77e498bb2 (diff) |
RX features - pre-resolve stage
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py')
-rwxr-xr-x | scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py index b93a797d..80260d4a 100755 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py @@ -1,6 +1,6 @@ import argparse from collections import namedtuple, OrderedDict -from .common import list_intersect, list_difference +from .common import list_intersect, list_difference, is_valid_ipv4, is_valid_mac from .text_opts import format_text from ..trex_stl_types import * from .constants import ON_OFF_DICT, UP_DOWN_DICT, FLOW_CTRL_DICT @@ -45,12 +45,14 @@ FLOW_CTRL = 28 SUPPORTED = 29 RX_FILTER_MODE = 30 - OUTPUT_FILENAME = 31 ALL_FILES = 32 LIMIT = 33 PORT_RESTART = 34 +IPV4 = 35 +DEST = 36 + GLOBAL_STATS = 50 PORT_STATS = 51 PORT_STATUS = 52 @@ -224,8 +226,20 @@ def is_valid_file(filename): return filename +def check_ipv4_addr (ipv4_str): + if not is_valid_ipv4(ipv4_str): + raise argparse.ArgumentTypeError("invalid IPv4 address: '{0}'".format(ipv4_str)) + + return ipv4_str + +def check_dest_addr (addr): + if not (is_valid_ipv4(addr) or is_valid_mac(addr)): + raise argparse.ArgumentTypeError("not a valid IPv4 or MAC address: '{0}'".format(addr)) + + return addr + def decode_tunables (tunable_str): tunables = {} @@ -316,6 +330,21 @@ OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'], 'choices': ['hw', 'all']}), + IPV4: ArgumentPack(['--ipv4'], + {'help': 'IPv4 address(s) for the port(s)', + 'dest': 'ipv4', + 'nargs': '+', + 'default': None, + 'type': check_ipv4_addr}), + + DEST: ArgumentPack(['--dest'], + {'help': 'Destination address(s) for the port(s) in either IPv4 or MAC format', + 'dest': 'dest', + 'nargs': '+', + 'default': None, + 'type': check_dest_addr}), + + OUTPUT_FILENAME: ArgumentPack(['-o', '--output'], {'help': 'Output PCAP filename', 'dest': 'output_filename', |