]>
Commit | Line | Data |
---|---|---|
b7080c8e A |
1 | /* |
2 | * Copyright (c) 1988, 1990, 1993 | |
3 | * The Regents of the University of California. All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
32 | * | |
33 | * @(#)externs.h 8.3 (Berkeley) 5/30/95 | |
7ba0088d | 34 | * $FreeBSD: src/crypto/telnet/telnet/externs.h,v 1.4.2.2 2002/04/13 10:59:08 markm Exp $ |
b7080c8e A |
35 | */ |
36 | ||
37 | #ifndef BSD | |
38 | # define BSD 43 | |
39 | #endif | |
40 | ||
41 | /* | |
7ba0088d | 42 | * ucb stdio.h defines BSD as something weird |
b7080c8e A |
43 | */ |
44 | #if defined(sun) && defined(__svr4__) | |
45 | #define BSD 43 | |
46 | #endif | |
47 | ||
48 | #ifndef USE_TERMIO | |
49 | # if BSD > 43 || defined(SYSV_TERMIO) | |
50 | # define USE_TERMIO | |
51 | # endif | |
52 | #endif | |
53 | ||
54 | #include <stdio.h> | |
55 | #include <setjmp.h> | |
b7080c8e | 56 | #include <sys/ioctl.h> |
7ba0088d | 57 | #include <errno.h> |
b7080c8e A |
58 | #ifdef USE_TERMIO |
59 | # ifndef VINTR | |
7ba0088d | 60 | # include <sys/termios.h> |
b7080c8e | 61 | # endif |
7ba0088d | 62 | # define termio termios |
b7080c8e A |
63 | #endif |
64 | #if defined(NO_CC_T) || !defined(USE_TERMIO) | |
65 | # if !defined(USE_TERMIO) | |
66 | typedef char cc_t; | |
67 | # else | |
68 | typedef unsigned char cc_t; | |
69 | # endif | |
70 | #endif | |
71 | ||
b7080c8e | 72 | #include <string.h> |
7ba0088d A |
73 | |
74 | #if defined(IPSEC) | |
75 | #include <netinet6/ipsec.h> | |
76 | #if defined(IPSEC_POLICY_IPSEC) | |
77 | extern char *ipsec_policy_in; | |
78 | extern char *ipsec_policy_out; | |
79 | #endif | |
b7080c8e A |
80 | #endif |
81 | ||
82 | #ifndef _POSIX_VDISABLE | |
83 | # ifdef sun | |
84 | # include <sys/param.h> /* pick up VDISABLE definition, mayby */ | |
85 | # endif | |
86 | # ifdef VDISABLE | |
87 | # define _POSIX_VDISABLE VDISABLE | |
88 | # else | |
89 | # define _POSIX_VDISABLE ((cc_t)'\377') | |
90 | # endif | |
91 | #endif | |
92 | ||
93 | #define SUBBUFSIZE 256 | |
94 | ||
b7080c8e A |
95 | #if !defined(P) |
96 | # ifdef __STDC__ | |
97 | # define P(x) x | |
98 | # else | |
99 | # define P(x) () | |
100 | # endif | |
101 | #endif | |
102 | ||
103 | extern int | |
104 | autologin, /* Autologin enabled */ | |
105 | skiprc, /* Don't process the ~/.telnetrc file */ | |
106 | eight, /* use eight bit mode (binary in and/or out */ | |
7ba0088d | 107 | family, /* address family of peer */ |
b7080c8e A |
108 | flushout, /* flush output */ |
109 | connected, /* Are we connected to the other side? */ | |
110 | globalmode, /* Mode tty should be in */ | |
b7080c8e A |
111 | telnetport, /* Are we connected to the telnet port? */ |
112 | localflow, /* Flow control handled locally */ | |
113 | restartany, /* If flow control, restart output on any character */ | |
114 | localchars, /* we recognize interrupt/quit */ | |
115 | donelclchars, /* the user has set "localchars" */ | |
116 | showoptions, | |
117 | net, /* Network file descriptor */ | |
118 | tin, /* Terminal input file descriptor */ | |
119 | tout, /* Terminal output file descriptor */ | |
120 | crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */ | |
121 | autoflush, /* flush output when interrupting? */ | |
122 | autosynch, /* send interrupt characters with SYNCH? */ | |
123 | SYNCHing, /* Is the stream in telnet SYNCH mode? */ | |
124 | donebinarytoggle, /* the user has put us in binary */ | |
125 | dontlecho, /* do we suppress local echoing right now? */ | |
126 | crmod, | |
127 | netdata, /* Print out network data flow */ | |
128 | prettydump, /* Print "netdata" output in user readable format */ | |
b7080c8e | 129 | termdata, /* Print out terminal data flow */ |
7ba0088d A |
130 | debug, /* Debug level */ |
131 | doaddrlookup, /* do a reverse lookup? */ | |
132 | clienteof; /* Client received EOF */ | |
b7080c8e A |
133 | |
134 | extern cc_t escape; /* Escape to command mode */ | |
135 | extern cc_t rlogin; /* Rlogin mode escape character */ | |
136 | #ifdef KLUDGELINEMODE | |
137 | extern cc_t echoc; /* Toggle local echoing */ | |
138 | #endif | |
139 | ||
140 | extern char | |
141 | *prompt; /* Prompt for command. */ | |
142 | ||
143 | extern char | |
144 | doopt[], | |
145 | dont[], | |
146 | will[], | |
147 | wont[], | |
148 | options[], /* All the little options */ | |
149 | *hostname; /* Who are we connected to? */ | |
150 | #ifdef ENCRYPTION | |
7ba0088d A |
151 | extern void (*encrypt_output)(unsigned char *, int); |
152 | extern int (*decrypt_input)(int); | |
b7080c8e A |
153 | #endif /* ENCRYPTION */ |
154 | ||
155 | /* | |
156 | * We keep track of each side of the option negotiation. | |
157 | */ | |
158 | ||
159 | #define MY_STATE_WILL 0x01 | |
160 | #define MY_WANT_STATE_WILL 0x02 | |
161 | #define MY_STATE_DO 0x04 | |
162 | #define MY_WANT_STATE_DO 0x08 | |
163 | ||
164 | /* | |
165 | * Macros to check the current state of things | |
166 | */ | |
167 | ||
168 | #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) | |
169 | #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) | |
170 | #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) | |
171 | #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) | |
172 | ||
173 | #define my_state_is_dont(opt) (!my_state_is_do(opt)) | |
174 | #define my_state_is_wont(opt) (!my_state_is_will(opt)) | |
175 | #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) | |
176 | #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) | |
177 | ||
178 | #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} | |
179 | #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} | |
180 | #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} | |
181 | #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} | |
182 | ||
183 | #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} | |
184 | #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} | |
185 | #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} | |
186 | #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} | |
187 | ||
188 | /* | |
189 | * Make everything symetrical | |
190 | */ | |
191 | ||
192 | #define HIS_STATE_WILL MY_STATE_DO | |
193 | #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO | |
194 | #define HIS_STATE_DO MY_STATE_WILL | |
195 | #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL | |
196 | ||
197 | #define his_state_is_do my_state_is_will | |
198 | #define his_state_is_will my_state_is_do | |
199 | #define his_want_state_is_do my_want_state_is_will | |
200 | #define his_want_state_is_will my_want_state_is_do | |
201 | ||
202 | #define his_state_is_dont my_state_is_wont | |
203 | #define his_state_is_wont my_state_is_dont | |
204 | #define his_want_state_is_dont my_want_state_is_wont | |
205 | #define his_want_state_is_wont my_want_state_is_dont | |
206 | ||
207 | #define set_his_state_do set_my_state_will | |
208 | #define set_his_state_will set_my_state_do | |
209 | #define set_his_want_state_do set_my_want_state_will | |
210 | #define set_his_want_state_will set_my_want_state_do | |
211 | ||
212 | #define set_his_state_dont set_my_state_wont | |
213 | #define set_his_state_wont set_my_state_dont | |
214 | #define set_his_want_state_dont set_my_want_state_wont | |
215 | #define set_his_want_state_wont set_my_want_state_dont | |
216 | ||
7ba0088d A |
217 | #if defined(USE_TERMIO) |
218 | #define SIG_FUNC_RET void | |
219 | #else | |
220 | #define SIG_FUNC_RET int | |
221 | #endif | |
222 | ||
223 | #ifdef SIGINFO | |
224 | extern SIG_FUNC_RET | |
225 | ayt_status(void); | |
226 | #endif | |
b7080c8e A |
227 | |
228 | extern FILE | |
229 | *NetTrace; /* Where debugging output goes */ | |
230 | extern unsigned char | |
231 | NetTraceFile[]; /* Name of file where debugging output goes */ | |
232 | extern void | |
7ba0088d | 233 | SetNetTrace(char *); /* Function to change where debugging goes */ |
b7080c8e A |
234 | |
235 | extern jmp_buf | |
236 | peerdied, | |
237 | toplevel; /* For error conditions. */ | |
238 | ||
239 | extern void | |
7ba0088d A |
240 | command(int, const char *, int), |
241 | Dump(char, unsigned char *, int), | |
242 | env_init(void), | |
243 | Exit(int), | |
244 | ExitString(const char *, int), | |
245 | init_network(void), | |
246 | init_sys(void), | |
247 | init_telnet(void), | |
248 | init_terminal(void), | |
249 | intp(void), | |
250 | optionstatus(void), | |
251 | printoption(const char *, int, int), | |
252 | printsub(char, unsigned char *, int), | |
253 | quit(void), | |
254 | sendabort(void), | |
255 | sendbrk(void), | |
256 | sendeof(void), | |
257 | sendsusp(void), | |
258 | sendnaws(void), | |
259 | sendayt(void), | |
260 | setconnmode(int), | |
261 | setcommandmode(void), | |
262 | set_escape_char(char *s), | |
263 | setneturg(void), | |
264 | sys_telnet_init(void), | |
265 | telnet(char *), | |
266 | tel_enter_binary(int), | |
267 | tel_leave_binary(int), | |
268 | TerminalFlushOutput(void), | |
269 | TerminalNewMode(int), | |
270 | TerminalRestoreState(void), | |
271 | TerminalSaveState(void), | |
272 | TerminalDefaultChars(void), | |
273 | TerminalSpeeds(long *, long *), | |
274 | tninit(void), | |
275 | upcase(char *), | |
276 | willoption(int), | |
277 | wontoption(int); | |
b7080c8e A |
278 | |
279 | extern void | |
7ba0088d A |
280 | send_do(int, int), |
281 | send_dont(int, int), | |
282 | send_will(int, int), | |
283 | send_wont(int, int); | |
b7080c8e A |
284 | |
285 | extern void | |
7ba0088d A |
286 | lm_will(unsigned char *, int), |
287 | lm_wont(unsigned char *, int), | |
288 | lm_do(unsigned char *, int), | |
289 | lm_dont(unsigned char *, int), | |
290 | lm_mode(unsigned char *, int, int); | |
b7080c8e A |
291 | |
292 | extern void | |
7ba0088d A |
293 | slc_init(void), |
294 | slcstate(void), | |
295 | slc_mode_export(void), | |
296 | slc_mode_import(int), | |
297 | slc_import(int), | |
298 | slc_export(void), | |
299 | slc(unsigned char *, int), | |
300 | slc_check(void), | |
301 | slc_start_reply(void), | |
302 | slc_add_reply(unsigned char, unsigned char, cc_t), | |
303 | slc_end_reply(void); | |
b7080c8e | 304 | extern int |
7ba0088d A |
305 | getconnmode(void), |
306 | opt_welldefined(const char *), | |
307 | NetClose(int), | |
308 | netflush(void), | |
309 | process_rings(int, int, int, int, int, int), | |
310 | rlogin_susp(void), | |
311 | SetSockOpt(int, int, int, int), | |
312 | slc_update(void), | |
313 | stilloob(void), | |
314 | telrcv(void), | |
315 | TerminalRead(char *, int), | |
316 | TerminalWrite(char *, int), | |
317 | TerminalAutoFlush(void), | |
318 | TerminalWindowSize(long *, long *), | |
319 | TerminalSpecialChars(int), | |
320 | tn(int, char **), | |
321 | ttyflush(int); | |
b7080c8e A |
322 | |
323 | extern void | |
7ba0088d A |
324 | env_opt(unsigned char *, int), |
325 | env_opt_start(void), | |
326 | env_opt_start_info(void), | |
327 | env_opt_add(unsigned char *), | |
328 | env_opt_end(int); | |
b7080c8e A |
329 | |
330 | extern unsigned char | |
7ba0088d A |
331 | *env_default(int, int), |
332 | *env_getvalue(const unsigned char *); | |
b7080c8e A |
333 | |
334 | extern int | |
7ba0088d A |
335 | get_status(char *), |
336 | dosynch(char *); | |
b7080c8e A |
337 | |
338 | extern cc_t | |
7ba0088d | 339 | *tcval(int); |
b7080c8e A |
340 | |
341 | #ifndef USE_TERMIO | |
342 | ||
343 | extern struct tchars ntc; | |
344 | extern struct ltchars nltc; | |
345 | extern struct sgttyb nttyb; | |
346 | ||
347 | # define termEofChar ntc.t_eofc | |
348 | # define termEraseChar nttyb.sg_erase | |
349 | # define termFlushChar nltc.t_flushc | |
350 | # define termIntChar ntc.t_intrc | |
351 | # define termKillChar nttyb.sg_kill | |
352 | # define termLiteralNextChar nltc.t_lnextc | |
353 | # define termQuitChar ntc.t_quitc | |
354 | # define termSuspChar nltc.t_suspc | |
355 | # define termRprntChar nltc.t_rprntc | |
356 | # define termWerasChar nltc.t_werasc | |
357 | # define termStartChar ntc.t_startc | |
358 | # define termStopChar ntc.t_stopc | |
359 | # define termForw1Char ntc.t_brkc | |
360 | extern cc_t termForw2Char; | |
361 | extern cc_t termAytChar; | |
362 | ||
363 | # define termEofCharp (cc_t *)&ntc.t_eofc | |
364 | # define termEraseCharp (cc_t *)&nttyb.sg_erase | |
365 | # define termFlushCharp (cc_t *)&nltc.t_flushc | |
366 | # define termIntCharp (cc_t *)&ntc.t_intrc | |
367 | # define termKillCharp (cc_t *)&nttyb.sg_kill | |
368 | # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc | |
369 | # define termQuitCharp (cc_t *)&ntc.t_quitc | |
370 | # define termSuspCharp (cc_t *)&nltc.t_suspc | |
371 | # define termRprntCharp (cc_t *)&nltc.t_rprntc | |
372 | # define termWerasCharp (cc_t *)&nltc.t_werasc | |
373 | # define termStartCharp (cc_t *)&ntc.t_startc | |
374 | # define termStopCharp (cc_t *)&ntc.t_stopc | |
375 | # define termForw1Charp (cc_t *)&ntc.t_brkc | |
376 | # define termForw2Charp (cc_t *)&termForw2Char | |
377 | # define termAytCharp (cc_t *)&termAytChar | |
378 | ||
379 | # else | |
380 | ||
381 | extern struct termio new_tc; | |
382 | ||
383 | # define termEofChar new_tc.c_cc[VEOF] | |
384 | # define termEraseChar new_tc.c_cc[VERASE] | |
385 | # define termIntChar new_tc.c_cc[VINTR] | |
386 | # define termKillChar new_tc.c_cc[VKILL] | |
387 | # define termQuitChar new_tc.c_cc[VQUIT] | |
388 | ||
389 | # ifndef VSUSP | |
390 | extern cc_t termSuspChar; | |
391 | # else | |
392 | # define termSuspChar new_tc.c_cc[VSUSP] | |
393 | # endif | |
394 | # if defined(VFLUSHO) && !defined(VDISCARD) | |
395 | # define VDISCARD VFLUSHO | |
396 | # endif | |
397 | # ifndef VDISCARD | |
398 | extern cc_t termFlushChar; | |
399 | # else | |
400 | # define termFlushChar new_tc.c_cc[VDISCARD] | |
401 | # endif | |
402 | # ifndef VWERASE | |
403 | extern cc_t termWerasChar; | |
404 | # else | |
405 | # define termWerasChar new_tc.c_cc[VWERASE] | |
406 | # endif | |
407 | # ifndef VREPRINT | |
408 | extern cc_t termRprntChar; | |
409 | # else | |
410 | # define termRprntChar new_tc.c_cc[VREPRINT] | |
411 | # endif | |
412 | # ifndef VLNEXT | |
413 | extern cc_t termLiteralNextChar; | |
414 | # else | |
415 | # define termLiteralNextChar new_tc.c_cc[VLNEXT] | |
416 | # endif | |
417 | # ifndef VSTART | |
418 | extern cc_t termStartChar; | |
419 | # else | |
420 | # define termStartChar new_tc.c_cc[VSTART] | |
421 | # endif | |
422 | # ifndef VSTOP | |
423 | extern cc_t termStopChar; | |
424 | # else | |
425 | # define termStopChar new_tc.c_cc[VSTOP] | |
426 | # endif | |
427 | # ifndef VEOL | |
428 | extern cc_t termForw1Char; | |
429 | # else | |
430 | # define termForw1Char new_tc.c_cc[VEOL] | |
431 | # endif | |
432 | # ifndef VEOL2 | |
433 | extern cc_t termForw2Char; | |
434 | # else | |
435 | # define termForw2Char new_tc.c_cc[VEOL] | |
436 | # endif | |
437 | # ifndef VSTATUS | |
438 | extern cc_t termAytChar; | |
439 | #else | |
440 | # define termAytChar new_tc.c_cc[VSTATUS] | |
441 | #endif | |
442 | ||
7ba0088d | 443 | # if defined(__STDC__) |
b7080c8e A |
444 | # define termEofCharp &termEofChar |
445 | # define termEraseCharp &termEraseChar | |
446 | # define termIntCharp &termIntChar | |
447 | # define termKillCharp &termKillChar | |
448 | # define termQuitCharp &termQuitChar | |
449 | # define termSuspCharp &termSuspChar | |
450 | # define termFlushCharp &termFlushChar | |
451 | # define termWerasCharp &termWerasChar | |
452 | # define termRprntCharp &termRprntChar | |
453 | # define termLiteralNextCharp &termLiteralNextChar | |
454 | # define termStartCharp &termStartChar | |
455 | # define termStopCharp &termStopChar | |
456 | # define termForw1Charp &termForw1Char | |
457 | # define termForw2Charp &termForw2Char | |
458 | # define termAytCharp &termAytChar | |
459 | # else | |
460 | /* Work around a compiler bug */ | |
461 | # define termEofCharp 0 | |
462 | # define termEraseCharp 0 | |
463 | # define termIntCharp 0 | |
464 | # define termKillCharp 0 | |
465 | # define termQuitCharp 0 | |
466 | # define termSuspCharp 0 | |
467 | # define termFlushCharp 0 | |
468 | # define termWerasCharp 0 | |
469 | # define termRprntCharp 0 | |
470 | # define termLiteralNextCharp 0 | |
471 | # define termStartCharp 0 | |
472 | # define termStopCharp 0 | |
473 | # define termForw1Charp 0 | |
474 | # define termForw2Charp 0 | |
475 | # define termAytCharp 0 | |
476 | # endif | |
477 | #endif | |
478 | ||
479 | ||
480 | /* Ring buffer structures which are shared */ | |
481 | ||
482 | extern Ring | |
483 | netoring, | |
484 | netiring, | |
485 | ttyoring, | |
486 | ttyiring; | |
487 | ||
b7080c8e | 488 | extern void |
7ba0088d A |
489 | xmitAO(void), |
490 | xmitEC(void), | |
491 | xmitEL(void); |