xref: /titanic_51/usr/src/cmd/cmd-inet/usr.bin/telnet/externs.h (revision 791a814c934fcd4deb13b26c1f116ff283272a0d)
1 /*
2  * Copyright 1994-2002 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 1988, 1990, 1993
8  *	The Regents of the University of California.  All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the University of
21  *	California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  *	@(#)externs.h	8.1 (Berkeley) 6/6/93
39  */
40 
41 #ifndef _EXTERNS_H
42 #define	_EXTERNS_H
43 
44 #pragma ident	"%Z%%M%	%I%	%E% SMI"
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 #include <libintl.h>
51 #include <stdio.h>
52 #include <setjmp.h>
53 #include <sys/filio.h>
54 #ifdef	USE_TERMIO
55 #include <sys/termios.h>
56 #define	termio termios
57 #endif
58 #if defined(NO_CC_T) || !defined(USE_TERMIO)
59 #if !defined(USE_TERMIO)
60 typedef char cc_t;
61 #else
62 typedef unsigned char cc_t;
63 #endif
64 #endif
65 
66 #include "auth.h"
67 #include "encrypt.h"
68 #include <profile/prof_int.h>
69 
70 extern profile_options_boolean	config_file_options[];
71 #define	forwardable_flag_set	config_file_options[0].found
72 #define	forward_flag_set	config_file_options[1].found
73 #define	encrypt_flag_set	config_file_options[2].found
74 #define	autologin_set		config_file_options[3].found
75 
76 #include <string.h>
77 
78 #ifndef	_POSIX_VDISABLE
79 #include <sys/param.h>	/* pick up VDISABLE definition, mayby */
80 #ifdef VDISABLE
81 #define	_POSIX_VDISABLE VDISABLE
82 #else
83 #define	_POSIX_VDISABLE ((cc_t)'\377')
84 #endif
85 #endif
86 
87 #include <wait.h>
88 #include <stdlib.h>
89 #include <unistd.h>
90 
91 
92 #define	SUBBUFSIZE	256
93 
94 extern int autologin;	/* Autologin enabled */
95 extern int skiprc;	/* Don't process the ~/.telnetrc file */
96 extern int eight;	/* use eight bit mode (binary in and/or out */
97 extern int flushout;	/* flush output */
98 extern int connected;	/* Are we connected to the other side? */
99 extern int globalmode;	/* Mode tty should be in */
100 extern int telnetport;	/* Are we connected to the telnet port? */
101 extern int localflow;	/* Flow control handled locally */
102 extern int restartany;	/* If flow control, restart output on any character */
103 extern int localchars;	/* we recognize interrupt/quit */
104 extern int donelclchars; /* the user has set "localchars" */
105 extern int showoptions;
106 extern int net;		/* Network file descriptor */
107 extern int tout;	/* Terminal output file descriptor */
108 extern int crlf;	/* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
109 extern int autoflush;	/* flush output when interrupting? */
110 extern int autosynch;	/* send interrupt characters with SYNCH? */
111 extern int SYNCHing;	/* Is the stream in telnet SYNCH mode? */
112 extern int donebinarytoggle;	/* the user has put us in binary */
113 extern int dontlecho;	/* do we suppress local echoing right now? */
114 extern int crmod;
115 extern int netdata;	/* Print out network data flow */
116 extern int prettydump;	/* Print "netdata" output in user readable format */
117 extern int termdata;	/* Print out terminal data flow */
118 extern int eof_pending;	/* Received EOF in line mode, need to send IAC-xEOF */
119 extern int debug;	/* Debug level */
120 
121 
122 extern int krb5auth_flag;
123 extern char *RemoteHostName;
124 extern char *UserNameRequested;
125 extern int forwardable_flag;
126 extern int forward_flag;
127 extern boolean_t wantencryption;	/* User has requested encryption */
128 extern int encrypt_flag;		/* for reading config file for Krb5 */
129 
130 extern boolean_t Ambiguous(void *);
131 extern boolean_t intr_happened;	/* for interrupt handling */
132 extern boolean_t intr_waiting;
133 
134 extern cc_t escape;	/* Escape to command mode */
135 extern cc_t rlogin;	/* Rlogin mode escape character */
136 extern boolean_t escape_valid;
137 #ifdef	KLUDGELINEMODE
138 extern cc_t echoc;	/* Toggle local echoing */
139 #endif
140 
141 extern char *prompt;	/* Prompt for command. */
142 
143 extern char doopt[];
144 extern char dont[];
145 extern char will[];
146 extern char wont[];
147 extern char options[];	/* All the little options */
148 extern char *hostname;	/* Who are we connected to? */
149 extern void (*encrypt_output) (unsigned char *, int);
150 extern int (*decrypt_input) (int);
151 
152 /*
153  * We keep track of each side of the option negotiation.
154  */
155 
156 #define	MY_STATE_WILL		0x01
157 #define	MY_WANT_STATE_WILL	0x02
158 #define	MY_STATE_DO		0x04
159 #define	MY_WANT_STATE_DO	0x08
160 
161 /*
162  * Macros to check the current state of things
163  */
164 
165 #define	my_state_is_do(opt)		(options[opt]&MY_STATE_DO)
166 #define	my_state_is_will(opt)		(options[opt]&MY_STATE_WILL)
167 #define	my_want_state_is_do(opt)	(options[opt]&MY_WANT_STATE_DO)
168 #define	my_want_state_is_will(opt)	(options[opt]&MY_WANT_STATE_WILL)
169 
170 #define	my_state_is_dont(opt)		(!my_state_is_do(opt))
171 #define	my_state_is_wont(opt)		(!my_state_is_will(opt))
172 #define	my_want_state_is_dont(opt)	(!my_want_state_is_do(opt))
173 #define	my_want_state_is_wont(opt)	(!my_want_state_is_will(opt))
174 
175 #define	set_my_state_do(opt)		{options[opt] |= MY_STATE_DO; }
176 #define	set_my_state_will(opt)		{options[opt] |= MY_STATE_WILL; }
177 #define	set_my_want_state_do(opt)	{options[opt] |= MY_WANT_STATE_DO; }
178 #define	set_my_want_state_will(opt)	{options[opt] |= MY_WANT_STATE_WILL; }
179 
180 #define	set_my_state_dont(opt)		{options[opt] &= ~MY_STATE_DO; }
181 #define	set_my_state_wont(opt)		{options[opt] &= ~MY_STATE_WILL; }
182 #define	set_my_want_state_dont(opt)	{options[opt] &= ~MY_WANT_STATE_DO; }
183 #define	set_my_want_state_wont(opt)	{options[opt] &= ~MY_WANT_STATE_WILL; }
184 
185 /*
186  * Make everything symetrical
187  */
188 
189 #define	HIS_STATE_WILL			MY_STATE_DO
190 #define	HIS_WANT_STATE_WILL		MY_WANT_STATE_DO
191 #define	HIS_STATE_DO			MY_STATE_WILL
192 #define	HIS_WANT_STATE_DO		MY_WANT_STATE_WILL
193 
194 #define	his_state_is_do			my_state_is_will
195 #define	his_state_is_will		my_state_is_do
196 #define	his_want_state_is_do		my_want_state_is_will
197 #define	his_want_state_is_will		my_want_state_is_do
198 
199 #define	his_state_is_dont		my_state_is_wont
200 #define	his_state_is_wont		my_state_is_dont
201 #define	his_want_state_is_dont		my_want_state_is_wont
202 #define	his_want_state_is_wont		my_want_state_is_dont
203 
204 #define	set_his_state_do		set_my_state_will
205 #define	set_his_state_will		set_my_state_do
206 #define	set_his_want_state_do		set_my_want_state_will
207 #define	set_his_want_state_will		set_my_want_state_do
208 
209 #define	set_his_state_dont		set_my_state_wont
210 #define	set_his_state_wont		set_my_state_dont
211 #define	set_his_want_state_dont		set_my_want_state_wont
212 #define	set_his_want_state_wont		set_my_want_state_dont
213 
214 
215 extern FILE *NetTrace;		/* Where debugging output goes */
216 				/* Name of file where debugging output goes */
217 extern unsigned char NetTraceFile[];
218 extern void SetNetTrace(char *); /* Function to change where debugging goes */
219 
220 extern jmp_buf peerdied;
221 extern jmp_buf toplevel;	/* For error conditions. */
222 
223 extern char *AllocStringBuffer(char **, unsigned int *, unsigned int);
224 extern void ExitString(char *, int);
225 extern void Exit(int);
226 extern void command(int, char *, int);
227 extern void Dump(int, unsigned char *, int);
228 extern char *GetAndAppendString(char **, unsigned int *, char *, FILE *);
229 extern char *GetString(char **, unsigned int *, FILE *);
230 extern void init_network(void);
231 extern void init_terminal(void);
232 extern void init_sys(void);
233 extern void optionstatus(void);
234 extern void printoption(char *, int, int);
235 extern void printsub(int, unsigned char *, int);
236 extern void sendnaws(void);
237 extern void setconnmode(int);
238 extern void setcommandmode(void);
239 extern void setneturg(void);
240 extern void sys_telnet_init(void);
241 extern void telnet(char *);
242 extern void tel_enter_binary(int);
243 extern void tel_leave_binary(int);
244 extern void TerminalDefaultChars(void);
245 extern void TerminalFlushOutput(void);
246 extern void TerminalNewMode(int);
247 extern void TerminalSaveState(void);
248 extern void TerminalSpeeds(int *, int *);
249 extern void upcase(char *);
250 
251 extern void xmitEL(void);
252 extern void xmitEC(void);
253 extern void intp(void);
254 extern void sendabort(void);
255 extern void sendsusp(void);
256 extern void set_escape_char(char *);
257 extern void fatal_tty_error(char *);
258 
259 extern void send_do(int, int);
260 extern void send_dont(int, int);
261 extern void send_will(int, int);
262 extern void send_wont(int, int);
263 
264 extern void lm_mode(unsigned char *, int, int);
265 
266 extern void slcstate(void);
267 extern void slc_mode_export(void);
268 extern void slc_mode_import(int);
269 extern void slc_check(void);
270 
271 extern void env_opt_start_info(void);
272 extern void env_opt_add(unsigned char *);
273 extern void env_opt_end(int);
274 
275 extern char **genget(char *, char **, int);
276 extern unsigned char *env_default(int, int);
277 extern unsigned char *env_getvalue(unsigned char *);
278 
279 extern int env_init(void);
280 extern int get_status(void);
281 extern int init_telnet(void);
282 extern int isprefix(register char *, register char *);
283 extern int netflush(void);
284 extern int opt_welldefined(char *);
285 extern int process_rings(int, int, int, int, int, int);
286 extern int quit(void);
287 extern int rlogin_susp(void);
288 extern int Scheduler(int);
289 extern int SetSockOpt(int, int, int, int);
290 extern int stilloob(void);
291 extern int telrcv(void);
292 extern int TerminalWindowSize(unsigned short *, unsigned short *);
293 extern int TerminalWrite(char *, int);
294 extern int TerminalSpecialChars(int);
295 extern int tn(int, char **);
296 extern int tninit(void);
297 extern int ttyflush(int);
298 extern int getconnmode(void);
299 extern int xmitAO(void);
300 extern int sendbrk(void);
301 extern int dosynch(void);
302 
303 extern cc_t *tcval(int);
304 
305 extern void	auth_encrypt_init(char *, char *, char *);
306 extern void	auth_encrypt_user(char *);
307 extern int	net_write(unsigned char *, int len);
308 extern void	net_encrypt(void);
309 extern void	telnet_spin(void);
310 extern void	printd(unsigned char *, int);
311 
312 #ifndef	USE_TERMIO
313 
314 extern struct	tchars ntc;
315 extern struct	ltchars nltc;
316 extern struct	sgttyb nttyb;
317 
318 #define	termEofChar		ntc.t_eofc
319 #define	termEraseChar		nttyb.sg_erase
320 #define	termFlushChar		nltc.t_flushc
321 #define	termIntChar		ntc.t_intrc
322 #define	termKillChar		nttyb.sg_kill
323 #define	termLiteralNextChar	nltc.t_lnextc
324 #define	termQuitChar		ntc.t_quitc
325 #define	termSuspChar		nltc.t_suspc
326 #define	termRprntChar		nltc.t_rprntc
327 #define	termWerasChar		nltc.t_werasc
328 #define	termStartChar		ntc.t_startc
329 #define	termStopChar		ntc.t_stopc
330 #define	termForw1Char		ntc.t_brkc
331 extern cc_t termForw2Char;
332 extern cc_t termAytChar;
333 
334 #define	termEofCharp		(cc_t *)&ntc.t_eofc
335 #define	termEraseCharp		(cc_t *)&nttyb.sg_erase
336 #define	termFlushCharp		(cc_t *)&nltc.t_flushc
337 #define	termIntCharp		(cc_t *)&ntc.t_intrc
338 #define	termKillCharp		(cc_t *)&nttyb.sg_kill
339 #define	termLiteralNextCharp	(cc_t *)&nltc.t_lnextc
340 #define	termQuitCharp		(cc_t *)&ntc.t_quitc
341 #define	termSuspCharp		(cc_t *)&nltc.t_suspc
342 #define	termRprntCharp		(cc_t *)&nltc.t_rprntc
343 #define	termWerasCharp		(cc_t *)&nltc.t_werasc
344 #define	termStartCharp		(cc_t *)&ntc.t_startc
345 #define	termStopCharp		(cc_t *)&ntc.t_stopc
346 #define	termForw1Charp		(cc_t *)&ntc.t_brkc
347 #define	termForw2Charp		(cc_t *)&termForw2Char
348 #define	termAytCharp		(cc_t *)&termAytChar
349 
350 #else
351 
352 extern struct	termio new_tc;
353 
354 #define	termEofChar		new_tc.c_cc[VEOF]
355 #define	termEraseChar		new_tc.c_cc[VERASE]
356 #define	termIntChar		new_tc.c_cc[VINTR]
357 #define	termKillChar		new_tc.c_cc[VKILL]
358 #define	termQuitChar		new_tc.c_cc[VQUIT]
359 
360 #define	termSuspChar		new_tc.c_cc[VSUSP]
361 #define	termFlushChar		new_tc.c_cc[VDISCARD]
362 #define	termWerasChar		new_tc.c_cc[VWERASE]
363 #define	termRprntChar		new_tc.c_cc[VREPRINT]
364 #define	termLiteralNextChar	new_tc.c_cc[VLNEXT]
365 #define	termStartChar		new_tc.c_cc[VSTART]
366 #define	termStopChar		new_tc.c_cc[VSTOP]
367 #define	termForw1Char		new_tc.c_cc[VEOL]
368 #define	termForw2Char		new_tc.c_cc[VEOL]
369 extern cc_t termAytChar;
370 
371 #define	termEofCharp		&termEofChar
372 #define	termEraseCharp		&termEraseChar
373 #define	termIntCharp		&termIntChar
374 #define	termKillCharp		&termKillChar
375 #define	termQuitCharp		&termQuitChar
376 #define	termSuspCharp		&termSuspChar
377 #define	termFlushCharp		&termFlushChar
378 #define	termWerasCharp		&termWerasChar
379 #define	termRprntCharp		&termRprntChar
380 #define	termLiteralNextCharp	&termLiteralNextChar
381 #define	termStartCharp		&termStartChar
382 #define	termStopCharp		&termStopChar
383 #define	termForw1Charp		&termForw1Char
384 #define	termForw2Charp		&termForw2Char
385 #define	termAytCharp		&termAytChar
386 #endif
387 
388 
389 /* Ring buffer structures which are shared */
390 
391 #include "ring.h"
392 
393 extern Ring netoring;
394 extern Ring netiring;
395 extern Ring ttyoring;
396 extern Ring ttyiring;
397 
398 #ifdef	__cplusplus
399 }
400 #endif
401 
402 #endif	/* _EXTERNS_H */
403