]>
git.proxmox.com Git - mirror_frr.git/blob - lib/vty.h
1 /* Virtual terminal [aka TeletYpe] interface routine
2 Copyright (C) 1997 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 #define VTY_BUFSIZ 512
25 #define VTY_MAXHIST 20
30 /* File descripter of this vty. */
33 /* Is this vty connect to file or not */
34 enum {VTY_TERM
, VTY_FILE
, VTY_SHELL
, VTY_SHELL_SERV
} type
;
36 /* Node status of this vty */
39 /* What address is this vty comming from. */
42 /* Privilege level of this vty. */
51 /* Command input buffer */
54 /* Command cursor point */
60 /* Command max length. */
63 /* Histry of command */
64 char *hist
[VTY_MAXHIST
];
66 /* History lookup current point */
69 /* History insert end point */
72 /* For current referencing point of interface, route-map,
76 /* For multiple level index treatment such as key chain and key. */
79 /* For escape character. */
82 /* Current vty status. */
83 enum {VTY_NORMAL
, VTY_CLOSE
, VTY_MORE
, VTY_MORELINE
,
84 VTY_START
, VTY_CONTINUE
} status
;
90 unsigned char iac_sb_in_progress
;
91 struct buffer
*sb_buffer
;
93 /* Window width/height. */
99 /* Configure lines. */
102 /* Current executing function pointer. */
103 int (*func
) (struct vty
*, void *arg
);
105 /* Terminal monitor. */
108 /* In configure mode. */
111 /* Read and write thread. */
112 struct thread
*t_read
;
113 struct thread
*t_write
;
115 /* Timeout seconds and thread. */
116 unsigned long v_timeout
;
117 struct thread
*t_timeout
;
119 /* Thread output function. */
120 struct thread
*t_output
;
122 /* Output data pointer. */
123 int (*output_func
) (struct vty
*, int);
124 void (*output_clean
) (struct vty
*);
126 unsigned long output_count
;
131 /* Integrated configuration file. */
132 #define INTEGRATE_DEFAULT_CONFIG "Zebra.conf"
134 /* Small macro to determine newline is newline only or linefeed needed. */
135 #define VTY_NEWLINE ((vty->type == VTY_TERM) ? "\r\n" : "\n")
137 /* Default time out value */
138 #define VTY_TIMEOUT_DEFAULT 600
140 /* Vty read buffer size. */
141 #define VTY_READ_BUFSIZ 512
143 /* Directory separator. */
144 #ifndef DIRECTORY_SEP
145 #define DIRECTORY_SEP '/'
146 #endif /* DIRECTORY_SEP */
148 #ifndef IS_DIRECTORY_SEP
149 #define IS_DIRECTORY_SEP(c) ((c) == DIRECTORY_SEP)
152 /* GCC have printf type attribute check. */
154 #define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
156 #define PRINTF_ATTRIBUTE(a,b)
157 #endif /* __GNUC__ */
159 /* Utility macro to convert VTY argument to unsigned integer. */
160 #define VTY_GET_INTEGER(NAME,V,STR) \
162 char *endptr = NULL; \
163 (V) = strtoul ((STR), &endptr, 10); \
164 if ((V) == ULONG_MAX || *endptr != '\0') \
166 vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
167 return CMD_WARNING; \
171 #define VTY_GET_INTEGER_RANGE(NAME,V,STR,MIN,MAX) \
173 char *endptr = NULL; \
174 (V) = strtoul ((STR), &endptr, 10); \
175 if ((V) == ULONG_MAX || *endptr != '\0' \
176 || (V) < (MIN) || (V) > (MAX)) \
178 vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
179 return CMD_WARNING; \
183 /* Exported variables */
184 extern char integrate_default
[];
187 void vty_init (void);
188 void vty_init_vtysh (void);
189 void vty_reset (void);
190 void vty_finish (void);
191 struct vty
*vty_new (void);
192 int vty_out (struct vty
*, const char *, ...) PRINTF_ATTRIBUTE(2, 3);
193 void vty_read_config (char *, char *, char *);
194 void vty_time_print (struct vty
*, int);
195 void vty_serv_sock (const char *, unsigned short, char *);
196 void vty_close (struct vty
*);
197 char *vty_get_cwd (void);
198 void vty_log (const char *, const char *, va_list);
199 int vty_config_lock (struct vty
*);
200 int vty_config_unlock (struct vty
*);
201 int vty_shell (struct vty
*);
202 int vty_shell_serv (struct vty
*);
203 void vty_hello (struct vty
*);
205 #endif /* _ZEBRA_VTY_H */