+ unformat_input_t _line_input, *line_input = &_line_input;
+ vlib_pcap_dispatch_trace_args_t _a, *a = &_a;
+ u8 *filename = 0;
+ u32 max = 1000;
+ int rv;
+ int enable = 0;
+ int status = 0;
+ u32 node_index = ~0, buffer_traces_to_capture = 100;
+
+ /* 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 (line_input, "on %=", &enable, 1))
+ ;
+ else if (unformat (line_input, "enable %=", &enable, 1))
+ ;
+ else if (unformat (line_input, "off %=", &enable, 0))
+ ;
+ else if (unformat (line_input, "disable %=", &enable, 0))
+ ;
+ else if (unformat (line_input, "max %d", &max))
+ ;
+ else if (unformat (line_input, "packets-to-capture %d", &max))
+ ;
+ else if (unformat (line_input, "file %U", unformat_vlib_tmpfile,
+ &filename))
+ ;
+ else if (unformat (line_input, "status %=", &status, 1))
+ ;
+ else if (unformat (line_input, "buffer-trace %U %d",
+ unformat_vlib_node, vm, &node_index,
+ &buffer_traces_to_capture))
+ ;
+ else
+ {
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ }
+ }
+
+ unformat_free (line_input);
+
+ /* no need for memset (a, 0, sizeof (*a)), set all fields here. */
+ a->filename = filename;
+ a->enable = enable;
+ a->status = status;
+ a->packets_to_capture = max;
+ a->buffer_trace_node_index = node_index;
+ a->buffer_traces_to_capture = buffer_traces_to_capture;
+
+ rv = vlib_pcap_dispatch_trace_configure (a);
+
+ switch (rv)
+ {
+ case 0:
+ break;
+
+ case -7:
+ return clib_error_return (0, "dispatch trace already enabled...");
+
+ case -81:
+ return clib_error_return (0, "dispatch trace already disabled...");
+
+ case -8:
+ return clib_error_return
+ (0, "can't change number of records to capture while tracing...");
+
+ case -11:
+ return clib_error_return (0, "I/O writing trace capture...");
+
+ case -6:
+ return clib_error_return (0, "No packets captured...");
+
+ default:
+ vlib_cli_output (vm, "WARNING: trace configure returned %d", rv);
+ break;
+ }
+ return 0;