From 3ce54f781213b28bea95449f294ffc07630c9412 Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Sun, 25 Sep 2016 14:22:48 +0000 Subject: [PATCH] Expand #defines in command strings Signed-off-by: Daniel Walton Reviewed-by: Donald Sharp Reviewed-by: Don Slice Reviewed-by: Sam Tannous Ticket: --- bgpd/bgp_bfd.c | 2 +- bgpd/bgp_vty.c | 58 ++++++++++++++++++++-------------------- lib/command.c | 6 ++--- tools/argv_translator.py | 6 +++-- zebra/zebra_vty.c | 2 +- 5 files changed, 38 insertions(+), 36 deletions(-) diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index bb8f4ceeea..72ea3c60ae 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -640,7 +640,7 @@ DEFUN_HIDDEN (neighbor_bfd_type, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NO_NEIGHBOR_CMD2 "bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE, + * "no neighbor bfd (2-255) (50-60000) (50-60000)", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index f1411ea5eb..4dcba02c24 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -2910,7 +2910,7 @@ DEFUN (neighbor_peer_group, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NO_NEIGHBOR_CMD "remote-as (" CMD_AS_RANGE "|internal|external)", + * "no neighbor remote-as ((1-4294967295)|internal|external)", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR @@ -3171,14 +3171,14 @@ DEFUN (neighbor_local_as_no_prepend_replace_as, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE, + * "no neighbor local-as (1-4294967295)", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 * "Specify a local-as number\n" * "AS number used as local AS\n" * - * NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend", + * "no neighbor local-as (1-4294967295) no-prepend", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -3186,7 +3186,7 @@ DEFUN (neighbor_local_as_no_prepend_replace_as, * "AS number used as local AS\n" * "Do not prepend local-as to updates from ebgp peers\n" * - * NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as", + * "no neighbor local-as (1-4294967295) no-prepend replace-as", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -3281,7 +3281,7 @@ DEFUN (neighbor_password, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NO_NEIGHBOR_CMD2 "password LINE", + * "no neighbor password LINE", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -4130,7 +4130,7 @@ DEFUN (no_neighbor_nexthop_local_unchanged, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path", + * "neighbor attribute-unchanged med next-hop as-path", * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 * "BGP attribute is propagated unchanged to this neighbor\n" @@ -4138,7 +4138,7 @@ DEFUN (no_neighbor_nexthop_local_unchanged, * "Nexthop attribute\n" * "As-path attribute\n" * - * NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop", + * "neighbor attribute-unchanged med as-path next-hop", * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 * "BGP attribute is propagated unchanged to this neighbor\n" @@ -4146,7 +4146,7 @@ DEFUN (no_neighbor_nexthop_local_unchanged, * "As-path attribute\n" * "Nexthop attribute\n" * - * NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med", + * "neighbor attribute-unchanged as-path next-hop med", * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 * "BGP attribute is propagated unchanged to this neighbor\n" @@ -4154,7 +4154,7 @@ DEFUN (no_neighbor_nexthop_local_unchanged, * "Nexthop attribute\n" * "Med attribute\n" * - * NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med", + * "neighbor attribute-unchanged next-hop as-path med", * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 * "BGP attribute is propagated unchanged to this neighbor\n" @@ -4162,7 +4162,7 @@ DEFUN (no_neighbor_nexthop_local_unchanged, * "As-path attribute\n" * "Med attribute\n" * - * NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop", + * "neighbor attribute-unchanged as-path med next-hop", * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 * "BGP attribute is propagated unchanged to this neighbor\n" @@ -4170,7 +4170,7 @@ DEFUN (no_neighbor_nexthop_local_unchanged, * "Med attribute\n" * "Nexthop attribute\n" * - * NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path", + * "neighbor attribute-unchanged next-hop med as-path", * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 * "BGP attribute is propagated unchanged to this neighbor\n" @@ -4297,7 +4297,7 @@ DEFUN (neighbor_attr_unchanged4, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path", + * "no neighbor attribute-unchanged next-hop med as-path", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -4306,7 +4306,7 @@ DEFUN (neighbor_attr_unchanged4, * "Med attribute\n" * "As-path attribute\n" * - * NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop", + * "no neighbor attribute-unchanged as-path med next-hop", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -4315,7 +4315,7 @@ DEFUN (neighbor_attr_unchanged4, * "Med attribute\n" * "Nexthop attribute\n" * - * NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop", + * "no neighbor attribute-unchanged med as-path next-hop", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -4324,7 +4324,7 @@ DEFUN (neighbor_attr_unchanged4, * "As-path attribute\n" * "Nexthop attribute\n" * - * NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med", + * "no neighbor attribute-unchanged next-hop as-path med", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -4333,7 +4333,7 @@ DEFUN (neighbor_attr_unchanged4, * "As-path attribute\n" * "Med attribute\n" * - * NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med", + * "no neighbor attribute-unchanged as-path next-hop med", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -4342,7 +4342,7 @@ DEFUN (neighbor_attr_unchanged4, * "Nexthop attribute\n" * "Med attribute\n" * - * NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path", + * "no neighbor attribute-unchanged med next-hop as-path", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -4534,7 +4534,7 @@ DEFUN (neighbor_ebgp_multihop_ttl, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NO_NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MAXTTL), + * "no neighbor ebgp-multihop (1-255)", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -4558,7 +4558,7 @@ DEFUN (no_neighbor_ebgp_multihop, /* disable-connected-check */ /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NEIGHBOR_CMD2 "enforce-multihop", + * "neighbor enforce-multihop", * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 * "Enforce EBGP neighbors perform multihop\n" @@ -4577,7 +4577,7 @@ DEFUN (neighbor_disable_connected_check, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NO_NEIGHBOR_CMD2 "enforce-multihop", + * "no neighbor enforce-multihop", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -4630,7 +4630,7 @@ DEFUN (neighbor_description, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NO_NEIGHBOR_CMD2 "description .LINE", + * "no neighbor description .LINE", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -4773,7 +4773,7 @@ DEFUN (neighbor_default_originate_rmap, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NO_NEIGHBOR_CMD2 "default-originate route-map WORD", + * "no neighbor default-originate route-map WORD", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -5779,14 +5779,14 @@ DEFUN (neighbor_maximum_prefix_threshold_restart, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>", + * "no neighbor maximum-prefix <1-4294967295>", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 * "Maximum number of prefix accept from this peer\n" * "maximum no. of prefix limit\n" * - * NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>", + * "no neighbor maximum-prefix <1-4294967295> <1-100> restart <1-65535>", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -5796,7 +5796,7 @@ DEFUN (neighbor_maximum_prefix_threshold_restart, * "Restart bgp connection after limit is exceeded\n" * "Restart interval in minutes" * - * NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only", + * "no neighbor maximum-prefix <1-4294967295> warning-only", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -5804,7 +5804,7 @@ DEFUN (neighbor_maximum_prefix_threshold_restart, * "maximum no. of prefix limit\n" * "Only give warning message when limit is exceeded\n" * - * NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>", + * "no neighbor maximum-prefix <1-4294967295> restart <1-65535>", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -5813,7 +5813,7 @@ DEFUN (neighbor_maximum_prefix_threshold_restart, * "Restart bgp connection after limit is exceeded\n" * "Restart interval in minutes" * - * NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only", + * "no neighbor maximum-prefix <1-4294967295> <1-100> warning-only", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -5822,7 +5822,7 @@ DEFUN (neighbor_maximum_prefix_threshold_restart, * "Threshold value (%) at which to generate a warning msg\n" * "Only give warning message when limit is exceeded\n" * - * NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>", + * "no neighbor maximum-prefix <1-4294967295> <1-100>", * NO_STR * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 @@ -5853,7 +5853,7 @@ DEFUN (no_neighbor_maximum_prefix, /* "neighbor allowas-in" */ /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * NEIGHBOR_CMD2 "allowas-in <1-10>", + * "neighbor allowas-in <1-10>", * NEIGHBOR_STR * NEIGHBOR_ADDR_STR2 * "Accept as-path with my AS present in it\n" diff --git a/lib/command.c b/lib/command.c index 6fb265f97a..10448ef6fb 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1814,7 +1814,7 @@ set_log_file(struct vty *vty, const char *fname, int loglevel) DEFUN (config_log_file, config_log_file_cmd, - "log file FILENAME [" LOG_LEVELS "]", + "log file FILENAME [emergencies|alerts|critical|errors|warnings|notifications|informational|debugging]", "Logging control\n" "Logging to file\n" "Logging filename\n" @@ -1855,7 +1855,7 @@ DEFUN (no_config_log_file, DEFUN (config_log_syslog, config_log_syslog_cmd, - "log syslog [" LOG_LEVELS "]", + "log syslog [emergencies|alerts|critical|errors|warnings|notifications|informational|debugging]", "Logging control\n" "Set syslog logging level\n" LOG_LEVEL_DESC) @@ -1893,7 +1893,7 @@ DEFUN_DEPRECATED (config_log_syslog_facility, DEFUN (no_config_log_syslog, no_config_log_syslog_cmd, - "no log syslog [] [" LOG_LEVELS "]", + "no log syslog [] [emergencies|alerts|critical|errors|warnings|notifications|informational|debugging]", NO_STR "Logging control\n" "Cancel logging to syslog\n" diff --git a/tools/argv_translator.py b/tools/argv_translator.py index 8a4a0b8cf2..4845c08d0a 100755 --- a/tools/argv_translator.py +++ b/tools/argv_translator.py @@ -520,6 +520,7 @@ def expand_command_string(line): line = line.replace('" QUAGGA_REDIST_STR_OSPF6D "', '') line = line.replace('" QUAGGA_REDIST_STR_ISISD "', '') line = line.replace('" LOG_FACILITIES "', '') + line = line.replace('" LOG_LEVELS "', ' (emergencies|alerts|critical|errors|warnings|notifications|informational|debugging)') # endswith line = line.replace('" CMD_AS_RANGE,', ' (1-4294967295)",') @@ -551,6 +552,7 @@ def expand_command_string(line): line = line.replace('" QUAGGA_REDIST_STR_OSPF6D,', ' ",') line = line.replace('" QUAGGA_REDIST_STR_ISISD,', ' ",') line = line.replace('" LOG_FACILITIES,', ' ",') + line = line.replace('" LOG_LEVELS,', ' (emergencies|alerts|critical|errors|warnings|notifications|informational|debugging)",') # startswith line = line.replace('LISTEN_RANGE_CMD "', '"bgp listen range ') @@ -562,6 +564,7 @@ def expand_command_string(line): line = line.replace('PIM_CMD_IP_IGMP_QUERY_INTERVAL "', '"ip igmp query-interval ') line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME "', '"ip igmp query-max-response-time ') line = line.replace('PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC "', '"ip igmp query-max-response-time-dsec ') + line = line.replace('LOG_LEVELS "', '"(emergencies|alerts|critical|errors|warnings|notifications|informational|debugging) ') # solo line = line.replace('NO_NEIGHBOR_CMD2,', '"no neighbor ",') @@ -720,7 +723,6 @@ DEFUN (no_bgp_maxmed_onstartup, new_command_string_expanded = expand_command_string(new_command_string) lines = [] - # dwalton lines.append("DEFUN (%s,\n" % self.name) lines.append(" %s,\n" % self.name_cmd) # lines.append(new_command_string) @@ -868,7 +870,7 @@ def update_argvs(filename): if line.strip() == '*/': state = None fh.write(line) - elif line.strip().startswith('* "'): + elif line.strip().startswith('* ') and not line.strip().startswith('* '): # dwalton new_line = expand_command_string(line[3:]) # chop the leading " * " fh.write(" * %s" % new_line) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 878af09ee0..005c9370b5 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -5597,7 +5597,7 @@ DEFUN (show_ipv6_route_prefix_longer, /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ipv6 route " VRF_CMD_STR " ", + * "show ipv6 route vrf NAME ", * SHOW_STR * IP_STR * "IP routing table\n" -- 2.39.5