telnet.h revision 109467
11539Srgrimes/* 21539Srgrimes * Copyright (c) 1983, 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * 51539Srgrimes * Redistribution and use in source and binary forms, with or without 61539Srgrimes * modification, are permitted provided that the following conditions 71539Srgrimes * are met: 81539Srgrimes * 1. Redistributions of source code must retain the above copyright 91539Srgrimes * notice, this list of conditions and the following disclaimer. 101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111539Srgrimes * notice, this list of conditions and the following disclaimer in the 121539Srgrimes * documentation and/or other materials provided with the distribution. 131539Srgrimes * 3. All advertising materials mentioning features or use of this software 141539Srgrimes * must display the following acknowledgement: 151539Srgrimes * This product includes software developed by the University of 161539Srgrimes * California, Berkeley and its contributors. 171539Srgrimes * 4. Neither the name of the University nor the names of its contributors 181539Srgrimes * may be used to endorse or promote products derived from this software 191539Srgrimes * without specific prior written permission. 201539Srgrimes * 211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311539Srgrimes * SUCH DAMAGE. 321539Srgrimes * 331539Srgrimes * @(#)telnet.h 8.2 (Berkeley) 12/15/93 3472092Sasmodai * $FreeBSD: head/include/arpa/telnet.h 109467 2003-01-18 06:13:57Z billf $ 351539Srgrimes */ 361539Srgrimes 372163Spaul#ifndef _ARPA_TELNET_H_ 382163Spaul#define _ARPA_TELNET_H_ 391539Srgrimes 401539Srgrimes/* 411539Srgrimes * Definitions for the TELNET protocol. 421539Srgrimes */ 431539Srgrimes#define IAC 255 /* interpret as command: */ 441539Srgrimes#define DONT 254 /* you are not to use option */ 451539Srgrimes#define DO 253 /* please, you use option */ 461539Srgrimes#define WONT 252 /* I won't use option */ 471539Srgrimes#define WILL 251 /* I will use option */ 481539Srgrimes#define SB 250 /* interpret as subnegotiation */ 491539Srgrimes#define GA 249 /* you may reverse the line */ 501539Srgrimes#define EL 248 /* erase the current line */ 511539Srgrimes#define EC 247 /* erase the current character */ 521539Srgrimes#define AYT 246 /* are you there */ 531539Srgrimes#define AO 245 /* abort output--but let prog finish */ 541539Srgrimes#define IP 244 /* interrupt process--permanently */ 551539Srgrimes#define BREAK 243 /* break */ 561539Srgrimes#define DM 242 /* data mark--for connect. cleaning */ 571539Srgrimes#define NOP 241 /* nop */ 581539Srgrimes#define SE 240 /* end sub negotiation */ 591539Srgrimes#define EOR 239 /* end of record (transparent mode) */ 601539Srgrimes#define ABORT 238 /* Abort process */ 611539Srgrimes#define SUSP 237 /* Suspend process */ 621539Srgrimes#define xEOF 236 /* End of file: EOF is already used... */ 631539Srgrimes 641539Srgrimes#define SYNCH 242 /* for telfunc calls */ 651539Srgrimes 661539Srgrimes#ifdef TELCMDS 6787268Smarkmconst char *telcmds[] = { 681539Srgrimes "EOF", "SUSP", "ABORT", "EOR", 691539Srgrimes "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", 7020003Sphk "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 7120003Sphk 0 721539Srgrimes}; 731539Srgrimes#else 741539Srgrimesextern char *telcmds[]; 751539Srgrimes#endif 761539Srgrimes 771539Srgrimes#define TELCMD_FIRST xEOF 781539Srgrimes#define TELCMD_LAST IAC 791539Srgrimes#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ 801539Srgrimes (unsigned int)(x) >= TELCMD_FIRST) 811539Srgrimes#define TELCMD(x) telcmds[(x)-TELCMD_FIRST] 821539Srgrimes 831539Srgrimes/* telnet options */ 841539Srgrimes#define TELOPT_BINARY 0 /* 8-bit data path */ 851539Srgrimes#define TELOPT_ECHO 1 /* echo */ 861539Srgrimes#define TELOPT_RCP 2 /* prepare to reconnect */ 871539Srgrimes#define TELOPT_SGA 3 /* suppress go ahead */ 881539Srgrimes#define TELOPT_NAMS 4 /* approximate message size */ 891539Srgrimes#define TELOPT_STATUS 5 /* give status */ 901539Srgrimes#define TELOPT_TM 6 /* timing mark */ 911539Srgrimes#define TELOPT_RCTE 7 /* remote controlled transmission and echo */ 921539Srgrimes#define TELOPT_NAOL 8 /* negotiate about output line width */ 931539Srgrimes#define TELOPT_NAOP 9 /* negotiate about output page size */ 941539Srgrimes#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ 951539Srgrimes#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ 961539Srgrimes#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ 971539Srgrimes#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ 981539Srgrimes#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ 991539Srgrimes#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ 1001539Srgrimes#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ 1011539Srgrimes#define TELOPT_XASCII 17 /* extended ascic character set */ 1021539Srgrimes#define TELOPT_LOGOUT 18 /* force logout */ 1031539Srgrimes#define TELOPT_BM 19 /* byte macro */ 1041539Srgrimes#define TELOPT_DET 20 /* data entry terminal */ 1051539Srgrimes#define TELOPT_SUPDUP 21 /* supdup protocol */ 1061539Srgrimes#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ 1071539Srgrimes#define TELOPT_SNDLOC 23 /* send location */ 1081539Srgrimes#define TELOPT_TTYPE 24 /* terminal type */ 1091539Srgrimes#define TELOPT_EOR 25 /* end or record */ 1101539Srgrimes#define TELOPT_TUID 26 /* TACACS user identification */ 1111539Srgrimes#define TELOPT_OUTMRK 27 /* output marking */ 1121539Srgrimes#define TELOPT_TTYLOC 28 /* terminal location number */ 1131539Srgrimes#define TELOPT_3270REGIME 29 /* 3270 regime */ 1141539Srgrimes#define TELOPT_X3PAD 30 /* X.3 PAD */ 1151539Srgrimes#define TELOPT_NAWS 31 /* window size */ 1161539Srgrimes#define TELOPT_TSPEED 32 /* terminal speed */ 1171539Srgrimes#define TELOPT_LFLOW 33 /* remote flow control */ 1181539Srgrimes#define TELOPT_LINEMODE 34 /* Linemode option */ 1191539Srgrimes#define TELOPT_XDISPLOC 35 /* X Display Location */ 1201539Srgrimes#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ 1211539Srgrimes#define TELOPT_AUTHENTICATION 37/* Authenticate */ 1221539Srgrimes#define TELOPT_ENCRYPT 38 /* Encryption option */ 1231539Srgrimes#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ 124109467Sbillf#define TELOPT_TN3270E 40 /* RFC2355 - TN3270 Enhancements */ 125109467Sbillf#define TELOPT_CHARSET 42 /* RFC2066 - Charset */ 126109467Sbillf#define TELOPT_COMPORT 44 /* RFC2217 - Com Port Control */ 127109467Sbillf#define TELOPT_KERMIT 47 /* RFC2840 - Kermit */ 1281539Srgrimes#define TELOPT_EXOPL 255 /* extended-options-list */ 1291539Srgrimes 1301539Srgrimes 131109467Sbillf#define NTELOPTS (1+TELOPT_KERMIT) 1321539Srgrimes#ifdef TELOPTS 13387268Smarkmconst char *telopts[NTELOPTS+1] = { 1341539Srgrimes "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", 1351539Srgrimes "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", 1361539Srgrimes "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", 1371539Srgrimes "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", 1381539Srgrimes "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", 1391539Srgrimes "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", 1401539Srgrimes "TACACS UID", "OUTPUT MARKING", "TTYLOC", 1411539Srgrimes "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", 1421539Srgrimes "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", 143109467Sbillf "ENCRYPT", "NEW-ENVIRON", "TN3270E", "CHARSET", "COM-PORT", 144109467Sbillf "KERMIT", 14520003Sphk 0 1461539Srgrimes}; 1471539Srgrimes#define TELOPT_FIRST TELOPT_BINARY 148109467Sbillf#define TELOPT_LAST TELOPT_KERMIT 1491539Srgrimes#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) 1501539Srgrimes#define TELOPT(x) telopts[(x)-TELOPT_FIRST] 1511539Srgrimes#endif 1521539Srgrimes 1531539Srgrimes/* sub-option qualifiers */ 1541539Srgrimes#define TELQUAL_IS 0 /* option is... */ 1551539Srgrimes#define TELQUAL_SEND 1 /* send option */ 1561539Srgrimes#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ 1571539Srgrimes#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ 1581539Srgrimes#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ 1591539Srgrimes 1601539Srgrimes#define LFLOW_OFF 0 /* Disable remote flow control */ 1611539Srgrimes#define LFLOW_ON 1 /* Enable remote flow control */ 1621539Srgrimes#define LFLOW_RESTART_ANY 2 /* Restart output on any char */ 1631539Srgrimes#define LFLOW_RESTART_XON 3 /* Restart output only on XON */ 1641539Srgrimes 1651539Srgrimes/* 1661539Srgrimes * LINEMODE suboptions 1671539Srgrimes */ 1681539Srgrimes 1691539Srgrimes#define LM_MODE 1 1701539Srgrimes#define LM_FORWARDMASK 2 1711539Srgrimes#define LM_SLC 3 1721539Srgrimes 1731539Srgrimes#define MODE_EDIT 0x01 1741539Srgrimes#define MODE_TRAPSIG 0x02 1751539Srgrimes#define MODE_ACK 0x04 1761539Srgrimes#define MODE_SOFT_TAB 0x08 1771539Srgrimes#define MODE_LIT_ECHO 0x10 1781539Srgrimes 1791539Srgrimes#define MODE_MASK 0x1f 1801539Srgrimes 1811539Srgrimes/* Not part of protocol, but needed to simplify things... */ 1821539Srgrimes#define MODE_FLOW 0x0100 1831539Srgrimes#define MODE_ECHO 0x0200 1841539Srgrimes#define MODE_INBIN 0x0400 1851539Srgrimes#define MODE_OUTBIN 0x0800 1861539Srgrimes#define MODE_FORCE 0x1000 1871539Srgrimes 1881539Srgrimes#define SLC_SYNCH 1 1891539Srgrimes#define SLC_BRK 2 1901539Srgrimes#define SLC_IP 3 1911539Srgrimes#define SLC_AO 4 1921539Srgrimes#define SLC_AYT 5 1931539Srgrimes#define SLC_EOR 6 1941539Srgrimes#define SLC_ABORT 7 1951539Srgrimes#define SLC_EOF 8 1961539Srgrimes#define SLC_SUSP 9 1971539Srgrimes#define SLC_EC 10 1981539Srgrimes#define SLC_EL 11 1991539Srgrimes#define SLC_EW 12 2001539Srgrimes#define SLC_RP 13 2011539Srgrimes#define SLC_LNEXT 14 2021539Srgrimes#define SLC_XON 15 2031539Srgrimes#define SLC_XOFF 16 2041539Srgrimes#define SLC_FORW1 17 2051539Srgrimes#define SLC_FORW2 18 20620003Sphk#define SLC_MCL 19 20720003Sphk#define SLC_MCR 20 20820003Sphk#define SLC_MCWL 21 20920003Sphk#define SLC_MCWR 22 21020003Sphk#define SLC_MCBOL 23 21120003Sphk#define SLC_MCEOL 24 21220003Sphk#define SLC_INSRT 25 21320003Sphk#define SLC_OVER 26 21420003Sphk#define SLC_ECR 27 21520003Sphk#define SLC_EWR 28 21620003Sphk#define SLC_EBOL 29 21720003Sphk#define SLC_EEOL 30 2181539Srgrimes 21920003Sphk#define NSLC 30 2201539Srgrimes 2211539Srgrimes/* 22272092Sasmodai * For backwards compatibility, we define SLC_NAMES to be the 2231539Srgrimes * list of names if SLC_NAMES is not defined. 2241539Srgrimes */ 22520003Sphk#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ 22620003Sphk "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ 22720003Sphk "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \ 22820003Sphk "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \ 22920003Sphk "MCEOL", "INSRT", "OVER", "ECR", "EWR", \ 23020003Sphk "EBOL", "EEOL", \ 23120003Sphk 0 23220003Sphk 2331539Srgrimes#ifdef SLC_NAMES 23487268Smarkmconst char *slc_names[] = { 2351539Srgrimes SLC_NAMELIST 2361539Srgrimes}; 2371539Srgrimes#else 2381539Srgrimesextern char *slc_names[]; 2391539Srgrimes#define SLC_NAMES SLC_NAMELIST 2401539Srgrimes#endif 2411539Srgrimes 2421539Srgrimes#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) 2431539Srgrimes#define SLC_NAME(x) slc_names[x] 2441539Srgrimes 2451539Srgrimes#define SLC_NOSUPPORT 0 2461539Srgrimes#define SLC_CANTCHANGE 1 2471539Srgrimes#define SLC_VARIABLE 2 2481539Srgrimes#define SLC_DEFAULT 3 2491539Srgrimes#define SLC_LEVELBITS 0x03 2501539Srgrimes 2511539Srgrimes#define SLC_FUNC 0 2521539Srgrimes#define SLC_FLAGS 1 2531539Srgrimes#define SLC_VALUE 2 2541539Srgrimes 2551539Srgrimes#define SLC_ACK 0x80 2561539Srgrimes#define SLC_FLUSHIN 0x40 2571539Srgrimes#define SLC_FLUSHOUT 0x20 2581539Srgrimes 2591539Srgrimes#define OLD_ENV_VAR 1 2601539Srgrimes#define OLD_ENV_VALUE 0 2611539Srgrimes#define NEW_ENV_VAR 0 2621539Srgrimes#define NEW_ENV_VALUE 1 2631539Srgrimes#define ENV_ESC 2 2641539Srgrimes#define ENV_USERVAR 3 2651539Srgrimes 2661539Srgrimes/* 2671539Srgrimes * AUTHENTICATION suboptions 2681539Srgrimes */ 2691539Srgrimes 2701539Srgrimes/* 2711539Srgrimes * Who is authenticating who ... 2721539Srgrimes */ 2731539Srgrimes#define AUTH_WHO_CLIENT 0 /* Client authenticating server */ 2741539Srgrimes#define AUTH_WHO_SERVER 1 /* Server authenticating client */ 2751539Srgrimes#define AUTH_WHO_MASK 1 2761539Srgrimes 2771539Srgrimes/* 2781539Srgrimes * amount of authentication done 2791539Srgrimes */ 2801539Srgrimes#define AUTH_HOW_ONE_WAY 0 2811539Srgrimes#define AUTH_HOW_MUTUAL 2 2821539Srgrimes#define AUTH_HOW_MASK 2 2831539Srgrimes 2841539Srgrimes#define AUTHTYPE_NULL 0 2851539Srgrimes#define AUTHTYPE_KERBEROS_V4 1 2861539Srgrimes#define AUTHTYPE_KERBEROS_V5 2 2871539Srgrimes#define AUTHTYPE_SPX 3 2881539Srgrimes#define AUTHTYPE_MINK 4 28985600Smarkm#define AUTHTYPE_SRA 6 29085600Smarkm#define AUTHTYPE_CNT 7 2911539Srgrimes 2921539Srgrimes#define AUTHTYPE_TEST 99 2931539Srgrimes 2941539Srgrimes#ifdef AUTH_NAMES 29587268Smarkmconst char *authtype_names[] = { 29685600Smarkm "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA", 29720003Sphk 0 2981539Srgrimes}; 2991539Srgrimes#else 3001539Srgrimesextern char *authtype_names[]; 3011539Srgrimes#endif 3021539Srgrimes 3031539Srgrimes#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) 3041539Srgrimes#define AUTHTYPE_NAME(x) authtype_names[x] 3051539Srgrimes 3061539Srgrimes/* 3071539Srgrimes * ENCRYPTion suboptions 3081539Srgrimes */ 3091539Srgrimes#define ENCRYPT_IS 0 /* I pick encryption type ... */ 3101539Srgrimes#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */ 3111539Srgrimes#define ENCRYPT_REPLY 2 /* Initial setup response */ 3121539Srgrimes#define ENCRYPT_START 3 /* Am starting to send encrypted */ 3131539Srgrimes#define ENCRYPT_END 4 /* Am ending encrypted */ 3141539Srgrimes#define ENCRYPT_REQSTART 5 /* Request you start encrypting */ 31528057Sfenner#define ENCRYPT_REQEND 6 /* Request you end encrypting */ 3161539Srgrimes#define ENCRYPT_ENC_KEYID 7 3171539Srgrimes#define ENCRYPT_DEC_KEYID 8 3181539Srgrimes#define ENCRYPT_CNT 9 3191539Srgrimes 3201539Srgrimes#define ENCTYPE_ANY 0 3211539Srgrimes#define ENCTYPE_DES_CFB64 1 3221539Srgrimes#define ENCTYPE_DES_OFB64 2 3231539Srgrimes#define ENCTYPE_CNT 3 3241539Srgrimes 3251539Srgrimes#ifdef ENCRYPT_NAMES 32687268Smarkmconst char *encrypt_names[] = { 3271539Srgrimes "IS", "SUPPORT", "REPLY", "START", "END", 3281539Srgrimes "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", 32920003Sphk 0 3301539Srgrimes}; 33187268Smarkmconst char *enctype_names[] = { 33220003Sphk "ANY", "DES_CFB64", "DES_OFB64", 33320003Sphk 0 3341539Srgrimes}; 3351539Srgrimes#else 3361539Srgrimesextern char *encrypt_names[]; 3371539Srgrimesextern char *enctype_names[]; 3381539Srgrimes#endif 3391539Srgrimes 3401539Srgrimes 3411539Srgrimes#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) 3421539Srgrimes#define ENCRYPT_NAME(x) encrypt_names[x] 3431539Srgrimes 3441539Srgrimes#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT) 3451539Srgrimes#define ENCTYPE_NAME(x) enctype_names[x] 3461539Srgrimes 3471539Srgrimes#endif /* !_TELNET_H_ */ 348