You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2014/01/30 00:48:33 UTC

[4/4] git commit: [SSHD-284] Do not use an enum for SSH commands to avoid clashes

[SSHD-284] Do not use an enum for SSH commands to avoid clashes

Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/ade49e48
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/ade49e48
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/ade49e48

Branch: refs/heads/master
Commit: ade49e489abbf049dc761a55bdf3ee52a3aadbfe
Parents: 8a8765b
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Jan 30 00:48:19 2014 +0100
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Jan 30 00:48:19 2014 +0100

----------------------------------------------------------------------
 .../sshd/agent/local/AgentForwardedChannel.java |   2 +-
 .../agent/local/ChannelAgentForwarding.java     |   2 +-
 .../sshd/agent/unix/AgentForwardedChannel.java  |   2 +-
 .../sshd/agent/unix/ChannelAgentForwarding.java |   2 +-
 .../apache/sshd/client/auth/UserAuthAgent.java  |  14 +-
 .../auth/UserAuthKeyboardInteractive.java       |  14 +-
 .../sshd/client/auth/UserAuthPassword.java      |  12 +-
 .../sshd/client/auth/UserAuthPublicKey.java     |  14 +-
 .../client/channel/AbstractClientChannel.java   |   2 +-
 .../sshd/client/channel/ChannelDirectTcpip.java |   4 +-
 .../apache/sshd/client/channel/ChannelExec.java |   2 +-
 .../sshd/client/channel/ChannelSession.java     |   2 +-
 .../sshd/client/channel/ChannelShell.java       |   8 +-
 .../sshd/client/channel/ChannelSubsystem.java   |   2 +-
 .../sshd/client/kex/AbstractDHGClient.java      |   8 +-
 .../java/org/apache/sshd/client/kex/DHGEX.java  |  19 +--
 .../client/session/ClientConnectionService.java |   2 +-
 .../sshd/client/session/ClientSessionImpl.java  |   2 +-
 .../client/session/ClientUserAuthService.java   |   4 +-
 .../java/org/apache/sshd/common/Service.java    |   2 +-
 .../java/org/apache/sshd/common/Session.java    |   2 +-
 .../org/apache/sshd/common/SshConstants.java    | 154 ++++++-------------
 .../sshd/common/channel/AbstractChannel.java    |  14 +-
 .../common/channel/ChannelOutputStream.java     |   8 +-
 .../common/forward/DefaultTcpipForwarder.java   |   4 +-
 .../sshd/common/forward/TcpipClientChannel.java |   4 +-
 .../sshd/common/forward/TcpipServerChannel.java |   2 +-
 .../session/AbstractConnectionService.java      |  22 +--
 .../sshd/common/session/AbstractSession.java    |  24 +--
 .../org/apache/sshd/common/util/Buffer.java     |  13 --
 .../auth/UserAuthKeyboardInteractive.java       |   6 +-
 .../sshd/server/auth/UserAuthPublicKey.java     |   4 +-
 .../sshd/server/auth/gss/UserAuthGSS.java       |  14 +-
 .../server/channel/AbstractServerChannel.java   |   2 +-
 .../sshd/server/channel/ChannelSession.java     |   4 +-
 .../global/CancelTcpipForwardHandler.java       |   2 +-
 .../sshd/server/global/TcpipForwardHandler.java |   2 +-
 .../sshd/server/kex/AbstractDHGServer.java      |   8 +-
 .../java/org/apache/sshd/server/kex/DHGEX.java  |  21 +--
 .../server/session/ServerUserAuthService.java   |  12 +-
 .../sshd/server/x11/X11ForwardSupport.java      |   4 +-
 .../test/java/org/apache/sshd/ClientTest.java   |   2 +-
 42 files changed, 196 insertions(+), 251 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentForwardedChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentForwardedChannel.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentForwardedChannel.java
