001: /*
002: * Copyright 2001-2005 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.net.telnet;
017:
018: /***
019: * The TelnetOption class cannot be instantiated and only serves as a
020: * storehouse for telnet option constants.
021: * <p>
022: * Details regarding Telnet option specification can be found in RFC 855.
023: * <p>
024: * <p>
025: * @author Daniel F. Savarese
026: * @see org.apache.commons.net.telnet.Telnet
027: * @see org.apache.commons.net.telnet.TelnetClient
028: ***/
029:
030: public class TelnetOption {
031: /*** The maximum value an option code can have. This value is 255. ***/
032: public static final int MAX_OPTION_VALUE = 255;
033:
034: public static int BINARY = 0;
035:
036: public static int ECHO = 1;
037:
038: public static int PREPARE_TO_RECONNECT = 2;
039:
040: public static int SUPPRESS_GO_AHEAD = 3;
041:
042: public static int APPROXIMATE_MESSAGE_SIZE = 4;
043:
044: public static int STATUS = 5;
045:
046: public static int TIMING_MARK = 6;
047:
048: public static int REMOTE_CONTROLLED_TRANSMISSION = 7;
049:
050: public static int NEGOTIATE_OUTPUT_LINE_WIDTH = 8;
051:
052: public static int NEGOTIATE_OUTPUT_PAGE_SIZE = 9;
053:
054: public static int NEGOTIATE_CARRIAGE_RETURN = 10;
055:
056: public static int NEGOTIATE_HORIZONTAL_TAB_STOP = 11;
057:
058: public static int NEGOTIATE_HORIZONTAL_TAB = 12;
059:
060: public static int NEGOTIATE_FORMFEED = 13;
061:
062: public static int NEGOTIATE_VERTICAL_TAB_STOP = 14;
063:
064: public static int NEGOTIATE_VERTICAL_TAB = 15;
065:
066: public static int NEGOTIATE_LINEFEED = 16;
067:
068: public static int EXTENDED_ASCII = 17;
069:
070: public static int FORCE_LOGOUT = 18;
071:
072: public static int BYTE_MACRO = 19;
073:
074: public static int DATA_ENTRY_TERMINAL = 20;
075:
076: public static int SUPDUP = 21;
077:
078: public static int SUPDUP_OUTPUT = 22;
079:
080: public static int SEND_LOCATION = 23;
081:
082: public static int TERMINAL_TYPE = 24;
083:
084: public static int END_OF_RECORD = 25;
085:
086: public static int TACACS_USER_IDENTIFICATION = 26;
087:
088: public static int OUTPUT_MARKING = 27;
089:
090: public static int TERMINAL_LOCATION_NUMBER = 28;
091:
092: public static int REGIME_3270 = 29;
093:
094: public static int X3_PAD = 30;
095:
096: public static int WINDOW_SIZE = 31;
097:
098: public static int TERMINAL_SPEED = 32;
099:
100: public static int REMOTE_FLOW_CONTROL = 33;
101:
102: public static int LINEMODE = 34;
103:
104: public static int X_DISPLAY_LOCATION = 35;
105:
106: public static int OLD_ENVIRONMENT_VARIABLES = 36;
107:
108: public static int AUTHENTICATION = 37;
109:
110: public static int ENCRYPTION = 38;
111:
112: public static int NEW_ENVIRONMENT_VARIABLES = 39;
113:
114: public static int EXTENDED_OPTIONS_LIST = 255;
115:
116: private static int __FIRST_OPTION = BINARY;
117: private static int __LAST_OPTION = EXTENDED_OPTIONS_LIST;
118:
119: private static final String __optionString[] = { "BINARY", "ECHO",
120: "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS",
121: "TIMING MARK", "RCTE", "NAOL", "NAOP", "NAOCRD", "NAOHTS",
122: "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD", "NAOLFD",
123: "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
124: "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
125: "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
126: "TACACS UID", "OUTPUT MARKING", "TTYLOC", "3270 REGIME",
127: "X.3 PAD", "NAWS", "TSPEED", "LFLOW", "LINEMODE",
128: "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT",
129: "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET", "RSP",
130: "Com Port Control", "Suppress Local Echo", "Start TLS",
131: "KERMIT", "SEND-URL", "FORWARD_X", "", "", "", "", "", "",
132: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
133: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
134: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
135: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
136: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
137: "", "", "", "", "", "", "", "TELOPT PRAGMA LOGON",
138: "TELOPT SSPI LOGON", "TELOPT PRAGMA HEARTBEAT", "", "", "",
139: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
140: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
141: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
142: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
143: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
144: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
145: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
146: "", "", "", "", "", "", "Extended-Options-List" };
147:
148: /***
149: * Returns the string representation of the telnet protocol option
150: * corresponding to the given option code.
151: * <p>
152: * @param code The option code of the telnet protocol option
153: * @return The string representation of the telnet protocol option.
154: ***/
155: public static final String getOption(int code) {
156: if (__optionString[code].length() == 0) {
157: return "UNASSIGNED";
158: } else {
159: return __optionString[code];
160: }
161: }
162:
163: /***
164: * Determines if a given option code is valid. Returns true if valid,
165: * false if not.
166: * <p>
167: * @param code The option code to test.
168: * @return True if the option code is valid, false if not.
169: **/
170: public static final boolean isValidOption(int code) {
171: return (code <= __LAST_OPTION);
172: }
173:
174: // Cannot be instantiated
175: private TelnetOption() {
176: }
177: }
|