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. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)externs.h 8.3 (Berkeley) 5/30/95
30 * $FreeBSD: src/crypto/telnet/telnet/externs.h,v 1.4.2.2 2002/04/13 10:59:08 markm Exp $
38 * ucb stdio.h defines BSD as something weird
40 #if defined(sun) && defined(__svr4__)
45 # if BSD > 43 || defined(SYSV_TERMIO)
52 #include <sys/ioctl.h>
58 # define termio termios
60 #if defined(NO_CC_T) || !defined(USE_TERMIO)
61 # if !defined(USE_TERMIO)
64 typedef unsigned char cc_t
;
70 #ifndef _POSIX_VDISABLE
72 # include <sys/param.h> /* pick up VDISABLE definition, mayby */
75 # define _POSIX_VDISABLE VDISABLE
77 # define _POSIX_VDISABLE ((cc_t)'\377')
81 #define SUBBUFSIZE 256
84 autologin
, /* Autologin enabled */
85 skiprc
, /* Don't process the ~/.telnetrc file */
86 eight
, /* use eight bit mode (binary in and/or out */
87 family
, /* address family of peer */
88 flushout
, /* flush output */
89 connected
, /* Are we connected to the other side? */
90 globalmode
, /* Mode tty should be in */
91 telnetport
, /* Are we connected to the telnet port? */
92 localflow
, /* Flow control handled locally */
93 restartany
, /* If flow control, restart output on any character */
94 localchars
, /* we recognize interrupt/quit */
95 donelclchars
, /* the user has set "localchars" */
97 net
, /* Network file descriptor */
98 tin
, /* Terminal input file descriptor */
99 tout
, /* Terminal output file descriptor */
100 crlf
, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
101 autoflush
, /* flush output when interrupting? */
102 autosynch
, /* send interrupt characters with SYNCH? */
103 SYNCHing
, /* Is the stream in telnet SYNCH mode? */
104 donebinarytoggle
, /* the user has put us in binary */
105 dontlecho
, /* do we suppress local echoing right now? */
107 netdata
, /* Print out network data flow */
108 prettydump
, /* Print "netdata" output in user readable format */
109 termdata
, /* Print out terminal data flow */
110 telnet_debug
, /* Debug level */
111 doaddrlookup
, /* do a reverse lookup? */
112 clienteof
; /* Client received EOF */
114 extern cc_t escape
; /* Escape to command mode */
115 extern cc_t rlogin
; /* Rlogin mode escape character */
116 #ifdef KLUDGELINEMODE
117 extern cc_t echoc
; /* Toggle local echoing */
121 *prompt
; /* Prompt for command. */
128 options
[], /* All the little options */
129 *hostname
; /* Who are we connected to? */
131 extern void (*encrypt_output
)(unsigned char *, int);
132 extern int (*decrypt_input
)(int);
133 #endif /* ENCRYPTION */
136 * We keep track of each side of the option negotiation.
139 #define MY_STATE_WILL 0x01
140 #define MY_WANT_STATE_WILL 0x02
141 #define MY_STATE_DO 0x04
142 #define MY_WANT_STATE_DO 0x08
145 * Macros to check the current state of things
148 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
149 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
150 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
151 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
153 #define my_state_is_dont(opt) (!my_state_is_do(opt))
154 #define my_state_is_wont(opt) (!my_state_is_will(opt))
155 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
156 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
158 #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
159 #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
160 #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
161 #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
163 #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
164 #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
165 #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
166 #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
169 * Make everything symetrical
172 #define HIS_STATE_WILL MY_STATE_DO
173 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
174 #define HIS_STATE_DO MY_STATE_WILL
175 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
177 #define his_state_is_do my_state_is_will
178 #define his_state_is_will my_state_is_do
179 #define his_want_state_is_do my_want_state_is_will
180 #define his_want_state_is_will my_want_state_is_do
182 #define his_state_is_dont my_state_is_wont
183 #define his_state_is_wont my_state_is_dont
184 #define his_want_state_is_dont my_want_state_is_wont
185 #define his_want_state_is_wont my_want_state_is_dont
187 #define set_his_state_do set_my_state_will
188 #define set_his_state_will set_my_state_do
189 #define set_his_want_state_do set_my_want_state_will
190 #define set_his_want_state_will set_my_want_state_do
192 #define set_his_state_dont set_my_state_wont
193 #define set_his_state_wont set_my_state_dont
194 #define set_his_want_state_dont set_my_want_state_wont
195 #define set_his_want_state_wont set_my_want_state_dont
197 #if defined(USE_TERMIO)
198 #define SIG_FUNC_RET void
200 #define SIG_FUNC_RET int
209 *NetTrace
; /* Where debugging output goes */
211 NetTraceFile
[]; /* Name of file where debugging output goes */
213 SetNetTrace(char *); /* Function to change where debugging goes */
217 toplevel
; /* For error conditions. */
220 command(int, const char *, int),
221 Dump(char, unsigned char *, int),
224 ExitString(const char *, int) __dead2
,
231 printoption(const char *, int, int),
232 printsub(char, unsigned char *, int),
241 setcommandmode(void),
242 set_escape_char(char *s
),
244 sys_telnet_init(void),
246 tel_enter_binary(int),
247 tel_leave_binary(int),
248 TerminalFlushOutput(void),
249 TerminalNewMode(int),
250 TerminalRestoreState(void),
251 TerminalSaveState(void),
252 TerminalDefaultChars(void),
253 TerminalSpeeds(long *, long *),
266 lm_will(unsigned char *, int),
267 lm_wont(unsigned char *, int),
268 lm_do(unsigned char *, int),
269 lm_dont(unsigned char *, int),
270 lm_mode(unsigned char *, int, int);
275 slc_mode_export(void),
276 slc_mode_import(int),
279 slc(unsigned char *, int),
281 slc_start_reply(void),
282 slc_add_reply(unsigned char, unsigned char, cc_t
),
286 opt_welldefined(const char *),
289 process_rings(int, int, int, int, int, int),
291 SetSockOpt(int, int, int, int),
295 TerminalRead(char *, int),
296 TerminalWrite(char *, int),
297 TerminalAutoFlush(void),
298 TerminalWindowSize(long *, long *),
299 TerminalSpecialChars(int),
304 env_opt(unsigned char *, int),
306 env_opt_start_info(void),
307 env_opt_add(unsigned char *),
311 *env_default(int, int),
312 *env_getvalue(const unsigned char *);
323 extern struct tchars ntc
;
324 extern struct ltchars nltc
;
325 extern struct sgttyb nttyb
;
327 # define termEofChar ntc.t_eofc
328 # define termEraseChar nttyb.sg_erase
329 # define termFlushChar nltc.t_flushc
330 # define termIntChar ntc.t_intrc
331 # define termKillChar nttyb.sg_kill
332 # define termLiteralNextChar nltc.t_lnextc
333 # define termQuitChar ntc.t_quitc
334 # define termSuspChar nltc.t_suspc
335 # define termRprntChar nltc.t_rprntc
336 # define termWerasChar nltc.t_werasc
337 # define termStartChar ntc.t_startc
338 # define termStopChar ntc.t_stopc
339 # define termForw1Char ntc.t_brkc
340 extern cc_t termForw2Char
;
341 extern cc_t termAytChar
;
343 # define termEofCharp (cc_t *)&ntc.t_eofc
344 # define termEraseCharp (cc_t *)&nttyb.sg_erase
345 # define termFlushCharp (cc_t *)&nltc.t_flushc
346 # define termIntCharp (cc_t *)&ntc.t_intrc
347 # define termKillCharp (cc_t *)&nttyb.sg_kill
348 # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc
349 # define termQuitCharp (cc_t *)&ntc.t_quitc
350 # define termSuspCharp (cc_t *)&nltc.t_suspc
351 # define termRprntCharp (cc_t *)&nltc.t_rprntc
352 # define termWerasCharp (cc_t *)&nltc.t_werasc
353 # define termStartCharp (cc_t *)&ntc.t_startc
354 # define termStopCharp (cc_t *)&ntc.t_stopc
355 # define termForw1Charp (cc_t *)&ntc.t_brkc
356 # define termForw2Charp (cc_t *)&termForw2Char
357 # define termAytCharp (cc_t *)&termAytChar
361 extern struct termio new_tc
;
363 # define termEofChar new_tc.c_cc[VEOF]
364 # define termEraseChar new_tc.c_cc[VERASE]
365 # define termIntChar new_tc.c_cc[VINTR]
366 # define termKillChar new_tc.c_cc[VKILL]
367 # define termQuitChar new_tc.c_cc[VQUIT]
370 extern cc_t termSuspChar
;
372 # define termSuspChar new_tc.c_cc[VSUSP]
374 # if defined(VFLUSHO) && !defined(VDISCARD)
375 # define VDISCARD VFLUSHO
378 extern cc_t termFlushChar
;
380 # define termFlushChar new_tc.c_cc[VDISCARD]
383 extern cc_t termWerasChar
;
385 # define termWerasChar new_tc.c_cc[VWERASE]
388 extern cc_t termRprntChar
;
390 # define termRprntChar new_tc.c_cc[VREPRINT]
393 extern cc_t termLiteralNextChar
;
395 # define termLiteralNextChar new_tc.c_cc[VLNEXT]
398 extern cc_t termStartChar
;
400 # define termStartChar new_tc.c_cc[VSTART]
403 extern cc_t termStopChar
;
405 # define termStopChar new_tc.c_cc[VSTOP]
408 extern cc_t termForw1Char
;
410 # define termForw1Char new_tc.c_cc[VEOL]
413 extern cc_t termForw2Char
;
415 # define termForw2Char new_tc.c_cc[VEOL]
418 extern cc_t termAytChar
;
420 # define termAytChar new_tc.c_cc[VSTATUS]
423 # if defined(__STDC__)
424 # define termEofCharp &termEofChar
425 # define termEraseCharp &termEraseChar
426 # define termIntCharp &termIntChar
427 # define termKillCharp &termKillChar
428 # define termQuitCharp &termQuitChar
429 # define termSuspCharp &termSuspChar
430 # define termFlushCharp &termFlushChar
431 # define termWerasCharp &termWerasChar
432 # define termRprntCharp &termRprntChar
433 # define termLiteralNextCharp &termLiteralNextChar
434 # define termStartCharp &termStartChar
435 # define termStopCharp &termStopChar
436 # define termForw1Charp &termForw1Char
437 # define termForw2Charp &termForw2Char
438 # define termAytCharp &termAytChar
440 /* Work around a compiler bug */
441 # define termEofCharp 0
442 # define termEraseCharp 0
443 # define termIntCharp 0
444 # define termKillCharp 0
445 # define termQuitCharp 0
446 # define termSuspCharp 0
447 # define termFlushCharp 0
448 # define termWerasCharp 0
449 # define termRprntCharp 0
450 # define termLiteralNextCharp 0
451 # define termStartCharp 0
452 # define termStopCharp 0
453 # define termForw1Charp 0
454 # define termForw2Charp 0
455 # define termAytCharp 0
460 /* Ring buffer structures which are shared */