index 8b29f70..84d51eb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentForwardedChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentForwardedChannel.java
@@ -75,7 +75,7 @@ public class AgentForwardedChannel extends AbstractClientChannel {
 
     @Override
     protected void doOpen() throws IOException {
-        invertedIn = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
+        invertedIn = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
     }
 
     protected void doWriteData(byte[] data, int off, int len) throws IOException {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
index 61aea86..23c8ee6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
@@ -65,7 +65,7 @@ public class ChannelAgentForwarding extends AbstractServerChannel {
     protected OpenFuture doInit(Buffer buffer) {
         final OpenFuture f = new DefaultOpenFuture(this);
         try {
-            out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
+            out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
             agent = session.getFactoryManager().getAgentFactory().createClient(session.getFactoryManager());
             client = new AgentClient();
             f.setOpened();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentForwardedChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentForwardedChannel.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentForwardedChannel.java
index 4f23584..d9f5e6f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentForwardedChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentForwardedChannel.java
@@ -62,7 +62,7 @@ public class AgentForwardedChannel extends AbstractClientChannel implements Runn
 
     @Override
     protected synchronized void doOpen() throws IOException {
-        out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
+        out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
index 5dff9db..0887a1d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
@@ -66,7 +66,7 @@ public class ChannelAgentForwarding extends AbstractServerChannel {
     protected OpenFuture doInit(Buffer buffer) {
         final OpenFuture f = new DefaultOpenFuture(this);
         try {
-            out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
+            out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
             authSocket = session.getFactoryManager().getProperties().get(SshAgent.SSH_AUTHSOCKET_ENV_NAME);
             pool = Pool.create(AprLibrary.getInstance().getRootPool());
             handle = Local.create(authSocket, pool);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthAgent.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthAgent.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthAgent.java
index 5fe5926..7ceac6a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthAgent.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthAgent.java
@@ -49,7 +49,7 @@ public class UserAuthAgent extends AbstractUserAuth {
     protected void sendNextKey(PublicKey key) throws IOException {
         try {
             log.info("Send SSH_MSG_USERAUTH_REQUEST for publickey");
-            Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST, 0);
+            Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, 0);
             int pos1 = buffer.wpos() - 1;
             buffer.putString(username);
             buffer.putString(service);
@@ -62,7 +62,7 @@ public class UserAuthAgent extends AbstractUserAuth {
 
             Buffer bs = new Buffer();
             bs.putString(session.getKex().getH());
-            bs.putCommand(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST);
+            bs.putByte(SshConstants.SSH_MSG_USERAUTH_REQUEST);
             bs.putString(username);
             bs.putString(service);
             bs.putString("publickey");
@@ -93,12 +93,13 @@ public class UserAuthAgent extends AbstractUserAuth {
                 return Result.Failure;
             }
         } else {
-            SshConstants.Message cmd = buffer.getCommand();
-            log.info("Received {}", cmd);
-            if (cmd == SshConstants.Message.SSH_MSG_USERAUTH_SUCCESS) {
+            byte cmd = buffer.getByte();
+            if (cmd == SshConstants.SSH_MSG_USERAUTH_SUCCESS) {
+                log.info("Received SSH_MSG_USERAUTH_SUCCESS");
                 agent.close();
                 return Result.Success;
-            } if (cmd == SshConstants.Message.SSH_MSG_USERAUTH_FAILURE) {
+            } if (cmd == SshConstants.SSH_MSG_USERAUTH_FAILURE) {
+                log.info("Received SSH_MSG_USERAUTH_FAILURE");
                 if (keys.hasNext()) {
                     sendNextKey(keys.next().getFirst());
                     return Result.Continued;
@@ -108,6 +109,7 @@ public class UserAuthAgent extends AbstractUserAuth {
                 }
             } else {
                 // TODO: check packets
+                log.info("Received unknown packet: {}", cmd);
                 return Result.Continued;
             }
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
index d3fa707..36cd4bb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthKeyboardInteractive.java
@@ -23,9 +23,10 @@ import java.io.IOException;
 import org.apache.sshd.client.UserInteraction;
 import org.apache.sshd.client.session.ClientSessionImpl;
 import org.apache.sshd.common.SshConstants;
-import org.apache.sshd.common.SshConstants.Message;
 import org.apache.sshd.common.util.Buffer;
 
+import static org.apache.sshd.common.SshConstants.*;
+
 /**
  * Userauth with keyboard-interactive method.
  *
@@ -44,7 +45,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
     public Result next(Buffer buffer) throws IOException {
         if (buffer == null) {
             log.info("Send SSH_MSG_USERAUTH_REQUEST for password");
-            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST, 0);
+            buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, 0);
             buffer.putString(username);
             buffer.putString(service);
             buffer.putString("keyboard-interactive");
@@ -53,10 +54,10 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
             session.writePacket(buffer);
             return Result.Continued;
         } else {
-            SshConstants.Message cmd = buffer.getCommand();
-            log.info("Received {}", cmd);
+            byte cmd = buffer.getByte();
             switch (cmd) {
                 case SSH_MSG_USERAUTH_INFO_REQUEST:
+                    log.info("Received SSH_MSG_USERAUTH_INFO_REQUEST");
                     String name = buffer.getString();
                     String instruction = buffer.getString();
                     String language_tag = buffer.getString();
@@ -87,7 +88,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
                         return Result.Failure;
                     }
 
-                    buffer = session.createBuffer(Message.SSH_MSG_USERAUTH_INFO_RESPONSE, 0);
+                    buffer = session.createBuffer(SSH_MSG_USERAUTH_INFO_RESPONSE, 0);
                     buffer.putInt(rep.length);
                     for (String r : rep) {
                         buffer.putString(r);
@@ -95,10 +96,13 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
                     session.writePacket(buffer);
                     return Result.Continued;
                 case SSH_MSG_USERAUTH_SUCCESS:
+                    log.info("Received SSH_MSG_USERAUTH_SUCCESS");
                     return Result.Success;
                 case SSH_MSG_USERAUTH_FAILURE:
+                    log.info("Received SSH_MSG_USERAUTH_FAILURE");
                     return Result.Failure;
                 default:
+                    log.info("Received unknown packet {}", cmd);
                     return Result.Continued;
             }
         }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
index cb50ab3..900e36c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPassword.java
@@ -46,7 +46,7 @@ public class UserAuthPassword extends AbstractUserAuth {
     public Result next(Buffer buffer) throws IOException {
         if (buffer == null) {
             log.info("Send SSH_MSG_USERAUTH_REQUEST for password");
-            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST, 0);
+            buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, 0);
             buffer.putString(username);
             buffer.putString(service);
             buffer.putString("password");
@@ -55,13 +55,15 @@ public class UserAuthPassword extends AbstractUserAuth {
             session.writePacket(buffer);
             return Result.Continued;
         } else {
-            SshConstants.Message cmd = buffer.getCommand();
-            log.info("Received {}", cmd);
-            if (cmd == SshConstants.Message.SSH_MSG_USERAUTH_SUCCESS) {
+            byte cmd = buffer.getByte();
+            if (cmd == SshConstants.SSH_MSG_USERAUTH_SUCCESS) {
+                log.info("Received SSH_MSG_USERAUTH_SUCCESS");
                 return Result.Success;
-            } if (cmd == SshConstants.Message.SSH_MSG_USERAUTH_FAILURE) {
+            } if (cmd == SshConstants.SSH_MSG_USERAUTH_FAILURE) {
+                log.info("Received SSH_MSG_USERAUTH_FAILURE");
                 return Result.Failure;
             } else {
+                log.info("Received unkown packet {}", cmd);
                 // TODO: check packets
                 return Result.Continued;
             }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
index 97816a9..9804d2f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java
@@ -52,7 +52,7 @@ public class UserAuthPublicKey extends AbstractUserAuth {
         if (buffer == null) {
             try {
                 log.info("Send SSH_MSG_USERAUTH_REQUEST for publickey");
-                buffer = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST, 0);
+                buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, 0);
                 int pos1 = buffer.wpos() - 1;
                 buffer.putString(username);
                 buffer.putString(service);
@@ -67,7 +67,7 @@ public class UserAuthPublicKey extends AbstractUserAuth {
 
                 Buffer bs = new Buffer();
                 bs.putString(session.getKex().getH());
-                bs.putCommand(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST);
+                bs.putByte(SshConstants.SSH_MSG_USERAUTH_REQUEST);
                 bs.putString(username);
                 bs.putString(service);
                 bs.putString("publickey");
@@ -89,13 +89,15 @@ public class UserAuthPublicKey extends AbstractUserAuth {
                 throw (IOException) new IOException("Error performing public key authentication").initCause(e);
             }
         } else {
-            SshConstants.Message cmd = buffer.getCommand();
-            log.info("Received {}", cmd);
-            if (cmd == SshConstants.Message.SSH_MSG_USERAUTH_SUCCESS) {
+            byte cmd = buffer.getByte();
+            if (cmd == SshConstants.SSH_MSG_USERAUTH_SUCCESS) {
+                log.info("Received SSH_MSG_USERAUTH_SUCCESS");
                 return Result.Success;
-            } if (cmd == SshConstants.Message.SSH_MSG_USERAUTH_FAILURE) {
+            } if (cmd == SshConstants.SSH_MSG_USERAUTH_FAILURE) {
+                log.info("Received SSH_MSG_USERAUTH_FAILURE");
                 return Result.Failure;
             } else {
+                log.info("Received unknown packet {}", cmd);
                 // TODO: check packets
                 return Result.Continued;
             }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
index 84c0a06..43c38d4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
@@ -188,7 +188,7 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C
         }
         openFuture = new DefaultOpenFuture(lock);
         log.info("Send SSH_MSG_CHANNEL_OPEN on channel {}", id);
-        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN, 0);
+        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN, 0);
         buffer.putString(type);
         buffer.putInt(id);
         buffer.putInt(localWindow.getSize());

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
index d262d42..aa90440 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
@@ -66,7 +66,7 @@ public class ChannelDirectTcpip extends AbstractClientChannel {
         }
         openFuture = new DefaultOpenFuture(lock);
         log.info("Send SSH_MSG_CHANNEL_OPEN on channel {}", id);
-        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN, 0);
+        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN, 0);
         buffer.putString(type);
         buffer.putInt(id);
         buffer.putInt(localWindow.getSize());
@@ -81,7 +81,7 @@ public class ChannelDirectTcpip extends AbstractClientChannel {
 
     @Override
     protected void doOpen() throws IOException {
-        out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
+        out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
         in = new PipedInputStream(pipe);
     }
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelExec.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelExec.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelExec.java
index 3650313..0708b2d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelExec.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelExec.java
@@ -41,7 +41,7 @@ public class ChannelExec extends ChannelSession {
 
     protected void doOpen() throws IOException {
         log.info("Send SSH_MSG_CHANNEL_REQUEST exec");
-        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_REQUEST, 0);
+        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, 0);
         buffer.putInt(recipient);
         buffer.putString("exec");
         buffer.putBoolean(false);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
index e18378a..a93a138 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
@@ -48,7 +48,7 @@ public class ChannelSession extends AbstractClientChannel {
 
     @Override
     protected void doOpen() throws IOException {
-        invertedIn = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
+        invertedIn = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
         if (out == null) {
             ChannelPipedInputStream pis = new ChannelPipedInputStream(localWindow);
             ChannelPipedOutputStream pos = new ChannelPipedOutputStream(pis);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java
index a4ec085..f05a9af 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java
@@ -153,7 +153,7 @@ public class ChannelShell extends ChannelSession {
 
         if (agentForwarding) {
             log.info("Send agent forwarding request");
-            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_REQUEST, 0);
+            buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, 0);
             buffer.putInt(recipient);
             buffer.putString("auth-agent-req@openssh.com");
             buffer.putBoolean(false);
@@ -162,7 +162,7 @@ public class ChannelShell extends ChannelSession {
 
         if (usePty) {
             log.info("Send SSH_MSG_CHANNEL_REQUEST pty-req");
-            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_REQUEST, 0);
+            buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, 0);
             buffer.putInt(recipient);
             buffer.putString("pty-req");
             buffer.putBoolean(false);
@@ -184,7 +184,7 @@ public class ChannelShell extends ChannelSession {
         if (!env.isEmpty()) {
             log.info("Send SSH_MSG_CHANNEL_REQUEST env");
             for (Map.Entry<String, String> entry : env.entrySet()) {
-                buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_REQUEST, 0);
+                buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, 0);
                 buffer.putInt(recipient);
                 buffer.putString("env");
                 buffer.putBoolean(false);
@@ -195,7 +195,7 @@ public class ChannelShell extends ChannelSession {
         }
 
         log.info("Send SSH_MSG_CHANNEL_REQUEST shell");
-        buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_REQUEST, 0);
+        buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, 0);
         buffer.putInt(recipient);
         buffer.putString("shell");
         buffer.putBoolean(false);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSubsystem.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSubsystem.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSubsystem.java
index 965d486..304ee49 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSubsystem.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSubsystem.java
@@ -43,7 +43,7 @@ public class ChannelSubsystem extends ChannelSession {
 
     protected void doOpen() throws IOException {
         log.info("Send SSH_MSG_CHANNEL_REQUEST exec");
-        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_REQUEST, 0);
+        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, 0);
         buffer.putInt(recipient);
         buffer.putString("subsystem");
         buffer.putBoolean(false);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/kex/AbstractDHGClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/AbstractDHGClient.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/AbstractDHGClient.java
index 5cbd930..f93bd83 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/AbstractDHGClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/AbstractDHGClient.java
@@ -78,7 +78,7 @@ public abstract class AbstractDHGClient implements KeyExchange {
         e = dh.getE();
 
         log.info("Send SSH_MSG_KEXDH_INIT");
-        Buffer buffer = s.createBuffer(SshConstants.Message.SSH_MSG_KEXDH_INIT, 0);
+        Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_KEXDH_INIT, 0);
         buffer.putMPInt(e);
         session.writePacket(buffer);
     }
@@ -86,10 +86,10 @@ public abstract class AbstractDHGClient implements KeyExchange {
     protected abstract AbstractDH getDH() throws Exception;
 
     public boolean next(Buffer buffer) throws Exception {
-        SshConstants.Message cmd = buffer.getCommand();
-        if (cmd != SshConstants.Message.SSH_MSG_KEXDH_REPLY_KEX_DH_GEX_GROUP) {
+        byte cmd = buffer.getByte();
+        if (cmd != SshConstants.SSH_MSG_KEXDH_REPLY) {
             throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
-                                   "Protocol error: expected packet " + SshConstants.Message.SSH_MSG_KEXDH_REPLY_KEX_DH_GEX_GROUP + ", got " + cmd);
+                                   "Protocol error: expected packet SSH_MSG_KEXDH_REPLY, got " + cmd);
         }
 
         log.info("Received SSH_MSG_KEXDH_REPLY");

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEX.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEX.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEX.java
index 4e82453..4eb033a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEX.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEX.java
@@ -78,7 +78,7 @@ public class DHGEX implements KeyExchange {
     private byte[] K;
     private byte[] H;
     private PublicKey serverKey;
-    private SshConstants.Message expected;
+    private byte expected;
 
     int min = 1024;
     int prf = 4096;
@@ -95,24 +95,24 @@ public class DHGEX implements KeyExchange {
         this.I_C = I_C;
 
         log.info("Send SSH_MSG_KEX_DH_GEX_REQUEST");
-        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_KEX_DH_GEX_REQUEST, 0);
+        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_KEX_DH_GEX_REQUEST, 0);
         buffer.putInt(min);
         buffer.putInt(prf);
         buffer.putInt(max);
         session.writePacket(buffer);
 
-        expected = SshConstants.Message.SSH_MSG_KEXDH_REPLY_KEX_DH_GEX_GROUP;
+        expected = SshConstants.SSH_MSG_KEX_DH_GEX_GROUP;
     }
 
     public boolean next(Buffer buffer) throws Exception {
-        SshConstants.Message cmd = buffer.getCommand();
-        log.info("Received " + cmd);
+        byte cmd = buffer.getByte();
         if (cmd != expected) {
             throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
                     "Protocol error: expected packet " + expected + ", got " + cmd);
         }
 
-        if (cmd == SshConstants.Message.SSH_MSG_KEXDH_REPLY_KEX_DH_GEX_GROUP) {
+        if (cmd == SshConstants.SSH_MSG_KEX_DH_GEX_GROUP) {
+            log.info("Received SSH_MSG_KEX_DH_GEX_GROUP");
             p = buffer.getMPIntAsBytes();
             g = buffer.getMPIntAsBytes();
 
@@ -122,14 +122,15 @@ public class DHGEX implements KeyExchange {
             e = dh.getE();
 
             log.info("Send SSH_MSG_KEX_DH_GEX_INIT");
-            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_KEX_DH_GEX_INIT, 0);
+            buffer = session.createBuffer(SshConstants.SSH_MSG_KEX_DH_GEX_INIT, 0);
             buffer.putMPInt(e);
             session.writePacket(buffer);
-            expected = SshConstants.Message.SSH_MSG_KEX_DH_GEX_REPLY;
+            expected = SshConstants.SSH_MSG_KEX_DH_GEX_REPLY;
             return false;
         }
 
-        if (cmd == SshConstants.Message.SSH_MSG_KEX_DH_GEX_REPLY) {
+        if (cmd == SshConstants.SSH_MSG_KEX_DH_GEX_REPLY) {
+            log.info("Received SSH_MSG_KEX_DH_GEX_REPLY");
             byte[] K_S = buffer.getBytes();
             f = buffer.getMPIntAsBytes();
             byte[] sig = buffer.getBytes();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
index d183284..f6e6346 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
@@ -86,7 +86,7 @@ public class ClientConnectionService extends AbstractConnectionService {
 
     protected void sendHeartBeat() {
         try {
-            Buffer buf = session.createBuffer(SshConstants.Message.SSH_MSG_GLOBAL_REQUEST, 0);
+            Buffer buf = session.createBuffer(SshConstants.SSH_MSG_GLOBAL_REQUEST, 0);
             String request = session.getFactoryManager().getProperties().get(ClientFactoryManager.HEARTBEAT_REQUEST);
             if (request == null) {
                 request = "keepalive@sshd.apache.org";

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
index 42af0ff..6da6c0c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
@@ -326,7 +326,7 @@ public class ClientSessionImpl extends AbstractSession implements ClientSession
         }
         initialServiceRequestSent = true;
         log.info("Send SSH_MSG_SERVICE_REQUEST for {}", currentServiceFactory.getName());
-        Buffer request = createBuffer(SshConstants.Message.SSH_MSG_SERVICE_REQUEST, 0);
+        Buffer request = createBuffer(SshConstants.SSH_MSG_SERVICE_REQUEST, 0);
         request.putString(currentServiceFactory.getName());
         writePacket(request);
         // Assuming that MINA-SSHD only implements "explicit server authentication" it is permissible

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
index 9527d34..d98c510 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
@@ -92,13 +92,13 @@ public class ClientUserAuthService implements Service {
         }
     }
 
-    public void process(SshConstants.Message cmd, Buffer buffer) throws Exception {
+    public void process(byte cmd, Buffer buffer) throws Exception {
         if (this.authFuture.isSuccess()) {
             throw new IllegalStateException("UserAuth message delivered to authenticated client");
         } else if (this.authFuture.isDone()) {
             log.debug("Ignoring random message");
             // ignore for now; TODO: random packets
-        } else if (cmd == SshConstants.Message.SSH_MSG_USERAUTH_BANNER) {
+        } else if (cmd == SshConstants.SSH_MSG_USERAUTH_BANNER) {
             String welcome = buffer.getString();
             String lang = buffer.getString();
             log.debug("Welcome banner: {}", welcome);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/common/Service.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/Service.java b/sshd-core/src/main/java/org/apache/sshd/common/Service.java
index e3f60b3..02f2052 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/Service.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/Service.java
@@ -41,7 +41,7 @@ public interface Service {
      * @param buffer
      * @throws Exception
      */
-    void process(SshConstants.Message cmd, Buffer buffer) throws Exception;
+    void process(byte cmd, Buffer buffer) throws Exception;
 
     /**
      * Close the service.

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/common/Session.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/Session.java b/sshd-core/src/main/java/org/apache/sshd/common/Session.java
index 9b8bcae..9451fd8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/Session.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/Session.java
@@ -94,7 +94,7 @@ public interface Session {
      * @param estimatedSize estimated number of bytes the buffer will hold, 0 if unknown.
      * @return a new buffer ready for write
      */
-    Buffer createBuffer(SshConstants.Message cmd, int estimatedSize);
+    Buffer createBuffer(byte cmd, int estimatedSize);
 
     /**
      * Encode and send the given buffer.

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java b/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
index 26148fd..1eda338 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
@@ -25,112 +25,54 @@ package org.apache.sshd.common;
  */
 public interface SshConstants {
 
-    /**
-     * SSH message identifiers
-     */
-    public enum Message {
-
-        SSH_MSG_DISCONNECT(1),
-        SSH_MSG_IGNORE(2),
-        SSH_MSG_UNIMPLEMENTED(3),
-        SSH_MSG_DEBUG(4),
-        SSH_MSG_SERVICE_REQUEST(5),
-        SSH_MSG_SERVICE_ACCEPT(6),
-        SSH_MSG_KEXINIT(20),
-        SSH_MSG_NEWKEYS(21),
-
-        SSH_MSG_KEXDH_INIT(30),
-
-        // KEXDH_REPLY and KEX_DH_GEX_GROUP have the same command ID
-        SSH_MSG_KEXDH_REPLY_KEX_DH_GEX_GROUP(31),
-
-        SSH_MSG_KEX_DH_GEX_INIT(32),
-        SSH_MSG_KEX_DH_GEX_REPLY(33),
-        SSH_MSG_KEX_DH_GEX_REQUEST(34),
-
-        SSH_MSG_USERAUTH_REQUEST(50),
-        SSH_MSG_USERAUTH_FAILURE(51),
-        SSH_MSG_USERAUTH_SUCCESS(52),
-        SSH_MSG_USERAUTH_BANNER(53),
-        SSH_MSG_USERAUTH_INFO_REQUEST(60),
-        SSH_MSG_USERAUTH_INFO_RESPONSE(61),
-        SSH_MSG_USERAUTH_PK_OK(60),
-
-        SSH_MSG_GLOBAL_REQUEST(80),
-        SSH_MSG_REQUEST_SUCCESS(81),
-        SSH_MSG_REQUEST_FAILURE(82),
-        
-        SSH_MSG_USERAUTH_GSSAPI_MIC(66),        
-
-        SSH_MSG_CHANNEL_OPEN(90),
-        SSH_MSG_CHANNEL_OPEN_CONFIRMATION(91),
-        SSH_MSG_CHANNEL_OPEN_FAILURE(92),
-        SSH_MSG_CHANNEL_WINDOW_ADJUST(93),
-        SSH_MSG_CHANNEL_DATA(94),
-        SSH_MSG_CHANNEL_EXTENDED_DATA(95),
-        SSH_MSG_CHANNEL_EOF(96),
-        SSH_MSG_CHANNEL_CLOSE(97),
-        SSH_MSG_CHANNEL_REQUEST(98),
-        SSH_MSG_CHANNEL_SUCCESS(99),
-        SSH_MSG_CHANNEL_FAILURE(100);
-
-        private byte b;
-        private Message(int b) {
-            this.b = (byte) b;
-        }
-
-        public byte toByte() {
-            return b;
-        }
-
-        static Message[] commands;
-        static {
-            commands = new Message[256];
-            for (Message c : Message.values()) {
-                if (commands[c.toByte()] == null) {
-                    commands[c.toByte()] = c;
-                }
-            }
-        }
-        public static Message fromByte(byte b) {
-            return commands[b];
-        }
-    }
-
-    static final int SSH_MSG_DISCONNECT=                      1;
-    static final int SSH_MSG_IGNORE=                          2;
-    static final int SSH_MSG_UNIMPLEMENTED=                   3;
-    static final int SSH_MSG_DEBUG=                           4;
-    static final int SSH_MSG_SERVICE_REQUEST=                 5;
-    static final int SSH_MSG_SERVICE_ACCEPT=                  6;
-    static final int SSH_MSG_KEXINIT=                        20;
-    static final int SSH_MSG_NEWKEYS=                        21;
-
-    static final int SSH_MSG_KEX_FIRST=                      30;
-    static final int SSH_MSG_KEX_LAST=                       49;
-
-    static final int SSH_MSG_KEXDH_INIT=                     30;
-    static final int SSH_MSG_KEXDH_REPLY=                    31;
-
-    static final int SSH_MSG_KEX_DH_GEX_GROUP=               31;
-    static final int SSH_MSG_KEX_DH_GEX_INIT=                32;
-    static final int SSH_MSG_KEX_DH_GEX_REPLY=               33;
-    static final int SSH_MSG_KEX_DH_GEX_REQUEST=             34;
-
-    static final int SSH_MSG_GLOBAL_REQUEST=                 80;
-    static final int SSH_MSG_REQUEST_SUCCESS=                81;
-    static final int SSH_MSG_REQUEST_FAILURE=                82;
-    static final int SSH_MSG_CHANNEL_OPEN=                   90;
-    static final int SSH_MSG_CHANNEL_OPEN_CONFIRMATION=      91;
-    static final int SSH_MSG_CHANNEL_OPEN_FAILURE=           92;
-    static final int SSH_MSG_CHANNEL_WINDOW_ADJUST=          93;
-    static final int SSH_MSG_CHANNEL_DATA=                   94;
-    static final int SSH_MSG_CHANNEL_EXTENDED_DATA=          95;
-    static final int SSH_MSG_CHANNEL_EOF=                    96;
-    static final int SSH_MSG_CHANNEL_CLOSE=                  97;
-    static final int SSH_MSG_CHANNEL_REQUEST=                98;
-    static final int SSH_MSG_CHANNEL_SUCCESS=                99;
-    static final int SSH_MSG_CHANNEL_FAILURE=               100;
+    //
+    // SSH message identifiers
+    //
+
+    static final byte SSH_MSG_DISCONNECT=                      1;
+    static final byte SSH_MSG_IGNORE=                          2;
+    static final byte SSH_MSG_UNIMPLEMENTED=                   3;
+    static final byte SSH_MSG_DEBUG=                           4;
+    static final byte SSH_MSG_SERVICE_REQUEST=                 5;
+    static final byte SSH_MSG_SERVICE_ACCEPT=                  6;
+    static final byte SSH_MSG_KEXINIT=                        20;
+    static final byte SSH_MSG_NEWKEYS=                        21;
+
+    static final byte SSH_MSG_KEX_FIRST=                      30;
+    static final byte SSH_MSG_KEX_LAST=                       49;
+
+    static final byte SSH_MSG_KEXDH_INIT=                     30;
+    static final byte SSH_MSG_KEXDH_REPLY=                    31;
+
+    static final byte SSH_MSG_KEX_DH_GEX_GROUP=               31;
+    static final byte SSH_MSG_KEX_DH_GEX_INIT=                32;
+    static final byte SSH_MSG_KEX_DH_GEX_REPLY=               33;
+    static final byte SSH_MSG_KEX_DH_GEX_REQUEST=             34;
+
+    static final byte SSH_MSG_USERAUTH_REQUEST=               50;
+    static final byte SSH_MSG_USERAUTH_FAILURE=               51;
+    static final byte SSH_MSG_USERAUTH_SUCCESS=               52;
+    static final byte SSH_MSG_USERAUTH_BANNER=                53;
+    static final byte SSH_MSG_USERAUTH_INFO_REQUEST=          60;
+    static final byte SSH_MSG_USERAUTH_INFO_RESPONSE=         61;
+    static final byte SSH_MSG_USERAUTH_PK_OK=                 60;
+
+    static final byte SSH_MSG_USERAUTH_GSSAPI_MIC=            66;
+
+    static final byte SSH_MSG_GLOBAL_REQUEST=                 80;
+    static final byte SSH_MSG_REQUEST_SUCCESS=                81;
+    static final byte SSH_MSG_REQUEST_FAILURE=                82;
+    static final byte SSH_MSG_CHANNEL_OPEN=                   90;
+    static final byte SSH_MSG_CHANNEL_OPEN_CONFIRMATION=      91;
+    static final byte SSH_MSG_CHANNEL_OPEN_FAILURE=           92;
+    static final byte SSH_MSG_CHANNEL_WINDOW_ADJUST=          93;
+    static final byte SSH_MSG_CHANNEL_DATA=                   94;
+    static final byte SSH_MSG_CHANNEL_EXTENDED_DATA=          95;
+    static final byte SSH_MSG_CHANNEL_EOF=                    96;
+    static final byte SSH_MSG_CHANNEL_CLOSE=                  97;
+    static final byte SSH_MSG_CHANNEL_REQUEST=                98;
+    static final byte SSH_MSG_CHANNEL_SUCCESS=                99;
+    static final byte SSH_MSG_CHANNEL_FAILURE=               100;
 
     //
     // Values for the algorithms negociation 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
index 4e610bb..c1fdd84 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
@@ -103,14 +103,14 @@ public abstract class AbstractChannel implements Channel {
                     return;
                 case ReplySuccess:
                     if (wantReply) {
-                        buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_SUCCESS, 0);
+                        buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_SUCCESS, 0);
                         buffer.putInt(recipient);
                         session.writePacket(buffer);
                     }
                     return;
                 case ReplyFailure:
                     if (wantReply) {
-                        buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_FAILURE, 0);
+                        buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_FAILURE, 0);
                         buffer.putInt(recipient);
                         session.writePacket(buffer);
                     }
@@ -119,7 +119,7 @@ public abstract class AbstractChannel implements Channel {
         }
         log.warn("Unknown channel request: {}", req);
         if (wantReply) {
-            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_FAILURE, 0);
+            buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_FAILURE, 0);
             buffer.putInt(recipient);
             session.writePacket(buffer);
         }
@@ -155,7 +155,7 @@ public abstract class AbstractChannel implements Channel {
                 preClose(immediately).addListener(new SshFutureListener<CloseFuture>() {
                     public void operationComplete(CloseFuture future) {
                         log.debug("Send SSH_MSG_CHANNEL_CLOSE on channel {}", id);
-                        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_CLOSE, 0);
+                        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_CLOSE, 0);
                         buffer.putInt(recipient);
                         try {
                             session.writePacket(buffer).addListener(new SshFutureListener<IoWriteFuture>() {
@@ -227,7 +227,7 @@ public abstract class AbstractChannel implements Channel {
         // Only accept extended data for stderr
         if (ex != 1) {
             log.debug("Send SSH_MSG_CHANNEL_FAILURE on channel {}", id);
-            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_FAILURE, 0);
+            buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_FAILURE, 0);
             buffer.putInt(recipient);
             writePacket(buffer);
             return;
@@ -266,7 +266,7 @@ public abstract class AbstractChannel implements Channel {
 
     protected void sendEof() throws IOException {
         log.debug("Send SSH_MSG_CHANNEL_EOF on channel {}", id);
-        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_EOF, 0);
+        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_EOF, 0);
         buffer.putInt(recipient);
         writePacket(buffer);
     }
@@ -279,7 +279,7 @@ public abstract class AbstractChannel implements Channel {
 
     protected void sendWindowAdjust(int len) throws IOException {
         log.debug("Send SSH_MSG_CHANNEL_WINDOW_ADJUST on channel {}", id);
-        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_WINDOW_ADJUST, 0);
+        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_WINDOW_ADJUST, 0);
         buffer.putInt(recipient);
         buffer.putInt(len);
         writePacket(buffer);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
index e0441ba..6aeafbc 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
@@ -37,7 +37,7 @@ public class ChannelOutputStream extends OutputStream {
     private final AbstractChannel channel;
     private final Window remoteWindow;
     private final Logger log;
-    private final SshConstants.Message cmd;
+    private final byte cmd;
     private final byte[] b = new byte[1];
     private Buffer buffer;
     private boolean closed;
@@ -45,7 +45,7 @@ public class ChannelOutputStream extends OutputStream {
     private int lastSize;
     private boolean noDelay = false;
 
-    public ChannelOutputStream(AbstractChannel channel, Window remoteWindow, Logger log, SshConstants.Message cmd) {
+    public ChannelOutputStream(AbstractChannel channel, Window remoteWindow, Logger log, byte cmd) {
         this.channel = channel;
         this.remoteWindow = remoteWindow;
         this.log = log;
@@ -115,7 +115,7 @@ public class ChannelOutputStream extends OutputStream {
                 int total = bufferLength;
                 int length = Math.min(Math.min(remoteWindow.waitForSpace(), total), remoteWindow.getPacketSize());
                 int pos = buf.wpos();
-                buf.wpos(cmd == SshConstants.Message.SSH_MSG_CHANNEL_EXTENDED_DATA ? 14 : 10);
+                buf.wpos(cmd == SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA ? 14 : 10);
                 buf.putInt(length);
                 buf.wpos(buf.wpos() + length);
                 if (total == length) {
@@ -150,7 +150,7 @@ public class ChannelOutputStream extends OutputStream {
     private void newBuffer(int size) {
         buffer = channel.getSession().createBuffer(cmd, size <= 0 ? 0 : 12 + size);
         buffer.putInt(channel.getRecipient());
-        if (cmd == SshConstants.Message.SSH_MSG_CHANNEL_EXTENDED_DATA) {
+        if (cmd == SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA) {
             buffer.putInt(1);
         }
         buffer.putInt(0);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
index 45d8612..1909f21 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
@@ -94,7 +94,7 @@ public class DefaultTcpipForwarder implements TcpipForwarder, IoHandler {
     }
 
     public synchronized SshdSocketAddress startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local) throws IOException {
-        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_GLOBAL_REQUEST, 0);
+        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_GLOBAL_REQUEST, 0);
         buffer.putString("tcpip-forward");
         buffer.putBoolean(true);
         buffer.putString(remote.getHostName());
@@ -111,7 +111,7 @@ public class DefaultTcpipForwarder implements TcpipForwarder, IoHandler {
 
     public synchronized void stopRemotePortForwarding(SshdSocketAddress remote) throws IOException {
         if (remoteToLocal.remove(remote.getPort()) != null) {
-            Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_GLOBAL_REQUEST, 0);
+            Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_GLOBAL_REQUEST, 0);
             buffer.putString("cancel-tcpip-forward");
             buffer.putBoolean(false);
             buffer.putString(remote.getHostName());

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
index 93ab19d..e4badbf 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
@@ -80,7 +80,7 @@ public class TcpipClientChannel extends AbstractClientChannel {
         }
         openFuture = new DefaultOpenFuture(lock);
         log.info("Send SSH_MSG_CHANNEL_OPEN on channel {}", id);
-        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN, 0);
+        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN, 0);
         buffer.putString(type);
         buffer.putInt(id);
         buffer.putInt(localWindow.getSize());
@@ -95,7 +95,7 @@ public class TcpipClientChannel extends AbstractClientChannel {
 
     @Override
     protected synchronized void doOpen() throws IOException {
-        out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
+        out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipServerChannel.java
index 48ee313..3ee8429 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipServerChannel.java
@@ -107,7 +107,7 @@ public class TcpipServerChannel extends AbstractServerChannel {
             return f;
         }
 
-        out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
+        out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
         IoHandler handler = new IoHandler() {
             public void messageReceived(IoSession session, Readable message) throws Exception {
                 if (closing.get()) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
index ce68594..a53c0a5 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
@@ -44,6 +44,8 @@ import org.apache.sshd.server.x11.X11ForwardSupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.sshd.common.SshConstants.*;
+
 /**
  * Base implementation of ConnectionService.
  *
@@ -147,7 +149,7 @@ public abstract class AbstractConnectionService implements ConnectionService {
         channels.remove(channel.getId());
     }
 
-    public void process(SshConstants.Message cmd, Buffer buffer) throws Exception {
+    public void process(byte cmd, Buffer buffer) throws Exception {
         switch (cmd) {
             case SSH_MSG_CHANNEL_OPEN:
                 channelOpen(buffer);
@@ -307,7 +309,7 @@ public abstract class AbstractConnectionService implements ConnectionService {
         Channel channel = channels.get(recipient);
         if (channel == null) {
             buffer.rpos(buffer.rpos() - 5);
-            SshConstants.Message cmd = buffer.getCommand();
+            byte cmd = buffer.getByte();
             throw new SshException("Received " + cmd + " on unknown channel " + recipient);
         }
         return channel;
@@ -322,7 +324,7 @@ public abstract class AbstractConnectionService implements ConnectionService {
         log.debug("Received SSH_MSG_CHANNEL_OPEN {}", type);
 
         if (closing) {
-            Buffer buf = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN_FAILURE, 0);
+            Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_FAILURE, 0);
             buf.putInt(id);
             buf.putInt(SshConstants.SSH_OPEN_CONNECT_FAILED);
             buf.putString("SSH server is shutting down: " + type);
@@ -331,7 +333,7 @@ public abstract class AbstractConnectionService implements ConnectionService {
             return;
         }
         if (!allowMoreSessions) {
-            Buffer buf = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN_FAILURE, 0);
+            Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_FAILURE, 0);
             buf.putInt(id);
             buf.putInt(SshConstants.SSH_OPEN_CONNECT_FAILED);
             buf.putString("additional sessions disabled");
@@ -342,7 +344,7 @@ public abstract class AbstractConnectionService implements ConnectionService {
 
         final Channel channel = NamedFactory.Utils.create(session.getFactoryManager().getChannelFactories(), type);
         if (channel == null) {
-            Buffer buf = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN_FAILURE, 0);
+            Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_FAILURE, 0);
             buf.putInt(id);
             buf.putInt(SshConstants.SSH_OPEN_UNKNOWN_CHANNEL_TYPE);
             buf.putString("Unsupported channel type: " + type);
@@ -356,7 +358,7 @@ public abstract class AbstractConnectionService implements ConnectionService {
             public void operationComplete(OpenFuture future) {
                 try {
                     if (future.isOpened()) {
-                        Buffer buf = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN_CONFIRMATION, 0);
+                        Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_CONFIRMATION, 0);
                         buf.putInt(id);
                         buf.putInt(channelId);
                         buf.putInt(channel.getLocalWindow().getSize());
@@ -365,7 +367,7 @@ public abstract class AbstractConnectionService implements ConnectionService {
                     } else {
                         Throwable exception = future.getException();
                         if (exception != null) {
-                            Buffer buf = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN_FAILURE, 0);
+                            Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_FAILURE, 0);
                             buf.putInt(id);
                             if (exception instanceof OpenChannelException) {
                                 buf.putInt(((OpenChannelException) exception).getReasonCode());
@@ -410,13 +412,13 @@ public abstract class AbstractConnectionService implements ConnectionService {
                         return;
                     case ReplySuccess:
                         if (wantReply) {
-                            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_REQUEST_SUCCESS, 0);
+                            buffer = session.createBuffer(SshConstants.SSH_MSG_REQUEST_SUCCESS, 0);
                             session.writePacket(buffer);
                         }
                         return;
                     case ReplyFailure:
                         if (wantReply) {
-                            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_REQUEST_FAILURE, 0);
+                            buffer = session.createBuffer(SshConstants.SSH_MSG_REQUEST_FAILURE, 0);
                             session.writePacket(buffer);
                         }
                         return;
@@ -425,7 +427,7 @@ public abstract class AbstractConnectionService implements ConnectionService {
         }
         log.warn("Unknown global request: {}", req);
         if (wantReply) {
-            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_REQUEST_FAILURE, 0);
+            buffer = session.createBuffer(SshConstants.SSH_MSG_REQUEST_FAILURE, 0);
             session.writePacket(buffer);
         }
     }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
index b703dff..4fa7ff8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
@@ -54,6 +54,8 @@ import org.apache.sshd.common.util.Readable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.sshd.common.SshConstants.*;
+
 /**
  * The AbstractSession handles all the basic SSH protocol such as key exchange, authentication,
  * encoding and decoding. Both server side and client side sessions should inherit from this
@@ -287,7 +289,7 @@ public abstract class AbstractSession implements Session {
      * @throws Exception if an exeption occurs while handling this packet.
      */
     protected void handleMessage(Buffer buffer) throws Exception {
-        SshConstants.Message cmd = buffer.getCommand();
+        byte cmd = buffer.getByte();
         switch (cmd) {
             case SSH_MSG_DISCONNECT: {
                 int code = buffer.getInt();
@@ -325,7 +327,7 @@ public abstract class AbstractSession implements Session {
                     break;
                 }
                 log.debug("Accepted service {}", service);
-                Buffer response = createBuffer(SshConstants.Message.SSH_MSG_SERVICE_ACCEPT, 0);
+                Buffer response = createBuffer(SshConstants.SSH_MSG_SERVICE_ACCEPT, 0);
                 response.putString(service);
                 writePacket(response);
                 break;
@@ -363,9 +365,9 @@ public abstract class AbstractSession implements Session {
                 break;
             default:
                 log.debug("Received {}", cmd);
-                if (cmd.toByte() >= SshConstants.SSH_MSG_KEX_FIRST && cmd.toByte() <= SshConstants.SSH_MSG_KEX_LAST) {
+                if (cmd >= SshConstants.SSH_MSG_KEX_FIRST && cmd <= SshConstants.SSH_MSG_KEX_LAST) {
                     if (kexState != KEX_STATE_RUN) {
-                        throw new IllegalStateException("Received kex command " + cmd.toByte() + " while not in key exchange");
+                        throw new IllegalStateException("Received kex command " + cmd + " while not in key exchange");
                     }
                     buffer.rpos(buffer.rpos() - 1);
                     if (kex.next(buffer)) {
@@ -512,7 +514,7 @@ public abstract class AbstractSession implements Session {
      * @param len estimated number of bytes the buffer will hold, 0 if unknown.
      * @return a new buffer ready for write
      */
-    public Buffer createBuffer(SshConstants.Message cmd, int len) {
+    public Buffer createBuffer(byte cmd, int len) {
         Buffer buffer;
         if (len <= 0) {
             buffer = new Buffer();
@@ -536,7 +538,7 @@ public abstract class AbstractSession implements Session {
         }
         buffer.rpos(5);
         buffer.wpos(5);
-        buffer.putByte(cmd.toByte());
+        buffer.putByte(cmd);
         return buffer;
     }
 
@@ -805,7 +807,7 @@ public abstract class AbstractSession implements Session {
      * @throws IOException if an error occured sending the packet
      */
     protected byte[] sendKexInit(String[] proposal) throws IOException {
-        Buffer buffer = createBuffer(SshConstants.Message.SSH_MSG_KEXINIT, 0);
+        Buffer buffer = createBuffer(SshConstants.SSH_MSG_KEXINIT, 0);
         int p = buffer.wpos();
         buffer.wpos(p + 16);
         random.fill(buffer.array(), p, 16);
@@ -832,7 +834,7 @@ public abstract class AbstractSession implements Session {
         int size = 22;
         byte[] d = buffer.array();
         byte[] data = new byte[buffer.available() + 1];
-        data[0] = SshConstants.Message.SSH_MSG_KEXINIT.toByte();
+        data[0] = SshConstants.SSH_MSG_KEXINIT;
         System.arraycopy(d, buffer.rpos(), data, 1, data.length - 1);
         // Skip 16 bytes of random data
         buffer.rpos(buffer.rpos() + 16);
@@ -858,7 +860,7 @@ public abstract class AbstractSession implements Session {
      */
     protected void sendNewKeys() throws IOException {
         log.debug("Send SSH_MSG_NEWKEYS");
-        Buffer buffer = createBuffer(SshConstants.Message.SSH_MSG_NEWKEYS, 0);
+        Buffer buffer = createBuffer(SshConstants.SSH_MSG_NEWKEYS, 0);
         writePacket(buffer);
     }
 
@@ -1006,7 +1008,7 @@ public abstract class AbstractSession implements Session {
      * @throws IOException if an error occured sending the packet
      */
     public void disconnect(int reason, String msg) throws IOException {
-        Buffer buffer = createBuffer(SshConstants.Message.SSH_MSG_DISCONNECT, 0);
+        Buffer buffer = createBuffer(SshConstants.SSH_MSG_DISCONNECT, 0);
         buffer.putInt(reason);
         buffer.putString(msg);
         buffer.putString("");
@@ -1025,7 +1027,7 @@ public abstract class AbstractSession implements Session {
      * @throws IOException if an error occured sending the packet
      */
     protected void notImplemented() throws IOException {
-        Buffer buffer = createBuffer(SshConstants.Message.SSH_MSG_UNIMPLEMENTED, 0);
+        Buffer buffer = createBuffer(SshConstants.SSH_MSG_UNIMPLEMENTED, 0);
         buffer.putInt(seqi - 1);
         writePacket(buffer);
     }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/common/util/Buffer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/Buffer.java b/sshd-core/src/main/java/org/apache/sshd/common/util/Buffer.java
index 804eec6..42c0d50 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/Buffer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/Buffer.java
@@ -356,15 +356,6 @@ public final class Buffer implements Readable {
         return new KeyPair(pubKey, privKey);
     }
 
-    public SshConstants.Message getCommand() {
-        byte b = getByte();
-        SshConstants.Message cmd = SshConstants.Message.fromByte(b);
-        if (cmd == null) {
-            throw new IllegalStateException("Unknown command code: " + b);
-        }
-        return cmd;
-    }
-
     private void ensureAvailable(int a) {
         if (available() < a) {
             throw new BufferException("Underflow");
@@ -530,10 +521,6 @@ public final class Buffer implements Readable {
         }
     }
 
-    public void putCommand(SshConstants.Message cmd) {
-        putByte(cmd.toByte());
-    }
-
     private void ensureCapacity(int capacity) {
         if (data.length - wpos < capacity) {
             int cw = wpos + capacity;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
index fd12e59..989d4a6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthKeyboardInteractive.java
@@ -49,7 +49,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
         }
         if (init) {
             // Prompt for password
-            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_INFO_REQUEST, 0);
+            buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_INFO_REQUEST, 0);
             buffer.putString("Password authentication");
             buffer.putString("");
             buffer.putString("en-US");
@@ -59,8 +59,8 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
             session.writePacket(buffer);
             return null;
         } else {
-            SshConstants.Message cmd = buffer.getCommand();
-            if (cmd != SshConstants.Message.SSH_MSG_USERAUTH_INFO_RESPONSE) {
+            byte cmd = buffer.getByte();
+            if (cmd != SshConstants.SSH_MSG_USERAUTH_INFO_RESPONSE) {
                 throw new SshException("Received unexepected message: " + cmd);
             }
             int num = buffer.getInt();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java
index bcf8a19..e71957c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java
@@ -79,7 +79,7 @@ public class UserAuthPublicKey extends AbstractUserAuth {
             return false;
         }
         if (!hasSig) {
-            Buffer buf = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_PK_OK, 0);
+            Buffer buf = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_PK_OK, 0);
             buf.putString(alg);
             buf.putRawBytes(buffer.array(), oldPos, 4 + len);
             session.writePacket(buf);
@@ -87,7 +87,7 @@ public class UserAuthPublicKey extends AbstractUserAuth {
         } else {
             Buffer buf = new Buffer();
             buf.putString(session.getKex().getH());
-            buf.putCommand(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST);
+            buf.putByte(SshConstants.SSH_MSG_USERAUTH_REQUEST);
             buf.putString(username);
             buf.putString("ssh-connection");
             buf.putString("publickey");

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
index de22a2a..ca6bb41 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
@@ -85,7 +85,7 @@ public class UserAuthGSS extends AbstractUserAuth {
 
                     // Send the matching mechanism back to the client
 
-                    Buffer b = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_INFO_REQUEST, 0);
+                    Buffer b = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_INFO_REQUEST, 0);
                     byte[] out = oid.getDER();
 
                     b.putBytes(out);
@@ -101,9 +101,9 @@ public class UserAuthGSS extends AbstractUserAuth {
         }
         else
         {
-            SshConstants.Message msg = buffer.getCommand();
-            if (!(msg == SshConstants.Message.SSH_MSG_USERAUTH_INFO_RESPONSE ||
-                    msg == SshConstants.Message.SSH_MSG_USERAUTH_GSSAPI_MIC && context.isEstablished())) {
+            byte msg = buffer.getByte();
+            if (!(msg == SshConstants.SSH_MSG_USERAUTH_INFO_RESPONSE ||
+                    msg == SshConstants.SSH_MSG_USERAUTH_GSSAPI_MIC && context.isEstablished())) {
                 throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
                         "Packet not supported by user authentication method");
             }
@@ -114,7 +114,7 @@ public class UserAuthGSS extends AbstractUserAuth {
 
             if (context.isEstablished()) {
 
-                if (msg != SshConstants.Message.SSH_MSG_USERAUTH_GSSAPI_MIC) {
+                if (msg != SshConstants.SSH_MSG_USERAUTH_GSSAPI_MIC) {
                     return Boolean.FALSE;
                 }
 
@@ -123,7 +123,7 @@ public class UserAuthGSS extends AbstractUserAuth {
                 Buffer msgbuf = new Buffer();
 
                 msgbuf.putString(session.getSessionId());
-                msgbuf.putByte(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST.toByte());
+                msgbuf.putByte(SshConstants.SSH_MSG_USERAUTH_REQUEST);
                 msgbuf.putString(username.getBytes("UTF-8"));
                 msgbuf.putString(service);
                 msgbuf.putString("gssapi-with-mic");
@@ -162,7 +162,7 @@ public class UserAuthGSS extends AbstractUserAuth {
                 // Send return token if necessary
 
                 if (out != null && out.length > 0) {
-                    Buffer b = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_INFO_RESPONSE, 0);
+                    Buffer b = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_INFO_RESPONSE, 0);
 
                     b.putBytes(out);
                     session.writePacket(b);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
index e96f483..9655ab3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
@@ -60,7 +60,7 @@ public abstract class AbstractServerChannel extends AbstractChannel {
         if (!exitStatusSent) {
             exitStatusSent = true;
             log.debug("Send SSH_MSG_CHANNEL_REQUEST exit-status on channel {}", id);
-            Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_REQUEST, 0);
+            Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, 0);
             buffer.putInt(recipient);
             buffer.putString("exit-status");
             buffer.putByte((byte) 0);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
index 86e6ea6..a3e9144 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
@@ -446,8 +446,8 @@ public class ChannelSession extends AbstractServerChannel {
             FileSystemFactory factory = ((ServerSession) session).getServerFactoryManager().getFileSystemFactory();
             ((FileSystemAware) command).setFileSystemView(factory.createFileSystemView(session));
         }
-        out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
-        err = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_EXTENDED_DATA);
+        out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
+        err = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA);
         if (log != null && log.isTraceEnabled()) {
             // Wrap in logging filters
             out = new LoggingFilterOutputStream(out, "OUT:", log);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
index 75fea9f..8e49f45 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
@@ -37,7 +37,7 @@ public class CancelTcpipForwardHandler implements RequestHandler<ConnectionServi
             int port = buffer.getInt();
             connectionService.getTcpipForwarder().localPortForwardingCancelled(new SshdSocketAddress(address, port));
             if (wantReply){
-                buffer = connectionService.getSession().createBuffer(SshConstants.Message.SSH_MSG_REQUEST_SUCCESS, 0);
+                buffer = connectionService.getSession().createBuffer(SshConstants.SSH_MSG_REQUEST_SUCCESS, 0);
                 buffer.putInt(port);
                 connectionService.getSession().writePacket(buffer);
             }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
index e94a197..2ee9478 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
@@ -38,7 +38,7 @@ public class TcpipForwardHandler implements RequestHandler<ConnectionService> {
             SshdSocketAddress bound = connectionService.getTcpipForwarder().localPortForwardingRequested(new SshdSocketAddress(address, port));
             port = bound.getPort();
             if (wantReply){
-                buffer = connectionService.getSession().createBuffer(SshConstants.Message.SSH_MSG_REQUEST_SUCCESS, 0);
+                buffer = connectionService.getSession().createBuffer(SshConstants.SSH_MSG_REQUEST_SUCCESS, 0);
                 buffer.putInt(port);
                 connectionService.getSession().writePacket(buffer);
             }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
index 16e107a..dd42317 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
@@ -74,10 +74,10 @@ public abstract class AbstractDHGServer implements KeyExchange {
     protected abstract AbstractDH getDH() throws Exception;
 
     public boolean next(Buffer buffer) throws Exception {
-        SshConstants.Message cmd = buffer.getCommand();
-        if (cmd != SshConstants.Message.SSH_MSG_KEXDH_INIT) {
+        byte cmd = buffer.getByte();
+        if (cmd != SshConstants.SSH_MSG_KEXDH_INIT) {
             throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED, 
-                                   "Protocol error: expected packet " + SshConstants.Message.SSH_MSG_KEXDH_INIT + ", got " + cmd);
+                                   "Protocol error: expected packet " + SshConstants.SSH_MSG_KEXDH_INIT + ", got " + cmd);
         }
         log.debug("Received SSH_MSG_KEXDH_INIT");
         e = buffer.getMPIntAsBytes();
@@ -124,7 +124,7 @@ public abstract class AbstractDHGServer implements KeyExchange {
         buffer.clear();
         buffer.rpos(5);
         buffer.wpos(5);
-        buffer.putCommand(SshConstants.Message.SSH_MSG_KEXDH_REPLY_KEX_DH_GEX_GROUP);
+        buffer.putByte(SshConstants.SSH_MSG_KEXDH_REPLY);
         buffer.putString(K_S);
         buffer.putString(f);
         buffer.putString(sigH);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
index a75fe6a..592ce75 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEX.java
@@ -78,7 +78,7 @@ public class DHGEX implements KeyExchange {
     int min;
     int prf;
     int max;
-    private SshConstants.Message expected;
+    private byte expected;
 
     public void init(AbstractSession s, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C) throws Exception {
         if (!(s instanceof ServerSession)) {
@@ -90,18 +90,18 @@ public class DHGEX implements KeyExchange {
         this.I_S = I_S;
         this.I_C = I_C;
 
-        expected = SshConstants.Message.SSH_MSG_KEX_DH_GEX_REQUEST;
+        expected = SshConstants.SSH_MSG_KEX_DH_GEX_REQUEST;
     }
 
     public boolean next(Buffer buffer) throws Exception {
-        SshConstants.Message cmd = buffer.getCommand();
-        log.info("Received " + cmd);
+        byte cmd = buffer.getByte();
         if (cmd != expected) {
             throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
                     "Protocol error: expected packet " + expected + ", got " + cmd);
         }
 
-        if (cmd == SshConstants.Message.SSH_MSG_KEX_DH_GEX_REQUEST) {
+        if (cmd == SshConstants.SSH_MSG_KEX_DH_GEX_REQUEST) {
+            log.info("Received SSH_MSG_KEX_DH_GEX_REQUEST");
             min = buffer.getInt();
             prf = buffer.getInt();
             max = buffer.getInt();
@@ -114,17 +114,18 @@ public class DHGEX implements KeyExchange {
             hash = dh.getHash();
             hash.init();
 
-            log.info("Send SSH_MSG_KEXDH_REPLY_KEX_DH_GEX_GROUP");
-            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_KEXDH_REPLY_KEX_DH_GEX_GROUP, 0);
+            log.info("Send SSH_MSG_KEX_DH_GEX_GROUP");
+            buffer = session.createBuffer(SshConstants.SSH_MSG_KEX_DH_GEX_GROUP, 0);
             buffer.putMPInt(dh.getP());
             buffer.putMPInt(dh.getG());
             session.writePacket(buffer);
 
-            expected = SshConstants.Message.SSH_MSG_KEX_DH_GEX_INIT;
+            expected = SshConstants.SSH_MSG_KEX_DH_GEX_INIT;
             return false;
         }
 
-        if (cmd == SshConstants.Message.SSH_MSG_KEX_DH_GEX_INIT) {
+        if (cmd == SshConstants.SSH_MSG_KEX_DH_GEX_INIT) {
+            log.info("Received SSH_MSG_KEX_DH_GEX_INIT");
             e = buffer.getMPIntAsBytes();
             dh.setF(e);
             K = dh.getK();
@@ -175,7 +176,7 @@ public class DHGEX implements KeyExchange {
             buffer.clear();
             buffer.rpos(5);
             buffer.wpos(5);
-            buffer.putCommand(SshConstants.Message.SSH_MSG_KEX_DH_GEX_REPLY);
+            buffer.putByte(SshConstants.SSH_MSG_KEX_DH_GEX_REPLY);
             buffer.putString(K_S);
             buffer.putString(f);
             buffer.putString(sigH);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
index 37a4e2e..5ad87ad 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
@@ -109,10 +109,10 @@ public class ServerUserAuthService implements Service {
         return session;
     }
 
-    public void process(SshConstants.Message cmd, Buffer buffer) throws Exception {
+    public void process(byte cmd, Buffer buffer) throws Exception {
         Boolean authed = Boolean.FALSE;
 
-        if (cmd == SshConstants.Message.SSH_MSG_USERAUTH_REQUEST) {
+        if (cmd == SshConstants.SSH_MSG_USERAUTH_REQUEST) {
             if (this.currentAuth != null) {
                 this.currentAuth.destroy();
                 this.currentAuth = null;
@@ -190,13 +190,13 @@ public class ServerUserAuthService implements Service {
 
                 String welcomeBanner = getFactoryManager().getProperties().get(ServerFactoryManager.WELCOME_BANNER);
                 if (welcomeBanner != null) {
-                    buffer = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_BANNER, 0);
+                    buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_BANNER, 0);
                     buffer.putString(welcomeBanner);
                     buffer.putString("en");
                     session.writePacket(buffer);
                 }
 
-                buffer = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_SUCCESS, 0);
+                buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_SUCCESS, 0);
                 session.writePacket(buffer);
                 session.setAuthenticated(username);
                 session.startService(authService);
@@ -204,7 +204,7 @@ public class ServerUserAuthService implements Service {
                 log.info("Session {}@{} authenticated", username, session.getIoSession().getRemoteAddress());
 
             } else {
-                buffer = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_FAILURE, 0);
+                buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_FAILURE, 0);
                 StringBuilder sb = new StringBuilder();
                 for (List<String> l : authMethods) {
                     if (!l.isEmpty()) {
@@ -224,7 +224,7 @@ public class ServerUserAuthService implements Service {
         } else {
             log.debug("Authentication failed");
 
-            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_FAILURE, 0);
+            buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_FAILURE, 0);
             StringBuilder sb = new StringBuilder();
             for (List<String> l : authMethods) {
                 if (!l.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/ade49e48/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java b/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
index 7b5de22..7cc9e22 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
@@ -178,7 +178,7 @@ public class X11ForwardSupport implements IoHandler {
             }
             openFuture = new DefaultOpenFuture(lock);
             log.info("Send SSH_MSG_CHANNEL_OPEN on channel {}", id);
-            Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN, 0);
+            Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN, 0);
             buffer.putString(type);
             buffer.putInt(id);
             buffer.putInt(localWindow.getSize());
@@ -191,7 +191,7 @@ public class X11ForwardSupport implements IoHandler {
 
         @Override
         protected synchronized void doOpen() throws IOException {
-            out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.Message.SSH_MSG_CHANNEL_DATA);
+            out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
         }
 
         @Override