]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/vty.h
2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
[mirror_frr.git] / lib / vty.h
index 3cf9c4a2111efd5ba7a3ab72146f8d028b97b363..8cd2b4e31323378580356bc4f905e9a6cc40aaa0 100644 (file)
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -41,9 +41,6 @@ struct vty
   /* What address is this vty comming from. */
   char *address;
 
-  /* Privilege level of this vty. */
-  int privilege;
-
   /* Failure count */
   int fail;
 
@@ -82,8 +79,7 @@ struct vty
   unsigned char escape;
 
   /* Current vty status. */
-  enum {VTY_NORMAL, VTY_CLOSE, VTY_MORE, VTY_MORELINE,
-        VTY_START, VTY_CONTINUE} status;
+  enum {VTY_NORMAL, VTY_CLOSE, VTY_MORE, VTY_MORELINE} status;
 
   /* IAC handling */
   unsigned char iac;
@@ -96,14 +92,9 @@ struct vty
   int width;
   int height;
 
-  int scroll_one;
-
   /* Configure lines. */
   int lines;
 
-  /* Current executing function pointer. */
-  int (*func) (struct vty *, void *arg);
-
   /* Terminal monitor. */
   int monitor;
 
@@ -117,17 +108,6 @@ struct vty
   /* Timeout seconds and thread. */
   unsigned long v_timeout;
   struct thread *t_timeout;
-
-  /* Thread output function. */
-  struct thread *t_output;
-
-  /* Output data pointer. */
-  int (*output_func) (struct vty *, int);
-  void (*output_clean) (struct vty *);
-  void *output_rn;
-  unsigned long output_count;
-  int output_type;
-  void *output_arg;
 };
 
 /* Integrated configuration file. */
@@ -158,30 +138,33 @@ struct vty
 #define PRINTF_ATTRIBUTE(a,b)
 #endif /* __GNUC__ */
 
-/* Utility macro to convert VTY argument to unsigned integer.  */
-#define VTY_GET_INTEGER(NAME,V,STR)                              \
-{                                                                \
-  char *endptr = NULL;                                           \
-  (V) = strtoul ((STR), &endptr, 10);                            \
-  if ((V) == ULONG_MAX || *endptr != '\0')                       \
-    {                                                            \
+/* Utility macros to convert VTY argument to unsigned long or integer. */
+#define VTY_GET_LONG(NAME,V,STR) \
+{ \
+  char *endptr = NULL; \
+  (V) = strtoul ((STR), &endptr, 10); \
+  if (*endptr != '\0' || (V) == ULONG_MAX) \
+    { \
       vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
-      return CMD_WARNING;                                        \
-    }                                                            \
+      return CMD_WARNING; \
+    } \
 }
 
-#define VTY_GET_INTEGER_RANGE(NAME,V,STR,MIN,MAX)                \
-{                                                                \
-  char *endptr = NULL;                                           \
-  (V) = strtoul ((STR), &endptr, 10);                            \
-  if ((V) == ULONG_MAX || *endptr != '\0'                        \
-      || (V) < (MIN) || (V) > (MAX))                             \
-    {                                                            \
+#define VTY_GET_INTEGER_RANGE(NAME,V,STR,MIN,MAX) \
+{ \
+  unsigned long tmpl; \
+  VTY_GET_LONG(NAME, tmpl, STR) \
+  if ( tmpl < (MIN) || tmpl > (MAX)) \
+    { \
       vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
-      return CMD_WARNING;                                        \
-    }                                                            \
+      return CMD_WARNING; \
+    } \
+  (V) = tmpl; \
 }
 
+#define VTY_GET_INTEGER(NAME,V,STR) \
+  VTY_GET_INTEGER_RANGE(NAME,V,STR,0U,UINT32_MAX)
+
 /* Exported variables */
 extern char integrate_default[];
 
@@ -194,14 +177,18 @@ struct vty *vty_new (void);
 int vty_out (struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3);
 void vty_read_config (char *, char *);
 void vty_time_print (struct vty *, int);
-void vty_serv_sock (const char *, unsigned short, char *);
+void vty_serv_sock (const char *, unsigned short, const char *);
 void vty_close (struct vty *);
 char *vty_get_cwd (void);
-void vty_log (const char *, const char *, va_list);
+void vty_log (const char *level, const char *proto, const char *fmt, va_list);
 int vty_config_lock (struct vty *);
 int vty_config_unlock (struct vty *);
 int vty_shell (struct vty *);
 int vty_shell_serv (struct vty *);
 void vty_hello (struct vty *);
 
+/* Send a fixed-size message to all vty terminal monitors; this should be
+   an async-signal-safe function. */
+extern void vty_log_fixed (const char *buf, size_t len);
+
 #endif /* _ZEBRA_VTY_H */