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 21734 2007-07-31 01:55:45Z lha $ */
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 wantencryption, /* User has requested encryption */
70 net, /* Network file descriptor */
71 tin, /* Terminal input file descriptor */
72 tout, /* Terminal output file descriptor */
73 crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
74 autoflush, /* flush output when interrupting? */
75 autosynch, /* send interrupt characters with SYNCH? */
76 SYNCHing, /* Is the stream in telnet SYNCH mode? */
77 donebinarytoggle, /* the user has put us in binary */
78 dontlecho, /* do we suppress local echoing right now? */
80 netdata, /* Print out network data flow */
81 prettydump, /* Print "netdata" output in user readable format */
82 termdata, /* Print out terminal data flow */
83 debug; /* Debug level */
85 extern int intr_happened, intr_waiting; /* for interrupt handling */
87 extern cc_t escape; /* Escape to command mode */
88 extern cc_t rlogin; /* Rlogin mode escape character */
90 extern cc_t echoc; /* Toggle local echoing */
94 *prompt; /* Prompt for command. */
103 options[], /* All the little options */
104 *hostname; /* Who are we connected to? */
105 #if defined(ENCRYPTION)
106 extern void (*encrypt_output) (unsigned char *, int);
107 extern int (*decrypt_input) (int);
111 * We keep track of each side of the option negotiation.
114 #define MY_STATE_WILL 0x01
115 #define MY_WANT_STATE_WILL 0x02
116 #define MY_STATE_DO 0x04
117 #define MY_WANT_STATE_DO 0x08
120 * Macros to check the current state of things
123 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
124 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
125 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
126 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
128 #define my_state_is_dont(opt) (!my_state_is_do(opt))
129 #define my_state_is_wont(opt) (!my_state_is_will(opt))
130 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
131 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
133 #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
134 #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
135 #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
136 #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
138 #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
139 #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
140 #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
141 #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
144 * Make everything symmetrical
147 #define HIS_STATE_WILL MY_STATE_DO
148 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
149 #define HIS_STATE_DO MY_STATE_WILL
150 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
152 #define his_state_is_do my_state_is_will
153 #define his_state_is_will my_state_is_do
154 #define his_want_state_is_do my_want_state_is_will
155 #define his_want_state_is_will my_want_state_is_do
157 #define his_state_is_dont my_state_is_wont
158 #define his_state_is_wont my_state_is_dont
159 #define his_want_state_is_dont my_want_state_is_wont
160 #define his_want_state_is_wont my_want_state_is_dont
162 #define set_his_state_do set_my_state_will
163 #define set_his_state_will set_my_state_do
164 #define set_his_want_state_do set_my_want_state_will
165 #define set_his_want_state_will set_my_want_state_do
167 #define set_his_state_dont set_my_state_wont
168 #define set_his_state_wont set_my_state_dont
169 #define set_his_want_state_dont set_my_want_state_wont
170 #define set_his_want_state_wont set_my_want_state_dont
174 *NetTrace; /* Where debugging output goes */
176 NetTraceFile[]; /* Name of file where debugging output goes */
178 SetNetTrace (char *); /* Function to change where debugging goes */
182 toplevel; /* For error conditions. */
185 extern int scheduler_lockout_tty;
190 #if defined(AUTHENTICATION) || defined(ENCRYPTION)
191 int telnet_net_write(unsigned char *str, int len);
192 void net_encrypt(void);
193 int telnet_spin(void);
194 char *telnet_getenv(const char *val);
195 char *telnet_gets(char *prompt, char *result, int length, int echo);
200 struct env_lst *env_define (unsigned char *, unsigned char *);
201 struct env_lst *env_find(unsigned char *var);
202 void env_init (void);
203 void env_undefine (unsigned char *);
204 void env_export (unsigned char *);
205 void env_unexport (unsigned char *);
206 void env_send (unsigned char *);
207 void env_list (void);
208 unsigned char * env_default(int init, int welldefined);
209 unsigned char * env_getvalue(unsigned char *var);
211 void set_escape_char(char *s);
212 int sourceroute(struct addrinfo *ai, char *arg, char **cpp,
213 int *prototp, int *optp);
215 #if defined(AUTHENTICATION)
216 int auth_enable (char *);
217 int auth_disable (char *);
218 int auth_status (void);
221 #if defined(ENCRYPTION)
222 int EncryptEnable (char *, char *);
223 int EncryptDisable (char *, char *);
224 int EncryptType (char *, char *);
225 int EncryptStart (char *);
226 int EncryptStartInput (void);
227 int EncryptStartOutput (void);
228 int EncryptStop (char *);
229 int EncryptStopInput (void);
230 int EncryptStopOutput (void);
231 int EncryptStatus (void);
235 RETSIGTYPE ayt_status(int);
237 int tn(int argc, char **argv);
238 void command(int top, char *tbuf, int cnt);
243 void set_forward_options(void);
247 void init_network(void);
249 void setneturg(void);
255 int TerminalWrite(char *buf, int n);
256 int TerminalRead(unsigned char *buf, int n);
257 int TerminalAutoFlush(void);
258 int TerminalSpecialChars(int c);
259 void TerminalFlushOutput(void);
260 void TerminalSaveState(void);
261 void TerminalDefaultChars(void);
262 void TerminalNewMode(int f);
263 cc_t *tcval(int func);
264 void TerminalSpeeds(long *input_speed, long *output_speed);
265 int TerminalWindowSize(long *rows, long *cols);
266 int NetClose(int fd);
267 void NetNonblockingIO(int fd, int onoff);
268 int process_rings(int netin, int netout, int netex, int ttyin, int ttyout,
273 void init_telnet(void);
275 void tel_leave_binary(int rw);
276 void tel_enter_binary(int rw);
277 int opt_welldefined(char *ep);
279 int rlogin_susp(void);
282 void sendabort(void);
292 void Dump (char, unsigned char *, int);
293 void printoption (char *, int, int);
294 void printsub (int, unsigned char *, int);
295 void sendnaws (void);
296 void setconnmode (int);
297 void setcommandmode (void);
298 void setneturg (void);
299 void sys_telnet_init (void);
300 void my_telnet (char *);
301 void tel_enter_binary (int);
302 void TerminalFlushOutput (void);
303 void TerminalNewMode (int);
304 void TerminalRestoreState (void);
305 void TerminalSaveState (void);
306 void willoption (int);
307 void wontoption (int);
310 void send_do (int, int);
311 void send_dont (int, int);
312 void send_will (int, int);
313 void send_wont (int, int);
315 void lm_will (unsigned char *, int);
316 void lm_wont (unsigned char *, int);
317 void lm_do (unsigned char *, int);
318 void lm_dont (unsigned char *, int);
319 void lm_mode (unsigned char *, int, int);
321 void slc_init (void);
322 void slcstate (void);
323 void slc_mode_export (void);
324 void slc_mode_import (int);
325 void slc_import (int);
326 void slc_export (void);
327 void slc (unsigned char *, int);
328 void slc_check (void);
329 void slc_start_reply (void);
330 void slc_add_reply (unsigned char, unsigned char, cc_t);
331 void slc_end_reply (void);
332 int slc_update (void);
334 void env_opt (unsigned char *, int);
335 void env_opt_start (void);
336 void env_opt_start_info (void);
337 void env_opt_add (unsigned char *);
338 void env_opt_end (int);
340 unsigned char *env_default (int, int);
341 unsigned char *env_getvalue (unsigned char *);
343 int get_status (void);
352 void init_terminal(void);
353 int ttyflush(int drop);
354 int getconnmode(void);
358 int SetSockOpt(int fd, int level, int option, int yesno);
359 void SetNetTrace(char *file);
360 void Dump(char direction, unsigned char *buffer, int length);
361 void printoption(char *direction, int cmd, int option);
362 void optionstatus(void);
363 void printsub(int direction, unsigned char *pointer, int length);
364 void EmptyTerminal(void);
365 void SetForExit(void);
366 void Exit(int returnCode);
367 void ExitString(char *string, int returnCode);
369 extern struct termios new_tc;
371 # define termEofChar new_tc.c_cc[VEOF]
372 # define termEraseChar new_tc.c_cc[VERASE]
373 # define termIntChar new_tc.c_cc[VINTR]
374 # define termKillChar new_tc.c_cc[VKILL]
375 # define termQuitChar new_tc.c_cc[VQUIT]
378 extern cc_t termSuspChar;
380 # define termSuspChar new_tc.c_cc[VSUSP]
382 # if defined(VFLUSHO) && !defined(VDISCARD)
383 # define VDISCARD VFLUSHO
386 extern cc_t termFlushChar;
388 # define termFlushChar new_tc.c_cc[VDISCARD]
391 extern cc_t termWerasChar;
393 # define termWerasChar new_tc.c_cc[VWERASE]
396 extern cc_t termRprntChar;
398 # define termRprntChar new_tc.c_cc[VREPRINT]
401 extern cc_t termLiteralNextChar;
403 # define termLiteralNextChar new_tc.c_cc[VLNEXT]
406 extern cc_t termStartChar;
408 # define termStartChar new_tc.c_cc[VSTART]
411 extern cc_t termStopChar;
413 # define termStopChar new_tc.c_cc[VSTOP]
416 extern cc_t termForw1Char;
418 # define termForw1Char new_tc.c_cc[VEOL]
421 extern cc_t termForw2Char;
423 # define termForw2Char new_tc.c_cc[VEOL]
426 extern cc_t termAytChar;
428 # define termAytChar new_tc.c_cc[VSTATUS]
431 /* Ring buffer structures which are shared */
439 extern int resettermname;
441 #ifdef KLUDGELINEMODE
442 extern int kludgelinemode;
444 extern int want_status_response;