VPP-27 Extend telnet protocol buffer guard
[vpp.git] / vlib / vlib / unix / main.c
index 1aac327..9049644 100644 (file)
 #include <sys/stat.h>
 #include <fcntl.h>
 
+/** Default CLI pager limit is not configured in startup.conf */
+#define UNIX_CLI_DEFAULT_PAGER_LIMIT 100000
+
+/** Default CLI history depth if not configured in startup.conf */
+#define UNIX_CLI_DEFAULT_HISTORY 50
+
+
 unix_main_t unix_main;
 
 static clib_error_t *
@@ -299,6 +306,10 @@ unix_config (vlib_main_t * vm, unformat_input_t * input)
   unix_main_t * um = &unix_main;
   clib_error_t * error = 0;
 
+  /* Defaults */
+  um->cli_pager_buffer_limit = UNIX_CLI_DEFAULT_PAGER_LIMIT;
+  um->cli_history_limit = UNIX_CLI_DEFAULT_HISTORY;
+
   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     {
       char * cli_prompt;
@@ -312,6 +323,13 @@ unix_config (vlib_main_t * vm, unformat_input_t * input)
        ;
       else if (unformat (input, "cli-line-mode"))
         um->cli_line_mode = 1;
+      else if (unformat (input, "cli-no-banner"))
+        um->cli_no_banner = 1;
+      else if (unformat (input, "cli-no-pager"))
+        um->cli_no_pager = 1;
+      else if (unformat (input, "cli-pager-buffer-limit %d",
+                                        &um->cli_pager_buffer_limit))
+        ;
       else if (unformat (input, "cli-history-limit %d", &um->cli_history_limit))
         ;
       else if (unformat (input, "full-coredump"))
@@ -403,7 +421,7 @@ static uword thread0 (uword arg)
   unformat_input_t input;
   int i;
   
-  unformat_init_command_line (&input, vm->argv);
+  unformat_init_command_line (&input, (char **)vm->argv);
   i = vlib_main (vm, &input);
   unformat_free (&input);
   
@@ -430,8 +448,9 @@ int vlib_unix_main (int argc, char * argv[])
   if (i)
     return i;
   
-  unformat_init_command_line (&input, vm->argv);
-  vm->init_functions_called = hash_create (0, /* value bytes */ 0);
+  unformat_init_command_line (&input, (char **)vm->argv);
+  if (vm->init_functions_called == 0)
+      vm->init_functions_called = hash_create (0, /* value bytes */ 0);
   e = vlib_call_all_config_functions (vm, &input, 1 /* early */);
   if (e != 0)
     {