1 // SPDX-License-Identifier: Apache-2.0
2 // Copyright(c) 2023 Cisco Systems, Inc.
6 #include <vnet/feature/feature.h>
7 #include <vnet/ip/ip.h>
8 #include <vppinfra/clib_error.h>
12 set_npt66_binding_command_fn (vlib_main_t *vm, unformat_input_t *input,
13 vlib_cli_command_t *cmd)
15 unformat_input_t _line_input, *line_input = &_line_input;
16 clib_error_t *error = 0;
17 bool internal_set = false, external_set = false;
20 ip6_address_t internal, external;
21 int internal_plen = 0, external_plen = 0;
23 /* Get a line of input. */
24 if (!unformat_user (input, unformat_line_input, line_input))
27 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
29 if (unformat (line_input, "internal %U/%d", unformat_ip6_address,
30 &internal, &internal_plen))
32 else if (unformat (line_input, "external %U/%d", unformat_ip6_address,
33 &external, &external_plen))
35 else if (unformat (line_input, "interface %U",
36 unformat_vnet_sw_interface, vnet_get_main (),
39 else if (unformat (line_input, "del"))
45 error = clib_error_return (0, "unknown input `%U'",
46 format_unformat_error, line_input);
50 if (sw_if_index == ~0)
52 error = clib_error_return (0, "interface is required `%U'",
53 format_unformat_error, line_input);
58 error = clib_error_return (0, "missing parameter: internal `%U'",
59 format_unformat_error, line_input);
64 error = clib_error_return (0, "missing parameter: external `%U'",
65 format_unformat_error, line_input);
69 int rv = npt66_binding_add_del (sw_if_index, &internal, internal_plen,
70 &external, external_plen, add);
73 error = clib_error_return (0, "Adding binding failed %d", rv);
78 unformat_free (line_input);
83 VLIB_CLI_COMMAND (set_npt66_binding_command, static) = {
84 .path = "set npt66 binding",
85 .short_help = "set npt66 binding interface <name> internal <pfx> "
86 "external <pfx> [del]",
87 .function = set_npt66_binding_command_fn,