001: package ch.ethz.ssh2.packets;
002:
003: /**
004: * Packets.
005: *
006: * @author Christian Plattner, plattner@inf.ethz.ch
007: * @version $Id: Packets.java,v 1.6 2006/09/20 12:51:37 cplattne Exp $
008: */
009: public class Packets {
010: public static final int SSH_MSG_DISCONNECT = 1;
011: public static final int SSH_MSG_IGNORE = 2;
012: public static final int SSH_MSG_UNIMPLEMENTED = 3;
013: public static final int SSH_MSG_DEBUG = 4;
014: public static final int SSH_MSG_SERVICE_REQUEST = 5;
015: public static final int SSH_MSG_SERVICE_ACCEPT = 6;
016:
017: public static final int SSH_MSG_KEXINIT = 20;
018: public static final int SSH_MSG_NEWKEYS = 21;
019:
020: public static final int SSH_MSG_KEXDH_INIT = 30;
021: public static final int SSH_MSG_KEXDH_REPLY = 31;
022:
023: public static final int SSH_MSG_KEX_DH_GEX_REQUEST_OLD = 30;
024: public static final int SSH_MSG_KEX_DH_GEX_REQUEST = 34;
025: public static final int SSH_MSG_KEX_DH_GEX_GROUP = 31;
026: public static final int SSH_MSG_KEX_DH_GEX_INIT = 32;
027: public static final int SSH_MSG_KEX_DH_GEX_REPLY = 33;
028:
029: public static final int SSH_MSG_USERAUTH_REQUEST = 50;
030: public static final int SSH_MSG_USERAUTH_FAILURE = 51;
031: public static final int SSH_MSG_USERAUTH_SUCCESS = 52;
032: public static final int SSH_MSG_USERAUTH_BANNER = 53;
033: public static final int SSH_MSG_USERAUTH_INFO_REQUEST = 60;
034: public static final int SSH_MSG_USERAUTH_INFO_RESPONSE = 61;
035:
036: public static final int SSH_MSG_GLOBAL_REQUEST = 80;
037: public static final int SSH_MSG_REQUEST_SUCCESS = 81;
038: public static final int SSH_MSG_REQUEST_FAILURE = 82;
039:
040: public static final int SSH_MSG_CHANNEL_OPEN = 90;
041: public static final int SSH_MSG_CHANNEL_OPEN_CONFIRMATION = 91;
042: public static final int SSH_MSG_CHANNEL_OPEN_FAILURE = 92;
043: public static final int SSH_MSG_CHANNEL_WINDOW_ADJUST = 93;
044: public static final int SSH_MSG_CHANNEL_DATA = 94;
045: public static final int SSH_MSG_CHANNEL_EXTENDED_DATA = 95;
046: public static final int SSH_MSG_CHANNEL_EOF = 96;
047: public static final int SSH_MSG_CHANNEL_CLOSE = 97;
048: public static final int SSH_MSG_CHANNEL_REQUEST = 98;
049: public static final int SSH_MSG_CHANNEL_SUCCESS = 99;
050: public static final int SSH_MSG_CHANNEL_FAILURE = 100;
051:
052: public static final int SSH_EXTENDED_DATA_STDERR = 1;
053:
054: public static final int SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT = 1;
055: public static final int SSH_DISCONNECT_PROTOCOL_ERROR = 2;
056: public static final int SSH_DISCONNECT_KEY_EXCHANGE_FAILED = 3;
057: public static final int SSH_DISCONNECT_RESERVED = 4;
058: public static final int SSH_DISCONNECT_MAC_ERROR = 5;
059: public static final int SSH_DISCONNECT_COMPRESSION_ERROR = 6;
060: public static final int SSH_DISCONNECT_SERVICE_NOT_AVAILABLE = 7;
061: public static final int SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED = 8;
062: public static final int SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE = 9;
063: public static final int SSH_DISCONNECT_CONNECTION_LOST = 10;
064: public static final int SSH_DISCONNECT_BY_APPLICATION = 11;
065: public static final int SSH_DISCONNECT_TOO_MANY_CONNECTIONS = 12;
066: public static final int SSH_DISCONNECT_AUTH_CANCELLED_BY_USER = 13;
067: public static final int SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE = 14;
068: public static final int SSH_DISCONNECT_ILLEGAL_USER_NAME = 15;
069:
070: public static final int SSH_OPEN_ADMINISTRATIVELY_PROHIBITED = 1;
071: public static final int SSH_OPEN_CONNECT_FAILED = 2;
072: public static final int SSH_OPEN_UNKNOWN_CHANNEL_TYPE = 3;
073: public static final int SSH_OPEN_RESOURCE_SHORTAGE = 4;
074:
075: private static final String[] reverseNames = new String[101];
076:
077: static {
078: reverseNames[1] = "SSH_MSG_DISCONNECT";
079: reverseNames[2] = "SSH_MSG_IGNORE";
080: reverseNames[3] = "SSH_MSG_UNIMPLEMENTED";
081: reverseNames[4] = "SSH_MSG_DEBUG";
082: reverseNames[5] = "SSH_MSG_SERVICE_REQUEST";
083: reverseNames[6] = "SSH_MSG_SERVICE_ACCEPT";
084:
085: reverseNames[20] = "SSH_MSG_KEXINIT";
086: reverseNames[21] = "SSH_MSG_NEWKEYS";
087:
088: reverseNames[30] = "SSH_MSG_KEXDH_INIT";
089: reverseNames[31] = "SSH_MSG_KEXDH_REPLY/SSH_MSG_KEX_DH_GEX_GROUP";
090: reverseNames[32] = "SSH_MSG_KEX_DH_GEX_INIT";
091: reverseNames[33] = "SSH_MSG_KEX_DH_GEX_REPLY";
092: reverseNames[34] = "SSH_MSG_KEX_DH_GEX_REQUEST";
093:
094: reverseNames[50] = "SSH_MSG_USERAUTH_REQUEST";
095: reverseNames[51] = "SSH_MSG_USERAUTH_FAILURE";
096: reverseNames[52] = "SSH_MSG_USERAUTH_SUCCESS";
097: reverseNames[53] = "SSH_MSG_USERAUTH_BANNER";
098:
099: reverseNames[60] = "SSH_MSG_USERAUTH_INFO_REQUEST";
100: reverseNames[61] = "SSH_MSG_USERAUTH_INFO_RESPONSE";
101:
102: reverseNames[80] = "SSH_MSG_GLOBAL_REQUEST";
103: reverseNames[81] = "SSH_MSG_REQUEST_SUCCESS";
104: reverseNames[82] = "SSH_MSG_REQUEST_FAILURE";
105:
106: reverseNames[90] = "SSH_MSG_CHANNEL_OPEN";
107: reverseNames[91] = "SSH_MSG_CHANNEL_OPEN_CONFIRMATION";
108: reverseNames[92] = "SSH_MSG_CHANNEL_OPEN_FAILURE";
109: reverseNames[93] = "SSH_MSG_CHANNEL_WINDOW_ADJUST";
110: reverseNames[94] = "SSH_MSG_CHANNEL_DATA";
111: reverseNames[95] = "SSH_MSG_CHANNEL_EXTENDED_DATA";
112: reverseNames[96] = "SSH_MSG_CHANNEL_EOF";
113: reverseNames[97] = "SSH_MSG_CHANNEL_CLOSE";
114: reverseNames[98] = "SSH_MSG_CHANNEL_REQUEST";
115: reverseNames[99] = "SSH_MSG_CHANNEL_SUCCESS";
116: reverseNames[100] = "SSH_MSG_CHANNEL_FAILURE";
117: }
118:
119: public static final String getMessageName(int type) {
120: String res = null;
121:
122: if ((type >= 0) && (type < reverseNames.length)) {
123: res = reverseNames[type];
124: }
125:
126: return (res == null) ? ("UNKNOWN MSG " + type) : res;
127: }
128:
129: // public static final void debug(String tag, byte[] msg)
130: // {
131: // System.err.println(tag + " Type: " + msg[0] + ", LEN: " + msg.length);
132: //
133: // for (int i = 0; i < msg.length; i++)
134: // {
135: // if (((msg[i] >= 'a') && (msg[i] <= 'z')) || ((msg[i] >= 'A') && (msg[i] <= 'Z'))
136: // || ((msg[i] >= '0') && (msg[i] <= '9')) || (msg[i] == ' '))
137: // System.err.print((char) msg[i]);
138: // else
139: // System.err.print(".");
140: // }
141: // System.err.println();
142: // System.err.flush();
143: // }
144: }
|