Annotation of src/usr.bin/telnet/externs.h, Revision 1.16
1.16 ! guenther 1: /* $OpenBSD: externs.h,v 1.15 2009/06/05 00:20:46 claudio 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: #ifndef BSD
36: # define BSD 43
37: #endif
38:
39: #ifndef _POSIX_VDISABLE
40: # ifdef sun
41: # include <sys/param.h> /* pick up VDISABLE definition, mayby */
42: # endif
43: # ifdef VDISABLE
44: # define _POSIX_VDISABLE VDISABLE
45: # else
46: # define _POSIX_VDISABLE ((cc_t)'\377')
47: # endif
48: #endif
49:
50: #define SUBBUFSIZE 256
51:
52: extern int
53: autologin, /* Autologin enabled */
54: skiprc, /* Don't process the ~/.telnetrc file */
55: eight, /* use eight bit mode (binary in and/or out */
1.3 art 56: binary,
1.12 otto 57: family, /* address family of peer */
1.1 deraadt 58: flushout, /* flush output */
59: connected, /* Are we connected to the other side? */
60: globalmode, /* Mode tty should be in */
61: telnetport, /* Are we connected to the telnet port? */
1.3 art 62: In3270, /* Are we in 3270 mode? */
1.1 deraadt 63: localflow, /* Flow control handled locally */
64: restartany, /* If flow control, restart output on any character */
65: localchars, /* we recognize interrupt/quit */
1.2 niklas 66: donelclchars, /* the user has set "localchars" */
1.1 deraadt 67: showoptions,
1.9 hin 68: wantencryption, /* User has requested encryption */
1.1 deraadt 69: net, /* Network file descriptor */
70: tin, /* Terminal input file descriptor */
71: tout, /* Terminal output file descriptor */
72: crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
73: autoflush, /* flush output when interrupting? */
74: autosynch, /* send interrupt characters with SYNCH? */
75: SYNCHing, /* Is the stream in telnet SYNCH mode? */
76: donebinarytoggle, /* the user has put us in binary */
77: dontlecho, /* do we suppress local echoing right now? */
78: crmod,
79: netdata, /* Print out network data flow */
80: prettydump, /* Print "netdata" output in user readable format */
1.4 deraadt 81: #if defined(TN3270)
82: cursesdata, /* Print out curses data flow */
83: apitrace, /* Trace API transactions */
84: #endif /* defined(TN3270) */
1.1 deraadt 85: termdata, /* Print out terminal data flow */
1.3 art 86: debug; /* Debug level */
1.9 hin 87:
1.10 hin 88: extern volatile sig_atomic_t intr_happened, intr_waiting; /* for interrupt handling */
1.1 deraadt 89:
90: extern cc_t escape; /* Escape to command mode */
91: extern cc_t rlogin; /* Rlogin mode escape character */
92: #ifdef KLUDGELINEMODE
93: extern cc_t echoc; /* Toggle local echoing */
94: #endif
95:
96: extern char
97: *prompt; /* Prompt for command. */
98:
99: extern char
100: doopt[],
101: dont[],
102: will[],
103: wont[],
104: options[], /* All the little options */
105: *hostname; /* Who are we connected to? */
1.3 art 106: #if defined(ENCRYPTION)
107: extern void (*encrypt_output) (unsigned char *, int);
108: extern int (*decrypt_input) (int);
109: #endif
1.15 claudio 110:
1.16 ! guenther 111: extern u_int rtableid; /* routing table to use */
1.1 deraadt 112:
113: /*
114: * We keep track of each side of the option negotiation.
115: */
116:
117: #define MY_STATE_WILL 0x01
118: #define MY_WANT_STATE_WILL 0x02
119: #define MY_STATE_DO 0x04
120: #define MY_WANT_STATE_DO 0x08
121:
122: /*
123: * Macros to check the current state of things
124: */
125:
126: #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
127: #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
128: #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
129: #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
130:
131: #define my_state_is_dont(opt) (!my_state_is_do(opt))
132: #define my_state_is_wont(opt) (!my_state_is_will(opt))
133: #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
134: #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
135:
136: #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
137: #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
138: #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
139: #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
140:
141: #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
142: #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
143: #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
144: #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
145:
146: /*
1.7 pvalchev 147: * Make everything symmetrical
1.1 deraadt 148: */
149:
150: #define HIS_STATE_WILL MY_STATE_DO
151: #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
152: #define HIS_STATE_DO MY_STATE_WILL
153: #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
154:
155: #define his_state_is_do my_state_is_will
156: #define his_state_is_will my_state_is_do
157: #define his_want_state_is_do my_want_state_is_will
158: #define his_want_state_is_will my_want_state_is_do
159:
160: #define his_state_is_dont my_state_is_wont
161: #define his_state_is_wont my_state_is_dont
162: #define his_want_state_is_dont my_want_state_is_wont
163: #define his_want_state_is_wont my_want_state_is_dont
164:
165: #define set_his_state_do set_my_state_will
166: #define set_his_state_will set_my_state_do
167: #define set_his_want_state_do set_my_want_state_will
168: #define set_his_want_state_will set_my_want_state_do
169:
170: #define set_his_state_dont set_my_state_wont
171: #define set_his_state_wont set_my_state_dont
172: #define set_his_want_state_dont set_my_want_state_wont
173: #define set_his_want_state_wont set_my_want_state_dont
174:
175:
176: extern FILE
177: *NetTrace; /* Where debugging output goes */
178: extern unsigned char
179: NetTraceFile[]; /* Name of file where debugging output goes */
180: extern void
1.3 art 181: SetNetTrace (char *); /* Function to change where debugging goes */
1.1 deraadt 182:
183: extern jmp_buf
184: peerdied,
185: toplevel; /* For error conditions. */
186:
1.3 art 187: /* authenc.c */
1.1 deraadt 188:
1.3 art 189: #if defined(AUTHENTICATION) || defined(ENCRYPTION)
190: int net_write(unsigned char *str, int len);
191: void net_encrypt(void);
192: int telnet_spin(void);
1.6 hin 193: char *telnet_getenv(const char *val);
1.3 art 194: char *telnet_gets(char *prompt, char *result, int length, int echo);
1.13 pvalchev 195: int Scheduler(int block);
1.3 art 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);
1.14 otto 209: unsigned char * env_getvalue(unsigned char *var, int exported_only);
1.3 art 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);
1.14 otto 341: unsigned char *env_getvalue (unsigned char *, int);
1.3 art 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) */