xref: /freebsd/crypto/heimdal/appl/telnet/telnetd/defs.h (revision 6a068746777241722b2b32c5d0bc443a2a64d80b)
113e3f4d6SMark Murray /*
213e3f4d6SMark Murray  * Copyright (c) 1989, 1993
313e3f4d6SMark Murray  *	The Regents of the University of California.  All rights reserved.
413e3f4d6SMark Murray  *
513e3f4d6SMark Murray  * Redistribution and use in source and binary forms, with or without
613e3f4d6SMark Murray  * modification, are permitted provided that the following conditions
713e3f4d6SMark Murray  * are met:
813e3f4d6SMark Murray  * 1. Redistributions of source code must retain the above copyright
913e3f4d6SMark Murray  *    notice, this list of conditions and the following disclaimer.
1013e3f4d6SMark Murray  * 2. Redistributions in binary form must reproduce the above copyright
1113e3f4d6SMark Murray  *    notice, this list of conditions and the following disclaimer in the
1213e3f4d6SMark Murray  *    documentation and/or other materials provided with the distribution.
1313e3f4d6SMark Murray  * 3. All advertising materials mentioning features or use of this software
1413e3f4d6SMark Murray  *    must display the following acknowledgement:
1513e3f4d6SMark Murray  *	This product includes software developed by the University of
1613e3f4d6SMark Murray  *	California, Berkeley and its contributors.
1713e3f4d6SMark Murray  * 4. Neither the name of the University nor the names of its contributors
1813e3f4d6SMark Murray  *    may be used to endorse or promote products derived from this software
1913e3f4d6SMark Murray  *    without specific prior written permission.
2013e3f4d6SMark Murray  *
2113e3f4d6SMark Murray  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2213e3f4d6SMark Murray  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2313e3f4d6SMark Murray  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2413e3f4d6SMark Murray  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2513e3f4d6SMark Murray  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2613e3f4d6SMark Murray  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2713e3f4d6SMark Murray  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2813e3f4d6SMark Murray  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2913e3f4d6SMark Murray  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3013e3f4d6SMark Murray  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3113e3f4d6SMark Murray  * SUCH DAMAGE.
3213e3f4d6SMark Murray  *
3313e3f4d6SMark Murray  *	@(#)defs.h	8.1 (Berkeley) 6/4/93
3413e3f4d6SMark Murray  */
3513e3f4d6SMark Murray 
3613e3f4d6SMark Murray /*
3713e3f4d6SMark Murray  * Telnet server defines
3813e3f4d6SMark Murray  */
3913e3f4d6SMark Murray 
4013e3f4d6SMark Murray #ifndef __DEFS_H__
4113e3f4d6SMark Murray #define __DEFS_H__
4213e3f4d6SMark Murray 
4313e3f4d6SMark Murray #ifndef	BSD
4413e3f4d6SMark Murray # define	BSD 43
4513e3f4d6SMark Murray #endif
4613e3f4d6SMark Murray 
4713e3f4d6SMark Murray #if defined(PRINTOPTIONS) && defined(DIAGNOSTICS)
4813e3f4d6SMark Murray #define TELOPTS
4913e3f4d6SMark Murray #define TELCMDS
5013e3f4d6SMark Murray #define	SLC_NAMES
5113e3f4d6SMark Murray #endif
5213e3f4d6SMark Murray 
5313e3f4d6SMark Murray #if	!defined(TIOCSCTTY) && defined(TCSETCTTY)
5413e3f4d6SMark Murray # define	TIOCSCTTY TCSETCTTY
5513e3f4d6SMark Murray #endif
5613e3f4d6SMark Murray 
5713e3f4d6SMark Murray #ifndef TIOCPKT_FLUSHWRITE
5813e3f4d6SMark Murray #define TIOCPKT_FLUSHWRITE      0x02
5913e3f4d6SMark Murray #endif
6013e3f4d6SMark Murray 
6113e3f4d6SMark Murray #ifndef TIOCPKT_NOSTOP
6213e3f4d6SMark Murray #define TIOCPKT_NOSTOP  0x10
6313e3f4d6SMark Murray #endif
6413e3f4d6SMark Murray 
6513e3f4d6SMark Murray #ifndef TIOCPKT_DOSTOP
6613e3f4d6SMark Murray #define TIOCPKT_DOSTOP  0x20
6713e3f4d6SMark Murray #endif
6813e3f4d6SMark Murray 
6913e3f4d6SMark Murray /*
7013e3f4d6SMark Murray  * I/O data buffers defines
7113e3f4d6SMark Murray  */
7213e3f4d6SMark Murray #define	NETSLOP	64
7313e3f4d6SMark Murray #ifdef _CRAY
7413e3f4d6SMark Murray #undef BUFSIZ
7513e3f4d6SMark Murray #define BUFSIZ  2048
7613e3f4d6SMark Murray #endif
7713e3f4d6SMark Murray 
7813e3f4d6SMark Murray #define	NIACCUM(c)	{   *netip++ = c; \
7913e3f4d6SMark Murray 			    ncc++; \
8013e3f4d6SMark Murray 			}
8113e3f4d6SMark Murray 
8213e3f4d6SMark Murray /* clock manipulations */
8313e3f4d6SMark Murray #define	settimer(x)	(clocks.x = ++clocks.system)
8413e3f4d6SMark Murray #define	sequenceIs(x,y)	(clocks.x < clocks.y)
8513e3f4d6SMark Murray 
8613e3f4d6SMark Murray /*
8713e3f4d6SMark Murray  * Structures of information for each special character function.
8813e3f4d6SMark Murray  */
8913e3f4d6SMark Murray typedef struct {
9013e3f4d6SMark Murray 	unsigned char	flag;		/* the flags for this function */
9113e3f4d6SMark Murray 	cc_t		val;		/* the value of the special character */
9213e3f4d6SMark Murray } slcent, *Slcent;
9313e3f4d6SMark Murray 
9413e3f4d6SMark Murray typedef struct {
9513e3f4d6SMark Murray 	slcent		defset;		/* the default settings */
9613e3f4d6SMark Murray 	slcent		current;	/* the current settings */
9713e3f4d6SMark Murray 	cc_t		*sptr;		/* a pointer to the char in */
9813e3f4d6SMark Murray 					/* system data structures */
9913e3f4d6SMark Murray } slcfun, *Slcfun;
10013e3f4d6SMark Murray 
10113e3f4d6SMark Murray #ifdef DIAGNOSTICS
10213e3f4d6SMark Murray /*
10313e3f4d6SMark Murray  * Diagnostics capabilities
10413e3f4d6SMark Murray  */
10513e3f4d6SMark Murray #define	TD_REPORT	0x01	/* Report operations to client */
10613e3f4d6SMark Murray #define TD_EXERCISE	0x02	/* Exercise client's implementation */
10713e3f4d6SMark Murray #define TD_NETDATA	0x04	/* Display received data stream */
10813e3f4d6SMark Murray #define TD_PTYDATA	0x08	/* Display data passed to pty */
10913e3f4d6SMark Murray #define	TD_OPTIONS	0x10	/* Report just telnet options */
11013e3f4d6SMark Murray #endif /* DIAGNOSTICS */
11113e3f4d6SMark Murray 
11213e3f4d6SMark Murray /*
11313e3f4d6SMark Murray  * We keep track of each side of the option negotiation.
11413e3f4d6SMark Murray  */
11513e3f4d6SMark Murray 
11613e3f4d6SMark Murray #define	MY_STATE_WILL		0x01
11713e3f4d6SMark Murray #define	MY_WANT_STATE_WILL	0x02
11813e3f4d6SMark Murray #define	MY_STATE_DO		0x04
11913e3f4d6SMark Murray #define	MY_WANT_STATE_DO	0x08
12013e3f4d6SMark Murray 
12113e3f4d6SMark Murray /*
12213e3f4d6SMark Murray  * Macros to check the current state of things
12313e3f4d6SMark Murray  */
12413e3f4d6SMark Murray 
12513e3f4d6SMark Murray #define	my_state_is_do(opt)		(options[opt]&MY_STATE_DO)
12613e3f4d6SMark Murray #define	my_state_is_will(opt)		(options[opt]&MY_STATE_WILL)
12713e3f4d6SMark Murray #define my_want_state_is_do(opt)	(options[opt]&MY_WANT_STATE_DO)
12813e3f4d6SMark Murray #define my_want_state_is_will(opt)	(options[opt]&MY_WANT_STATE_WILL)
12913e3f4d6SMark Murray 
13013e3f4d6SMark Murray #define	my_state_is_dont(opt)		(!my_state_is_do(opt))
13113e3f4d6SMark Murray #define	my_state_is_wont(opt)		(!my_state_is_will(opt))
13213e3f4d6SMark Murray #define my_want_state_is_dont(opt)	(!my_want_state_is_do(opt))
13313e3f4d6SMark Murray #define my_want_state_is_wont(opt)	(!my_want_state_is_will(opt))
13413e3f4d6SMark Murray 
13513e3f4d6SMark Murray #define	set_my_state_do(opt)		(options[opt] |= MY_STATE_DO)
13613e3f4d6SMark Murray #define	set_my_state_will(opt)		(options[opt] |= MY_STATE_WILL)
13713e3f4d6SMark Murray #define	set_my_want_state_do(opt)	(options[opt] |= MY_WANT_STATE_DO)
13813e3f4d6SMark Murray #define	set_my_want_state_will(opt)	(options[opt] |= MY_WANT_STATE_WILL)
13913e3f4d6SMark Murray 
14013e3f4d6SMark Murray #define	set_my_state_dont(opt)		(options[opt] &= ~MY_STATE_DO)
14113e3f4d6SMark Murray #define	set_my_state_wont(opt)		(options[opt] &= ~MY_STATE_WILL)
14213e3f4d6SMark Murray #define	set_my_want_state_dont(opt)	(options[opt] &= ~MY_WANT_STATE_DO)
14313e3f4d6SMark Murray #define	set_my_want_state_wont(opt)	(options[opt] &= ~MY_WANT_STATE_WILL)
14413e3f4d6SMark Murray 
14513e3f4d6SMark Murray /*
14613e3f4d6SMark Murray  * Tricky code here.  What we want to know is if the MY_STATE_WILL
14713e3f4d6SMark Murray  * and MY_WANT_STATE_WILL bits have the same value.  Since the two
14813e3f4d6SMark Murray  * bits are adjacent, a little arithmatic will show that by adding
14913e3f4d6SMark Murray  * in the lower bit, the upper bit will be set if the two bits were
15013e3f4d6SMark Murray  * different, and clear if they were the same.
15113e3f4d6SMark Murray  */
15213e3f4d6SMark Murray #define my_will_wont_is_changing(opt) \
15313e3f4d6SMark Murray 			((options[opt]+MY_STATE_WILL) & MY_WANT_STATE_WILL)
15413e3f4d6SMark Murray 
15513e3f4d6SMark Murray #define my_do_dont_is_changing(opt) \
15613e3f4d6SMark Murray 			((options[opt]+MY_STATE_DO) & MY_WANT_STATE_DO)
15713e3f4d6SMark Murray 
15813e3f4d6SMark Murray /*
1594137ff4cSJacques Vidrine  * Make everything symmetrical
16013e3f4d6SMark Murray  */
16113e3f4d6SMark Murray 
16213e3f4d6SMark Murray #define	HIS_STATE_WILL			MY_STATE_DO
16313e3f4d6SMark Murray #define	HIS_WANT_STATE_WILL		MY_WANT_STATE_DO
16413e3f4d6SMark Murray #define HIS_STATE_DO			MY_STATE_WILL
16513e3f4d6SMark Murray #define HIS_WANT_STATE_DO		MY_WANT_STATE_WILL
16613e3f4d6SMark Murray 
16713e3f4d6SMark Murray #define	his_state_is_do			my_state_is_will
16813e3f4d6SMark Murray #define	his_state_is_will		my_state_is_do
16913e3f4d6SMark Murray #define his_want_state_is_do		my_want_state_is_will
17013e3f4d6SMark Murray #define his_want_state_is_will		my_want_state_is_do
17113e3f4d6SMark Murray 
17213e3f4d6SMark Murray #define	his_state_is_dont		my_state_is_wont
17313e3f4d6SMark Murray #define	his_state_is_wont		my_state_is_dont
17413e3f4d6SMark Murray #define his_want_state_is_dont		my_want_state_is_wont
17513e3f4d6SMark Murray #define his_want_state_is_wont		my_want_state_is_dont
17613e3f4d6SMark Murray 
17713e3f4d6SMark Murray #define	set_his_state_do		set_my_state_will
17813e3f4d6SMark Murray #define	set_his_state_will		set_my_state_do
17913e3f4d6SMark Murray #define	set_his_want_state_do		set_my_want_state_will
18013e3f4d6SMark Murray #define	set_his_want_state_will		set_my_want_state_do
18113e3f4d6SMark Murray 
18213e3f4d6SMark Murray #define	set_his_state_dont		set_my_state_wont
18313e3f4d6SMark Murray #define	set_his_state_wont		set_my_state_dont
18413e3f4d6SMark Murray #define	set_his_want_state_dont		set_my_want_state_wont
18513e3f4d6SMark Murray #define	set_his_want_state_wont		set_my_want_state_dont
18613e3f4d6SMark Murray 
18713e3f4d6SMark Murray #define his_will_wont_is_changing	my_do_dont_is_changing
18813e3f4d6SMark Murray #define his_do_dont_is_changing		my_will_wont_is_changing
18913e3f4d6SMark Murray 
19013e3f4d6SMark Murray #endif /* __DEFS_H__ */
191