summaryrefslogtreecommitdiffstats
path: root/src/plugins/cnat/cnat_snat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/cnat/cnat_snat.c')
-rw-r--r--src/plugins/cnat/cnat_snat.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/plugins/cnat/cnat_snat.c b/src/plugins/cnat/cnat_snat.c
index 68b2f2b11bf..b063715d585 100644
--- a/src/plugins/cnat/cnat_snat.c
+++ b/src/plugins/cnat/cnat_snat.c
@@ -17,6 +17,59 @@
#include <cnat/cnat_snat.h>
#include <cnat/cnat_translation.h>
+cnat_snat_policy_main_t cnat_snat_policy_main;
+
+void
+cnat_set_snat_policy (cnat_snat_policy_t fp)
+{
+ cnat_snat_policy_main.snat_policy = fp;
+}
+
+static clib_error_t *
+cnat_snat_policy_cmd (vlib_main_t *vm, unformat_input_t *input,
+ vlib_cli_command_t *cmd)
+{
+ cnat_snat_policy_t fp = NULL;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "none"))
+ ;
+ else
+ return clib_error_return (0, "unknown input '%U'",
+ format_unformat_error, input);
+ }
+
+ cnat_set_snat_policy (fp);
+ return NULL;
+}
+
+VLIB_CLI_COMMAND (cnat_snat_policy_command, static) = {
+ .path = "cnat set snat policy",
+ .short_help = "cnat set snat policy {none,k8s}",
+ .function = cnat_snat_policy_cmd,
+};
+
+static clib_error_t *
+show_cnat_snat_policy_cmd (vlib_main_t *vm, unformat_input_t *input,
+ vlib_cli_command_t *cmd)
+{
+ u8 *s = format (NULL, "snat policy: ");
+ if (cnat_snat_policy_main.snat_policy == NULL)
+ s = format (s, "none");
+ else
+ s = format (s, "unknown (%x)", cnat_snat_policy_main.snat_policy);
+
+ vlib_cli_output (vm, (char *) s);
+ return NULL;
+}
+
+VLIB_CLI_COMMAND (show_cnat_snat_policy_command, static) = {
+ .path = "show cnat snat policy",
+ .short_help = "show cnat snat policy",
+ .function = show_cnat_snat_policy_cmd,
+};
+
static void
cnat_compute_prefix_lengths_in_search_order (cnat_snat_pfx_table_t *
table, ip_address_family_t af)