Annotation of src/usr.bin/telnet/externs.h, Revision 1.26
1.26 ! guenther 1: /* $OpenBSD: externs.h,v 1.25 2014/07/20 10:18:10 guenther Exp $ */
1.3 art 2: /* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */
1.2 niklas 3:
1.1 deraadt 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.
1.11 millert 16: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 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: *
1.3 art 32: * @(#)externs.h 8.3 (Berkeley) 5/30/95
1.1 deraadt 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 */
1.3 art 41: binary,
1.12 otto 42: family, /* address family of peer */
1.1 deraadt 43: flushout, /* flush output */
44: connected, /* Are we connected to the other side? */
45: globalmode, /* Mode tty should be in */
46: telnetport, /* Are we connected to the telnet port? */
47: localflow, /* Flow control handled locally */
48: restartany, /* If flow control, restart output on any character */
49: localchars, /* we recognize interrupt/quit */
1.2 niklas 50: donelclchars, /* the user has set "localchars" */
1.1 deraadt 51: showoptions,
52: net, /* Network file descriptor */
53: tin, /* Terminal input file descriptor */
54: tout, /* Terminal output file descriptor */
55: crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
56: autoflush, /* flush output when interrupting? */
57: autosynch, /* send interrupt characters with SYNCH? */
58: SYNCHing, /* Is the stream in telnet SYNCH mode? */
59: donebinarytoggle, /* the user has put us in binary */
60: dontlecho, /* do we suppress local echoing right now? */
61: crmod,
62: netdata, /* Print out network data flow */
63: prettydump, /* Print "netdata" output in user readable format */
64: termdata, /* Print out terminal data flow */
1.3 art 65: debug; /* Debug level */
1.1 deraadt 66:
67: extern cc_t escape; /* Escape to command mode */
68: extern cc_t rlogin; /* Rlogin mode escape character */
69: #ifdef KLUDGELINEMODE
70: extern cc_t echoc; /* Toggle local echoing */
71: #endif
72:
73: extern char
74: *prompt; /* Prompt for command. */
75:
76: extern char
77: doopt[],
78: dont[],
79: will[],
80: wont[],
81: options[], /* All the little options */
82: *hostname; /* Who are we connected to? */
1.15 claudio 83:
1.17 sthen 84: extern int rtableid; /* routing table to use */
1.1 deraadt 85:
86: /*
87: * We keep track of each side of the option negotiation.
88: */
89:
90: #define MY_STATE_WILL 0x01
91: #define MY_WANT_STATE_WILL 0x02
92: #define MY_STATE_DO 0x04
93: #define MY_WANT_STATE_DO 0x08
94:
95: /*
96: * Macros to check the current state of things
97: */
98:
99: #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
100: #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
101: #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
102: #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
103:
104: #define my_state_is_dont(opt) (!my_state_is_do(opt))
105: #define my_state_is_wont(opt) (!my_state_is_will(opt))
106: #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
107: #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
108:
109: #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
110: #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
111: #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
112: #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
113:
114: #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
115: #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
116: #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
117: #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
118:
119: /*
1.7 pvalchev 120: * Make everything symmetrical
1.1 deraadt 121: */
122:
123: #define HIS_STATE_WILL MY_STATE_DO
124: #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
125: #define HIS_STATE_DO MY_STATE_WILL
126: #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
127:
128: #define his_state_is_do my_state_is_will
129: #define his_state_is_will my_state_is_do
130: #define his_want_state_is_do my_want_state_is_will
131: #define his_want_state_is_will my_want_state_is_do
132:
133: #define his_state_is_dont my_state_is_wont
134: #define his_state_is_wont my_state_is_dont
135: #define his_want_state_is_dont my_want_state_is_wont
136: #define his_want_state_is_wont my_want_state_is_dont
137:
138: #define set_his_state_do set_my_state_will
139: #define set_his_state_will set_my_state_do
140: #define set_his_want_state_do set_my_want_state_will
141: #define set_his_want_state_will set_my_want_state_do
142:
143: #define set_his_state_dont set_my_state_wont
144: #define set_his_state_wont set_my_state_dont
145: #define set_his_want_state_dont set_my_want_state_wont
146: #define set_his_want_state_wont set_my_want_state_dont
147:
148:
149: extern unsigned char
150: NetTraceFile[]; /* Name of file where debugging output goes */
151: extern void
1.3 art 152: SetNetTrace (char *); /* Function to change where debugging goes */
1.1 deraadt 153:
154: extern jmp_buf
155: peerdied,
156: toplevel; /* For error conditions. */
157:
1.3 art 158: /* commands.c */
159:
160: struct env_lst *env_define (unsigned char *, unsigned char *);
161: void env_init (void);
162: unsigned char * env_default(int init, int welldefined);
1.14 otto 163: unsigned char * env_getvalue(unsigned char *var, int exported_only);
1.3 art 164:
165: void set_escape_char(char *s);
166:
167: #ifdef SIGINFO
168: void ayt_status(void);
169: #endif
170: int tn(int argc, char **argv);
171: void command(int top, char *tbuf, int cnt);
172:
173: /* main.c */
174:
175: void tninit(void);
176:
177: /* network.c */
178:
179: void init_network(void);
180: int stilloob(void);
181: void setneturg(void);
182: int netflush(void);
183:
184: /* sys_bsd.c */
185:
186: void init_sys(void);
187: int TerminalSpecialChars(int c);
188: void TerminalDefaultChars(void);
189: cc_t *tcval(int func);
190: void TerminalSpeeds(long *input_speed, long *output_speed);
191: int TerminalWindowSize(long *rows, long *cols);
1.26 ! guenther 192: void TerminalNewMode(int);
! 193: void TerminalSaveState(void);
! 194: void sys_telnet_init(void);
1.3 art 195: int process_rings(int netin, int netout, int netex, int ttyin, int ttyout,
196: int poll);
197:
198: /* telnet.c */
199:
200: void init_telnet(void);
201:
202: void tel_leave_binary(int rw);
203: void tel_enter_binary(int rw);
204: int opt_welldefined(char *ep);
1.26 ! guenther 205: void telnet(char *);
1.3 art 206: int telrcv(void);
207: int rlogin_susp(void);
208: void intp(void);
209: void sendbrk(void);
210: void sendabort(void);
211: void sendsusp(void);
212: void sendeof(void);
213: void sendayt(void);
1.26 ! guenther 214: void sendnaws(void);
1.3 art 215:
216: void xmitAO(void);
217: void xmitEL(void);
218: void xmitEC(void);
219:
220: void send_do (int, int);
221: void send_dont (int, int);
222: void send_will (int, int);
223: void send_wont (int, int);
224:
225: void lm_mode (unsigned char *, int, int);
226:
227: void slcstate (void);
1.23 guenther 228: void slc_mode_export (int);
1.3 art 229: void slc_mode_import (int);
230: void slc_check (void);
231:
232: void env_opt_start_info (void);
233: void env_opt_add (unsigned char *);
234: void env_opt_end (int);
235:
236: unsigned char *env_default (int, int);
1.14 otto 237: unsigned char *env_getvalue (unsigned char *, int);
1.3 art 238:
239: int get_status (void);
240: int dosynch (void);
241:
242: cc_t *tcval (int);
243:
1.23 guenther 244: __dead void quit(void);
1.3 art 245:
1.18 guenther 246: /* genget.c */
247:
248: char **genget(char *name, char **table, int stlen);
249: int isprefix(char *s1, char *s2);
250: int Ambiguous(void *s);
251:
1.3 art 252: /* terminal.c */
253:
254: void init_terminal(void);
255: int ttyflush(int drop);
256: int getconnmode(void);
1.26 ! guenther 257: void setconnmode(int);
! 258: void setcommandmode(void);
1.3 art 259:
260: /* utilities.c */
261:
262: void SetNetTrace(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);
1.6 hin 266: void printsub(int direction, unsigned char *pointer, int length);
1.3 art 267: void EmptyTerminal(void);
268: void SetForExit(void);
1.20 guenther 269: __dead void Exit(int returnCode);
1.25 guenther 270: __dead void ExitString(char *string, int returnCode);
1.1 deraadt 271:
1.3 art 272: extern struct termios new_tc;
1.1 deraadt 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]
1.24 guenther 279: # define termSuspChar new_tc.c_cc[VSUSP]
1.1 deraadt 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;