diff options
Diffstat (limited to 'src/vnet/bfd/bfd_cli.c')
-rw-r--r-- | src/vnet/bfd/bfd_cli.c | 104 |
1 files changed, 78 insertions, 26 deletions
diff --git a/src/vnet/bfd/bfd_cli.c b/src/vnet/bfd/bfd_cli.c index 0e73172b7cb..33492ca8500 100644 --- a/src/vnet/bfd/bfd_cli.c +++ b/src/vnet/bfd/bfd_cli.c @@ -121,8 +121,13 @@ show_bfd (vlib_main_t * vm, unformat_input_t * input, { bfd_main_t *bm = &bfd_main; bfd_session_t *bs = NULL; + unformat_input_t _line_input, *line_input = &_line_input; - if (unformat (input, "keys")) + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + if (unformat (line_input, "keys")) { bfd_auth_key_t *key = NULL; u8 *s = format (NULL, "%=10s %=25s %=10s\n", "Configuration Key ID", @@ -138,7 +143,7 @@ show_bfd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_output (vm, "Number of configured BFD keys: %lu\n", (u64) pool_elts (bm->auth_keys)); } - else if (unformat (input, "sessions")) + else if (unformat (line_input, "sessions")) { u8 *s = format (NULL, "%=10s %=32s %=20s %=20s\n", "Index", "Property", "Local value", "Remote value"); @@ -152,7 +157,7 @@ show_bfd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_output (vm, "Number of configured BFD sessions: %lu\n", (u64) pool_elts (bm->sessions)); } - else if (unformat (input, "echo-source")) + else if (unformat (line_input, "echo-source")) { int is_set; u32 sw_if_index; @@ -239,16 +244,21 @@ bfd_cli_key_add (vlib_main_t * vm, unformat_input_t * input, u8 *vec_auth_type = NULL; bfd_auth_type_e auth_type = BFD_AUTH_TYPE_reserved; u8 *secret = NULL; + unformat_input_t _line_input, *line_input = &_line_input; static const u8 keyed_sha1[] = "keyed-sha1"; static const u8 meticulous_keyed_sha1[] = "meticulous-keyed-sha1"; - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - if (unformat (input, "conf-key-id %u", &key_id)) + if (unformat (line_input, "conf-key-id %u", &key_id)) { have_key_id = 1; } - else if (unformat (input, "type %U", unformat_token, "a-zA-Z0-9-", + else if (unformat (line_input, "type %U", unformat_token, "a-zA-Z0-9-", &vec_auth_type)) { if (vec_len (vec_auth_type) == sizeof (keyed_sha1) - 1 && @@ -270,14 +280,15 @@ bfd_cli_key_add (vlib_main_t * vm, unformat_input_t * input, goto out; } } - else if (unformat (input, "secret %U", unformat_hex_string, &secret)) + else + if (unformat (line_input, "secret %U", unformat_hex_string, &secret)) { /* nothing to do here */ } else { ret = clib_error_return (0, "Unknown input `%U'", - format_unformat_error, input); + format_unformat_error, line_input); goto out; } } @@ -330,13 +341,18 @@ bfd_cli_key_del (vlib_main_t * vm, unformat_input_t * input, { clib_error_t *ret = NULL; u32 key_id = 0; + unformat_input_t _line_input, *line_input = &_line_input; - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - if (!unformat (input, "conf-key-id %u", &key_id)) + if (!unformat (line_input, "conf-key-id %u", &key_id)) { ret = clib_error_return (0, "Unknown input `%U'", - format_unformat_error, input); + format_unformat_error, line_input); goto out; } } @@ -380,7 +396,7 @@ static const unsigned optional = 0; t n; #define UNFORMAT(t, n, s, r, ...) \ - if (unformat (input, s " " __VA_ARGS__, &n)) \ + if (unformat (line_input, s " " __VA_ARGS__, &n)) \ { \ something_parsed = 1; \ have_##n = 1; \ @@ -400,6 +416,7 @@ bfd_cli_udp_session_add (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; + unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_add_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ @@ -415,7 +432,11 @@ bfd_cli_udp_session_add (vlib_main_t * vm, unformat_input_t * input, foreach_bfd_cli_udp_session_add_cli_param (DECLARE); - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_add_cli_param (UNFORMAT); @@ -423,7 +444,7 @@ bfd_cli_udp_session_add (vlib_main_t * vm, unformat_input_t * input, if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", - format_unformat_error, input); + format_unformat_error, line_input); goto out; } } @@ -493,6 +514,7 @@ bfd_cli_udp_session_mod (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; + unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_mod_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ @@ -506,7 +528,11 @@ bfd_cli_udp_session_mod (vlib_main_t * vm, unformat_input_t * input, foreach_bfd_cli_udp_session_mod_cli_param (DECLARE); - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_mod_cli_param (UNFORMAT); @@ -514,7 +540,7 @@ bfd_cli_udp_session_mod (vlib_main_t * vm, unformat_input_t * input, if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", - format_unformat_error, input); + format_unformat_error, line_input); goto out; } } @@ -563,6 +589,7 @@ bfd_cli_udp_session_del (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; + unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_del_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ @@ -573,7 +600,11 @@ bfd_cli_udp_session_del (vlib_main_t * vm, unformat_input_t * input, foreach_bfd_cli_udp_session_del_cli_param (DECLARE); - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_del_cli_param (UNFORMAT); @@ -581,7 +612,7 @@ bfd_cli_udp_session_del (vlib_main_t * vm, unformat_input_t * input, if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", - format_unformat_error, input); + format_unformat_error, line_input); goto out; } } @@ -619,6 +650,7 @@ bfd_cli_udp_session_set_flags (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; + unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_set_flags_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ @@ -631,7 +663,11 @@ bfd_cli_udp_session_set_flags (vlib_main_t * vm, unformat_input_t * input, foreach_bfd_cli_udp_session_set_flags_cli_param (DECLARE); - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_set_flags_cli_param (UNFORMAT); @@ -639,7 +675,7 @@ bfd_cli_udp_session_set_flags (vlib_main_t * vm, unformat_input_t * input, if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", - format_unformat_error, input); + format_unformat_error, line_input); goto out; } } @@ -692,10 +728,12 @@ VLIB_CLI_COMMAND (bfd_cli_udp_session_set_flags_command, static) = { /* *INDENT-ON* */ static clib_error_t * -bfd_cli_udp_session_auth_activate (vlib_main_t * vm, unformat_input_t * input, +bfd_cli_udp_session_auth_activate (vlib_main_t * vm, + unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; + unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_auth_activate_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ @@ -709,7 +747,11 @@ bfd_cli_udp_session_auth_activate (vlib_main_t * vm, unformat_input_t * input, foreach_bfd_cli_udp_session_auth_activate_cli_param (DECLARE); - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_auth_activate_cli_param (UNFORMAT); @@ -717,7 +759,7 @@ bfd_cli_udp_session_auth_activate (vlib_main_t * vm, unformat_input_t * input, if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", - format_unformat_error, input); + format_unformat_error, line_input); goto out; } } @@ -788,6 +830,7 @@ bfd_cli_udp_session_auth_deactivate (vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED (vlib_cli_command_t *lmd)) { clib_error_t *ret = NULL; + unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_auth_deactivate_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ @@ -799,7 +842,11 @@ bfd_cli_udp_session_auth_deactivate (vlib_main_t *vm, unformat_input_t *input, foreach_bfd_cli_udp_session_auth_deactivate_cli_param (DECLARE); - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_auth_deactivate_cli_param (UNFORMAT); @@ -867,13 +914,18 @@ bfd_cli_udp_set_echo_source (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; + unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_set_echo_source_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) foreach_bfd_cli_udp_set_echo_source_cli_param (DECLARE); - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_set_echo_source_cli_param (UNFORMAT); @@ -881,7 +933,7 @@ bfd_cli_udp_set_echo_source (vlib_main_t * vm, unformat_input_t * input, if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", - format_unformat_error, input); + format_unformat_error, line_input); goto out; } } |