]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - crypto/heimdal/appl/telnet/telnet/externs.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / crypto / heimdal / appl / telnet / telnet / externs.h
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
34  */
35
36 /* $Id$ */
37
38 #ifndef BSD
39 # define BSD 43
40 #endif
41
42 #ifndef _POSIX_VDISABLE
43 # ifdef sun
44 #  include <sys/param.h>        /* pick up VDISABLE definition, mayby */
45 # endif
46 # ifdef VDISABLE
47 #  define _POSIX_VDISABLE VDISABLE
48 # else
49 #  define _POSIX_VDISABLE ((cc_t)'\377')
50 # endif
51 #endif
52
53 #define SUBBUFSIZE      256
54
55 extern int
56     autologin,          /* Autologin enabled */
57     skiprc,             /* Don't process the ~/.telnetrc file */
58     eight,              /* use eight bit mode (binary in and/or out */
59     binary,
60     flushout,           /* flush output */
61     connected,          /* Are we connected to the other side? */
62     globalmode,         /* Mode tty should be in */
63     telnetport,         /* Are we connected to the telnet port? */
64     localflow,          /* Flow control handled locally */
65     restartany,         /* If flow control, restart output on any character */
66     localchars,         /* we recognize interrupt/quit */
67     donelclchars,       /* the user has set "localchars" */
68     showoptions,
69     wantencryption,     /* User has requested encryption */
70     net,                /* Network file descriptor */
71     tin,                /* Terminal input file descriptor */
72     tout,               /* Terminal output file descriptor */
73     crlf,               /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
74     autoflush,          /* flush output when interrupting? */
75     autosynch,          /* send interrupt characters with SYNCH? */
76     SYNCHing,           /* Is the stream in telnet SYNCH mode? */
77     donebinarytoggle,   /* the user has put us in binary */
78     dontlecho,          /* do we suppress local echoing right now? */
79     crmod,
80     netdata,            /* Print out network data flow */
81     prettydump,         /* Print "netdata" output in user readable format */
82     termdata,           /* Print out terminal data flow */
83     debug;              /* Debug level */
84
85 extern int intr_happened, intr_waiting; /* for interrupt handling */
86
87 extern cc_t escape;     /* Escape to command mode */
88 extern cc_t rlogin;     /* Rlogin mode escape character */
89 #ifdef  KLUDGELINEMODE
90 extern cc_t echoc;      /* Toggle local echoing */
91 #endif
92
93 extern char
94     *prompt;            /* Prompt for command. */
95
96 extern char
97     doopt[],
98     dont[],
99     will[],
100     wont[],
101     do_dont_resp[],
102     will_wont_resp[],
103     options[],          /* All the little options */
104     *hostname;          /* Who are we connected to? */
105 #if     defined(ENCRYPTION)
106 extern void (*encrypt_output) (unsigned char *, int);
107 extern int (*decrypt_input) (int);
108 #endif
109
110 /*
111  * We keep track of each side of the option negotiation.
112  */
113
114 #define MY_STATE_WILL           0x01
115 #define MY_WANT_STATE_WILL      0x02
116 #define MY_STATE_DO             0x04
117 #define MY_WANT_STATE_DO        0x08
118
119 /*
120  * Macros to check the current state of things
121  */
122
123 #define my_state_is_do(opt)             (options[opt]&MY_STATE_DO)
124 #define my_state_is_will(opt)           (options[opt]&MY_STATE_WILL)
125 #define my_want_state_is_do(opt)        (options[opt]&MY_WANT_STATE_DO)
126 #define my_want_state_is_will(opt)      (options[opt]&MY_WANT_STATE_WILL)
127
128 #define my_state_is_dont(opt)           (!my_state_is_do(opt))
129 #define my_state_is_wont(opt)           (!my_state_is_will(opt))
130 #define my_want_state_is_dont(opt)      (!my_want_state_is_do(opt))
131 #define my_want_state_is_wont(opt)      (!my_want_state_is_will(opt))
132
133 #define set_my_state_do(opt)            {options[opt] |= MY_STATE_DO;}
134 #define set_my_state_will(opt)          {options[opt] |= MY_STATE_WILL;}
135 #define set_my_want_state_do(opt)       {options[opt] |= MY_WANT_STATE_DO;}
136 #define set_my_want_state_will(opt)     {options[opt] |= MY_WANT_STATE_WILL;}
137
138 #define set_my_state_dont(opt)          {options[opt] &= ~MY_STATE_DO;}
139 #define set_my_state_wont(opt)          {options[opt] &= ~MY_STATE_WILL;}
140 #define set_my_want_state_dont(opt)     {options[opt] &= ~MY_WANT_STATE_DO;}
141 #define set_my_want_state_wont(opt)     {options[opt] &= ~MY_WANT_STATE_WILL;}
142
143 /*
144  * Make everything symmetrical
145  */
146
147 #define HIS_STATE_WILL                  MY_STATE_DO
148 #define HIS_WANT_STATE_WILL             MY_WANT_STATE_DO
149 #define HIS_STATE_DO                    MY_STATE_WILL
150 #define HIS_WANT_STATE_DO               MY_WANT_STATE_WILL
151
152 #define his_state_is_do                 my_state_is_will
153 #define his_state_is_will               my_state_is_do
154 #define his_want_state_is_do            my_want_state_is_will
155 #define his_want_state_is_will          my_want_state_is_do
156
157 #define his_state_is_dont               my_state_is_wont
158 #define his_state_is_wont               my_state_is_dont
159 #define his_want_state_is_dont          my_want_state_is_wont
160 #define his_want_state_is_wont          my_want_state_is_dont
161
162 #define set_his_state_do                set_my_state_will
163 #define set_his_state_will              set_my_state_do
164 #define set_his_want_state_do           set_my_want_state_will
165 #define set_his_want_state_will         set_my_want_state_do
166
167 #define set_his_state_dont              set_my_state_wont
168 #define set_his_state_wont              set_my_state_dont
169 #define set_his_want_state_dont         set_my_want_state_wont
170 #define set_his_want_state_wont         set_my_want_state_dont
171
172
173 extern FILE
174     *NetTrace;          /* Where debugging output goes */
175 extern char
176     NetTraceFile[];     /* Name of file where debugging output goes */
177 extern void
178     SetNetTrace (char *);       /* Function to change where debugging goes */
179
180 extern jmp_buf
181     peerdied,
182     toplevel;           /* For error conditions. */
183
184 int Scheduler(int);
185 extern int scheduler_lockout_tty;
186
187
188 /* authenc.c */
189
190 #if     defined(AUTHENTICATION) || defined(ENCRYPTION)
191 int telnet_net_write(unsigned char *str, int len);
192 void net_encrypt(void);
193 int telnet_spin(void);
194 char *telnet_getenv(const char *val);
195 char *telnet_gets(char *prompt, char *result, int length, int echo);
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);
209 unsigned char * env_getvalue(unsigned char *var);
210
211 void set_escape_char(char *s);
212 int sourceroute(struct addrinfo *ai, char *arg, char **cpp,
213                 int *prototp, int *optp);
214
215 #if     defined(AUTHENTICATION)
216 int auth_enable (char *);
217 int auth_disable (char *);
218 int auth_status (void);
219 #endif
220
221 #if defined(ENCRYPTION)
222 int     EncryptEnable (char *, char *);
223 int     EncryptDisable (char *, char *);
224 int     EncryptType (char *, char *);
225 int     EncryptStart (char *);
226 int     EncryptStartInput (void);
227 int     EncryptStartOutput (void);
228 int     EncryptStop (char *);
229 int     EncryptStopInput (void);
230 int     EncryptStopOutput (void);
231 int     EncryptStatus (void);
232 #endif
233
234 #ifdef SIGINFO
235 RETSIGTYPE ayt_status(int);
236 #endif
237 int tn(int argc, char **argv);
238 void command(int top, char *tbuf, int cnt);
239
240 /* main.c */
241
242 void tninit(void);
243 void set_forward_options(void);
244
245 /* network.c */
246
247 void init_network(void);
248 int stilloob(void);
249 void setneturg(void);
250 int netflush(void);
251
252 /* sys_bsd.c */
253
254 void init_sys(void);
255 int TerminalWrite(char *buf, int n);
256 int TerminalRead(unsigned char *buf, int n);
257 int TerminalAutoFlush(void);
258 int TerminalSpecialChars(int c);
259 void TerminalFlushOutput(void);
260 void TerminalSaveState(void);
261 void TerminalDefaultChars(void);
262 void TerminalNewMode(int f);
263 cc_t *tcval(int func);
264 void TerminalSpeeds(long *input_speed, long *output_speed);
265 int TerminalWindowSize(long *rows, long *cols);
266 int NetClose(int fd);
267 void NetNonblockingIO(int fd, int onoff);
268 int process_rings(int netin, int netout, int netex, int ttyin, int ttyout,
269                   int poll);
270
271 /* telnet.c */
272
273 void init_telnet(void);
274
275 void tel_leave_binary(int rw);
276 void tel_enter_binary(int rw);
277 int opt_welldefined(char *ep);
278 int telrcv(void);
279 int rlogin_susp(void);
280 void intp(void);
281 void sendbrk(void);
282 void sendabort(void);
283 void sendsusp(void);
284 void sendeof(void);
285 void sendayt(void);
286
287 void xmitAO(void);
288 void xmitEL(void);
289 void xmitEC(void);
290
291
292 void     Dump (char, unsigned char *, int);
293 void     printoption (char *, int, int);
294 void     sendnaws (void);
295 void     setconnmode (int);
296 void     setcommandmode (void);
297 void     setneturg (void);
298 void     sys_telnet_init (void);
299 void     my_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     willoption (int);
306 void     wontoption (int);
307
308
309 void     send_do (int, int);
310 void     send_dont (int, int);
311 void     send_will (int, int);
312 void     send_wont (int, int);
313
314 void     lm_will (unsigned char *, int);
315 void     lm_wont (unsigned char *, int);
316 void     lm_do (unsigned char *, int);
317 void     lm_dont (unsigned char *, int);
318 void     lm_mode (unsigned char *, int, int);
319
320 void     slc_init (void);
321 void     slcstate (void);
322 void     slc_mode_export (void);
323 void     slc_mode_import (int);
324 void     slc_import (int);
325 void     slc_export (void);
326 void     slc (unsigned char *, int);
327 void     slc_check (void);
328 void     slc_start_reply (void);
329 void     slc_add_reply (unsigned char, unsigned char, cc_t);
330 void     slc_end_reply (void);
331 int      slc_update (void);
332
333 void     env_opt (unsigned char *, int);
334 void     env_opt_start (void);
335 void     env_opt_start_info (void);
336 void     env_opt_add (unsigned char *);
337 void     env_opt_end (int);
338
339 unsigned char     *env_default (int, int);
340 unsigned char     *env_getvalue (unsigned char *);
341
342 int get_status (void);
343 int dosynch (void);
344
345 cc_t *tcval (int);
346
347 int quit (void);
348
349 /* terminal.c */
350
351 void init_terminal(void);
352 int ttyflush(int drop);
353 int getconnmode(void);
354
355 /* utilities.c */
356
357 int SetSockOpt(int fd, int level, int option, int yesno);
358 void SetNetTrace(char *file);
359 void Dump(char direction, unsigned char *buffer, int length);
360 void printoption(char *direction, int cmd, int option);
361 void optionstatus(void);
362 void printsub(int direction, unsigned char *pointer, size_t length);
363 void EmptyTerminal(void);
364 void SetForExit(void);
365 void Exit(int returnCode);
366 void ExitString(char *string, int returnCode);
367
368 extern struct   termios new_tc;
369
370 # define termEofChar            new_tc.c_cc[VEOF]
371 # define termEraseChar          new_tc.c_cc[VERASE]
372 # define termIntChar            new_tc.c_cc[VINTR]
373 # define termKillChar           new_tc.c_cc[VKILL]
374 # define termQuitChar           new_tc.c_cc[VQUIT]
375
376 # ifndef        VSUSP
377 extern cc_t termSuspChar;
378 # else
379 #  define termSuspChar          new_tc.c_cc[VSUSP]
380 # endif
381 # if    defined(VFLUSHO) && !defined(VDISCARD)
382 #  define VDISCARD VFLUSHO
383 # endif
384 # ifndef        VDISCARD
385 extern cc_t termFlushChar;
386 # else
387 #  define termFlushChar         new_tc.c_cc[VDISCARD]
388 # endif
389 # ifndef VWERASE
390 extern cc_t termWerasChar;
391 # else
392 #  define termWerasChar         new_tc.c_cc[VWERASE]
393 # endif
394 # ifndef        VREPRINT
395 extern cc_t termRprntChar;
396 # else
397 #  define termRprntChar         new_tc.c_cc[VREPRINT]
398 # endif
399 # ifndef        VLNEXT
400 extern cc_t termLiteralNextChar;
401 # else
402 #  define termLiteralNextChar   new_tc.c_cc[VLNEXT]
403 # endif
404 # ifndef        VSTART
405 extern cc_t termStartChar;
406 # else
407 #  define termStartChar         new_tc.c_cc[VSTART]
408 # endif
409 # ifndef        VSTOP
410 extern cc_t termStopChar;
411 # else
412 #  define termStopChar          new_tc.c_cc[VSTOP]
413 # endif
414 # ifndef        VEOL
415 extern cc_t termForw1Char;
416 # else
417 #  define termForw1Char         new_tc.c_cc[VEOL]
418 # endif
419 # ifndef        VEOL2
420 extern cc_t termForw2Char;
421 # else
422 #  define termForw2Char         new_tc.c_cc[VEOL]
423 # endif
424 # ifndef        VSTATUS
425 extern cc_t termAytChar;
426 #else
427 #  define termAytChar           new_tc.c_cc[VSTATUS]
428 #endif
429
430 /* Ring buffer structures which are shared */
431
432 extern Ring
433     netoring,
434     netiring,
435     ttyoring,
436     ttyiring;
437
438 extern int resettermname;
439 extern int linemode;
440 #ifdef KLUDGELINEMODE
441 extern int kludgelinemode;
442 #endif
443 extern int want_status_response;