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