KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > ssh2 > packets > Packets


1
2 package ch.ethz.ssh2.packets;
3
4 /**
5  * Packets.
6  *
7  * @author Christian Plattner, plattner@inf.ethz.ch
8  * @version $Id: Packets.java,v 1.6 2006/09/20 12:51:37 cplattne Exp $
9  */

10 public class Packets
11 {
12     public static final int SSH_MSG_DISCONNECT = 1;
13     public static final int SSH_MSG_IGNORE = 2;
14     public static final int SSH_MSG_UNIMPLEMENTED = 3;
15     public static final int SSH_MSG_DEBUG = 4;
16     public static final int SSH_MSG_SERVICE_REQUEST = 5;
17     public static final int SSH_MSG_SERVICE_ACCEPT = 6;
18
19     public static final int SSH_MSG_KEXINIT = 20;
20     public static final int SSH_MSG_NEWKEYS = 21;
21
22     public static final int SSH_MSG_KEXDH_INIT = 30;
23     public static final int SSH_MSG_KEXDH_REPLY = 31;
24
25     public static final int SSH_MSG_KEX_DH_GEX_REQUEST_OLD = 30;
26     public static final int SSH_MSG_KEX_DH_GEX_REQUEST = 34;
27     public static final int SSH_MSG_KEX_DH_GEX_GROUP = 31;
28     public static final int SSH_MSG_KEX_DH_GEX_INIT = 32;
29     public static final int SSH_MSG_KEX_DH_GEX_REPLY = 33;
30
31     public static final int SSH_MSG_USERAUTH_REQUEST = 50;
32     public static final int SSH_MSG_USERAUTH_FAILURE = 51;
33     public static final int SSH_MSG_USERAUTH_SUCCESS = 52;
34     public static final int SSH_MSG_USERAUTH_BANNER = 53;
35     public static final int SSH_MSG_USERAUTH_INFO_REQUEST = 60;
36     public static final int SSH_MSG_USERAUTH_INFO_RESPONSE = 61;
37
38     public static final int SSH_MSG_GLOBAL_REQUEST = 80;
39     public static final int SSH_MSG_REQUEST_SUCCESS = 81;
40     public static final int SSH_MSG_REQUEST_FAILURE = 82;
41
42     public static final int SSH_MSG_CHANNEL_OPEN = 90;
43     public static final int SSH_MSG_CHANNEL_OPEN_CONFIRMATION = 91;
44     public static final int SSH_MSG_CHANNEL_OPEN_FAILURE = 92;
45     public static final int SSH_MSG_CHANNEL_WINDOW_ADJUST = 93;
46     public static final int SSH_MSG_CHANNEL_DATA = 94;
47     public static final int SSH_MSG_CHANNEL_EXTENDED_DATA = 95;
48     public static final int SSH_MSG_CHANNEL_EOF = 96;
49     public static final int SSH_MSG_CHANNEL_CLOSE = 97;
50     public static final int SSH_MSG_CHANNEL_REQUEST = 98;
51     public static final int SSH_MSG_CHANNEL_SUCCESS = 99;
52     public static final int SSH_MSG_CHANNEL_FAILURE = 100;
53
54     public static final int SSH_EXTENDED_DATA_STDERR = 1;
55
56     public static final int SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT = 1;
57     public static final int SSH_DISCONNECT_PROTOCOL_ERROR = 2;
58     public static final int SSH_DISCONNECT_KEY_EXCHANGE_FAILED = 3;
59     public static final int SSH_DISCONNECT_RESERVED = 4;
60     public static final int SSH_DISCONNECT_MAC_ERROR = 5;
61     public static final int SSH_DISCONNECT_COMPRESSION_ERROR = 6;
62     public static final int SSH_DISCONNECT_SERVICE_NOT_AVAILABLE = 7;
63     public static final int SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED = 8;
64     public static final int SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE = 9;
65     public static final int SSH_DISCONNECT_CONNECTION_LOST = 10;
66     public static final int SSH_DISCONNECT_BY_APPLICATION = 11;
67     public static final int SSH_DISCONNECT_TOO_MANY_CONNECTIONS = 12;
68     public static final int SSH_DISCONNECT_AUTH_CANCELLED_BY_USER = 13;
69     public static final int SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE = 14;
70     public static final int SSH_DISCONNECT_ILLEGAL_USER_NAME = 15;
71
72     public static final int SSH_OPEN_ADMINISTRATIVELY_PROHIBITED = 1;
73     public static final int SSH_OPEN_CONNECT_FAILED = 2;
74     public static final int SSH_OPEN_UNKNOWN_CHANNEL_TYPE = 3;
75     public static final int SSH_OPEN_RESOURCE_SHORTAGE = 4;
76
77     private static final String JavaDoc[] reverseNames = new String JavaDoc[101];
78
79     static
80     {
81         reverseNames[1] = "SSH_MSG_DISCONNECT";
82         reverseNames[2] = "SSH_MSG_IGNORE";
83         reverseNames[3] = "SSH_MSG_UNIMPLEMENTED";
84         reverseNames[4] = "SSH_MSG_DEBUG";
85         reverseNames[5] = "SSH_MSG_SERVICE_REQUEST";
86         reverseNames[6] = "SSH_MSG_SERVICE_ACCEPT";
87
88         reverseNames[20] = "SSH_MSG_KEXINIT";
89         reverseNames[21] = "SSH_MSG_NEWKEYS";
90
91         reverseNames[30] = "SSH_MSG_KEXDH_INIT";
92         reverseNames[31] = "SSH_MSG_KEXDH_REPLY/SSH_MSG_KEX_DH_GEX_GROUP";
93         reverseNames[32] = "SSH_MSG_KEX_DH_GEX_INIT";
94         reverseNames[33] = "SSH_MSG_KEX_DH_GEX_REPLY";
95         reverseNames[34] = "SSH_MSG_KEX_DH_GEX_REQUEST";
96
97         reverseNames[50] = "SSH_MSG_USERAUTH_REQUEST";
98         reverseNames[51] = "SSH_MSG_USERAUTH_FAILURE";
99         reverseNames[52] = "SSH_MSG_USERAUTH_SUCCESS";
100         reverseNames[53] = "SSH_MSG_USERAUTH_BANNER";
101
102         reverseNames[60] = "SSH_MSG_USERAUTH_INFO_REQUEST";
103         reverseNames[61] = "SSH_MSG_USERAUTH_INFO_RESPONSE";
104
105         reverseNames[80] = "SSH_MSG_GLOBAL_REQUEST";
106         reverseNames[81] = "SSH_MSG_REQUEST_SUCCESS";
107         reverseNames[82] = "SSH_MSG_REQUEST_FAILURE";
108
109         reverseNames[90] = "SSH_MSG_CHANNEL_OPEN";
110         reverseNames[91] = "SSH_MSG_CHANNEL_OPEN_CONFIRMATION";
111         reverseNames[92] = "SSH_MSG_CHANNEL_OPEN_FAILURE";
112         reverseNames[93] = "SSH_MSG_CHANNEL_WINDOW_ADJUST";
113         reverseNames[94] = "SSH_MSG_CHANNEL_DATA";
114         reverseNames[95] = "SSH_MSG_CHANNEL_EXTENDED_DATA";
115         reverseNames[96] = "SSH_MSG_CHANNEL_EOF";
116         reverseNames[97] = "SSH_MSG_CHANNEL_CLOSE";
117         reverseNames[98] = "SSH_MSG_CHANNEL_REQUEST";
118         reverseNames[99] = "SSH_MSG_CHANNEL_SUCCESS";
119         reverseNames[100] = "SSH_MSG_CHANNEL_FAILURE";
120     }
121
122     public static final String JavaDoc getMessageName(int type)
123     {
124         String JavaDoc res = null;
125
126         if ((type >= 0) && (type < reverseNames.length))
127         {
128             res = reverseNames[type];
129         }
130
131         return (res == null) ? ("UNKNOWN MSG " + type) : res;
132     }
133
134     // public static final void debug(String tag, byte[] msg)
135
// {
136
// System.err.println(tag + " Type: " + msg[0] + ", LEN: " + msg.length);
137
//
138
// for (int i = 0; i < msg.length; i++)
139
// {
140
// if (((msg[i] >= 'a') && (msg[i] <= 'z')) || ((msg[i] >= 'A') && (msg[i] <= 'Z'))
141
// || ((msg[i] >= '0') && (msg[i] <= '9')) || (msg[i] == ' '))
142
// System.err.print((char) msg[i]);
143
// else
144
// System.err.print(".");
145
// }
146
// System.err.println();
147
// System.err.flush();
148
// }
149
}
150
Popular Tags