1 /* $NetBSD: externs.h,v 1.37 2012/01/10 23:39:11 joerg Exp $ */
4 * Copyright (c) 1988, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * from: @(#)externs.h 8.3 (Berkeley) 5/30/95
37 #include <sys/ioctl.h>
39 #include <sys/termios.h>
44 #include <netipsec/ipsec.h>
45 #if defined(IPSEC_POLICY_IPSEC)
46 extern char *ipsec_policy_in
;
47 extern char *ipsec_policy_out
;
51 #ifndef _POSIX_VDISABLE
53 # include <sys/param.h> /* pick up VDISABLE definition, mayby */
56 # define _POSIX_VDISABLE VDISABLE
58 # define _POSIX_VDISABLE ((cc_t)'\377')
62 #define SUBBUFSIZE 256
64 #include <sys/cdefs.h>
67 autologin
, /* Autologin enabled */
68 skiprc
, /* Don't process the ~/.telnetrc file */
69 eight
, /* use eight bit mode (binary in and/or out */
70 family
, /* address family of peer */
71 flushout
, /* flush output */
72 connected
, /* Are we connected to the other side? */
73 globalmode
, /* Mode tty should be in */
74 In3270
, /* Are we in 3270 mode? */
75 telnetport
, /* Are we connected to the telnet port? */
76 localflow
, /* Flow control handled locally */
77 restartany
, /* If flow control, restart output on any character */
78 localchars
, /* we recognize interrupt/quit */
79 donelclchars
, /* the user has set "localchars" */
81 net
, /* Network file descriptor */
82 tin
, /* Terminal input file descriptor */
83 tout
, /* Terminal output file descriptor */
84 crlf
, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
85 autoflush
, /* flush output when interrupting? */
86 autosynch
, /* send interrupt characters with SYNCH? */
87 SYNCHing
, /* Is the stream in telnet SYNCH mode? */
88 donebinarytoggle
, /* the user has put us in binary */
89 dontlecho
, /* do we suppress local echoing right now? */
91 netdata
, /* Print out network data flow */
92 prettydump
, /* Print "netdata" output in user readable format */
94 cursesdata
, /* Print out curses data flow */
95 apitrace
, /* Trace API transactions */
96 #endif /* defined(TN3270) */
97 termdata
, /* Print out terminal data flow */
98 telnet_debug
, /* Debug level */
99 doaddrlookup
, /* do a reverse address lookup? */
100 clienteof
; /* Client received EOF */
102 extern cc_t escape
; /* Escape to command mode */
103 extern cc_t rlogin
; /* Rlogin mode escape character */
104 #ifdef KLUDGELINEMODE
105 extern cc_t echoc
; /* Toggle local echoing */
109 *prompt
; /* Prompt for command. */
116 options
[], /* All the little options */
117 *hostname
; /* Who are we connected to? */
120 extern void (*encrypt_output
)(unsigned char *, int);
121 extern int (*decrypt_input
)(int);
122 #endif /* ENCRYPTION */
125 * We keep track of each side of the option negotiation.
128 #define MY_STATE_WILL 0x01
129 #define MY_WANT_STATE_WILL 0x02
130 #define MY_STATE_DO 0x04
131 #define MY_WANT_STATE_DO 0x08
134 * Macros to check the current state of things
137 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
138 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
139 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
140 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
142 #define my_state_is_dont(opt) (!my_state_is_do(opt))
143 #define my_state_is_wont(opt) (!my_state_is_will(opt))
144 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
145 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
147 #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
148 #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
149 #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
150 #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
152 #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
153 #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
154 #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
155 #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
158 * Make everything symmetrical
161 #define HIS_STATE_WILL MY_STATE_DO
162 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
163 #define HIS_STATE_DO MY_STATE_WILL
164 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
166 #define his_state_is_do my_state_is_will
167 #define his_state_is_will my_state_is_do
168 #define his_want_state_is_do my_want_state_is_will
169 #define his_want_state_is_will my_want_state_is_do
171 #define his_state_is_dont my_state_is_wont
172 #define his_state_is_wont my_state_is_dont
173 #define his_want_state_is_dont my_want_state_is_wont
174 #define his_want_state_is_wont my_want_state_is_dont
176 #define set_his_state_do set_my_state_will
177 #define set_his_state_will set_my_state_do
178 #define set_his_want_state_do set_my_want_state_will
179 #define set_his_want_state_will set_my_want_state_do
181 #define set_his_state_dont set_my_state_wont
182 #define set_his_state_wont set_my_state_dont
183 #define set_his_want_state_dont set_my_want_state_wont
184 #define set_his_want_state_wont set_my_want_state_dont
188 *NetTrace
; /* Where debugging output goes */
190 NetTraceFile
[]; /* Name of file where debugging output goes */
193 toplevel
; /* For error conditions. */
197 int telnet_net_write(unsigned char *, int);
198 void net_encrypt(void);
199 int telnet_spin(void);
200 char *telnet_getenv(char *);
201 char *telnet_gets(char *, char *, int, int);
204 int send_tncmd(void (*)(int, int), const char *, char *);
205 void _setlist_init(void);
206 void set_escape_char(char *);
210 int suspend(int, char *[]);
211 int shell(int, char *[]);
212 int quit(int, char *[]);
213 int logout(int, char *[]);
214 int env_cmd(int, char *[]);
215 struct env_lst
*env_find(const unsigned char *);
217 struct env_lst
*env_define(const unsigned char *, unsigned char *);
218 struct env_lst
*env_undefine(const unsigned char *, unsigned char *);
219 struct env_lst
*env_export(const unsigned char *, unsigned char *);
220 struct env_lst
*env_unexport(const unsigned char *, unsigned char *);
221 struct env_lst
*env_send(const unsigned char *, unsigned char *);
222 struct env_lst
*env_list(const unsigned char *, unsigned char *);
223 unsigned char *env_default(int, int );
224 unsigned char *env_getvalue(const unsigned char *);
225 void env_varval(const unsigned char *);
226 int auth_cmd(int, char *[]);
227 int ayt_status(void);
228 int encrypt_cmd(int, char *[]);
229 int tn(int, char *[]);
230 void command(int, const char *, int);
231 void cmdrc(const char *, const char *);
233 int sourceroute(struct addrinfo
*, char *, char **, int *, int*);
237 void usage(void) __dead
;
240 void init_network(void);
242 void setneturg(void);
247 int TerminalWrite(char *, int);
248 int TerminalRead(unsigned char *, int);
249 int TerminalAutoFlush(void);
250 int TerminalSpecialChars(int);
251 void TerminalFlushOutput(void);
252 void TerminalSaveState(void);
254 void TerminalDefaultChars(void);
255 void TerminalRestoreState(void);
256 void TerminalNewMode(int);
257 void TerminalSpeeds(long *, long *);
258 int TerminalWindowSize(long *, long *);
260 void NetNonblockingIO(int, int);
261 void NetSigIO(int, int);
262 void NetSetPgrp(int);
263 void sys_telnet_init(void);
264 int process_rings(int , int , int , int , int , int);
267 void init_telnet(void);
268 void send_do(int, int );
269 void send_dont(int, int );
270 void send_will(int, int );
271 void send_wont(int, int );
272 void willoption(int);
273 void wontoption(int);
274 char **mklist(char *, char *);
275 int is_unique(char *, char **, char **);
276 int setup_term(char *, int, int *);
277 char *gettermname(void);
278 void lm_will(unsigned char *, int);
279 void lm_wont(unsigned char *, int);
280 void lm_do(unsigned char *, int);
281 void lm_dont(unsigned char *, int);
282 void lm_mode(unsigned char *, int, int );
285 void slc_mode_export(int);
286 void slc_mode_import(int);
287 void slc_import(int);
288 void slc_export(void);
289 void slc(unsigned char *, int);
290 void slc_check(void);
291 void slc_start_reply(void);
292 void slc_add_reply(unsigned int, unsigned int, cc_t
);
293 void slc_end_reply(void);
294 int slc_update(void);
295 void env_opt(unsigned char *, int);
296 void env_opt_start(void);
297 void env_opt_start_info(void);
298 void env_opt_add(unsigned char *);
299 int opt_welldefined(const char *);
300 void env_opt_end(int);
302 int rlogin_susp(void);
304 void telnet(const char *);
309 int get_status(char *);
312 void sendabort(void);
317 void tel_enter_binary(int);
318 void tel_leave_binary(int);
321 void init_terminal(void);
323 int getconnmode(void);
324 void setconnmode(int);
325 void setcommandmode(void);
329 int SetSockOpt(int, int, int, int);
330 void SetNetTrace(char *);
331 void Dump(int, unsigned char *, int);
332 void printoption(const char *, int, int );
333 void optionstatus(void);
334 void printsub(int, unsigned char *, int);
335 void EmptyTerminal(void);
336 void SetForExit(void);
337 void Exit(int) __attribute__((__noreturn__
));
338 void ExitString(const char *, int) __attribute__((__noreturn__
));
341 extern struct termios new_tc
;
343 # define termEofChar new_tc.c_cc[VEOF]
344 # define termEraseChar new_tc.c_cc[VERASE]
345 # define termIntChar new_tc.c_cc[VINTR]
346 # define termKillChar new_tc.c_cc[VKILL]
347 # define termQuitChar new_tc.c_cc[VQUIT]
349 # define termSuspChar new_tc.c_cc[VSUSP]
350 # define termFlushChar new_tc.c_cc[VDISCARD]
351 # define termWerasChar new_tc.c_cc[VWERASE]
352 # define termRprntChar new_tc.c_cc[VREPRINT]
353 # define termLiteralNextChar new_tc.c_cc[VLNEXT]
354 # define termStartChar new_tc.c_cc[VSTART]
355 # define termStopChar new_tc.c_cc[VSTOP]
356 # define termForw1Char new_tc.c_cc[VEOL]
357 # define termForw2Char new_tc.c_cc[VEOL]
358 # define termAytChar new_tc.c_cc[VSTATUS]
360 # define termEofCharp &termEofChar
361 # define termEraseCharp &termEraseChar
362 # define termIntCharp &termIntChar
363 # define termKillCharp &termKillChar
364 # define termQuitCharp &termQuitChar
365 # define termSuspCharp &termSuspChar
366 # define termFlushCharp &termFlushChar
367 # define termWerasCharp &termWerasChar
368 # define termRprntCharp &termRprntChar
369 # define termLiteralNextCharp &termLiteralNextChar
370 # define termStartCharp &termStartChar
371 # define termStopCharp &termStopChar
372 # define termForw1Charp &termForw1Char
373 # define termForw2Charp &termForw2Char
374 # define termAytCharp &termAytChar
381 HaveInput
, /* Whether an asynchronous I/O indication came in */
382 noasynchtty
, /* Don't do signals on I/O (SIGURG, SIGIO) */
383 noasynchnet
, /* Don't do signals on I/O (SIGURG, SIGIO) */
384 sigiocount
, /* Count of SIGIO receptions */
385 shell_active
; /* Subshell is active */
388 *Ibackp
, /* Oldest byte of 3270 data */
389 Ibuf
[], /* 3270 buffer */
390 *Ifrontp
, /* Where next 3270 byte goes */
392 *transcom
; /* Transparent command */
395 void init_3270(void);
396 int DataToNetwork(char *, int, int);
397 void inputAvailable(int);
398 void outputPurge(void);
399 int DataToTerminal(char *, int);
401 void Finish3270(void);
402 void StringToTerminal(char *);
404 void SetIn3270(void);
405 int tn3270_ttype(void);
406 int settranscom(int, char *[]);
407 int shell_continue(void);
408 int DataFromTerminal(char *, int);
409 int DataFromNetwork(char *, int, int);
410 void ConnectScreen(void);
411 int DoTerminalOutput(void);
413 #endif /* defined(TN3270) */