// // Wunderland Mudlib // // telnet.h -- Standard telnet definitions // // $Log: telnetneg.h,v $ // Revision 1.1.1.1 2006/07/10 02:42:09 lynx // ldmud 3.3.714 // // Revision 1.10 2002/12/02 17:31:56 Fiona // sb_ttype und sb_xdisp // #ifndef __TELNET_H__ #define __TELNET_H__ // ******************** Telnet State Machine ******************** // Each option could be in one of the following four states. There // is also a one element queue for each option. Mind that each option // could have different states for the lokal and the remote system. // Six bits of TS_STATE are used. #define NO 0x00 // option is deactivated #define YES 0x01 // option is activated #define WANT_NO 0x02 // option is activated, negotiating to switch off #define WANT_YES 0x03 // option is deactivated, negotiating to switch on #define Q_EMPTY 0x00 // no entry in queue #define Q_OPPOSITE 0x04 // request to toggle state in queue #define REJECTED 0x08 // option denied, don't retry // State and queue on the remote side (DO + DONT) (bits 0-3) #define Q_REMOTE(x) ((x) & 0x03) #define S_REMOTE(x, y) (((x) & ~0x03) | (y)) #define Q_REMOTEQ(x) ((x) & 0x04) #define S_REMOTEQ(x, y) (((x) & ~0x04) | (y)) #define Q_REMOTER(x) ((x) & 0x08) #define S_REMOTER(x, y) (((x) & ~0x08) | (y)) // State and queue on this side (WILL + WONT) (bits 4-7) #define Q_LOCAL(x) (((x) & 0x30) >> 4) #define S_LOCAL(x,y) (((x) & ~0x30) | ((y) << 4)) #define Q_LOCALQ(x) (((x) & 0x40) >> 4) #define S_LOCALQ(x, y) (((x) & ~0x40) | ((y) << 4)) #define Q_LOCALR(x) (((x) & 0x80) >> 4) #define S_LOCALR(x, y) (((x) & ~0x80) | ((y) << 4)) // Access to mapping ts #define TS_STATE 0 // option state (yes, no, want yes, want no, Q) #define TS_SB 1 // sb infos (option specific) #define TS_R_AGREE 2 // preference or decision callback (remote state) #define TS_L_AGREE 3 // preference or decision callback (local state) #define TS_CB 4 // option state change callback (yes, no) #define TS_SBCB 5 // option sb callback #define TS_SIZE 6 // To have everything in one place we have one special key in ts #define TS_EXTRA -1 // key #define TSE_STATE 0 // input_to's INPUT_NOECHO and/or INPUT_CHARMODE #define TSE_TELNETNEG 1 // client answered a negotiation #define TSE_LOG 2 // negotiation log // Bits used for the charmode and noecho state of the connection // Bits 0 + 1 used for TSE_NOECHO (set for noecho mode) // Bits 2 + 3 used for TSE_SGA_CHAR (set for charmode using SGA) // Bits 4 + 5 used for TSE_LM_CHAR (set for charmode using LINEMODE) // each representing the state with NO, YES, WANT_NO and WANT_YES #define Q_TSE_NOECHO ((ts[TS_EXTRA, TSE_STATE]) & 0x03) #define S_TSE_NOECHO(y) (ts[TS_EXTRA, TSE_STATE] = \ ((ts[TS_EXTRA, TSE_STATE]) & ~0x03) | (y)) #define Q_TSE_SGA_CHAR (((ts[TS_EXTRA, TSE_STATE]) & 0x0c) >> 2) #define S_TSE_SGA_CHAR(y) (ts[TS_EXTRA, TSE_STATE] = \ ((ts[TS_EXTRA, TSE_STATE]) & ~0x0c) | ((y) << 2)) #define Q_TSE_LM_CHAR (((ts[TS_EXTRA, TSE_STATE]) & 0x30) >> 4) #define S_TSE_LM_CHAR(y) (ts[TS_EXTRA, TSE_STATE] = \ ((ts[TS_EXTRA, TSE_STATE]) & ~0x30) | ((y) << 4)) #ifdef NEED_PRIVATE_PROTOTYPES #ifndef __TELNET_H_P_PROTO__ #define __TELNET_H_P_PROTO__ private int send(int* x); private void tel_error(string err); private void start_telnetneg(); private string telnet_to_text(int command, int option, int* args); private void sb_ttype(int command, int option, int* optargs); private void sb_xdisp(int command, int option, int* optargs); private void sb_tspeed(int command, int option, int* optargs); private void sb_env(int command, int option, int* optargs); private void sb_naws(int command, int option, int* optargs); private void sb_status(int command, int option, int* optargs); private void sb_line(int command, int option, int* optargs); private int neg_sga(int command, int option); private int neg_echo(int command, int option); private int neg_bin(int command, int option); private int neg_tm(int command, int option); private void start_sb(int command, int option); private void start_eor(int command, int option); private void start_lm(int command, int option); private void cb_echo(int command, int option); private void cb_sga(int command, int option); static void modify_prompt(); // std/player/prompt.c #endif #endif // NEED_PRIVATE_PROTOTYPES // ************ Definitions for the TELNET protocol ************* #define IAC 255 /* interpret as command: */ #define DONT 254 /* you are not to use option */ #define DO 253 /* please, you use option */ #define WONT 252 /* I won't use option */ #define WILL 251 /* I will use option */ #define SB 250 /* interpret as subnegotiation */ #define SE 240 /* end sub negotiation */ #define EOR 239 /* end of record (transparent mode) */ #define TELCMDS ({\ "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",\ "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",\ }) /* backward starting with IAC == 255 */ #define TELCMD2STRING(x) (((256-x)