7 /*! \defgroup vty VTY (Virtual TTY) interface
12 /* GCC have printf type attribute check. */
14 #define VTY_PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
16 #define VTY_PRINTF_ATTRIBUTE(a,b)
19 /* Does the I/O error indicate that the operation should be retried later? */
20 #define ERRNO_IO_RETRY(EN) \
21 (((EN) == EAGAIN) || ((EN) == EWOULDBLOCK) || ((EN) == EINTR))
23 /* Vty read buffer size. */
24 #define VTY_READ_BUFSIZ 512
26 #define VTY_BUFSIZ 512
27 #define VTY_MAXHIST 20
29 /*! \brief VTY events */
50 /*! Internal representation of a single VTY */
52 /*! \brief underlying file (if any) */
55 /*! \brief private data, specified by creator */
58 /*! \brief File descripter of this vty. */
61 /*! \brief Is this vty connect to file or not */
64 /*! \brief Node status of this vty */
67 /*! \brief Failure count */
70 /*! \brief Output buffer. */
73 /*! \brief Command input buffer */
76 /*! \brief Command cursor point */
79 /*! \brief Command length */
82 /*! \brief Command max length. */
85 /*! \brief Histry of command */
86 char *hist
[VTY_MAXHIST
];
88 /*! \brief History lookup current point */
91 /*! \brief History insert end point */
94 /*! \brief For current referencing point of interface, route-map,
98 /*! \brief For multiple level index treatment such as key chain and key. */
101 /*! \brief For escape character. */
102 unsigned char escape
;
104 /*! \brief Current vty status. */
105 enum { VTY_NORMAL
, VTY_CLOSE
, VTY_MORE
, VTY_MORELINE
} status
;
107 /*! \brief IAC handling
109 * IAC handling: was the last character received the IAC
110 * (interpret-as-command) escape character (and therefore the next
111 * character will be the command code)? Refer to Telnet RFC 854. */
114 /*! \brief IAC SB (option subnegotiation) handling */
115 unsigned char iac_sb_in_progress
;
116 /* At the moment, we care only about the NAWS (window size) negotiation,
117 * and that requires just a 5-character buffer (RFC 1073):
118 * <NAWS char> <16-bit width> <16-bit height> */
119 #define TELNET_NAWS_SB_LEN 5
120 /*! \brief sub-negotiation buffer */
121 unsigned char sb_buf
[TELNET_NAWS_SB_LEN
];
122 /*! \brief How many subnegotiation characters have we received?
124 * We just drop those that do not fit in the buffer. */
127 /*! \brief Window width */
129 /*! \brief Widnow height */
132 /*! \brief Configure lines. */
137 /*! \brief In configure mode. */
141 /* Small macro to determine newline is newline only or linefeed needed. */
142 #define VTY_NEWLINE ((vty->type == VTY_TERM) ? "\r\n" : "\n")
144 static inline const char *vty_newline(struct vty
*vty
)
149 /*! Information an application registers with the VTY */
150 struct vty_app_info
{
151 /*! \brief name of the application */
153 /*! \brief version string of the application */
155 /*! \brief copyright string of the application */
156 const char *copyright
;
157 /*! \brief \ref talloc context */
159 /*! \brief call-back for returning to parent n ode */
160 enum node_type (*go_parent_cb
)(struct vty
*vty
);
161 /*! \brief call-back to determine if node is config node */
162 int (*is_config_node
)(struct vty
*vty
, int node
);
166 void vty_init(struct vty_app_info
*app_info
);
167 int vty_read_config_file(const char *file_name
, void *priv
);
168 void vty_init_vtysh (void);
169 void vty_reset (void);
170 struct vty
*vty_new (void);
171 struct vty
*vty_create (int vty_sock
, void *priv
);
172 int vty_out (struct vty
*, const char *, ...) VTY_PRINTF_ATTRIBUTE(2, 3);
173 int vty_out_newline(struct vty
*);
174 int vty_read(struct vty
*vty
);
175 //void vty_time_print (struct vty *, int);
176 void vty_close (struct vty
*);
177 char *vty_get_cwd (void);
178 void vty_log (const char *level
, const char *proto
, const char *fmt
, va_list);
179 int vty_config_lock (struct vty
*);
180 int vty_config_unlock (struct vty
*);
181 int vty_shell (struct vty
*);
182 int vty_shell_serv (struct vty
*);
183 void vty_hello (struct vty
*);
184 void *vty_current_index(struct vty
*);
185 int vty_current_node(struct vty
*vty
);
186 enum node_type
vty_go_parent(struct vty
*vty
);
188 extern void *tall_vty_ctx
;
190 extern struct cmd_element cfg_description_cmd
;
191 extern struct cmd_element cfg_no_description_cmd
;