Annotation of src/usr.bin/telnet/externs.h, Revision 1.21
1.21 ! guenther 1: /* $OpenBSD: externs.h,v 1.20 2014/07/20 05:22:02 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.9 hin 66:
1.10 hin 67: extern volatile sig_atomic_t intr_happened, intr_waiting; /* for interrupt handling */
1.1 deraadt 68:
69: extern cc_t escape; /* Escape to command mode */
70: extern cc_t rlogin; /* Rlogin mode escape character */
71: #ifdef KLUDGELINEMODE
72: extern cc_t echoc; /* Toggle local echoing */
73: #endif
74:
75: extern char
76: *prompt; /* Prompt for command. */
77:
78: extern char
79: doopt[],
80: dont[],
81: will[],
82: wont[],
83: options[], /* All the little options */
84: *hostname; /* Who are we connected to? */
1.15 claudio 85:
1.17 sthen 86: extern int rtableid; /* routing table to use */
1.1 deraadt 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: /*
1.7 pvalchev 122: * Make everything symmetrical
1.1 deraadt 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 FILE
152: *NetTrace; /* Where debugging output goes */
153: extern unsigned char
154: NetTraceFile[]; /* Name of file where debugging output goes */
155: extern void
1.3 art 156: SetNetTrace (char *); /* Function to change where debugging goes */
1.1 deraadt 157:
158: extern jmp_buf
159: peerdied,
160: toplevel; /* For error conditions. */
161:
1.3 art 162: /* commands.c */
163:
164: struct env_lst *env_define (unsigned char *, unsigned char *);
165: struct env_lst *env_find(unsigned char *var);
166: void env_init (void);
167: void env_undefine (unsigned char *);
168: void env_export (unsigned char *);
169: void env_unexport (unsigned char *);
170: void env_send (unsigned char *);
171: void env_list (void);
172: unsigned char * env_default(int init, int welldefined);
1.14 otto 173: unsigned char * env_getvalue(unsigned char *var, int exported_only);
1.3 art 174:
175: void set_escape_char(char *s);
176: unsigned long sourceroute(char *arg, char **cpp, int *lenp);
177:
178: #ifdef SIGINFO
179: void ayt_status(void);
180: #endif
181: int tn(int argc, char **argv);
182: void command(int top, char *tbuf, int cnt);
183:
184: /* main.c */
185:
186: void tninit(void);
187: void usage(void);
188:
189: /* network.c */
190:
191: void init_network(void);
192: int stilloob(void);
193: void setneturg(void);
194: int netflush(void);
195:
196: /* sys_bsd.c */
197:
198: void init_sys(void);
199: int TerminalSpecialChars(int c);
200: void TerminalDefaultChars(void);
201: cc_t *tcval(int func);
202: void TerminalSpeeds(long *input_speed, long *output_speed);
203: int TerminalWindowSize(long *rows, long *cols);
204: int NetClose(int fd);
205: void NetNonblockingIO(int fd, int onoff);
206: int process_rings(int netin, int netout, int netex, int ttyin, int ttyout,
207: int poll);
208:
209: /* telnet.c */
210:
211: void init_telnet(void);
212:
213: void tel_leave_binary(int rw);
214: void tel_enter_binary(int rw);
215: int opt_welldefined(char *ep);
216: int telrcv(void);
217: int rlogin_susp(void);
218: void intp(void);
219: void sendbrk(void);
220: void sendabort(void);
221: void sendsusp(void);
222: void sendeof(void);
223: void sendayt(void);
224:
225: void xmitAO(void);
226: void xmitEL(void);
227: void xmitEC(void);
228:
229:
230: void Dump (char, unsigned char *, int);
231: void printoption (char *, int, int);
232: void sendnaws (void);
233: void setconnmode (int);
234: void setcommandmode (void);
235: void setneturg (void);
236: void sys_telnet_init (void);
237: void telnet (char *);
238: void tel_enter_binary (int);
239: void TerminalNewMode (int);
240: void TerminalRestoreState (void);
241: void TerminalSaveState (void);
242: void tninit (void);
243: void willoption (int);
244: void wontoption (int);
245:
246:
247: void send_do (int, int);
248: void send_dont (int, int);
249: void send_will (int, int);
250: void send_wont (int, int);
251:
252: void lm_will (unsigned char *, int);
253: void lm_wont (unsigned char *, int);
254: void lm_do (unsigned char *, int);
255: void lm_dont (unsigned char *, int);
256: void lm_mode (unsigned char *, int, int);
257:
258: void slc_init (void);
259: void slcstate (void);
260: void slc_mode_export (void);
261: void slc_mode_import (int);
262: void slc_import (int);
263: void slc_export (void);
264: void slc (unsigned char *, int);
265: void slc_check (void);
266: void slc_start_reply (void);
267: void slc_add_reply (unsigned char, unsigned char, cc_t);
268: void slc_end_reply (void);
269: int slc_update (void);
270:
271: void env_opt (unsigned char *, int);
272: void env_opt_start (void);
273: void env_opt_start_info (void);
274: void env_opt_add (unsigned char *);
275: void env_opt_end (int);
276:
277: unsigned char *env_default (int, int);
1.14 otto 278: unsigned char *env_getvalue (unsigned char *, int);
1.3 art 279:
280: int get_status (void);
281: int dosynch (void);
282:
283: cc_t *tcval (int);
284:
1.20 guenther 285: __dead int quit(void);
1.3 art 286:
1.18 guenther 287: /* genget.c */
288:
289: char **genget(char *name, char **table, int stlen);
290: int isprefix(char *s1, char *s2);
291: int Ambiguous(void *s);
292:
1.3 art 293: /* terminal.c */
294:
295: void init_terminal(void);
296: int ttyflush(int drop);
297: int getconnmode(void);
298:
299: /* utilities.c */
300:
301: void SetNetTrace(char *file);
302: void Dump(char direction, unsigned char *buffer, int length);
303: void printoption(char *direction, int cmd, int option);
304: void optionstatus(void);
1.6 hin 305: void printsub(int direction, unsigned char *pointer, int length);
1.3 art 306: void EmptyTerminal(void);
307: void SetForExit(void);
1.20 guenther 308: __dead void Exit(int returnCode);
1.3 art 309: void ExitString(char *string, int returnCode);
1.1 deraadt 310:
1.3 art 311: extern struct termios new_tc;
1.1 deraadt 312:
313: # define termEofChar new_tc.c_cc[VEOF]
314: # define termEraseChar new_tc.c_cc[VERASE]
315: # define termIntChar new_tc.c_cc[VINTR]
316: # define termKillChar new_tc.c_cc[VKILL]
317: # define termQuitChar new_tc.c_cc[VQUIT]
318:
319: # ifndef VSUSP
320: extern cc_t termSuspChar;
321: # else
322: # define termSuspChar new_tc.c_cc[VSUSP]
323: # endif
324: # if defined(VFLUSHO) && !defined(VDISCARD)
325: # define VDISCARD VFLUSHO
326: # endif
327: # ifndef VDISCARD
328: extern cc_t termFlushChar;
329: # else
330: # define termFlushChar new_tc.c_cc[VDISCARD]
331: # endif
332: # ifndef VWERASE
333: extern cc_t termWerasChar;
334: # else
335: # define termWerasChar new_tc.c_cc[VWERASE]
336: # endif
337: # ifndef VREPRINT
338: extern cc_t termRprntChar;
339: # else
340: # define termRprntChar new_tc.c_cc[VREPRINT]
341: # endif
342: # ifndef VLNEXT
343: extern cc_t termLiteralNextChar;
344: # else
345: # define termLiteralNextChar new_tc.c_cc[VLNEXT]
346: # endif
347: # ifndef VSTART
348: extern cc_t termStartChar;
349: # else
350: # define termStartChar new_tc.c_cc[VSTART]
351: # endif
352: # ifndef VSTOP
353: extern cc_t termStopChar;
354: # else
355: # define termStopChar new_tc.c_cc[VSTOP]
356: # endif
357: # ifndef VEOL
358: extern cc_t termForw1Char;
359: # else
360: # define termForw1Char new_tc.c_cc[VEOL]
361: # endif
362: # ifndef VEOL2
363: extern cc_t termForw2Char;
364: # else
365: # define termForw2Char new_tc.c_cc[VEOL]
366: # endif
367: # ifndef VSTATUS
368: extern cc_t termAytChar;
369: #else
370: # define termAytChar new_tc.c_cc[VSTATUS]
371: #endif
372:
373: /* Ring buffer structures which are shared */
374:
375: extern Ring
376: netoring,
377: netiring,
378: ttyoring,
379: ttyiring;