1 /* $OpenBSD: externs.h,v 1.30 2015/11/24 05:06:24 beck 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 debug; /* Debug level */ 71 72 extern cc_t escape; /* Escape to command mode */ 73 extern cc_t rlogin; /* Rlogin mode escape character */ 74 #ifdef KLUDGELINEMODE 75 extern cc_t echoc; /* Toggle local echoing */ 76 #endif 77 78 extern char 79 *prompt; /* Prompt for command. */ 80 81 extern char 82 doopt[], 83 dont[], 84 will[], 85 wont[], 86 will_wont_resp[], 87 do_dont_resp[], 88 options[], /* All the little options */ 89 *hostname; /* Who are we connected to? */ 90 91 extern int rtableid; /* routing table to use */ 92 93 /* 94 * We keep track of each side of the option negotiation. 95 */ 96 97 #define MY_STATE_WILL 0x01 98 #define MY_WANT_STATE_WILL 0x02 99 #define MY_STATE_DO 0x04 100 #define MY_WANT_STATE_DO 0x08 101 102 /* 103 * Macros to check the current state of things 104 */ 105 106 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 107 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 108 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 109 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 110 111 #define my_state_is_dont(opt) (!my_state_is_do(opt)) 112 #define my_state_is_wont(opt) (!my_state_is_will(opt)) 113 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 114 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 115 116 #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} 117 #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} 118 #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} 119 #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} 120 121 #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} 122 #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} 123 #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} 124 #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} 125 126 /* 127 * Make everything symmetrical 128 */ 129 130 #define HIS_STATE_WILL MY_STATE_DO 131 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 132 #define HIS_STATE_DO MY_STATE_WILL 133 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 134 135 #define his_state_is_do my_state_is_will 136 #define his_state_is_will my_state_is_do 137 #define his_want_state_is_do my_want_state_is_will 138 #define his_want_state_is_will my_want_state_is_do 139 140 #define his_state_is_dont my_state_is_wont 141 #define his_state_is_wont my_state_is_dont 142 #define his_want_state_is_dont my_want_state_is_wont 143 #define his_want_state_is_wont my_want_state_is_dont 144 145 #define set_his_state_do set_my_state_will 146 #define set_his_state_will set_my_state_do 147 #define set_his_want_state_do set_my_want_state_will 148 #define set_his_want_state_will set_my_want_state_do 149 150 #define set_his_state_dont set_my_state_wont 151 #define set_his_state_wont set_my_state_dont 152 #define set_his_want_state_dont set_my_want_state_wont 153 #define set_his_want_state_wont set_my_want_state_dont 154 155 156 extern jmp_buf 157 peerdied, 158 toplevel; /* For error conditions. */ 159 160 /* commands.c */ 161 162 struct env_lst *env_define (const char *, const char *); 163 void env_init (void); 164 char *env_default(int init, int welldefined); 165 char *env_getvalue(const char *var, int exported_only); 166 167 void set_escape_char(char *s); 168 169 #ifdef SIGINFO 170 void ayt_status(int sig); 171 #endif 172 int tn(int argc, char **argv); 173 void command(int top, char *tbuf, int cnt); 174 175 /* main.c */ 176 177 void tninit(void); 178 179 /* network.c */ 180 181 void init_network(void); 182 int stilloob(void); 183 void setneturg(void); 184 int netflush(void); 185 186 /* sys_bsd.c */ 187 188 void init_sys(void); 189 int TerminalSpecialChars(int c); 190 void TerminalDefaultChars(void); 191 cc_t *tcval(int func); 192 void TerminalSpeeds(long *input_speed, long *output_speed); 193 int TerminalWindowSize(long *rows, long *cols); 194 void TerminalNewMode(int); 195 void TerminalSaveState(void); 196 void sys_telnet_init(void); 197 int process_rings(int netin, int netout, int netex, int ttyin, int ttyout, 198 int poll); 199 200 /* telnet.c */ 201 202 void init_telnet(void); 203 204 void tel_leave_binary(int rw); 205 void tel_enter_binary(int rw); 206 int opt_welldefined(const char *ep); 207 void telnet(char *); 208 int telrcv(void); 209 int rlogin_susp(void); 210 void intp(void); 211 void sendbrk(void); 212 void sendabort(void); 213 void sendsusp(void); 214 void sendeof(void); 215 void sendayt(void); 216 void sendnaws(void); 217 218 void xmitAO(void); 219 void xmitEL(void); 220 void xmitEC(void); 221 222 void send_do (int, int); 223 void send_dont (int, int); 224 void send_will (int, int); 225 void send_wont (int, int); 226 227 void lm_mode (unsigned char *, int, int); 228 229 void slcstate (void); 230 void slc_mode_export (int); 231 void slc_mode_import (int); 232 void slc_check (void); 233 234 void env_opt_start_info (void); 235 void env_opt_add (char *); 236 void env_opt_end (int); 237 238 int get_status (void); 239 int dosynch (void); 240 241 cc_t *tcval (int); 242 243 __dead void quit(void); 244 245 /* genget.c */ 246 247 char **genget(char *name, char **table, int stlen); 248 int isprefix(char *s1, char *s2); 249 int Ambiguous(void *s); 250 251 /* terminal.c */ 252 253 void init_terminal(void); 254 int ttyflush(int drop); 255 int getconnmode(void); 256 void setconnmode(int); 257 void setcommandmode(void); 258 259 /* utilities.c */ 260 261 extern char NetTraceFile[]; 262 void SetNetTrace(const char *file); 263 void Dump(char direction, unsigned char *buffer, int length); 264 void printoption(char *direction, int cmd, int option); 265 void optionstatus(void); 266 void printsub(char direction, unsigned char *pointer, int length); 267 void EmptyTerminal(void); 268 void SetForExit(void); 269 __dead void Exit(int returnCode); 270 __dead void ExitString(char *string, int returnCode); 271 272 extern struct termios new_tc; 273 274 # define termEofChar new_tc.c_cc[VEOF] 275 # define termEraseChar new_tc.c_cc[VERASE] 276 # define termIntChar new_tc.c_cc[VINTR] 277 # define termKillChar new_tc.c_cc[VKILL] 278 # define termQuitChar new_tc.c_cc[VQUIT] 279 # define termSuspChar new_tc.c_cc[VSUSP] 280 281 # if defined(VFLUSHO) && !defined(VDISCARD) 282 # define VDISCARD VFLUSHO 283 # endif 284 # ifndef VDISCARD 285 extern cc_t termFlushChar; 286 # else 287 # define termFlushChar new_tc.c_cc[VDISCARD] 288 # endif 289 # ifndef VWERASE 290 extern cc_t termWerasChar; 291 # else 292 # define termWerasChar new_tc.c_cc[VWERASE] 293 # endif 294 # ifndef VREPRINT 295 extern cc_t termRprntChar; 296 # else 297 # define termRprntChar new_tc.c_cc[VREPRINT] 298 # endif 299 # ifndef VLNEXT 300 extern cc_t termLiteralNextChar; 301 # else 302 # define termLiteralNextChar new_tc.c_cc[VLNEXT] 303 # endif 304 # ifndef VSTART 305 extern cc_t termStartChar; 306 # else 307 # define termStartChar new_tc.c_cc[VSTART] 308 # endif 309 # ifndef VSTOP 310 extern cc_t termStopChar; 311 # else 312 # define termStopChar new_tc.c_cc[VSTOP] 313 # endif 314 # ifndef VEOL 315 extern cc_t termForw1Char; 316 # else 317 # define termForw1Char new_tc.c_cc[VEOL] 318 # endif 319 # ifndef VEOL2 320 extern cc_t termForw2Char; 321 # else 322 # define termForw2Char new_tc.c_cc[VEOL] 323 # endif 324 # ifndef VSTATUS 325 extern cc_t termAytChar; 326 #else 327 # define termAytChar new_tc.c_cc[VSTATUS] 328 #endif 329 330 /* Ring buffer structures which are shared */ 331 332 extern Ring 333 netoring, 334 netiring, 335 ttyoring, 336 ttyiring; 337