1 /* $OpenBSD: externs.h,v 1.32 2024/05/21 05:00:48 jsg Exp $ */ 2 /* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */ 3 4 /* 5 * Copyright (c) 1988, 1990, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)externs.h 8.3 (Berkeley) 5/30/95 33 */ 34 35 #define SUBBUFSIZE 256 36 37 extern int 38 autologin, /* Autologin enabled */ 39 skiprc, /* Don't process the ~/.telnetrc file */ 40 eight, /* use eight bit mode (binary in and/or out */ 41 binary, 42 family, /* address family of peer */ 43 flushout, /* flush output */ 44 connections, 45 connected, /* Are we connected to the other side? */ 46 globalmode, /* Mode tty should be in */ 47 telnetport, /* Are we connected to the telnet port? */ 48 localflow, /* Flow control handled locally */ 49 restartany, /* If flow control, restart output on any character */ 50 localchars, /* we recognize interrupt/quit */ 51 donelclchars, /* the user has set "localchars" */ 52 showoptions, 53 net, /* Network file descriptor */ 54 tin, /* Terminal input file descriptor */ 55 tout, /* Terminal output file descriptor */ 56 crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */ 57 autoflush, /* flush output when interrupting? */ 58 autosynch, /* send interrupt characters with SYNCH? */ 59 SYNCHing, /* Is the stream in telnet SYNCH mode? */ 60 donebinarytoggle, /* the user has put us in binary */ 61 dontlecho, /* do we suppress local echoing right now? */ 62 crmod, 63 netdata, /* Print out network data flow */ 64 prettydump, /* Print "netdata" output in user readable format */ 65 termdata, /* Print out terminal data flow */ 66 resettermname, 67 linemode, 68 kludgelinemode, 69 want_status_response; 70 71 extern cc_t escape; /* Escape to command mode */ 72 extern cc_t rlogin; /* Rlogin mode escape character */ 73 #ifdef KLUDGELINEMODE 74 extern cc_t echoc; /* Toggle local echoing */ 75 #endif 76 77 extern char 78 *prompt; /* Prompt for command. */ 79 80 extern char 81 will_wont_resp[], 82 do_dont_resp[], 83 options[], /* All the little options */ 84 *hostname; /* Who are we connected to? */ 85 86 extern int rtableid; /* routing table to use */ 87 88 /* 89 * We keep track of each side of the option negotiation. 90 */ 91 92 #define MY_STATE_WILL 0x01 93 #define MY_WANT_STATE_WILL 0x02 94 #define MY_STATE_DO 0x04 95 #define MY_WANT_STATE_DO 0x08 96 97 /* 98 * Macros to check the current state of things 99 */ 100 101 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 102 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 103 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 104 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 105 106 #define my_state_is_dont(opt) (!my_state_is_do(opt)) 107 #define my_state_is_wont(opt) (!my_state_is_will(opt)) 108 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 109 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 110 111 #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} 112 #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} 113 #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} 114 #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} 115 116 #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} 117 #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} 118 #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} 119 #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} 120 121 /* 122 * Make everything symmetrical 123 */ 124 125 #define HIS_STATE_WILL MY_STATE_DO 126 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 127 #define HIS_STATE_DO MY_STATE_WILL 128 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 129 130 #define his_state_is_do my_state_is_will 131 #define his_state_is_will my_state_is_do 132 #define his_want_state_is_do my_want_state_is_will 133 #define his_want_state_is_will my_want_state_is_do 134 135 #define his_state_is_dont my_state_is_wont 136 #define his_state_is_wont my_state_is_dont 137 #define his_want_state_is_dont my_want_state_is_wont 138 #define his_want_state_is_wont my_want_state_is_dont 139 140 #define set_his_state_do set_my_state_will 141 #define set_his_state_will set_my_state_do 142 #define set_his_want_state_do set_my_want_state_will 143 #define set_his_want_state_will set_my_want_state_do 144 145 #define set_his_state_dont set_my_state_wont 146 #define set_his_state_wont set_my_state_dont 147 #define set_his_want_state_dont set_my_want_state_wont 148 #define set_his_want_state_wont set_my_want_state_dont 149 150 151 extern jmp_buf 152 peerdied, 153 toplevel; /* For error conditions. */ 154 155 /* commands.c */ 156 157 struct env_lst *env_define (const char *, const char *); 158 void env_init (void); 159 char *env_default(int init, int welldefined); 160 char *env_getvalue(const char *var, int exported_only); 161 162 void set_escape_char(char *s); 163 164 #ifdef SIGINFO 165 void ayt_status(int sig); 166 #endif 167 int tn(int argc, char **argv); 168 void command(int top, char *tbuf, int cnt); 169 170 /* main.c */ 171 172 void tninit(void); 173 174 /* network.c */ 175 176 void init_network(void); 177 int stilloob(void); 178 void setneturg(void); 179 int netflush(void); 180 181 /* sys_bsd.c */ 182 183 void init_sys(void); 184 int TerminalSpecialChars(int c); 185 void TerminalDefaultChars(void); 186 cc_t *tcval(int func); 187 void TerminalSpeeds(long *input_speed, long *output_speed); 188 int TerminalWindowSize(long *rows, long *cols); 189 void TerminalNewMode(int); 190 void TerminalSaveState(void); 191 void sys_telnet_init(void); 192 int process_rings(int netin, int netout, int netex, int ttyin, int ttyout, 193 int poll); 194 195 /* telnet.c */ 196 197 void init_telnet(void); 198 199 void tel_leave_binary(int rw); 200 void tel_enter_binary(int rw); 201 int opt_welldefined(const char *ep); 202 void telnet(char *); 203 int telrcv(void); 204 int rlogin_susp(void); 205 void intp(void); 206 void sendbrk(void); 207 void sendabort(void); 208 void sendsusp(void); 209 void sendeof(void); 210 void sendayt(void); 211 void sendnaws(void); 212 213 void xmitAO(void); 214 void xmitEL(void); 215 void xmitEC(void); 216 217 void send_do (int, int); 218 void send_dont (int, int); 219 void send_will (int, int); 220 void send_wont (int, int); 221 222 void lm_mode (unsigned char *, int, int); 223 224 void slcstate (void); 225 void slc_mode_export (int); 226 void slc_mode_import (int); 227 void slc_check (void); 228 229 void env_opt_start_info (void); 230 void env_opt_add (char *); 231 void env_opt_end (int); 232 233 int get_status (void); 234 int dosynch (void); 235 236 cc_t *tcval (int); 237 238 __dead void quit(void); 239 240 /* genget.c */ 241 242 char **genget(char *name, char **table, int stlen); 243 int isprefix(char *s1, char *s2); 244 int Ambiguous(void *s); 245 246 /* terminal.c */ 247 248 void init_terminal(void); 249 int ttyflush(int drop); 250 int getconnmode(void); 251 void setconnmode(int); 252 void setcommandmode(void); 253 254 /* utilities.c */ 255 256 extern char NetTraceFile[]; 257 void SetNetTrace(const char *file); 258 void Dump(char direction, unsigned char *buffer, int length); 259 void printoption(char *direction, int cmd, int option); 260 void optionstatus(void); 261 void printsub(char direction, unsigned char *pointer, int length); 262 void EmptyTerminal(void); 263 void SetForExit(void); 264 __dead void Exit(int returnCode); 265 __dead void ExitString(char *string, int returnCode); 266 267 extern struct termios new_tc; 268 269 # define termEofChar new_tc.c_cc[VEOF] 270 # define termEraseChar new_tc.c_cc[VERASE] 271 # define termIntChar new_tc.c_cc[VINTR] 272 # define termKillChar new_tc.c_cc[VKILL] 273 # define termQuitChar new_tc.c_cc[VQUIT] 274 # define termSuspChar new_tc.c_cc[VSUSP] 275 # define termFlushChar new_tc.c_cc[VDISCARD] 276 # define termWerasChar new_tc.c_cc[VWERASE] 277 # define termRprntChar new_tc.c_cc[VREPRINT] 278 # define termLiteralNextChar new_tc.c_cc[VLNEXT] 279 # define termStartChar new_tc.c_cc[VSTART] 280 # define termStopChar new_tc.c_cc[VSTOP] 281 # define termForw1Char new_tc.c_cc[VEOL] 282 # define termForw2Char new_tc.c_cc[VEOL] 283 # define termAytChar new_tc.c_cc[VSTATUS] 284 285 /* Ring buffer structures which are shared */ 286 287 extern Ring 288 netoring, 289 netiring, 290 ttyoring, 291 ttyiring; 292