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
;
71 #include <netinet6/ipsec.h>
72 #if defined(IPSEC_POLICY_IPSEC)
73 extern char *ipsec_policy_in
;
74 extern char *ipsec_policy_out
;
78 #ifndef _POSIX_VDISABLE
80 # include <sys/param.h> /* pick up VDISABLE definition, mayby */
83 # define _POSIX_VDISABLE VDISABLE
85 # define _POSIX_VDISABLE ((cc_t)'\377')
89 #define SUBBUFSIZE 256
92 autologin
, /* Autologin enabled */
93 skiprc
, /* Don't process the ~/.telnetrc file */
94 eight
, /* use eight bit mode (binary in and/or out */
95 family
, /* address family of peer */
96 flushout
, /* flush output */
97 connected
, /* Are we connected to the other side? */
98 globalmode
, /* Mode tty should be in */
99 telnetport
, /* Are we connected to the telnet port? */
100 localflow
, /* Flow control handled locally */
101 restartany
, /* If flow control, restart output on any character */
102 localchars
, /* we recognize interrupt/quit */
103 donelclchars
, /* the user has set "localchars" */
105 net
, /* Network file descriptor */
106 tin
, /* Terminal input file descriptor */
107 tout
, /* Terminal output file descriptor */
108 crlf
, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
109 autoflush
, /* flush output when interrupting? */
110 autosynch
, /* send interrupt characters with SYNCH? */
111 SYNCHing
, /* Is the stream in telnet SYNCH mode? */
112 donebinarytoggle
, /* the user has put us in binary */
113 dontlecho
, /* do we suppress local echoing right now? */
115 netdata
, /* Print out network data flow */
116 prettydump
, /* Print "netdata" output in user readable format */
117 termdata
, /* Print out terminal data flow */
118 debug
, /* Debug level */
119 doaddrlookup
, /* do a reverse lookup? */
120 clienteof
; /* Client received EOF */
122 extern cc_t escape
; /* Escape to command mode */
123 extern cc_t rlogin
; /* Rlogin mode escape character */
124 #ifdef KLUDGELINEMODE
125 extern cc_t echoc
; /* Toggle local echoing */
129 *prompt
; /* Prompt for command. */
136 options
[], /* All the little options */
137 *hostname
; /* Who are we connected to? */
139 extern void (*encrypt_output
)(unsigned char *, int);
140 extern int (*decrypt_input
)(int);
141 #endif /* ENCRYPTION */
144 * We keep track of each side of the option negotiation.
147 #define MY_STATE_WILL 0x01
148 #define MY_WANT_STATE_WILL 0x02
149 #define MY_STATE_DO 0x04
150 #define MY_WANT_STATE_DO 0x08
153 * Macros to check the current state of things
156 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
157 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
158 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
159 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
161 #define my_state_is_dont(opt) (!my_state_is_do(opt))
162 #define my_state_is_wont(opt) (!my_state_is_will(opt))
163 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
164 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
166 #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
167 #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
168 #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
169 #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
171 #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
172 #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
173 #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
174 #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
177 * Make everything symetrical
180 #define HIS_STATE_WILL MY_STATE_DO
181 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
182 #define HIS_STATE_DO MY_STATE_WILL
183 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
185 #define his_state_is_do my_state_is_will
186 #define his_state_is_will my_state_is_do
187 #define his_want_state_is_do my_want_state_is_will
188 #define his_want_state_is_will my_want_state_is_do
190 #define his_state_is_dont my_state_is_wont
191 #define his_state_is_wont my_state_is_dont
192 #define his_want_state_is_dont my_want_state_is_wont
193 #define his_want_state_is_wont my_want_state_is_dont
195 #define set_his_state_do set_my_state_will
196 #define set_his_state_will set_my_state_do
197 #define set_his_want_state_do set_my_want_state_will
198 #define set_his_want_state_will set_my_want_state_do
200 #define set_his_state_dont set_my_state_wont
201 #define set_his_state_wont set_my_state_dont
202 #define set_his_want_state_dont set_my_want_state_wont
203 #define set_his_want_state_wont set_my_want_state_dont
205 #if defined(USE_TERMIO)
206 #define SIG_FUNC_RET void
208 #define SIG_FUNC_RET int
217 *NetTrace
; /* Where debugging output goes */
219 NetTraceFile
[]; /* Name of file where debugging output goes */
221 SetNetTrace(char *); /* Function to change where debugging goes */
225 toplevel
; /* For error conditions. */
228 command(int, const char *, int),
229 Dump(char, unsigned char *, int),
232 ExitString(const char *, int),
239 printoption(const char *, int, int),
240 printsub(char, unsigned char *, int),
249 setcommandmode(void),
250 set_escape_char(char *s
),
252 sys_telnet_init(void),
254 tel_enter_binary(int),
255 tel_leave_binary(int),
256 TerminalFlushOutput(void),
257 TerminalNewMode(int),
258 TerminalRestoreState(void),
259 TerminalSaveState(void),
260 TerminalDefaultChars(void),
261 TerminalSpeeds(long *, long *),
274 lm_will(unsigned char *, int),
275 lm_wont(unsigned char *, int),
276 lm_do(unsigned char *, int),
277 lm_dont(unsigned char *, int),
278 lm_mode(unsigned char *, int, int);
283 slc_mode_export(void),
284 slc_mode_import(int),
287 slc(unsigned char *, int),
289 slc_start_reply(void),
290 slc_add_reply(unsigned char, unsigned char, cc_t
),
294 opt_welldefined(const char *),
297 process_rings(int, int, int, int, int, int),
299 SetSockOpt(int, int, int, int),
303 TerminalRead(char *, int),
304 TerminalWrite(char *, int),
305 TerminalAutoFlush(void),
306 TerminalWindowSize(long *, long *),
307 TerminalSpecialChars(int),
312 env_opt(unsigned char *, int),
314 env_opt_start_info(void),
315 env_opt_add(unsigned char *),
319 *env_default(int, int),
320 *env_getvalue(const unsigned char *);
331 extern struct tchars ntc
;
332 extern struct ltchars nltc
;
333 extern struct sgttyb nttyb
;
335 # define termEofChar ntc.t_eofc
336 # define termEraseChar nttyb.sg_erase
337 # define termFlushChar nltc.t_flushc
338 # define termIntChar ntc.t_intrc
339 # define termKillChar nttyb.sg_kill
340 # define termLiteralNextChar nltc.t_lnextc
341 # define termQuitChar ntc.t_quitc
342 # define termSuspChar nltc.t_suspc
343 # define termRprntChar nltc.t_rprntc
344 # define termWerasChar nltc.t_werasc
345 # define termStartChar ntc.t_startc
346 # define termStopChar ntc.t_stopc
347 # define termForw1Char ntc.t_brkc
348 extern cc_t termForw2Char
;
349 extern cc_t termAytChar
;
351 # define termEofCharp (cc_t *)&ntc.t_eofc
352 # define termEraseCharp (cc_t *)&nttyb.sg_erase
353 # define termFlushCharp (cc_t *)&nltc.t_flushc
354 # define termIntCharp (cc_t *)&ntc.t_intrc
355 # define termKillCharp (cc_t *)&nttyb.sg_kill
356 # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc
357 # define termQuitCharp (cc_t *)&ntc.t_quitc
358 # define termSuspCharp (cc_t *)&nltc.t_suspc
359 # define termRprntCharp (cc_t *)&nltc.t_rprntc
360 # define termWerasCharp (cc_t *)&nltc.t_werasc
361 # define termStartCharp (cc_t *)&ntc.t_startc
362 # define termStopCharp (cc_t *)&ntc.t_stopc
363 # define termForw1Charp (cc_t *)&ntc.t_brkc
364 # define termForw2Charp (cc_t *)&termForw2Char
365 # define termAytCharp (cc_t *)&termAytChar
369 extern struct termio 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 # if defined(__STDC__)
432 # define termEofCharp &termEofChar
433 # define termEraseCharp &termEraseChar
434 # define termIntCharp &termIntChar
435 # define termKillCharp &termKillChar
436 # define termQuitCharp &termQuitChar
437 # define termSuspCharp &termSuspChar
438 # define termFlushCharp &termFlushChar
439 # define termWerasCharp &termWerasChar
440 # define termRprntCharp &termRprntChar
441 # define termLiteralNextCharp &termLiteralNextChar
442 # define termStartCharp &termStartChar
443 # define termStopCharp &termStopChar
444 # define termForw1Charp &termForw1Char
445 # define termForw2Charp &termForw2Char
446 # define termAytCharp &termAytChar
448 /* Work around a compiler bug */
449 # define termEofCharp 0
450 # define termEraseCharp 0
451 # define termIntCharp 0
452 # define termKillCharp 0
453 # define termQuitCharp 0
454 # define termSuspCharp 0
455 # define termFlushCharp 0
456 # define termWerasCharp 0
457 # define termRprntCharp 0
458 # define termLiteralNextCharp 0
459 # define termStartCharp 0
460 # define termStopCharp 0
461 # define termForw1Charp 0
462 # define termForw2Charp 0
463 # define termAytCharp 0
468 /* Ring buffer structures which are shared */