2 * Copyright (c) 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * @(#)externs.h 8.3 (Berkeley) 5/30/95
36 /* $Id: externs.h,v 1.18 1998/07/09 23:16:36 assar Exp $ */
42 #ifndef _POSIX_VDISABLE
44 # include <sys/param.h> /* pick up VDISABLE definition, mayby */
47 # define _POSIX_VDISABLE VDISABLE
49 # define _POSIX_VDISABLE ((cc_t)'\377')
53 #define SUBBUFSIZE 256
56 autologin, /* Autologin enabled */
57 skiprc, /* Don't process the ~/.telnetrc file */
58 eight, /* use eight bit mode (binary in and/or out */
60 flushout, /* flush output */
61 connected, /* Are we connected to the other side? */
62 globalmode, /* Mode tty should be in */
63 telnetport, /* Are we connected to the telnet port? */
64 localflow, /* Flow control handled locally */
65 restartany, /* If flow control, restart output on any character */
66 localchars, /* we recognize interrupt/quit */
67 donelclchars, /* the user has set "localchars" */
69 net, /* Network file descriptor */
70 tin, /* Terminal input file descriptor */
71 tout, /* Terminal output file descriptor */
72 crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
73 autoflush, /* flush output when interrupting? */
74 autosynch, /* send interrupt characters with SYNCH? */
75 SYNCHing, /* Is the stream in telnet SYNCH mode? */
76 donebinarytoggle, /* the user has put us in binary */
77 dontlecho, /* do we suppress local echoing right now? */
79 netdata, /* Print out network data flow */
80 prettydump, /* Print "netdata" output in user readable format */
81 termdata, /* Print out terminal data flow */
82 debug; /* Debug level */
84 extern cc_t escape; /* Escape to command mode */
85 extern cc_t rlogin; /* Rlogin mode escape character */
87 extern cc_t echoc; /* Toggle local echoing */
91 *prompt; /* Prompt for command. */
98 options[], /* All the little options */
99 *hostname; /* Who are we connected to? */
100 #if defined(ENCRYPTION)
101 extern void (*encrypt_output) (unsigned char *, int);
102 extern int (*decrypt_input) (int);
106 * We keep track of each side of the option negotiation.
109 #define MY_STATE_WILL 0x01
110 #define MY_WANT_STATE_WILL 0x02
111 #define MY_STATE_DO 0x04
112 #define MY_WANT_STATE_DO 0x08
115 * Macros to check the current state of things
118 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
119 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
120 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
121 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
123 #define my_state_is_dont(opt) (!my_state_is_do(opt))
124 #define my_state_is_wont(opt) (!my_state_is_will(opt))
125 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
126 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
128 #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
129 #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
130 #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
131 #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
133 #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
134 #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
135 #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
136 #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
139 * Make everything symetrical
142 #define HIS_STATE_WILL MY_STATE_DO
143 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
144 #define HIS_STATE_DO MY_STATE_WILL
145 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
147 #define his_state_is_do my_state_is_will
148 #define his_state_is_will my_state_is_do
149 #define his_want_state_is_do my_want_state_is_will
150 #define his_want_state_is_will my_want_state_is_do
152 #define his_state_is_dont my_state_is_wont
153 #define his_state_is_wont my_state_is_dont
154 #define his_want_state_is_dont my_want_state_is_wont
155 #define his_want_state_is_wont my_want_state_is_dont
157 #define set_his_state_do set_my_state_will
158 #define set_his_state_will set_my_state_do
159 #define set_his_want_state_do set_my_want_state_will
160 #define set_his_want_state_will set_my_want_state_do
162 #define set_his_state_dont set_my_state_wont
163 #define set_his_state_wont set_my_state_dont
164 #define set_his_want_state_dont set_my_want_state_wont
165 #define set_his_want_state_wont set_my_want_state_dont
169 *NetTrace; /* Where debugging output goes */
171 NetTraceFile[]; /* Name of file where debugging output goes */
173 SetNetTrace (char *); /* Function to change where debugging goes */
177 toplevel; /* For error conditions. */
181 #if defined(AUTHENTICATION) || defined(ENCRYPTION)
182 int telnet_net_write(unsigned char *str, int len);
183 void net_encrypt(void);
184 int telnet_spin(void);
185 char *telnet_getenv(char *val);
186 char *telnet_gets(char *prompt, char *result, int length, int echo);
191 struct env_lst *env_define (unsigned char *, unsigned char *);
192 struct env_lst *env_find(unsigned char *var);
193 void env_init (void);
194 void env_undefine (unsigned char *);
195 void env_export (unsigned char *);
196 void env_unexport (unsigned char *);
197 void env_send (unsigned char *);
198 void env_list (void);
199 unsigned char * env_default(int init, int welldefined);
200 unsigned char * env_getvalue(unsigned char *var);
202 void set_escape_char(char *s);
203 unsigned long sourceroute(char *arg, char **cpp, int *lenp);
205 #if defined(AUTHENTICATION)
206 int auth_enable (char *);
207 int auth_disable (char *);
208 int auth_status (void);
211 #if defined(ENCRYPTION)
212 int EncryptEnable (char *, char *);
213 int EncryptDisable (char *, char *);
214 int EncryptType (char *, char *);
215 int EncryptStart (char *);
216 int EncryptStartInput (void);
217 int EncryptStartOutput (void);
218 int EncryptStop (char *);
219 int EncryptStopInput (void);
220 int EncryptStopOutput (void);
221 int EncryptStatus (void);
225 void ayt_status(int);
227 int tn(int argc, char **argv);
228 void command(int top, char *tbuf, int cnt);
237 void init_network(void);
239 void setneturg(void);
245 int TerminalWrite(char *buf, int n);
246 int TerminalRead(unsigned char *buf, int n);
247 int TerminalAutoFlush(void);
248 int TerminalSpecialChars(int c);
249 void TerminalFlushOutput(void);
250 void TerminalSaveState(void);
251 void TerminalDefaultChars(void);
252 void TerminalNewMode(int f);
253 cc_t *tcval(int func);
254 void TerminalSpeeds(long *input_speed, long *output_speed);
255 int TerminalWindowSize(long *rows, long *cols);
256 int NetClose(int fd);
257 void NetNonblockingIO(int fd, int onoff);
258 int process_rings(int netin, int netout, int netex, int ttyin, int ttyout,
263 void init_telnet(void);
265 void tel_leave_binary(int rw);
266 void tel_enter_binary(int rw);
267 int opt_welldefined(char *ep);
269 int rlogin_susp(void);
272 void sendabort(void);
282 void Dump (char, unsigned char *, int);
283 void printoption (char *, int, int);
284 void printsub (int, unsigned char *, int);
285 void sendnaws (void);
286 void setconnmode (int);
287 void setcommandmode (void);
288 void setneturg (void);
289 void sys_telnet_init (void);
290 void my_telnet (char *);
291 void tel_enter_binary (int);
292 void TerminalFlushOutput (void);
293 void TerminalNewMode (int);
294 void TerminalRestoreState (void);
295 void TerminalSaveState (void);
297 void willoption (int);
298 void wontoption (int);
301 void send_do (int, int);
302 void send_dont (int, int);
303 void send_will (int, int);
304 void send_wont (int, int);
306 void lm_will (unsigned char *, int);
307 void lm_wont (unsigned char *, int);
308 void lm_do (unsigned char *, int);
309 void lm_dont (unsigned char *, int);
310 void lm_mode (unsigned char *, int, int);
312 void slc_init (void);
313 void slcstate (void);
314 void slc_mode_export (void);
315 void slc_mode_import (int);
316 void slc_import (int);
317 void slc_export (void);
318 void slc (unsigned char *, int);
319 void slc_check (void);
320 void slc_start_reply (void);
321 void slc_add_reply (unsigned char, unsigned char, cc_t);
322 void slc_end_reply (void);
323 int slc_update (void);
325 void env_opt (unsigned char *, int);
326 void env_opt_start (void);
327 void env_opt_start_info (void);
328 void env_opt_add (unsigned char *);
329 void env_opt_end (int);
331 unsigned char *env_default (int, int);
332 unsigned char *env_getvalue (unsigned char *);
334 int get_status (void);
343 void init_terminal(void);
344 int ttyflush(int drop);
345 int getconnmode(void);
349 int SetSockOpt(int fd, int level, int option, int yesno);
350 void SetNetTrace(char *file);
351 void Dump(char direction, unsigned char *buffer, int length);
352 void printoption(char *direction, int cmd, int option);
353 void optionstatus(void);
354 void printsub(int direction, unsigned char *pointer, int length);
355 void EmptyTerminal(void);
356 void SetForExit(void);
357 void Exit(int returnCode);
358 void ExitString(char *string, int returnCode);
360 extern struct termios new_tc;
362 # define termEofChar new_tc.c_cc[VEOF]
363 # define termEraseChar new_tc.c_cc[VERASE]
364 # define termIntChar new_tc.c_cc[VINTR]
365 # define termKillChar new_tc.c_cc[VKILL]
366 # define termQuitChar new_tc.c_cc[VQUIT]
369 extern cc_t termSuspChar;
371 # define termSuspChar new_tc.c_cc[VSUSP]
373 # if defined(VFLUSHO) && !defined(VDISCARD)
374 # define VDISCARD VFLUSHO
377 extern cc_t termFlushChar;
379 # define termFlushChar new_tc.c_cc[VDISCARD]
382 extern cc_t termWerasChar;
384 # define termWerasChar new_tc.c_cc[VWERASE]
387 extern cc_t termRprntChar;
389 # define termRprntChar new_tc.c_cc[VREPRINT]
392 extern cc_t termLiteralNextChar;
394 # define termLiteralNextChar new_tc.c_cc[VLNEXT]
397 extern cc_t termStartChar;
399 # define termStartChar new_tc.c_cc[VSTART]
402 extern cc_t termStopChar;
404 # define termStopChar new_tc.c_cc[VSTOP]
407 extern cc_t termForw1Char;
409 # define termForw1Char new_tc.c_cc[VEOL]
412 extern cc_t termForw2Char;
414 # define termForw2Char new_tc.c_cc[VEOL]
417 extern cc_t termAytChar;
419 # define termAytChar new_tc.c_cc[VSTATUS]
422 /* Ring buffer structures which are shared */