comparison src/ch/ethz/ssh2/packets/Packets.java @ 307:071eccdff8ea ganymed

fix java formatting
author Carl Byington <carl@five-ten-sg.com>
date Wed, 30 Jul 2014 14:16:58 -0700
parents 91a31873c42a
children
comparison
equal deleted inserted replaced
305:d2b303406d63 307:071eccdff8ea
4 */ 4 */
5 package ch.ethz.ssh2.packets; 5 package ch.ethz.ssh2.packets;
6 6
7 /** 7 /**
8 * Packets. 8 * Packets.
9 * 9 *
10 * @author Christian Plattner 10 * @author Christian Plattner
11 * @version 2.50, 03/15/10 11 * @version 2.50, 03/15/10
12 */ 12 */
13 public final class Packets 13 public final class Packets {
14 { 14 public static final int SSH_MSG_DISCONNECT = 1;
15 public static final int SSH_MSG_DISCONNECT = 1; 15 public static final int SSH_MSG_IGNORE = 2;
16 public static final int SSH_MSG_IGNORE = 2; 16 public static final int SSH_MSG_UNIMPLEMENTED = 3;
17 public static final int SSH_MSG_UNIMPLEMENTED = 3; 17 public static final int SSH_MSG_DEBUG = 4;
18 public static final int SSH_MSG_DEBUG = 4; 18 public static final int SSH_MSG_SERVICE_REQUEST = 5;
19 public static final int SSH_MSG_SERVICE_REQUEST = 5; 19 public static final int SSH_MSG_SERVICE_ACCEPT = 6;
20 public static final int SSH_MSG_SERVICE_ACCEPT = 6;
21 20
22 public static final int SSH_MSG_KEXINIT = 20; 21 public static final int SSH_MSG_KEXINIT = 20;
23 public static final int SSH_MSG_NEWKEYS = 21; 22 public static final int SSH_MSG_NEWKEYS = 21;
24 23
25 public static final int SSH_MSG_KEXDH_INIT = 30; 24 public static final int SSH_MSG_KEXDH_INIT = 30;
26 public static final int SSH_MSG_KEXDH_REPLY = 31; 25 public static final int SSH_MSG_KEXDH_REPLY = 31;
27 26
28 public static final int SSH_MSG_KEX_DH_GEX_REQUEST_OLD = 30; 27 public static final int SSH_MSG_KEX_DH_GEX_REQUEST_OLD = 30;
29 public static final int SSH_MSG_KEX_DH_GEX_REQUEST = 34; 28 public static final int SSH_MSG_KEX_DH_GEX_REQUEST = 34;
30 public static final int SSH_MSG_KEX_DH_GEX_GROUP = 31; 29 public static final int SSH_MSG_KEX_DH_GEX_GROUP = 31;
31 public static final int SSH_MSG_KEX_DH_GEX_INIT = 32; 30 public static final int SSH_MSG_KEX_DH_GEX_INIT = 32;
32 public static final int SSH_MSG_KEX_DH_GEX_REPLY = 33; 31 public static final int SSH_MSG_KEX_DH_GEX_REPLY = 33;
33 32
34 public static final int SSH_MSG_USERAUTH_REQUEST = 50; 33 public static final int SSH_MSG_USERAUTH_REQUEST = 50;
35 public static final int SSH_MSG_USERAUTH_FAILURE = 51; 34 public static final int SSH_MSG_USERAUTH_FAILURE = 51;
36 public static final int SSH_MSG_USERAUTH_SUCCESS = 52; 35 public static final int SSH_MSG_USERAUTH_SUCCESS = 52;
37 public static final int SSH_MSG_USERAUTH_BANNER = 53; 36 public static final int SSH_MSG_USERAUTH_BANNER = 53;
38 public static final int SSH_MSG_USERAUTH_INFO_REQUEST = 60; 37 public static final int SSH_MSG_USERAUTH_INFO_REQUEST = 60;
39 public static final int SSH_MSG_USERAUTH_INFO_RESPONSE = 61; 38 public static final int SSH_MSG_USERAUTH_INFO_RESPONSE = 61;
40 39
41 public static final int SSH_MSG_GLOBAL_REQUEST = 80; 40 public static final int SSH_MSG_GLOBAL_REQUEST = 80;
42 public static final int SSH_MSG_REQUEST_SUCCESS = 81; 41 public static final int SSH_MSG_REQUEST_SUCCESS = 81;
43 public static final int SSH_MSG_REQUEST_FAILURE = 82; 42 public static final int SSH_MSG_REQUEST_FAILURE = 82;
44 43
45 public static final int SSH_MSG_CHANNEL_OPEN = 90; 44 public static final int SSH_MSG_CHANNEL_OPEN = 90;
46 public static final int SSH_MSG_CHANNEL_OPEN_CONFIRMATION = 91; 45 public static final int SSH_MSG_CHANNEL_OPEN_CONFIRMATION = 91;
47 public static final int SSH_MSG_CHANNEL_OPEN_FAILURE = 92; 46 public static final int SSH_MSG_CHANNEL_OPEN_FAILURE = 92;
48 public static final int SSH_MSG_CHANNEL_WINDOW_ADJUST = 93; 47 public static final int SSH_MSG_CHANNEL_WINDOW_ADJUST = 93;
49 public static final int SSH_MSG_CHANNEL_DATA = 94; 48 public static final int SSH_MSG_CHANNEL_DATA = 94;
50 public static final int SSH_MSG_CHANNEL_EXTENDED_DATA = 95; 49 public static final int SSH_MSG_CHANNEL_EXTENDED_DATA = 95;
51 public static final int SSH_MSG_CHANNEL_EOF = 96; 50 public static final int SSH_MSG_CHANNEL_EOF = 96;
52 public static final int SSH_MSG_CHANNEL_CLOSE = 97; 51 public static final int SSH_MSG_CHANNEL_CLOSE = 97;
53 public static final int SSH_MSG_CHANNEL_REQUEST = 98; 52 public static final int SSH_MSG_CHANNEL_REQUEST = 98;
54 public static final int SSH_MSG_CHANNEL_SUCCESS = 99; 53 public static final int SSH_MSG_CHANNEL_SUCCESS = 99;
55 public static final int SSH_MSG_CHANNEL_FAILURE = 100; 54 public static final int SSH_MSG_CHANNEL_FAILURE = 100;
56 55
57 public static final int SSH_EXTENDED_DATA_STDERR = 1; 56 public static final int SSH_EXTENDED_DATA_STDERR = 1;
58 57
59 public static final int SSH_OPEN_ADMINISTRATIVELY_PROHIBITED = 1; 58 public static final int SSH_OPEN_ADMINISTRATIVELY_PROHIBITED = 1;
60 public static final int SSH_OPEN_CONNECT_FAILED = 2; 59 public static final int SSH_OPEN_CONNECT_FAILED = 2;
61 public static final int SSH_OPEN_UNKNOWN_CHANNEL_TYPE = 3; 60 public static final int SSH_OPEN_UNKNOWN_CHANNEL_TYPE = 3;
62 public static final int SSH_OPEN_RESOURCE_SHORTAGE = 4; 61 public static final int SSH_OPEN_RESOURCE_SHORTAGE = 4;
63 62
64 private static final String[] reverseNames = new String[101]; 63 private static final String[] reverseNames = new String[101];
65 64
66 static 65 static {
67 { 66 reverseNames[1] = "SSH_MSG_DISCONNECT";
68 reverseNames[1] = "SSH_MSG_DISCONNECT"; 67 reverseNames[2] = "SSH_MSG_IGNORE";
69 reverseNames[2] = "SSH_MSG_IGNORE"; 68 reverseNames[3] = "SSH_MSG_UNIMPLEMENTED";
70 reverseNames[3] = "SSH_MSG_UNIMPLEMENTED"; 69 reverseNames[4] = "SSH_MSG_DEBUG";
71 reverseNames[4] = "SSH_MSG_DEBUG"; 70 reverseNames[5] = "SSH_MSG_SERVICE_REQUEST";
72 reverseNames[5] = "SSH_MSG_SERVICE_REQUEST"; 71 reverseNames[6] = "SSH_MSG_SERVICE_ACCEPT";
73 reverseNames[6] = "SSH_MSG_SERVICE_ACCEPT"; 72 reverseNames[20] = "SSH_MSG_KEXINIT";
73 reverseNames[21] = "SSH_MSG_NEWKEYS";
74 reverseNames[30] = "SSH_MSG_KEXDH_INIT";
75 reverseNames[31] = "SSH_MSG_KEXDH_REPLY/SSH_MSG_KEX_DH_GEX_GROUP";
76 reverseNames[32] = "SSH_MSG_KEX_DH_GEX_INIT";
77 reverseNames[33] = "SSH_MSG_KEX_DH_GEX_REPLY";
78 reverseNames[34] = "SSH_MSG_KEX_DH_GEX_REQUEST";
79 reverseNames[50] = "SSH_MSG_USERAUTH_REQUEST";
80 reverseNames[51] = "SSH_MSG_USERAUTH_FAILURE";
81 reverseNames[52] = "SSH_MSG_USERAUTH_SUCCESS";
82 reverseNames[53] = "SSH_MSG_USERAUTH_BANNER";
83 reverseNames[60] = "SSH_MSG_USERAUTH_INFO_REQUEST";
84 reverseNames[61] = "SSH_MSG_USERAUTH_INFO_RESPONSE";
85 reverseNames[80] = "SSH_MSG_GLOBAL_REQUEST";
86 reverseNames[81] = "SSH_MSG_REQUEST_SUCCESS";
87 reverseNames[82] = "SSH_MSG_REQUEST_FAILURE";
88 reverseNames[90] = "SSH_MSG_CHANNEL_OPEN";
89 reverseNames[91] = "SSH_MSG_CHANNEL_OPEN_CONFIRMATION";
90 reverseNames[92] = "SSH_MSG_CHANNEL_OPEN_FAILURE";
91 reverseNames[93] = "SSH_MSG_CHANNEL_WINDOW_ADJUST";
92 reverseNames[94] = "SSH_MSG_CHANNEL_DATA";
93 reverseNames[95] = "SSH_MSG_CHANNEL_EXTENDED_DATA";
94 reverseNames[96] = "SSH_MSG_CHANNEL_EOF";
95 reverseNames[97] = "SSH_MSG_CHANNEL_CLOSE";
96 reverseNames[98] = "SSH_MSG_CHANNEL_REQUEST";
97 reverseNames[99] = "SSH_MSG_CHANNEL_SUCCESS";
98 reverseNames[100] = "SSH_MSG_CHANNEL_FAILURE";
99 }
74 100
75 reverseNames[20] = "SSH_MSG_KEXINIT"; 101 public static final String getMessageName(int type) {
76 reverseNames[21] = "SSH_MSG_NEWKEYS"; 102 String res = null;
77 103
78 reverseNames[30] = "SSH_MSG_KEXDH_INIT"; 104 if ((type >= 0) && (type < reverseNames.length)) {
79 reverseNames[31] = "SSH_MSG_KEXDH_REPLY/SSH_MSG_KEX_DH_GEX_GROUP"; 105 res = reverseNames[type];
80 reverseNames[32] = "SSH_MSG_KEX_DH_GEX_INIT"; 106 }
81 reverseNames[33] = "SSH_MSG_KEX_DH_GEX_REPLY";
82 reverseNames[34] = "SSH_MSG_KEX_DH_GEX_REQUEST";
83 107
84 reverseNames[50] = "SSH_MSG_USERAUTH_REQUEST"; 108 return (res == null) ? ("UNKNOWN MSG " + type) : res;
85 reverseNames[51] = "SSH_MSG_USERAUTH_FAILURE"; 109 }
86 reverseNames[52] = "SSH_MSG_USERAUTH_SUCCESS";
87 reverseNames[53] = "SSH_MSG_USERAUTH_BANNER";
88 110
89 reverseNames[60] = "SSH_MSG_USERAUTH_INFO_REQUEST"; 111 // public static final void debug(String tag, byte[] msg)
90 reverseNames[61] = "SSH_MSG_USERAUTH_INFO_RESPONSE"; 112 // {
91 113 // System.err.println(tag + " Type: " + msg[0] + ", LEN: " + msg.length);
92 reverseNames[80] = "SSH_MSG_GLOBAL_REQUEST"; 114 //
93 reverseNames[81] = "SSH_MSG_REQUEST_SUCCESS"; 115 // for (int i = 0; i < msg.length; i++)
94 reverseNames[82] = "SSH_MSG_REQUEST_FAILURE"; 116 // {
95 117 // if (((msg[i] >= 'a') && (msg[i] <= 'z')) || ((msg[i] >= 'A') && (msg[i] <= 'Z'))
96 reverseNames[90] = "SSH_MSG_CHANNEL_OPEN"; 118 // || ((msg[i] >= '0') && (msg[i] <= '9')) || (msg[i] == ' '))
97 reverseNames[91] = "SSH_MSG_CHANNEL_OPEN_CONFIRMATION"; 119 // System.err.print((char) msg[i]);
98 reverseNames[92] = "SSH_MSG_CHANNEL_OPEN_FAILURE"; 120 // else
99 reverseNames[93] = "SSH_MSG_CHANNEL_WINDOW_ADJUST"; 121 // System.err.print(".");
100 reverseNames[94] = "SSH_MSG_CHANNEL_DATA"; 122 // }
101 reverseNames[95] = "SSH_MSG_CHANNEL_EXTENDED_DATA"; 123 // System.err.println();
102 reverseNames[96] = "SSH_MSG_CHANNEL_EOF"; 124 // System.err.flush();
103 reverseNames[97] = "SSH_MSG_CHANNEL_CLOSE"; 125 // }
104 reverseNames[98] = "SSH_MSG_CHANNEL_REQUEST";
105 reverseNames[99] = "SSH_MSG_CHANNEL_SUCCESS";
106 reverseNames[100] = "SSH_MSG_CHANNEL_FAILURE";
107 }
108
109 public static final String getMessageName(int type)
110 {
111 String res = null;
112
113 if ((type >= 0) && (type < reverseNames.length))
114 {
115 res = reverseNames[type];
116 }
117
118 return (res == null) ? ("UNKNOWN MSG " + type) : res;
119 }
120
121 // public static final void debug(String tag, byte[] msg)
122 // {
123 // System.err.println(tag + " Type: " + msg[0] + ", LEN: " + msg.length);
124 //
125 // for (int i = 0; i < msg.length; i++)
126 // {
127 // if (((msg[i] >= 'a') && (msg[i] <= 'z')) || ((msg[i] >= 'A') && (msg[i] <= 'Z'))
128 // || ((msg[i] >= '0') && (msg[i] <= '9')) || (msg[i] == ' '))
129 // System.err.print((char) msg[i]);
130 // else
131 // System.err.print(".");
132 // }
133 // System.err.println();
134 // System.err.flush();
135 // }
136 } 126 }