xref: /dragonfly/libexec/telnetd/ext.h (revision 333227be)
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. 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  *	@(#)ext.h	8.2 (Berkeley) 12/15/93
34  * $FreeBSD: src/libexec/telnetd/ext.h,v 1.7.2.4 2002/04/13 11:07:12 markm Exp $
35  * $DragonFly: src/libexec/telnetd/ext.h,v 1.3 2004/02/13 03:49:50 dillon Exp $
36  */
37 
38 /*
39  * Telnet server variable declarations
40  */
41 extern char	options[256];
42 extern char	do_dont_resp[256];
43 extern char	will_wont_resp[256];
44 extern int	linemode;	/* linemode on/off */
45 #ifdef	LINEMODE
46 extern int	uselinemode;	/* what linemode to use (on/off) */
47 extern int	editmode;	/* edit modes in use */
48 extern int	useeditmode;	/* edit modes to use */
49 extern int	alwayslinemode;	/* command line option */
50 extern int	lmodetype;	/* Client support for linemode */
51 #endif	/* LINEMODE */
52 extern int	flowmode;	/* current flow control state */
53 extern int	restartany;	/* restart output on any character state */
54 #ifdef DIAGNOSTICS
55 extern int	diagnostic;	/* telnet diagnostic capabilities */
56 #endif /* DIAGNOSTICS */
57 #ifdef BFTPDAEMON
58 extern int	bftpd;		/* behave as bftp daemon */
59 #endif /* BFTPDAEMON */
60 
61 extern slcfun	slctab[NSLC + 1];	/* slc mapping table */
62 
63 char	*terminaltype;
64 
65 /*
66  * I/O data buffers, pointers, and counters.
67  */
68 extern char	ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp;
69 
70 extern char	netibuf[BUFSIZ], *netip;
71 
72 extern char	netobuf[BUFSIZ], *nfrontp, *nbackp;
73 extern char	*neturg;		/* one past last bye of urgent data */
74 
75 extern int	pcc, ncc;
76 
77 extern int	pty, net;
78 extern char	line[16];
79 extern int	SYNCHing;		/* we are in TELNET SYNCH mode */
80 
81 extern void
82 	_termstat(void),
83 	add_slc(char, char, cc_t),
84 	check_slc(void),
85 	change_slc(char, char, cc_t),
86 	cleanup(int),
87 	clientstat(int, int, int),
88 	copy_termbuf(char *, size_t),
89 	deferslc(void),
90 	defer_terminit(void),
91 	do_opt_slc(unsigned char *, int),
92 	doeof(void),
93 	dooption(int),
94 	dontoption(int),
95 	edithost(char *, char *),
96 	fatal(int, const char *),
97 	fatalperror(int, const char *),
98 	get_slc_defaults(void),
99 	init_env(void),
100 	init_termbuf(void),
101 	interrupt(void),
102 	localstat(void),
103 	flowstat(void),
104 	netclear(void),
105 	netflush(void),
106 #ifdef DIAGNOSTICS
107 	printoption(const char *, int),
108 	printdata(const char *, char *, int),
109 	printsub(char, unsigned char *, int),
110 #endif
111 	process_slc(unsigned char, unsigned char, cc_t),
112 	ptyflush(void),
113 	putchr(int),
114 	putf(char *, char *),
115 	recv_ayt(void),
116 	send_do(int, int),
117 	send_dont(int, int),
118 	send_slc(void),
119 	send_status(void),
120 	send_will(int, int),
121 	send_wont(int, int),
122 	sendbrk(void),
123 	sendsusp(void),
124 	set_termbuf(void),
125 	start_login(char *, int, char *),
126 	start_slc(int),
127 	start_slave(char *, int, char *),
128 	suboption(void),
129 	telrcv(void),
130 	ttloop(void),
131 	tty_binaryin(int),
132 	tty_binaryout(int);
133 
134 extern int
135 	end_slc(unsigned char **),
136 	getnpty(void),
137 #ifndef convex
138 	getpty(int *),
139 #endif
140 	login_tty(int),
141 	spcset(int, cc_t *, cc_t **),
142 	stilloob(int),
143 	terminit(void),
144 	termstat(void),
145 	tty_flowmode(void),
146 	tty_restartany(void),
147 	tty_isbinaryin(void),
148 	tty_isbinaryout(void),
149 	tty_iscrnl(void),
150 	tty_isecho(void),
151 	tty_isediting(void),
152 	tty_islitecho(void),
153 	tty_isnewmap(void),
154 	tty_israw(void),
155 	tty_issofttab(void),
156 	tty_istrapsig(void),
157 	tty_linemode(void);
158 
159 extern void
160 	tty_rspeed(int),
161 	tty_setecho(int),
162 	tty_setedit(int),
163 	tty_setlinemode(int),
164 	tty_setlitecho(int),
165 	tty_setsig(int),
166 	tty_setsofttab(int),
167 	tty_tspeed(int),
168 	willoption(int),
169 	wontoption(int);
170 
171 int	output_data(const char *, ...) __printflike(1, 2);
172 void	output_datalen(const char *, int);
173 void	startslave(char *, int, char *);
174 
175 
176 
177 /*
178  * The following are some clocks used to decide how to interpret
179  * the relationship between various variables.
180  */
181 
182 extern struct {
183     int
184 	system,			/* what the current time is */
185 	echotoggle,		/* last time user entered echo character */
186 	modenegotiated,		/* last time operating mode negotiated */
187 	didnetreceive,		/* last time we read data from network */
188 	ttypesubopt,		/* ttype subopt is received */
189 	tspeedsubopt,		/* tspeed subopt is received */
190 	environsubopt,		/* environ subopt is received */
191 	oenvironsubopt,		/* old environ subopt is received */
192 	xdisplocsubopt,		/* xdisploc subopt is received */
193 	baseline,		/* time started to do timed action */
194 	gotDM;			/* when did we last see a data mark */
195 } clocks;
196 
197 #ifndef	DEFAULT_IM
198 #   ifdef ultrix
199 #    define DEFAULT_IM	"\r\n\r\nULTRIX (%h) (%t)\r\n\r\r\n\r"
200 #   else
201 #    if defined(__DragonFly__)
202 #     define DEFAULT_IM  "\r\n\r\nDragonFly (%h) (%t)\r\n\r\r\n\r"
203 #    elif defined(__FreeBSD__)
204 #     define DEFAULT_IM  "\r\n\r\nFreeBSD (%h) (%t)\r\n\r\r\n\r"
205 #    else
206 #    define DEFAULT_IM	"\r\n\r\n4.4 BSD UNIX (%h) (%t)\r\n\r\r\n\r"
207 #    endif
208 #   endif
209 #endif
210