+static clib_error_t *
+show_ipsec_sa_command_fn (vlib_main_t * vm,
+ unformat_input_t * input, vlib_cli_command_t * cmd)
+{
+ ipsec_main_t *im = &ipsec_main;
+ u32 sai = ~0;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "%u", &sai))
+ ;
+ else
+ break;
+ }
+
+ if (~0 == sai)
+ ipsec_sa_show_all (vm, im);
+ else
+ vlib_cli_output (vm, "%U", format_ipsec_sa, sai, IPSEC_FORMAT_DETAIL);
+
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (show_ipsec_sa_command, static) = {
+ .path = "show ipsec sa",
+ .short_help = "show ipsec sa [index]",
+ .function = show_ipsec_sa_command_fn,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+show_ipsec_spd_command_fn (vlib_main_t * vm,
+ unformat_input_t * input, vlib_cli_command_t * cmd)
+{
+ ipsec_main_t *im = &ipsec_main;
+ u8 show_bindings = 0;
+ u32 spdi = ~0;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "%u", &spdi))
+ ;
+ else if (unformat (input, "bindings"))
+ show_bindings = 1;
+ else
+ break;
+ }
+
+ if (show_bindings)
+ ipsec_spd_bindings_show_all (vm, im);
+ else if (~0 != spdi)
+ vlib_cli_output (vm, "%U", format_ipsec_spd, spdi);
+ else
+ ipsec_spd_show_all (vm, im);
+
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (show_ipsec_spd_command, static) = {
+ .path = "show ipsec spd",
+ .short_help = "show ipsec spd [index]",
+ .function = show_ipsec_spd_command_fn,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+show_ipsec_tunnel_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ ipsec_main_t *im = &ipsec_main;
+ u32 ti = ~0;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "%u", &ti))
+ ;
+ else
+ break;
+ }
+
+ if (~0 != ti)
+ vlib_cli_output (vm, "%U", format_ipsec_tunnel, ti);
+ else
+ ipsec_tunnel_show_all (vm, im);
+
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (show_ipsec_tunnel_command, static) = {
+ .path = "show ipsec tunnel",
+ .short_help = "show ipsec tunnel [index]",
+ .function = show_ipsec_tunnel_command_fn,
+};
+/* *INDENT-ON* */
+