This commit is contained in:
Shikhar Bhushan
2010-08-12 17:31:42 +01:00
parent 2f4fa62b14
commit 2e32bb9aca
2 changed files with 6 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ package net.schmizz.sshj.common;
/** SSH message identifiers */
public enum Message {
UNKNOWN(0),
DISCONNECT(1),
IGNORE(2),
UNIMPLEMENTED(3),
@@ -68,6 +69,10 @@ public enum Message {
static {
for (Message c : Message.values())
cache[c.toByte()] = c;
for (int i = 0; i < 256; i++) {
if (cache[i] == null)
cache[i] = UNKNOWN;
}
}
public static Message fromByte(byte b) {

View File

@@ -76,11 +76,7 @@ public class SSHPacket
* @return the message identifier
*/
public Message readMessageID() {
byte b = readByte();
Message cmd = Message.fromByte(b);
if (cmd == null)
throw new BufferException("Unknown message ID: " + b);
return cmd;
return Message.fromByte(readByte());
}
/**