/****************************************************************************** * This file is part of a software distribution, which is furnished under the * * terms of a license. Use of this software by any means is subject to this * * license and signifies the acceptance of the licensing terms stated * * therein. Please see the file LICENSE in the top-level directory of this * * software distribution for detailed copyright disclaimers and licensing * * terms. * ****************************************************************************** * Copryight (c) by Andreas S. Wetzel - All rights reserved. * ******************************************************************************/ /* $Id: if_telnet.h,v 1.2 2001/03/19 14:54:06 mickey Exp $ */ #ifndef __IF_TELNET_H__ #define __IF_TELNET_H__ #include /*-------------------------------------------* | Yuck! SunOS seems to be a bit out of date | | with its options in | *-------------------------------------------*/ #ifndef ABORT #define ABORT 238 #endif #ifndef SUSP #define SUSP 237 #endif #ifndef xEOF #define xEOF 236 #endif #ifndef TELOPT_NAWS #define TELOPT_NAWS 31 #endif #ifndef TELOPT_NEW_ENVIRON #define TELOPT_NEW_ENVIRON 39 #endif /*----------------------------------------------* | Some makros to deal with TELNET option names | *----------------------------------------------*/ #define NTOPTS (1+TELOPT_NEW_ENVIRON) #define TOPT_FIRST TELOPT_BINARY #define TOPT_LAST TELOPT_NEW_ENVIRON #define TOPT_OK(x) ((unsigned int)(x) <= TOPT_LAST) #define TOPT(x) topts[(x)-TOPT_FIRST] /*-----------------------------------* | Operating states of tel_filter(); | *-----------------------------------*/ #define MODE_DATA 0x00 #define MODE_IAC 0x01 #define MODE_WILL 0x02 #define MODE_WONT 0x04 #define MODE_DO 0x08 #define MODE_DONT 0x10 #define MODE_SB 0x20 #define MODE_SE 0x40 /*---------------------------* | Telnet option state masks | *---------------------------*/ #define STATE_DO 0x01 #define WANT_STATE_DO 0x02 #define STATE_WILL 0x04 #define WANT_STATE_WILL 0x08 /*--------------------------------* | Makros to deal with suboptions | *--------------------------------*/ #define SUB_BUFSIZE 256 #define SUB_CLEAR() (sub_bufptr = &subopt_buf[0]) #define SUB_STORE(c) if(sub_bufptr < (u_char *)(subopt_buf + SUB_BUFSIZE)) \ { *sub_bufptr++ = (u_char) c; } #define SUB_FLUSH() {sub_endptr = sub_bufptr; SUB_CLEAR(); } #define SUB_GET() ((*sub_bufptr++) & 0xff) #define SUB_EOF() (sub_bufptr >= sub_endptr) #define SUB_LEN() (sub_endptr - sub_bufptr) /*----------------------------------* | Macros to check&set option state | *----------------------------------*/ #define MY_STATE_DO STATE_DO #define MY_STATE_WILL STATE_WILL #define MY_WANT_STATE_DO WANT_STATE_DO #define MY_WANT_STATE_WILL WANT_STATE_WILL #define HIS_STATE_DO STATE_WILL #define HIS_STATE_WILL STATE_DO #define HIS_WANT_STATE_DO WANT_STATE_WILL #define HIS_WANT_STATE_WILL WANT_STATE_DO #define my_state_is_do(opt) (tel_option[opt] & STATE_DO) #define my_state_is_will(opt) (tel_option[opt] & STATE_WILL) #define my_want_state_is_do(opt) (tel_option[opt] & WANT_STATE_DO) #define my_want_state_is_will(opt) (tel_option[opt] & WANT_STATE_WILL) #define his_state_is_do my_state_is_will #define his_state_is_will my_state_is_do #define his_want_state_is_do my_want_state_is_will #define his_want_state_is_will my_want_state_is_do #define my_state_is_dont(opt) (!my_state_is_do(opt)) #define my_state_is_wont(opt) (!my_state_is_will(opt)) #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) #define his_state_is_dont my_state_is_wont #define his_state_is_wont my_state_is_dont #define his_want_state_is_dont my_want_state_is_wont #define his_want_state_is_wont my_want_state_is_dont #define set_my_state_do(opt) (tel_option[opt] |= STATE_DO) #define set_my_state_will(opt) (tel_option[opt] |= STATE_WILL) #define set_my_want_state_do(opt) (tel_option[opt] |= WANT_STATE_DO) #define set_my_want_state_will(opt) (tel_option[opt] |= WANT_STATE_WILL) #define set_his_state_do set_my_state_will #define set_his_state_will set_my_state_do #define set_his_want_state_do set_my_want_state_will #define set_his_want_state_will set_my_want_state_do #define set_my_state_dont(opt) (tel_option[opt] &= ~STATE_DO) #define set_my_state_wont(opt) (tel_option[opt] &= ~STATE_WILL) #define set_my_want_state_dont(opt) (tel_option[opt] &= ~WANT_STATE_DO) #define set_my_want_state_wont(opt) (tel_option[opt] &= ~WANT_STATE_WILL) #define set_his_state_dont set_my_state_wont #define set_his_state_wont set_my_state_dont #define set_his_want_state_dont set_my_want_state_wont #define set_his_want_state_wont set_my_want_state_dont #define my_will_wont_differs(opt) ((tel_option[opt] + STATE_WILL) & WANT_STATE_WILL) #define my_do_dont_differs(opt) ((tel_option[opt] + STATE_DO) & WANT_STATE_DO) #define his_will_wont_differs my_do_dont_differs #define his_do_dont_differs my_will_wont_differs #endif /* __IF_TELNET_H__ */