7 /* GCC have printf type attribute check. */
9 #define VTY_PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
11 #define VTY_PRINTF_ATTRIBUTE(a,b)
14 /* Does the I/O error indicate that the operation should be retried later? */
15 #define ERRNO_IO_RETRY(EN) \
16 (((EN) == EAGAIN) || ((EN) == EWOULDBLOCK) || ((EN) == EINTR))
18 /* Vty read buffer size. */
19 #define VTY_READ_BUFSIZ 512
21 #define VTY_BUFSIZ 512
22 #define VTY_MAXHIST 20
41 /* private data, specified by creator */
44 /* File descripter of this vty. */
47 /* Is this vty connect to file or not */
48 enum { VTY_TERM, VTY_FILE, VTY_SHELL, VTY_SHELL_SERV } type;
50 /* Node status of this vty */
59 /* Command input buffer */
62 /* Command cursor point */
68 /* Command max length. */
71 /* Histry of command */
72 char *hist[VTY_MAXHIST];
74 /* History lookup current point */
77 /* History insert end point */
80 /* For current referencing point of interface, route-map,
84 /* For multiple level index treatment such as key chain and key. */
87 /* For escape character. */
90 /* Current vty status. */
91 enum { VTY_NORMAL, VTY_CLOSE, VTY_MORE, VTY_MORELINE } status;
93 /* IAC handling: was the last character received the IAC
94 * (interpret-as-command) escape character (and therefore the next
95 * character will be the command code)? Refer to Telnet RFC 854. */
98 /* IAC SB (option subnegotiation) handling */
99 unsigned char iac_sb_in_progress;
100 /* At the moment, we care only about the NAWS (window size) negotiation,
101 * and that requires just a 5-character buffer (RFC 1073):
102 * <NAWS char> <16-bit width> <16-bit height> */
103 #define TELNET_NAWS_SB_LEN 5
104 unsigned char sb_buf[TELNET_NAWS_SB_LEN];
105 /* How many subnegotiation characters have we received? We just drop
106 * those that do not fit in the buffer. */
109 /* Window width/height. */
113 /* Configure lines. */
118 /* In configure mode. */
122 /* Small macro to determine newline is newline only or linefeed needed. */
123 #define VTY_NEWLINE ((vty->type == VTY_TERM) ? "\r\n" : "\n")
125 static inline char *vty_newline(struct vty *vty)
130 struct vty_app_info {
133 const char *copyright;
135 enum node_type (*go_parent_cb)(struct vty *vty);
139 void vty_init(struct vty_app_info *app_info);
140 int vty_read_config_file(const char *file_name, void *priv);
141 void vty_init_vtysh (void);
142 void vty_reset (void);
143 struct vty *vty_new (void);
144 struct vty *vty_create (int vty_sock, void *priv);
145 int vty_out (struct vty *, const char *, ...) VTY_PRINTF_ATTRIBUTE(2, 3);
146 int vty_out_newline(struct vty *);
147 int vty_read(struct vty *vty);
148 //void vty_time_print (struct vty *, int);
149 void vty_close (struct vty *);
150 char *vty_get_cwd (void);
151 void vty_log (const char *level, const char *proto, const char *fmt, va_list);
152 int vty_config_lock (struct vty *);
153 int vty_config_unlock (struct vty *);
154 int vty_shell (struct vty *);
155 int vty_shell_serv (struct vty *);
156 void vty_hello (struct vty *);