Back to index

glibc  2.9
telnet.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1983, 1993
00003  *     The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 4. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  *     @(#)telnet.h  8.2 (Berkeley) 12/15/93
00030  */
00031 
00032 #ifndef _ARPA_TELNET_H
00033 #define       _ARPA_TELNET_H 1
00034 
00035 /*
00036  * Definitions for the TELNET protocol.
00037  */
00038 #define       IAC    255           /* interpret as command: */
00039 #define       DONT   254           /* you are not to use option */
00040 #define       DO     253           /* please, you use option */
00041 #define       WONT   252           /* I won't use option */
00042 #define       WILL   251           /* I will use option */
00043 #define       SB     250           /* interpret as subnegotiation */
00044 #define       GA     249           /* you may reverse the line */
00045 #define       EL     248           /* erase the current line */
00046 #define       EC     247           /* erase the current character */
00047 #define       AYT    246           /* are you there */
00048 #define       AO     245           /* abort output--but let prog finish */
00049 #define       IP     244           /* interrupt process--permanently */
00050 #define       BREAK  243           /* break */
00051 #define       DM     242           /* data mark--for connect. cleaning */
00052 #define       NOP    241           /* nop */
00053 #define       SE     240           /* end sub negotiation */
00054 #define EOR     239             /* end of record (transparent mode) */
00055 #define       ABORT  238           /* Abort process */
00056 #define       SUSP   237           /* Suspend process */
00057 #define       xEOF   236           /* End of file: EOF is already used... */
00058 
00059 #define SYNCH 242           /* for telfunc calls */
00060 
00061 #ifdef TELCMDS
00062 char *telcmds[] = {
00063        "EOF", "SUSP", "ABORT", "EOR",
00064        "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
00065        "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
00066 };
00067 #else
00068 extern char *telcmds[];
00069 #endif
00070 
00071 #define       TELCMD_FIRST  xEOF
00072 #define       TELCMD_LAST   IAC
00073 #define       TELCMD_OK(x)  ((unsigned int)(x) <= TELCMD_LAST && \
00074                       (unsigned int)(x) >= TELCMD_FIRST)
00075 #define       TELCMD(x)     telcmds[(x)-TELCMD_FIRST]
00076 
00077 /* telnet options */
00078 #define TELOPT_BINARY       0      /* 8-bit data path */
00079 #define TELOPT_ECHO  1      /* echo */
00080 #define       TELOPT_RCP    2      /* prepare to reconnect */
00081 #define       TELOPT_SGA    3      /* suppress go ahead */
00082 #define       TELOPT_NAMS   4      /* approximate message size */
00083 #define       TELOPT_STATUS 5      /* give status */
00084 #define       TELOPT_TM     6      /* timing mark */
00085 #define       TELOPT_RCTE   7      /* remote controlled transmission and echo */
00086 #define TELOPT_NAOL  8      /* negotiate about output line width */
00087 #define TELOPT_NAOP  9      /* negotiate about output page size */
00088 #define TELOPT_NAOCRD       10     /* negotiate about CR disposition */
00089 #define TELOPT_NAOHTS       11     /* negotiate about horizontal tabstops */
00090 #define TELOPT_NAOHTD       12     /* negotiate about horizontal tab disposition */
00091 #define TELOPT_NAOFFD       13     /* negotiate about formfeed disposition */
00092 #define TELOPT_NAOVTS       14     /* negotiate about vertical tab stops */
00093 #define TELOPT_NAOVTD       15     /* negotiate about vertical tab disposition */
00094 #define TELOPT_NAOLFD       16     /* negotiate about output LF disposition */
00095 #define TELOPT_XASCII       17     /* extended ascii character set */
00096 #define       TELOPT_LOGOUT 18     /* force logout */
00097 #define       TELOPT_BM     19     /* byte macro */
00098 #define       TELOPT_DET    20     /* data entry terminal */
00099 #define       TELOPT_SUPDUP 21     /* supdup protocol */
00100 #define       TELOPT_SUPDUPOUTPUT 22      /* supdup output */
00101 #define       TELOPT_SNDLOC 23     /* send location */
00102 #define       TELOPT_TTYPE  24     /* terminal type */
00103 #define       TELOPT_EOR    25     /* end or record */
00104 #define       TELOPT_TUID   26     /* TACACS user identification */
00105 #define       TELOPT_OUTMRK 27     /* output marking */
00106 #define       TELOPT_TTYLOC 28     /* terminal location number */
00107 #define       TELOPT_3270REGIME 29 /* 3270 regime */
00108 #define       TELOPT_X3PAD  30     /* X.3 PAD */
00109 #define       TELOPT_NAWS   31     /* window size */
00110 #define       TELOPT_TSPEED 32     /* terminal speed */
00111 #define       TELOPT_LFLOW  33     /* remote flow control */
00112 #define TELOPT_LINEMODE     34     /* Linemode option */
00113 #define TELOPT_XDISPLOC     35     /* X Display Location */
00114 #define TELOPT_OLD_ENVIRON 36      /* Old - Environment variables */
00115 #define       TELOPT_AUTHENTICATION 37/* Authenticate */
00116 #define       TELOPT_ENCRYPT       38     /* Encryption option */
00117 #define TELOPT_NEW_ENVIRON 39      /* New - Environment variables */
00118 #define       TELOPT_EXOPL  255    /* extended-options-list */
00119 
00120 
00121 #define       NTELOPTS      (1+TELOPT_NEW_ENVIRON)
00122 #ifdef TELOPTS
00123 char *telopts[NTELOPTS+1] = {
00124        "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
00125        "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
00126        "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
00127        "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
00128        "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
00129        "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
00130        "TACACS UID", "OUTPUT MARKING", "TTYLOC",
00131        "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
00132        "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
00133        "ENCRYPT", "NEW-ENVIRON",
00134        0,
00135 };
00136 #define       TELOPT_FIRST  TELOPT_BINARY
00137 #define       TELOPT_LAST   TELOPT_NEW_ENVIRON
00138 #define       TELOPT_OK(x)  ((unsigned int)(x) <= TELOPT_LAST)
00139 #define       TELOPT(x)     telopts[(x)-TELOPT_FIRST]
00140 #endif
00141 
00142 /* sub-option qualifiers */
00143 #define       TELQUAL_IS    0      /* option is... */
00144 #define       TELQUAL_SEND  1      /* send option */
00145 #define       TELQUAL_INFO  2      /* ENVIRON: informational version of IS */
00146 #define       TELQUAL_REPLY 2      /* AUTHENTICATION: client version of IS */
00147 #define       TELQUAL_NAME  3      /* AUTHENTICATION: client version of IS */
00148 
00149 #define       LFLOW_OFF            0      /* Disable remote flow control */
00150 #define       LFLOW_ON             1      /* Enable remote flow control */
00151 #define       LFLOW_RESTART_ANY    2      /* Restart output on any char */
00152 #define       LFLOW_RESTART_XON    3      /* Restart output only on XON */
00153 
00154 /*
00155  * LINEMODE suboptions
00156  */
00157 
00158 #define       LM_MODE              1
00159 #define       LM_FORWARDMASK       2
00160 #define       LM_SLC        3
00161 
00162 #define       MODE_EDIT     0x01
00163 #define       MODE_TRAPSIG  0x02
00164 #define       MODE_ACK      0x04
00165 #define MODE_SOFT_TAB       0x08
00166 #define MODE_LIT_ECHO       0x10
00167 
00168 #define       MODE_MASK     0x1f
00169 
00170 /* Not part of protocol, but needed to simplify things... */
00171 #define MODE_FLOW           0x0100
00172 #define MODE_ECHO           0x0200
00173 #define MODE_INBIN          0x0400
00174 #define MODE_OUTBIN         0x0800
00175 #define MODE_FORCE          0x1000
00176 
00177 #define       SLC_SYNCH     1
00178 #define       SLC_BRK              2
00179 #define       SLC_IP        3
00180 #define       SLC_AO        4
00181 #define       SLC_AYT              5
00182 #define       SLC_EOR              6
00183 #define       SLC_ABORT     7
00184 #define       SLC_EOF              8
00185 #define       SLC_SUSP      9
00186 #define       SLC_EC        10
00187 #define       SLC_EL        11
00188 #define       SLC_EW        12
00189 #define       SLC_RP        13
00190 #define       SLC_LNEXT     14
00191 #define       SLC_XON              15
00192 #define       SLC_XOFF      16
00193 #define       SLC_FORW1     17
00194 #define       SLC_FORW2     18
00195 
00196 #define       NSLC          18
00197 
00198 /*
00199  * For backwards compatibility, we define SLC_NAMES to be the
00200  * list of names if SLC_NAMES is not defined.
00201  */
00202 #define       SLC_NAMELIST  "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
00203                      "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
00204                      "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
00205 #ifdef SLC_NAMES
00206 char *slc_names[] = {
00207        SLC_NAMELIST
00208 };
00209 #else
00210 extern char *slc_names[];
00211 #define       SLC_NAMES SLC_NAMELIST
00212 #endif
00213 
00214 #define       SLC_NAME_OK(x)       ((unsigned int)(x) <= NSLC)
00215 #define SLC_NAME(x)  slc_names[x]
00216 
00217 #define       SLC_NOSUPPORT 0
00218 #define       SLC_CANTCHANGE       1
00219 #define       SLC_VARIABLE  2
00220 #define       SLC_DEFAULT   3
00221 #define       SLC_LEVELBITS 0x03
00222 
00223 #define       SLC_FUNC      0
00224 #define       SLC_FLAGS     1
00225 #define       SLC_VALUE     2
00226 
00227 #define       SLC_ACK              0x80
00228 #define       SLC_FLUSHIN   0x40
00229 #define       SLC_FLUSHOUT  0x20
00230 
00231 #define       OLD_ENV_VAR   1
00232 #define       OLD_ENV_VALUE 0
00233 #define       NEW_ENV_VAR   0
00234 #define       NEW_ENV_VALUE 1
00235 #define       ENV_ESC              2
00236 #define ENV_USERVAR  3
00237 
00238 /*
00239  * AUTHENTICATION suboptions
00240  */
00241 
00242 /*
00243  * Who is authenticating who ...
00244  */
00245 #define       AUTH_WHO_CLIENT             0      /* Client authenticating server */
00246 #define       AUTH_WHO_SERVER             1      /* Server authenticating client */
00247 #define       AUTH_WHO_MASK        1
00248 
00249 /*
00250  * amount of authentication done
00251  */
00252 #define       AUTH_HOW_ONE_WAY     0
00253 #define       AUTH_HOW_MUTUAL             2
00254 #define       AUTH_HOW_MASK        2
00255 
00256 #define       AUTHTYPE_NULL        0
00257 #define       AUTHTYPE_KERBEROS_V4 1
00258 #define       AUTHTYPE_KERBEROS_V5 2
00259 #define       AUTHTYPE_SPX         3
00260 #define       AUTHTYPE_MINK        4
00261 #define       AUTHTYPE_CNT         5
00262 
00263 #define       AUTHTYPE_TEST        99
00264 
00265 #ifdef AUTH_NAMES
00266 char *authtype_names[] = {
00267        "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
00268 };
00269 #else
00270 extern char *authtype_names[];
00271 #endif
00272 
00273 #define       AUTHTYPE_NAME_OK(x)  ((unsigned int)(x) < AUTHTYPE_CNT)
00274 #define       AUTHTYPE_NAME(x)     authtype_names[x]
00275 
00276 /*
00277  * ENCRYPTion suboptions
00278  */
00279 #define       ENCRYPT_IS           0      /* I pick encryption type ... */
00280 #define       ENCRYPT_SUPPORT             1      /* I support encryption types ... */
00281 #define       ENCRYPT_REPLY        2      /* Initial setup response */
00282 #define       ENCRYPT_START        3      /* Am starting to send encrypted */
00283 #define       ENCRYPT_END          4      /* Am ending encrypted */
00284 #define       ENCRYPT_REQSTART     5      /* Request you start encrypting */
00285 #define       ENCRYPT_REQEND              6      /* Request you send encrypting */
00286 #define       ENCRYPT_ENC_KEYID    7
00287 #define       ENCRYPT_DEC_KEYID    8
00288 #define       ENCRYPT_CNT          9
00289 
00290 #define       ENCTYPE_ANY          0
00291 #define       ENCTYPE_DES_CFB64    1
00292 #define       ENCTYPE_DES_OFB64    2
00293 #define       ENCTYPE_CNT          3
00294 
00295 #ifdef ENCRYPT_NAMES
00296 char *encrypt_names[] = {
00297        "IS", "SUPPORT", "REPLY", "START", "END",
00298        "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
00299        0,
00300 };
00301 char *enctype_names[] = {
00302        "ANY", "DES_CFB64",  "DES_OFB64",  0,
00303 };
00304 #else
00305 extern char *encrypt_names[];
00306 extern char *enctype_names[];
00307 #endif
00308 
00309 
00310 #define       ENCRYPT_NAME_OK(x)   ((unsigned int)(x) < ENCRYPT_CNT)
00311 #define       ENCRYPT_NAME(x)             encrypt_names[x]
00312 
00313 #define       ENCTYPE_NAME_OK(x)   ((unsigned int)(x) < ENCTYPE_CNT)
00314 #define       ENCTYPE_NAME(x)             enctype_names[x]
00315 
00316 #endif /* arpa/telnet.h */