Path: blob/main/crypto/heimdal/appl/telnet/telnetd/defs.h
34889 views
/*1* Copyright (c) 1989, 19932* The Regents of the University of California. All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. All advertising materials mentioning features or use of this software13* must display the following acknowledgement:14* This product includes software developed by the University of15* California, Berkeley and its contributors.16* 4. Neither the name of the University nor the names of its contributors17* may be used to endorse or promote products derived from this software18* without specific prior written permission.19*20* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*32* @(#)defs.h 8.1 (Berkeley) 6/4/9333*/3435/*36* Telnet server defines37*/3839#ifndef __DEFS_H__40#define __DEFS_H__4142#ifndef BSD43# define BSD 4344#endif4546#if defined(PRINTOPTIONS) && defined(DIAGNOSTICS)47#define TELOPTS48#define TELCMDS49#define SLC_NAMES50#endif5152#if !defined(TIOCSCTTY) && defined(TCSETCTTY)53# define TIOCSCTTY TCSETCTTY54#endif5556#ifndef TIOCPKT_FLUSHWRITE57#define TIOCPKT_FLUSHWRITE 0x0258#endif5960#ifndef TIOCPKT_NOSTOP61#define TIOCPKT_NOSTOP 0x1062#endif6364#ifndef TIOCPKT_DOSTOP65#define TIOCPKT_DOSTOP 0x2066#endif6768/*69* I/O data buffers defines70*/71#define NETSLOP 6472#ifdef _CRAY73#undef BUFSIZ74#define BUFSIZ 204875#endif7677#define NIACCUM(c) { *netip++ = c; \78ncc++; \79}8081/* clock manipulations */82#define settimer(x) (clocks.x = ++clocks.system)83#define sequenceIs(x,y) (clocks.x < clocks.y)8485/*86* Structures of information for each special character function.87*/88typedef struct {89unsigned char flag; /* the flags for this function */90cc_t val; /* the value of the special character */91} slcent, *Slcent;9293typedef struct {94slcent defset; /* the default settings */95slcent current; /* the current settings */96cc_t *sptr; /* a pointer to the char in */97/* system data structures */98} slcfun, *Slcfun;99100#ifdef DIAGNOSTICS101/*102* Diagnostics capabilities103*/104#define TD_REPORT 0x01 /* Report operations to client */105#define TD_EXERCISE 0x02 /* Exercise client's implementation */106#define TD_NETDATA 0x04 /* Display received data stream */107#define TD_PTYDATA 0x08 /* Display data passed to pty */108#define TD_OPTIONS 0x10 /* Report just telnet options */109#endif /* DIAGNOSTICS */110111/*112* We keep track of each side of the option negotiation.113*/114115#define MY_STATE_WILL 0x01116#define MY_WANT_STATE_WILL 0x02117#define MY_STATE_DO 0x04118#define MY_WANT_STATE_DO 0x08119120/*121* Macros to check the current state of things122*/123124#define my_state_is_do(opt) (options[opt]&MY_STATE_DO)125#define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)126#define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)127#define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)128129#define my_state_is_dont(opt) (!my_state_is_do(opt))130#define my_state_is_wont(opt) (!my_state_is_will(opt))131#define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))132#define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))133134#define set_my_state_do(opt) (options[opt] |= MY_STATE_DO)135#define set_my_state_will(opt) (options[opt] |= MY_STATE_WILL)136#define set_my_want_state_do(opt) (options[opt] |= MY_WANT_STATE_DO)137#define set_my_want_state_will(opt) (options[opt] |= MY_WANT_STATE_WILL)138139#define set_my_state_dont(opt) (options[opt] &= ~MY_STATE_DO)140#define set_my_state_wont(opt) (options[opt] &= ~MY_STATE_WILL)141#define set_my_want_state_dont(opt) (options[opt] &= ~MY_WANT_STATE_DO)142#define set_my_want_state_wont(opt) (options[opt] &= ~MY_WANT_STATE_WILL)143144/*145* Tricky code here. What we want to know is if the MY_STATE_WILL146* and MY_WANT_STATE_WILL bits have the same value. Since the two147* bits are adjacent, a little arithmatic will show that by adding148* in the lower bit, the upper bit will be set if the two bits were149* different, and clear if they were the same.150*/151#define my_will_wont_is_changing(opt) \152((options[opt]+MY_STATE_WILL) & MY_WANT_STATE_WILL)153154#define my_do_dont_is_changing(opt) \155((options[opt]+MY_STATE_DO) & MY_WANT_STATE_DO)156157/*158* Make everything symmetrical159*/160161#define HIS_STATE_WILL MY_STATE_DO162#define HIS_WANT_STATE_WILL MY_WANT_STATE_DO163#define HIS_STATE_DO MY_STATE_WILL164#define HIS_WANT_STATE_DO MY_WANT_STATE_WILL165166#define his_state_is_do my_state_is_will167#define his_state_is_will my_state_is_do168#define his_want_state_is_do my_want_state_is_will169#define his_want_state_is_will my_want_state_is_do170171#define his_state_is_dont my_state_is_wont172#define his_state_is_wont my_state_is_dont173#define his_want_state_is_dont my_want_state_is_wont174#define his_want_state_is_wont my_want_state_is_dont175176#define set_his_state_do set_my_state_will177#define set_his_state_will set_my_state_do178#define set_his_want_state_do set_my_want_state_will179#define set_his_want_state_will set_my_want_state_do180181#define set_his_state_dont set_my_state_wont182#define set_his_state_wont set_my_state_dont183#define set_his_want_state_dont set_my_want_state_wont184#define set_his_want_state_wont set_my_want_state_dont185186#define his_will_wont_is_changing my_do_dont_is_changing187#define his_do_dont_is_changing my_will_wont_is_changing188189#endif /* __DEFS_H__ */190191192