157416Smarkm/* 257416Smarkm * Copyright (c) 1989, 1993 357416Smarkm * The Regents of the University of California. All rights reserved. 457416Smarkm * 557416Smarkm * Redistribution and use in source and binary forms, with or without 657416Smarkm * modification, are permitted provided that the following conditions 757416Smarkm * are met: 857416Smarkm * 1. Redistributions of source code must retain the above copyright 957416Smarkm * notice, this list of conditions and the following disclaimer. 1057416Smarkm * 2. Redistributions in binary form must reproduce the above copyright 1157416Smarkm * notice, this list of conditions and the following disclaimer in the 1257416Smarkm * documentation and/or other materials provided with the distribution. 1357416Smarkm * 3. All advertising materials mentioning features or use of this software 1457416Smarkm * must display the following acknowledgement: 1557416Smarkm * This product includes software developed by the University of 1657416Smarkm * California, Berkeley and its contributors. 1757416Smarkm * 4. Neither the name of the University nor the names of its contributors 1857416Smarkm * may be used to endorse or promote products derived from this software 1957416Smarkm * without specific prior written permission. 2057416Smarkm * 2157416Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2257416Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2357416Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2457416Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2557416Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2657416Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2757416Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2857416Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2957416Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3057416Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3157416Smarkm * SUCH DAMAGE. 3257416Smarkm * 3357416Smarkm * @(#)defs.h 8.1 (Berkeley) 6/4/93 3457416Smarkm */ 3557416Smarkm 3657416Smarkm/* 3757416Smarkm * Telnet server defines 3857416Smarkm */ 3957416Smarkm 4057416Smarkm#ifndef __DEFS_H__ 4157416Smarkm#define __DEFS_H__ 4257416Smarkm 4357416Smarkm#ifndef BSD 4457416Smarkm# define BSD 43 4557416Smarkm#endif 4657416Smarkm 4757416Smarkm#if defined(PRINTOPTIONS) && defined(DIAGNOSTICS) 4857416Smarkm#define TELOPTS 4957416Smarkm#define TELCMDS 5057416Smarkm#define SLC_NAMES 5157416Smarkm#endif 5257416Smarkm 5357416Smarkm#if !defined(TIOCSCTTY) && defined(TCSETCTTY) 5457416Smarkm# define TIOCSCTTY TCSETCTTY 5557416Smarkm#endif 5657416Smarkm 5757416Smarkm#ifndef TIOCPKT_FLUSHWRITE 5857416Smarkm#define TIOCPKT_FLUSHWRITE 0x02 5957416Smarkm#endif 60233294Sstas 6157416Smarkm#ifndef TIOCPKT_NOSTOP 6257416Smarkm#define TIOCPKT_NOSTOP 0x10 6357416Smarkm#endif 64233294Sstas 6557416Smarkm#ifndef TIOCPKT_DOSTOP 6657416Smarkm#define TIOCPKT_DOSTOP 0x20 6757416Smarkm#endif 6857416Smarkm 6957416Smarkm/* 7057416Smarkm * I/O data buffers defines 7157416Smarkm */ 7257416Smarkm#define NETSLOP 64 7357416Smarkm#ifdef _CRAY 7457416Smarkm#undef BUFSIZ 7557416Smarkm#define BUFSIZ 2048 7657416Smarkm#endif 7757416Smarkm 7857416Smarkm#define NIACCUM(c) { *netip++ = c; \ 7957416Smarkm ncc++; \ 8057416Smarkm } 8157416Smarkm 8257416Smarkm/* clock manipulations */ 8357416Smarkm#define settimer(x) (clocks.x = ++clocks.system) 8457416Smarkm#define sequenceIs(x,y) (clocks.x < clocks.y) 8557416Smarkm 8657416Smarkm/* 8757416Smarkm * Structures of information for each special character function. 8857416Smarkm */ 8957416Smarkmtypedef struct { 9057416Smarkm unsigned char flag; /* the flags for this function */ 9157416Smarkm cc_t val; /* the value of the special character */ 9257416Smarkm} slcent, *Slcent; 9357416Smarkm 9457416Smarkmtypedef struct { 9557416Smarkm slcent defset; /* the default settings */ 9657416Smarkm slcent current; /* the current settings */ 9757416Smarkm cc_t *sptr; /* a pointer to the char in */ 9857416Smarkm /* system data structures */ 9957416Smarkm} slcfun, *Slcfun; 10057416Smarkm 10157416Smarkm#ifdef DIAGNOSTICS 10257416Smarkm/* 10357416Smarkm * Diagnostics capabilities 10457416Smarkm */ 10557416Smarkm#define TD_REPORT 0x01 /* Report operations to client */ 10657416Smarkm#define TD_EXERCISE 0x02 /* Exercise client's implementation */ 10757416Smarkm#define TD_NETDATA 0x04 /* Display received data stream */ 10857416Smarkm#define TD_PTYDATA 0x08 /* Display data passed to pty */ 10957416Smarkm#define TD_OPTIONS 0x10 /* Report just telnet options */ 11057416Smarkm#endif /* DIAGNOSTICS */ 11157416Smarkm 11257416Smarkm/* 11357416Smarkm * We keep track of each side of the option negotiation. 11457416Smarkm */ 11557416Smarkm 11657416Smarkm#define MY_STATE_WILL 0x01 11757416Smarkm#define MY_WANT_STATE_WILL 0x02 11857416Smarkm#define MY_STATE_DO 0x04 11957416Smarkm#define MY_WANT_STATE_DO 0x08 12057416Smarkm 12157416Smarkm/* 12257416Smarkm * Macros to check the current state of things 12357416Smarkm */ 12457416Smarkm 12557416Smarkm#define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 12657416Smarkm#define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 12757416Smarkm#define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 12857416Smarkm#define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 12957416Smarkm 13057416Smarkm#define my_state_is_dont(opt) (!my_state_is_do(opt)) 13157416Smarkm#define my_state_is_wont(opt) (!my_state_is_will(opt)) 13257416Smarkm#define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 13357416Smarkm#define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 13457416Smarkm 13557416Smarkm#define set_my_state_do(opt) (options[opt] |= MY_STATE_DO) 13657416Smarkm#define set_my_state_will(opt) (options[opt] |= MY_STATE_WILL) 13757416Smarkm#define set_my_want_state_do(opt) (options[opt] |= MY_WANT_STATE_DO) 13857416Smarkm#define set_my_want_state_will(opt) (options[opt] |= MY_WANT_STATE_WILL) 13957416Smarkm 14057416Smarkm#define set_my_state_dont(opt) (options[opt] &= ~MY_STATE_DO) 14157416Smarkm#define set_my_state_wont(opt) (options[opt] &= ~MY_STATE_WILL) 14257416Smarkm#define set_my_want_state_dont(opt) (options[opt] &= ~MY_WANT_STATE_DO) 14357416Smarkm#define set_my_want_state_wont(opt) (options[opt] &= ~MY_WANT_STATE_WILL) 14457416Smarkm 14557416Smarkm/* 14657416Smarkm * Tricky code here. What we want to know is if the MY_STATE_WILL 14757416Smarkm * and MY_WANT_STATE_WILL bits have the same value. Since the two 14857416Smarkm * bits are adjacent, a little arithmatic will show that by adding 14957416Smarkm * in the lower bit, the upper bit will be set if the two bits were 15057416Smarkm * different, and clear if they were the same. 15157416Smarkm */ 15257416Smarkm#define my_will_wont_is_changing(opt) \ 15357416Smarkm ((options[opt]+MY_STATE_WILL) & MY_WANT_STATE_WILL) 15457416Smarkm 15557416Smarkm#define my_do_dont_is_changing(opt) \ 15657416Smarkm ((options[opt]+MY_STATE_DO) & MY_WANT_STATE_DO) 15757416Smarkm 15857416Smarkm/* 15990926Snectar * Make everything symmetrical 16057416Smarkm */ 16157416Smarkm 16257416Smarkm#define HIS_STATE_WILL MY_STATE_DO 16357416Smarkm#define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 16457416Smarkm#define HIS_STATE_DO MY_STATE_WILL 16557416Smarkm#define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 16657416Smarkm 16757416Smarkm#define his_state_is_do my_state_is_will 16857416Smarkm#define his_state_is_will my_state_is_do 16957416Smarkm#define his_want_state_is_do my_want_state_is_will 17057416Smarkm#define his_want_state_is_will my_want_state_is_do 17157416Smarkm 17257416Smarkm#define his_state_is_dont my_state_is_wont 17357416Smarkm#define his_state_is_wont my_state_is_dont 17457416Smarkm#define his_want_state_is_dont my_want_state_is_wont 17557416Smarkm#define his_want_state_is_wont my_want_state_is_dont 17657416Smarkm 17757416Smarkm#define set_his_state_do set_my_state_will 17857416Smarkm#define set_his_state_will set_my_state_do 17957416Smarkm#define set_his_want_state_do set_my_want_state_will 18057416Smarkm#define set_his_want_state_will set_my_want_state_do 18157416Smarkm 18257416Smarkm#define set_his_state_dont set_my_state_wont 18357416Smarkm#define set_his_state_wont set_my_state_dont 18457416Smarkm#define set_his_want_state_dont set_my_want_state_wont 18557416Smarkm#define set_his_want_state_wont set_my_want_state_dont 18657416Smarkm 18757416Smarkm#define his_will_wont_is_changing my_do_dont_is_changing 18857416Smarkm#define his_do_dont_is_changing my_will_wont_is_changing 18957416Smarkm 19057416Smarkm#endif /* __DEFS_H__ */ 191