xref: /dragonfly/libexec/telnetd/ext.h (revision 62dc643e)
1 /*
2  * Copyright (c) 1989, 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. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *	@(#)ext.h	8.2 (Berkeley) 12/15/93
30  * $FreeBSD: src/crypto/telnet/telnetd/ext.h,v 1.2.8.4 2002/04/13 10:59:08 markm Exp $
31  * $DragonFly: src/crypto/telnet/telnetd/ext.h,v 1.3 2006/01/17 23:50:35 dillon Exp $
32  */
33 
34 /*
35  * Telnet server variable declarations
36  */
37 extern char	options[256];
38 extern char	do_dont_resp[256];
39 extern char	will_wont_resp[256];
40 extern int	linemode;	/* linemode on/off */
41 #ifdef	LINEMODE
42 extern int	uselinemode;	/* what linemode to use (on/off) */
43 extern int	editmode;	/* edit modes in use */
44 extern int	useeditmode;	/* edit modes to use */
45 extern int	alwayslinemode;	/* command line option */
46 extern int	lmodetype;	/* Client support for linemode */
47 #endif	/* LINEMODE */
48 extern int	flowmode;	/* current flow control state */
49 extern int	restartany;	/* restart output on any character state */
50 #ifdef DIAGNOSTICS
51 extern int	diagnostic;	/* telnet diagnostic capabilities */
52 #endif /* DIAGNOSTICS */
53 #ifdef BFTPDAEMON
54 extern int	bftpd;		/* behave as bftp daemon */
55 #endif /* BFTPDAEMON */
56 #ifdef	AUTHENTICATION
57 extern int	auth_level;
58 #endif
59 
60 extern slcfun	slctab[NSLC + 1];	/* slc mapping table */
61 
62 #define TERMINAL_TYPE_SIZE	41	/* allocated space for terminaltype */
63 
64 char	*terminaltype;
65 
66 /*
67  * I/O data buffers, pointers, and counters.
68  */
69 extern char	ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp;
70 
71 extern char	netibuf[BUFSIZ], *netip;
72 
73 extern char	netobuf[BUFSIZ], *nfrontp, *nbackp;
74 extern char	*neturg;		/* one past last bye of urgent data */
75 
76 extern int	pcc, ncc;
77 
78 extern int	pty, net;
79 extern char	line[16];
80 extern int	SYNCHing;		/* we are in TELNET SYNCH mode */
81 
82 extern void
83 	_termstat(void),
84 	add_slc(char, char, cc_t),
85 	check_slc(void),
86 	change_slc(char, char, cc_t),
87 	cleanup(int),
88 	clientstat(int, int, int),
89 	copy_termbuf(char *, size_t),
90 	deferslc(void),
91 	defer_terminit(void),
92 	do_opt_slc(unsigned char *, int),
93 	doeof(void),
94 	dooption(int),
95 	dontoption(int),
96 	edithost(char *, char *),
97 	fatal(int, const char *),
98 	fatalperror(int, const char *),
99 	get_slc_defaults(void),
100 	init_env(void),
101 	init_termbuf(void),
102 	interrupt(void),
103 	localstat(void),
104 	flowstat(void),
105 	netclear(void),
106 	netflush(void),
107 #ifdef DIAGNOSTICS
108 	printoption(const char *, int),
109 	printdata(const char *, char *, int),
110 	printsub(char, unsigned char *, int),
111 #endif
112 	process_slc(unsigned char, unsigned char, cc_t),
113 	ptyflush(void),
114 	putchr(int),
115 	putf(char *, char *),
116 	recv_ayt(void),
117 	send_do(int, int),
118 	send_dont(int, int),
119 	send_slc(void),
120 	send_status(void),
121 	send_will(int, int),
122 	send_wont(int, int),
123 	sendbrk(void),
124 	sendsusp(void),
125 	set_termbuf(void),
126 	start_login(char *, int, char *),
127 	start_slc(int),
128 #ifdef	AUTHENTICATION
129 	start_slave(char *),
130 #else
131 	start_slave(char *, int, char *),
132 #endif
133 	suboption(void),
134 	telrcv(void),
135 	ttloop(void),
136 	tty_binaryin(int),
137 	tty_binaryout(int);
138 
139 extern int
140 	end_slc(unsigned char **),
141 	getnpty(void),
142 #ifndef convex
143 	getpty(int *),
144 #endif
145 	login_tty(int),
146 	spcset(int, cc_t *, cc_t **),
147 	stilloob(int),
148 	terminit(void),
149 	termstat(void),
150 	tty_flowmode(void),
151 	tty_restartany(void),
152 	tty_isbinaryin(void),
153 	tty_isbinaryout(void),
154 	tty_iscrnl(void),
155 	tty_isecho(void),
156 	tty_isediting(void),
157 	tty_islitecho(void),
158 	tty_isnewmap(void),
159 	tty_israw(void),
160 	tty_issofttab(void),
161 	tty_istrapsig(void),
162 	tty_linemode(void);
163 
164 extern void
165 	tty_rspeed(int),
166 	tty_setecho(int),
167 	tty_setedit(int),
168 	tty_setlinemode(int),
169 	tty_setlitecho(int),
170 	tty_setsig(int),
171 	tty_setsofttab(int),
172 	tty_tspeed(int),
173 	willoption(int),
174 	wontoption(int);
175 
176 int	output_data(const char *, ...) __printflike(1, 2);
177 void	output_datalen(const char *, int);
178 void	startslave(char *, int, char *);
179 
180 #ifdef	ENCRYPTION
181 extern void	(*encrypt_output)(unsigned char *, int);
182 extern int	(*decrypt_input)(int);
183 extern char	*nclearto;
184 #endif	/* ENCRYPTION */
185 
186 
187 /*
188  * The following are some clocks used to decide how to interpret
189  * the relationship between various variables.
190  */
191 
192 extern struct {
193     int
194 	system,			/* what the current time is */
195 	echotoggle,		/* last time user entered echo character */
196 	modenegotiated,		/* last time operating mode negotiated */
197 	didnetreceive,		/* last time we read data from network */
198 	ttypesubopt,		/* ttype subopt is received */
199 	tspeedsubopt,		/* tspeed subopt is received */
200 	environsubopt,		/* environ subopt is received */
201 	oenvironsubopt,		/* old environ subopt is received */
202 	xdisplocsubopt,		/* xdisploc subopt is received */
203 	baseline,		/* time started to do timed action */
204 	gotDM;			/* when did we last see a data mark */
205 } clocks;
206 
207 #ifndef	DEFAULT_IM
208 #   ifdef ultrix
209 #    define DEFAULT_IM	"\r\n\r\nULTRIX (%h) (%t)\r\n\r\r\n\r"
210 #   else
211 #    if defined(__DragonFly__)
212 #     define DEFAULT_IM  "\r\n\r\nDragonFly (%h) (%t)\r\n\r\r\n\r"
213 #    elif defined(__FreeBSD__)
214 #     define DEFAULT_IM  "\r\n\r\nFreeBSD (%h) (%t)\r\n\r\r\n\r"
215 #    else
216 #    define DEFAULT_IM	"\r\n\r\n4.4 BSD UNIX (%h) (%t)\r\n\r\r\n\r"
217 #    endif
218 #   endif
219 #endif
220