Annotation of src/usr.bin/telnet/externs.h, Revision 1.9
1.9 ! hin 1: /* $OpenBSD: externs.h,v 1.8 2002/02/17 17:20:49 millert 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.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by the University of
19: * California, Berkeley and its contributors.
20: * 4. Neither the name of the University nor the names of its contributors
21: * may be used to endorse or promote products derived from this software
22: * without specific prior written permission.
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34: * SUCH DAMAGE.
35: *
1.3 art 36: * @(#)externs.h 8.3 (Berkeley) 5/30/95
1.1 deraadt 37: */
38:
39: #ifndef BSD
40: # define BSD 43
41: #endif
42:
43: #ifndef _POSIX_VDISABLE
44: # ifdef sun
45: # include <sys/param.h> /* pick up VDISABLE definition, mayby */
46: # endif
47: # ifdef VDISABLE
48: # define _POSIX_VDISABLE VDISABLE
49: # else
50: # define _POSIX_VDISABLE ((cc_t)'\377')
51: # endif
52: #endif
53:
54: #define SUBBUFSIZE 256
55:
56: extern int
57: autologin, /* Autologin enabled */
58: skiprc, /* Don't process the ~/.telnetrc file */
59: eight, /* use eight bit mode (binary in and/or out */
1.3 art 60: binary,
1.1 deraadt 61: flushout, /* flush output */
62: connected, /* Are we connected to the other side? */
63: globalmode, /* Mode tty should be in */
64: telnetport, /* Are we connected to the telnet port? */
1.3 art 65: In3270, /* Are we in 3270 mode? */
1.1 deraadt 66: localflow, /* Flow control handled locally */
67: restartany, /* If flow control, restart output on any character */
68: localchars, /* we recognize interrupt/quit */
1.2 niklas 69: donelclchars, /* the user has set "localchars" */
1.1 deraadt 70: showoptions,
1.9 ! hin 71: wantencryption, /* User has requested encryption */
1.1 deraadt 72: net, /* Network file descriptor */
73: tin, /* Terminal input file descriptor */
74: tout, /* Terminal output file descriptor */
75: crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
76: autoflush, /* flush output when interrupting? */
77: autosynch, /* send interrupt characters with SYNCH? */
78: SYNCHing, /* Is the stream in telnet SYNCH mode? */
79: donebinarytoggle, /* the user has put us in binary */
80: dontlecho, /* do we suppress local echoing right now? */
81: crmod,
82: netdata, /* Print out network data flow */
83: prettydump, /* Print "netdata" output in user readable format */
1.4 deraadt 84: #if defined(TN3270)
85: cursesdata, /* Print out curses data flow */
86: apitrace, /* Trace API transactions */
87: #endif /* defined(TN3270) */
1.1 deraadt 88: termdata, /* Print out terminal data flow */
1.3 art 89: debug; /* Debug level */
1.9 ! hin 90:
! 91: extern sig_atomic_t intr_happened, intr_waiting; /* for interrupt handling */
1.1 deraadt 92:
93: extern cc_t escape; /* Escape to command mode */
94: extern cc_t rlogin; /* Rlogin mode escape character */
95: #ifdef KLUDGELINEMODE
96: extern cc_t echoc; /* Toggle local echoing */
97: #endif
98:
99: extern char
100: *prompt; /* Prompt for command. */
101:
102: extern char
103: doopt[],
104: dont[],
105: will[],
106: wont[],
107: options[], /* All the little options */
108: *hostname; /* Who are we connected to? */
1.3 art 109: #if defined(ENCRYPTION)
110: extern void (*encrypt_output) (unsigned char *, int);
111: extern int (*decrypt_input) (int);
112: #endif
1.1 deraadt 113:
114: /*
115: * We keep track of each side of the option negotiation.
116: */
117:
118: #define MY_STATE_WILL 0x01
119: #define MY_WANT_STATE_WILL 0x02
120: #define MY_STATE_DO 0x04
121: #define MY_WANT_STATE_DO 0x08
122:
123: /*
124: * Macros to check the current state of things
125: */
126:
127: #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
128: #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
129: #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
130: #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
131:
132: #define my_state_is_dont(opt) (!my_state_is_do(opt))
133: #define my_state_is_wont(opt) (!my_state_is_will(opt))
134: #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
135: #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
136:
137: #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
138: #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
139: #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
140: #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
141:
142: #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
143: #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
144: #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
145: #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
146:
147: /*
1.7 pvalchev 148: * Make everything symmetrical
1.1 deraadt 149: */
150:
151: #define HIS_STATE_WILL MY_STATE_DO
152: #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
153: #define HIS_STATE_DO MY_STATE_WILL
154: #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
155:
156: #define his_state_is_do my_state_is_will
157: #define his_state_is_will my_state_is_do
158: #define his_want_state_is_do my_want_state_is_will
159: #define his_want_state_is_will my_want_state_is_do
160:
161: #define his_state_is_dont my_state_is_wont
162: #define his_state_is_wont my_state_is_dont
163: #define his_want_state_is_dont my_want_state_is_wont
164: #define his_want_state_is_wont my_want_state_is_dont
165:
166: #define set_his_state_do set_my_state_will
167: #define set_his_state_will set_my_state_do
168: #define set_his_want_state_do set_my_want_state_will
169: #define set_his_want_state_will set_my_want_state_do
170:
171: #define set_his_state_dont set_my_state_wont
172: #define set_his_state_wont set_my_state_dont
173: #define set_his_want_state_dont set_my_want_state_wont
174: #define set_his_want_state_wont set_my_want_state_dont
175:
176:
177: extern FILE
178: *NetTrace; /* Where debugging output goes */
179: extern unsigned char
180: NetTraceFile[]; /* Name of file where debugging output goes */
181: extern void
1.3 art 182: SetNetTrace (char *); /* Function to change where debugging goes */
1.1 deraadt 183:
184: extern jmp_buf
185: peerdied,
186: toplevel; /* For error conditions. */
187:
1.3 art 188: /* authenc.c */
1.1 deraadt 189:
1.3 art 190: #if defined(AUTHENTICATION) || defined(ENCRYPTION)
191: int net_write(unsigned char *str, int len);
192: void net_encrypt(void);
193: int telnet_spin(void);
1.6 hin 194: char *telnet_getenv(const char *val);
1.3 art 195: char *telnet_gets(char *prompt, char *result, int length, int echo);
196: #endif
197:
198: /* commands.c */
199:
200: struct env_lst *env_define (unsigned char *, unsigned char *);
201: struct env_lst *env_find(unsigned char *var);
202: void env_init (void);
203: void env_undefine (unsigned char *);
204: void env_export (unsigned char *);
205: void env_unexport (unsigned char *);
206: void env_send (unsigned char *);
207: void env_list (void);
208: unsigned char * env_default(int init, int welldefined);
209: unsigned char * env_getvalue(unsigned char *var);
210:
211: void set_escape_char(char *s);
212: unsigned long sourceroute(char *arg, char **cpp, int *lenp);
213:
214: #if defined(AUTHENTICATION)
215: int auth_enable (char *);
216: int auth_disable (char *);
217: int auth_status (void);
218: #endif
219:
220: #if defined(ENCRYPTION)
221: int EncryptEnable (char *, char *);
222: int EncryptDisable (char *, char *);
223: int EncryptType (char *, char *);
224: int EncryptStart (char *);
225: int EncryptStartInput (void);
226: int EncryptStartOutput (void);
227: int EncryptStop (char *);
228: int EncryptStopInput (void);
229: int EncryptStopOutput (void);
230: int EncryptStatus (void);
231: #endif
232:
233: #ifdef SIGINFO
234: void ayt_status(void);
235: #endif
236: int tn(int argc, char **argv);
237: void command(int top, char *tbuf, int cnt);
238:
239: /* main.c */
240:
241: void tninit(void);
242: void usage(void);
243:
244: /* network.c */
245:
246: void init_network(void);
247: int stilloob(void);
248: void setneturg(void);
249: int netflush(void);
250:
251: /* sys_bsd.c */
252:
253: void init_sys(void);
254: int TerminalWrite(char *buf, int n);
255: int TerminalRead(unsigned char *buf, int n);
256: int TerminalAutoFlush(void);
257: int TerminalSpecialChars(int c);
258: void TerminalFlushOutput(void);
259: void TerminalSaveState(void);
260: void TerminalDefaultChars(void);
261: void TerminalNewMode(int f);
262: cc_t *tcval(int func);
263: void TerminalSpeeds(long *input_speed, long *output_speed);
264: int TerminalWindowSize(long *rows, long *cols);
265: int NetClose(int fd);
266: void NetNonblockingIO(int fd, int onoff);
267: int process_rings(int netin, int netout, int netex, int ttyin, int ttyout,
268: int poll);
269:
270: /* telnet.c */
271:
272: void init_telnet(void);
273:
274: void tel_leave_binary(int rw);
275: void tel_enter_binary(int rw);
276: int opt_welldefined(char *ep);
277: int telrcv(void);
278: int rlogin_susp(void);
279: void intp(void);
280: void sendbrk(void);
281: void sendabort(void);
282: void sendsusp(void);
283: void sendeof(void);
284: void sendayt(void);
285:
286: void xmitAO(void);
287: void xmitEL(void);
288: void xmitEC(void);
289:
290:
291: void Dump (char, unsigned char *, int);
292: void printoption (char *, int, int);
1.6 hin 293: void printsub (int, unsigned char *, int);
1.3 art 294: void sendnaws (void);
295: void setconnmode (int);
296: void setcommandmode (void);
297: void setneturg (void);
298: void sys_telnet_init (void);
299: void telnet (char *);
300: void tel_enter_binary (int);
301: void TerminalFlushOutput (void);
302: void TerminalNewMode (int);
303: void TerminalRestoreState (void);
304: void TerminalSaveState (void);
305: void tninit (void);
306: void willoption (int);
307: void wontoption (int);
308:
309:
310: void send_do (int, int);
311: void send_dont (int, int);
312: void send_will (int, int);
313: void send_wont (int, int);
314:
315: void lm_will (unsigned char *, int);
316: void lm_wont (unsigned char *, int);
317: void lm_do (unsigned char *, int);
318: void lm_dont (unsigned char *, int);
319: void lm_mode (unsigned char *, int, int);
320:
321: void slc_init (void);
322: void slcstate (void);
323: void slc_mode_export (void);
324: void slc_mode_import (int);
325: void slc_import (int);
326: void slc_export (void);
327: void slc (unsigned char *, int);
328: void slc_check (void);
329: void slc_start_reply (void);
330: void slc_add_reply (unsigned char, unsigned char, cc_t);
331: void slc_end_reply (void);
332: int slc_update (void);
333:
334: void env_opt (unsigned char *, int);
335: void env_opt_start (void);
336: void env_opt_start_info (void);
337: void env_opt_add (unsigned char *);
338: void env_opt_end (int);
339:
340: unsigned char *env_default (int, int);
341: unsigned char *env_getvalue (unsigned char *);
342:
343: int get_status (void);
344: int dosynch (void);
345:
346: cc_t *tcval (int);
347:
348: int quit (void);
349:
350: /* terminal.c */
351:
352: void init_terminal(void);
353: int ttyflush(int drop);
354: int getconnmode(void);
355:
356: /* utilities.c */
357:
358: int SetSockOpt(int fd, int level, int option, int yesno);
359: void SetNetTrace(char *file);
360: void Dump(char direction, unsigned char *buffer, int length);
361: void printoption(char *direction, int cmd, int option);
362: void optionstatus(void);
1.6 hin 363: void printsub(int direction, unsigned char *pointer, int length);
1.3 art 364: void EmptyTerminal(void);
365: void SetForExit(void);
366: void Exit(int returnCode);
367: void ExitString(char *string, int returnCode);
1.1 deraadt 368:
1.3 art 369: extern struct termios new_tc;
1.1 deraadt 370:
371: # define termEofChar new_tc.c_cc[VEOF]
372: # define termEraseChar new_tc.c_cc[VERASE]
373: # define termIntChar new_tc.c_cc[VINTR]
374: # define termKillChar new_tc.c_cc[VKILL]
375: # define termQuitChar new_tc.c_cc[VQUIT]
376:
377: # ifndef VSUSP
378: extern cc_t termSuspChar;
379: # else
380: # define termSuspChar new_tc.c_cc[VSUSP]
381: # endif
382: # if defined(VFLUSHO) && !defined(VDISCARD)
383: # define VDISCARD VFLUSHO
384: # endif
385: # ifndef VDISCARD
386: extern cc_t termFlushChar;
387: # else
388: # define termFlushChar new_tc.c_cc[VDISCARD]
389: # endif
390: # ifndef VWERASE
391: extern cc_t termWerasChar;
392: # else
393: # define termWerasChar new_tc.c_cc[VWERASE]
394: # endif
395: # ifndef VREPRINT
396: extern cc_t termRprntChar;
397: # else
398: # define termRprntChar new_tc.c_cc[VREPRINT]
399: # endif
400: # ifndef VLNEXT
401: extern cc_t termLiteralNextChar;
402: # else
403: # define termLiteralNextChar new_tc.c_cc[VLNEXT]
404: # endif
405: # ifndef VSTART
406: extern cc_t termStartChar;
407: # else
408: # define termStartChar new_tc.c_cc[VSTART]
409: # endif
410: # ifndef VSTOP
411: extern cc_t termStopChar;
412: # else
413: # define termStopChar new_tc.c_cc[VSTOP]
414: # endif
415: # ifndef VEOL
416: extern cc_t termForw1Char;
417: # else
418: # define termForw1Char new_tc.c_cc[VEOL]
419: # endif
420: # ifndef VEOL2
421: extern cc_t termForw2Char;
422: # else
423: # define termForw2Char new_tc.c_cc[VEOL]
424: # endif
425: # ifndef VSTATUS
426: extern cc_t termAytChar;
427: #else
428: # define termAytChar new_tc.c_cc[VSTATUS]
429: #endif
430:
431: /* Ring buffer structures which are shared */
432:
433: extern Ring
434: netoring,
435: netiring,
436: ttyoring,
437: ttyiring;
438:
1.4 deraadt 439: /* Tn3270 section */
440: #if defined(TN3270)
441:
442: extern int
443: HaveInput, /* Whether an asynchronous I/O indication came in */
444: noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */
445: noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */
446: sigiocount, /* Count of SIGIO receptions */
447: shell_active; /* Subshell is active */
448:
449: extern char
450: *Ibackp, /* Oldest byte of 3270 data */
451: Ibuf[], /* 3270 buffer */
452: *Ifrontp, /* Where next 3270 byte goes */
1.5 fgsch 453: tline[200],
1.4 deraadt 454: *transcom; /* Transparent command */
455:
456: extern int
1.8 millert 457: settranscom(int, char**);
1.4 deraadt 458:
459: extern void
1.8 millert 460: inputAvailable(int);
1.4 deraadt 461: #endif /* defined(TN3270) */