defs.h revision 233294
1139749Simp/*
2102445Sjhb * Copyright (c) 1989, 1993
3102445Sjhb *	The Regents of the University of California.  All rights reserved.
4102445Sjhb *
5102445Sjhb * Redistribution and use in source and binary forms, with or without
6102445Sjhb * modification, are permitted provided that the following conditions
7102445Sjhb * are met:
8102445Sjhb * 1. Redistributions of source code must retain the above copyright
9102445Sjhb *    notice, this list of conditions and the following disclaimer.
10102445Sjhb * 2. Redistributions in binary form must reproduce the above copyright
11102445Sjhb *    notice, this list of conditions and the following disclaimer in the
12102445Sjhb *    documentation and/or other materials provided with the distribution.
13102445Sjhb * 3. All advertising materials mentioning features or use of this software
14102445Sjhb *    must display the following acknowledgement:
15102445Sjhb *	This product includes software developed by the University of
16102445Sjhb *	California, Berkeley and its contributors.
17102445Sjhb * 4. Neither the name of the University nor the names of its contributors
18102445Sjhb *    may be used to endorse or promote products derived from this software
19102445Sjhb *    without specific prior written permission.
20102445Sjhb *
21102445Sjhb * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22102445Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23102445Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24102445Sjhb * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25102445Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26102445Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27102445Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28102445Sjhb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29119418Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30119418Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31119418Sobrien * SUCH DAMAGE.
32259512Skib *
33259512Skib *	@(#)defs.h	8.1 (Berkeley) 6/4/93
34102445Sjhb */
35102445Sjhb
36102445Sjhb/*
37102445Sjhb * Telnet server defines
38102445Sjhb */
39102445Sjhb
40102445Sjhb#ifndef __DEFS_H__
41193530Sjkim#define __DEFS_H__
42193530Sjkim
43193530Sjkim#ifndef	BSD
44102445Sjhb# define	BSD 43
45102445Sjhb#endif
46102445Sjhb
47102445Sjhb#if defined(PRINTOPTIONS) && defined(DIAGNOSTICS)
48102445Sjhb#define TELOPTS
49102445Sjhb#define TELCMDS
50102445Sjhb#define	SLC_NAMES
51102445Sjhb#endif
52102445Sjhb
53102445Sjhb#if	!defined(TIOCSCTTY) && defined(TCSETCTTY)
54129829Snjl# define	TIOCSCTTY TCSETCTTY
55102445Sjhb#endif
56102445Sjhb
57102445Sjhb#ifndef TIOCPKT_FLUSHWRITE
58102445Sjhb#define TIOCPKT_FLUSHWRITE      0x02
59129829Snjl#endif
60129829Snjl
61131341Snjl#ifndef TIOCPKT_NOSTOP
62102445Sjhb#define TIOCPKT_NOSTOP  0x10
63102445Sjhb#endif
64133619Snjl
65133619Snjl#ifndef TIOCPKT_DOSTOP
66138200Snjl#define TIOCPKT_DOSTOP  0x20
67138200Snjl#endif
68138200Snjl
69138200Snjl/*
70138200Snjl * I/O data buffers defines
71138200Snjl */
72130978Sjhb#define	NETSLOP	64
73130978Sjhb#ifdef _CRAY
74130978Sjhb#undef BUFSIZ
75102445Sjhb#define BUFSIZ  2048
76102445Sjhb#endif
77129829Snjl
78131341Snjl#define	NIACCUM(c)	{   *netip++ = c; \
79131341Snjl			    ncc++; \
80130978Sjhb			}
81130978Sjhb
82102445Sjhb/* clock manipulations */
83129829Snjl#define	settimer(x)	(clocks.x = ++clocks.system)
84130978Sjhb#define	sequenceIs(x,y)	(clocks.x < clocks.y)
85259512Skib
86102445Sjhb/*
87102445Sjhb * Structures of information for each special character function.
88102445Sjhb */
89102445Sjhbtypedef struct {
90102445Sjhb	unsigned char	flag;		/* the flags for this function */
91102445Sjhb	cc_t		val;		/* the value of the special character */
92102445Sjhb} slcent, *Slcent;
93102445Sjhb
94131341Snjltypedef struct {
95127680Stakawata	slcent		defset;		/* the default settings */
96259512Skib	slcent		current;	/* the current settings */
97102445Sjhb	cc_t		*sptr;		/* a pointer to the char in */
98102445Sjhb					/* system data structures */
99128016Sjhb} slcfun, *Slcfun;
100102445Sjhb
101246128Ssbz#ifdef DIAGNOSTICS
102102445Sjhb/*
103102445Sjhb * Diagnostics capabilities
104154600Sjhb */
105102445Sjhb#define	TD_REPORT	0x01	/* Report operations to client */
106232403Sjhb#define TD_EXERCISE	0x02	/* Exercise client's implementation */
107232403Sjhb#define TD_NETDATA	0x04	/* Display received data stream */
108102445Sjhb#define TD_PTYDATA	0x08	/* Display data passed to pty */
109128071Snjl#define	TD_OPTIONS	0x10	/* Report just telnet options */
110128071Snjl#endif /* DIAGNOSTICS */
111102445Sjhb
112102445Sjhb/*
113102445Sjhb * We keep track of each side of the option negotiation.
114102445Sjhb */
115102445Sjhb
116102445Sjhb#define	MY_STATE_WILL		0x01
117102445Sjhb#define	MY_WANT_STATE_WILL	0x02
118131341Snjl#define	MY_STATE_DO		0x04
119102445Sjhb#define	MY_WANT_STATE_DO	0x08
120127681Snjl
121102445Sjhb/*
122127681Snjl * Macros to check the current state of things
123131341Snjl */
124131341Snjl
125131341Snjl#define	my_state_is_do(opt)		(options[opt]&MY_STATE_DO)
126102445Sjhb#define	my_state_is_will(opt)		(options[opt]&MY_STATE_WILL)
127127681Snjl#define my_want_state_is_do(opt)	(options[opt]&MY_WANT_STATE_DO)
128102445Sjhb#define my_want_state_is_will(opt)	(options[opt]&MY_WANT_STATE_WILL)
129102445Sjhb
130127680Stakawata#define	my_state_is_dont(opt)		(!my_state_is_do(opt))
131131341Snjl#define	my_state_is_wont(opt)		(!my_state_is_will(opt))
132131341Snjl#define my_want_state_is_dont(opt)	(!my_want_state_is_do(opt))
133131341Snjl#define my_want_state_is_wont(opt)	(!my_want_state_is_will(opt))
134131341Snjl
135131341Snjl#define	set_my_state_do(opt)		(options[opt] |= MY_STATE_DO)
136131341Snjl#define	set_my_state_will(opt)		(options[opt] |= MY_STATE_WILL)
137131341Snjl#define	set_my_want_state_do(opt)	(options[opt] |= MY_WANT_STATE_DO)
138131341Snjl#define	set_my_want_state_will(opt)	(options[opt] |= MY_WANT_STATE_WILL)
139131341Snjl
140131341Snjl#define	set_my_state_dont(opt)		(options[opt] &= ~MY_STATE_DO)
141131341Snjl#define	set_my_state_wont(opt)		(options[opt] &= ~MY_STATE_WILL)
142131341Snjl#define	set_my_want_state_dont(opt)	(options[opt] &= ~MY_WANT_STATE_DO)
143131341Snjl#define	set_my_want_state_wont(opt)	(options[opt] &= ~MY_WANT_STATE_WILL)
144131341Snjl
145131341Snjl/*
146131341Snjl * Tricky code here.  What we want to know is if the MY_STATE_WILL
147131341Snjl * and MY_WANT_STATE_WILL bits have the same value.  Since the two
148127680Stakawata * bits are adjacent, a little arithmatic will show that by adding
149127680Stakawata * in the lower bit, the upper bit will be set if the two bits were
150127680Stakawata * different, and clear if they were the same.
151127680Stakawata */
152127681Snjl#define my_will_wont_is_changing(opt) \
153127680Stakawata			((options[opt]+MY_STATE_WILL) & MY_WANT_STATE_WILL)
154127680Stakawata
155127681Snjl#define my_do_dont_is_changing(opt) \
156132136Stakawata			((options[opt]+MY_STATE_DO) & MY_WANT_STATE_DO)
157127680Stakawata
158127680Stakawata/*
159127680Stakawata * Make everything symmetrical
160127680Stakawata */
161127680Stakawata
162102445Sjhb#define	HIS_STATE_WILL			MY_STATE_DO
163102445Sjhb#define	HIS_WANT_STATE_WILL		MY_WANT_STATE_DO
164102445Sjhb#define HIS_STATE_DO			MY_STATE_WILL
165102445Sjhb#define HIS_WANT_STATE_DO		MY_WANT_STATE_WILL
166102445Sjhb
167102445Sjhb#define	his_state_is_do			my_state_is_will
168128247Snjl#define	his_state_is_will		my_state_is_do
169128016Sjhb#define his_want_state_is_do		my_want_state_is_will
170138200Snjl#define his_want_state_is_will		my_want_state_is_do
171102445Sjhb
172133619Snjl#define	his_state_is_dont		my_state_is_wont
173138200Snjl#define	his_state_is_wont		my_state_is_dont
174128016Sjhb#define his_want_state_is_dont		my_want_state_is_wont
175128016Sjhb#define his_want_state_is_wont		my_want_state_is_dont
176128016Sjhb
177128016Sjhb#define	set_his_state_do		set_my_state_will
178128016Sjhb#define	set_his_state_will		set_my_state_do
179128016Sjhb#define	set_his_want_state_do		set_my_want_state_will
180128016Sjhb#define	set_his_want_state_will		set_my_want_state_do
181128016Sjhb
182128016Sjhb#define	set_his_state_dont		set_my_state_wont
183128016Sjhb#define	set_his_state_wont		set_my_state_dont
184128016Sjhb#define	set_his_want_state_dont		set_my_want_state_wont
185133619Snjl#define	set_his_want_state_wont		set_my_want_state_dont
186128016Sjhb
187214110Sjkim#define his_will_wont_is_changing	my_do_dont_is_changing
188128016Sjhb#define his_do_dont_is_changing		my_will_wont_is_changing
189128016Sjhb
190133619Snjl#endif /* __DEFS_H__ */
191128016Sjhb