externs.h revision 275508
1/* 2 * Copyright (c) 1988, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 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. 20 * 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 31 * SUCH DAMAGE. 32 * 33 * @(#)externs.h 8.3 (Berkeley) 5/30/95 34 * $FreeBSD: stable/10/contrib/telnet/telnet/externs.h 275508 2014-12-05 12:23:29Z ngie $ 35 */ 36 37#ifndef BSD 38# define BSD 43 39#endif 40 41/* 42 * ucb stdio.h defines BSD as something weird 43 */ 44#if defined(sun) && defined(__svr4__) 45#define BSD 43 46#endif 47 48#ifndef USE_TERMIO 49# if BSD > 43 || defined(SYSV_TERMIO) 50# define USE_TERMIO 51# endif 52#endif 53 54#include <stdio.h> 55#include <setjmp.h> 56#include <sys/ioctl.h> 57#include <errno.h> 58#ifdef USE_TERMIO 59# ifndef VINTR 60# include <termios.h> 61# endif 62# define termio termios 63#endif 64#if defined(NO_CC_T) || !defined(USE_TERMIO) 65# if !defined(USE_TERMIO) 66typedef char cc_t; 67# else 68typedef unsigned char cc_t; 69# endif 70#endif 71 72#include <string.h> 73 74#if defined(IPSEC) 75#include <netipsec/ipsec.h> 76#if defined(IPSEC_POLICY_IPSEC) 77extern char *ipsec_policy_in; 78extern char *ipsec_policy_out; 79#endif 80#endif 81 82#ifndef _POSIX_VDISABLE 83# ifdef sun 84# include <sys/param.h> /* pick up VDISABLE definition, mayby */ 85# endif 86# ifdef VDISABLE 87# define _POSIX_VDISABLE VDISABLE 88# else 89# define _POSIX_VDISABLE ((cc_t)'\377') 90# endif 91#endif 92 93#define SUBBUFSIZE 256 94 95#if !defined(P) 96# ifdef __STDC__ 97# define P(x) x 98# else 99# define P(x) () 100# endif 101#endif 102 103extern int 104 autologin, /* Autologin enabled */ 105 skiprc, /* Don't process the ~/.telnetrc file */ 106 eight, /* use eight bit mode (binary in and/or out */ 107 family, /* address family of peer */ 108 flushout, /* flush output */ 109 connected, /* Are we connected to the other side? */ 110 globalmode, /* Mode tty should be in */ 111 telnetport, /* Are we connected to the telnet port? */ 112 localflow, /* Flow control handled locally */ 113 restartany, /* If flow control, restart output on any character */ 114 localchars, /* we recognize interrupt/quit */ 115 donelclchars, /* the user has set "localchars" */ 116 showoptions, 117 net, /* Network file descriptor */ 118 tin, /* Terminal input file descriptor */ 119 tout, /* Terminal output file descriptor */ 120 crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */ 121 autoflush, /* flush output when interrupting? */ 122 autosynch, /* send interrupt characters with SYNCH? */ 123 SYNCHing, /* Is the stream in telnet SYNCH mode? */ 124 donebinarytoggle, /* the user has put us in binary */ 125 dontlecho, /* do we suppress local echoing right now? */ 126 crmod, 127 netdata, /* Print out network data flow */ 128 prettydump, /* Print "netdata" output in user readable format */ 129 termdata, /* Print out terminal data flow */ 130 telnet_debug, /* Debug level */ 131 doaddrlookup, /* do a reverse lookup? */ 132 clienteof; /* Client received EOF */ 133 134extern cc_t escape; /* Escape to command mode */ 135extern cc_t rlogin; /* Rlogin mode escape character */ 136#ifdef KLUDGELINEMODE 137extern cc_t echoc; /* Toggle local echoing */ 138#endif 139 140extern char 141 *prompt; /* Prompt for command. */ 142 143extern char 144 doopt[], 145 dont[], 146 will[], 147 wont[], 148 options[], /* All the little options */ 149 *hostname; /* Who are we connected to? */ 150#ifdef ENCRYPTION 151extern void (*encrypt_output)(unsigned char *, int); 152extern int (*decrypt_input)(int); 153#endif /* ENCRYPTION */ 154 155/* 156 * We keep track of each side of the option negotiation. 157 */ 158 159#define MY_STATE_WILL 0x01 160#define MY_WANT_STATE_WILL 0x02 161#define MY_STATE_DO 0x04 162#define MY_WANT_STATE_DO 0x08 163 164/* 165 * Macros to check the current state of things 166 */ 167 168#define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 169#define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 170#define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 171#define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 172 173#define my_state_is_dont(opt) (!my_state_is_do(opt)) 174#define my_state_is_wont(opt) (!my_state_is_will(opt)) 175#define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 176#define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 177 178#define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} 179#define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} 180#define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} 181#define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} 182 183#define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} 184#define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} 185#define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} 186#define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} 187 188/* 189 * Make everything symetrical 190 */ 191 192#define HIS_STATE_WILL MY_STATE_DO 193#define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 194#define HIS_STATE_DO MY_STATE_WILL 195#define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 196 197#define his_state_is_do my_state_is_will 198#define his_state_is_will my_state_is_do 199#define his_want_state_is_do my_want_state_is_will 200#define his_want_state_is_will my_want_state_is_do 201 202#define his_state_is_dont my_state_is_wont 203#define his_state_is_wont my_state_is_dont 204#define his_want_state_is_dont my_want_state_is_wont 205#define his_want_state_is_wont my_want_state_is_dont 206 207#define set_his_state_do set_my_state_will 208#define set_his_state_will set_my_state_do 209#define set_his_want_state_do set_my_want_state_will 210#define set_his_want_state_will set_my_want_state_do 211 212#define set_his_state_dont set_my_state_wont 213#define set_his_state_wont set_my_state_dont 214#define set_his_want_state_dont set_my_want_state_wont 215#define set_his_want_state_wont set_my_want_state_dont 216 217#if defined(USE_TERMIO) 218#define SIG_FUNC_RET void 219#else 220#define SIG_FUNC_RET int 221#endif 222 223#ifdef SIGINFO 224extern SIG_FUNC_RET 225 ayt_status(void); 226#endif 227 228extern FILE 229 *NetTrace; /* Where debugging output goes */ 230extern unsigned char 231 NetTraceFile[]; /* Name of file where debugging output goes */ 232extern void 233 SetNetTrace(char *); /* Function to change where debugging goes */ 234extern unsigned char 235 ComPortBaudRate[]; /* Baud rate of the remote end */ 236extern void 237 DoBaudRate(char *); /* Function to set the baud rate of the remote end */ 238 239extern jmp_buf 240 toplevel; /* For error conditions. */ 241 242extern void 243 command(int, const char *, int), 244 Dump(char, unsigned char *, int), 245 env_init(void), 246 Exit(int), 247 ExitString(const char *, int), 248 init_network(void), 249 init_sys(void), 250 init_telnet(void), 251 init_terminal(void), 252 intp(void), 253 optionstatus(void), 254 printoption(const char *, int, int), 255 printsub(char, unsigned char *, int), 256 quit(void), 257 sendabort(void), 258 sendbrk(void), 259 sendeof(void), 260 sendsusp(void), 261 sendnaws(void), 262 sendayt(void), 263 setconnmode(int), 264 setcommandmode(void), 265 set_escape_char(char *s), 266 setneturg(void), 267 sys_telnet_init(void), 268 telnet(char *), 269 tel_enter_binary(int), 270 tel_leave_binary(int), 271 TerminalFlushOutput(void), 272 TerminalNewMode(int), 273 TerminalRestoreState(void), 274 TerminalSaveState(void), 275 TerminalDefaultChars(void), 276 TerminalSpeeds(long *, long *), 277 tninit(void), 278 upcase(char *), 279 willoption(int), 280 wontoption(int); 281 282extern void 283 send_do(int, int), 284 send_dont(int, int), 285 send_will(int, int), 286 send_wont(int, int); 287 288extern void 289 lm_will(unsigned char *, int), 290 lm_wont(unsigned char *, int), 291 lm_do(unsigned char *, int), 292 lm_dont(unsigned char *, int), 293 lm_mode(unsigned char *, int, int); 294 295extern void 296 slc_init(void), 297 slcstate(void), 298 slc_mode_export(void), 299 slc_mode_import(int), 300 slc_import(int), 301 slc_export(void), 302 slc(unsigned char *, int), 303 slc_check(void), 304 slc_start_reply(void), 305 slc_add_reply(unsigned char, unsigned char, cc_t), 306 slc_end_reply(void); 307extern int 308 getconnmode(void), 309 opt_welldefined(const char *), 310 NetClose(int), 311 netflush(void), 312 process_rings(int, int, int, int, int, int), 313 rlogin_susp(void), 314 SetSockOpt(int, int, int, int), 315 slc_update(void), 316 stilloob(void), 317 telrcv(void), 318 TerminalRead(char *, int), 319 TerminalWrite(char *, int), 320 TerminalAutoFlush(void), 321 TerminalWindowSize(long *, long *), 322 TerminalSpecialChars(int), 323 tn(int, char **), 324 ttyflush(int); 325 326extern void 327 env_opt(unsigned char *, int), 328 env_opt_start(void), 329 env_opt_start_info(void), 330 env_opt_add(unsigned char *), 331 env_opt_end(int); 332 333extern unsigned char 334 *env_default(int, int), 335 *env_getvalue(const unsigned char *); 336 337extern int 338 get_status(char *), 339 dosynch(char *); 340 341extern cc_t 342 *tcval(int); 343 344#ifndef USE_TERMIO 345 346extern struct tchars ntc; 347extern struct ltchars nltc; 348extern struct sgttyb nttyb; 349 350# define termEofChar ntc.t_eofc 351# define termEraseChar nttyb.sg_erase 352# define termFlushChar nltc.t_flushc 353# define termIntChar ntc.t_intrc 354# define termKillChar nttyb.sg_kill 355# define termLiteralNextChar nltc.t_lnextc 356# define termQuitChar ntc.t_quitc 357# define termSuspChar nltc.t_suspc 358# define termRprntChar nltc.t_rprntc 359# define termWerasChar nltc.t_werasc 360# define termStartChar ntc.t_startc 361# define termStopChar ntc.t_stopc 362# define termForw1Char ntc.t_brkc 363extern cc_t termForw2Char; 364extern cc_t termAytChar; 365 366# define termEofCharp (cc_t *)&ntc.t_eofc 367# define termEraseCharp (cc_t *)&nttyb.sg_erase 368# define termFlushCharp (cc_t *)&nltc.t_flushc 369# define termIntCharp (cc_t *)&ntc.t_intrc 370# define termKillCharp (cc_t *)&nttyb.sg_kill 371# define termLiteralNextCharp (cc_t *)&nltc.t_lnextc 372# define termQuitCharp (cc_t *)&ntc.t_quitc 373# define termSuspCharp (cc_t *)&nltc.t_suspc 374# define termRprntCharp (cc_t *)&nltc.t_rprntc 375# define termWerasCharp (cc_t *)&nltc.t_werasc 376# define termStartCharp (cc_t *)&ntc.t_startc 377# define termStopCharp (cc_t *)&ntc.t_stopc 378# define termForw1Charp (cc_t *)&ntc.t_brkc 379# define termForw2Charp (cc_t *)&termForw2Char 380# define termAytCharp (cc_t *)&termAytChar 381 382# else 383 384extern struct termio new_tc; 385 386# define termEofChar new_tc.c_cc[VEOF] 387# define termEraseChar new_tc.c_cc[VERASE] 388# define termIntChar new_tc.c_cc[VINTR] 389# define termKillChar new_tc.c_cc[VKILL] 390# define termQuitChar new_tc.c_cc[VQUIT] 391 392# ifndef VSUSP 393extern cc_t termSuspChar; 394# else 395# define termSuspChar new_tc.c_cc[VSUSP] 396# endif 397# if defined(VFLUSHO) && !defined(VDISCARD) 398# define VDISCARD VFLUSHO 399# endif 400# ifndef VDISCARD 401extern cc_t termFlushChar; 402# else 403# define termFlushChar new_tc.c_cc[VDISCARD] 404# endif 405# ifndef VWERASE 406extern cc_t termWerasChar; 407# else 408# define termWerasChar new_tc.c_cc[VWERASE] 409# endif 410# ifndef VREPRINT 411extern cc_t termRprntChar; 412# else 413# define termRprntChar new_tc.c_cc[VREPRINT] 414# endif 415# ifndef VLNEXT 416extern cc_t termLiteralNextChar; 417# else 418# define termLiteralNextChar new_tc.c_cc[VLNEXT] 419# endif 420# ifndef VSTART 421extern cc_t termStartChar; 422# else 423# define termStartChar new_tc.c_cc[VSTART] 424# endif 425# ifndef VSTOP 426extern cc_t termStopChar; 427# else 428# define termStopChar new_tc.c_cc[VSTOP] 429# endif 430# ifndef VEOL 431extern cc_t termForw1Char; 432# else 433# define termForw1Char new_tc.c_cc[VEOL] 434# endif 435# ifndef VEOL2 436extern cc_t termForw2Char; 437# else 438# define termForw2Char new_tc.c_cc[VEOL] 439# endif 440# ifndef VSTATUS 441extern cc_t termAytChar; 442#else 443# define termAytChar new_tc.c_cc[VSTATUS] 444#endif 445 446# if defined(__STDC__) 447# define termEofCharp &termEofChar 448# define termEraseCharp &termEraseChar 449# define termIntCharp &termIntChar 450# define termKillCharp &termKillChar 451# define termQuitCharp &termQuitChar 452# define termSuspCharp &termSuspChar 453# define termFlushCharp &termFlushChar 454# define termWerasCharp &termWerasChar 455# define termRprntCharp &termRprntChar 456# define termLiteralNextCharp &termLiteralNextChar 457# define termStartCharp &termStartChar 458# define termStopCharp &termStopChar 459# define termForw1Charp &termForw1Char 460# define termForw2Charp &termForw2Char 461# define termAytCharp &termAytChar 462# else 463 /* Work around a compiler bug */ 464# define termEofCharp 0 465# define termEraseCharp 0 466# define termIntCharp 0 467# define termKillCharp 0 468# define termQuitCharp 0 469# define termSuspCharp 0 470# define termFlushCharp 0 471# define termWerasCharp 0 472# define termRprntCharp 0 473# define termLiteralNextCharp 0 474# define termStartCharp 0 475# define termStopCharp 0 476# define termForw1Charp 0 477# define termForw2Charp 0 478# define termAytCharp 0 479# endif 480#endif 481 482typedef struct { 483 int 484 system, /* what the current time is */ 485 echotoggle, /* last time user entered echo character */ 486 modenegotiated, /* last time operating mode negotiated */ 487 didnetreceive, /* last time we read data from network */ 488 gotDM; /* when did we last see a data mark */ 489} Clocks; 490 491extern Clocks clocks; 492 493/* Ring buffer structures which are shared */ 494 495extern Ring 496 netoring, 497 netiring, 498 ttyoring, 499 ttyiring; 500 501extern void 502 xmitAO(void), 503 xmitEC(void), 504 xmitEL(void); 505