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