[Ttssh2-commit] [6950] SSH プロトコルの定数を enum に変更。

scmno****@osdn***** scmno****@osdn*****
2017年 10月 17日 (火) 23:14:01 JST


Revision: 6950
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6950
Author:   doda
Date:     2017-10-17 23:14:00 +0900 (Tue, 17 Oct 2017)
Log Message:
-----------
SSH プロトコルの定数を enum に変更。

デバッグし易さの為。

Modified Paths:
--------------
    trunk/ttssh2/ttxssh/ssh.h

-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/ssh.h
===================================================================
--- trunk/ttssh2/ttxssh/ssh.h	2017-10-17 13:44:16 UTC (rev 6949)
+++ trunk/ttssh2/ttxssh/ssh.h	2017-10-17 14:14:00 UTC (rev 6950)
@@ -135,131 +135,165 @@
 /* SSH2 constants */
 
 /* SSH2 messages */
-#define SSH2_MSG_DISCONNECT             1
-#define SSH2_MSG_IGNORE                 2
-#define SSH2_MSG_UNIMPLEMENTED          3
-#define SSH2_MSG_DEBUG                  4
-#define SSH2_MSG_SERVICE_REQUEST        5
-#define SSH2_MSG_SERVICE_ACCEPT         6
+typedef enum {
+	// Transport layer protocol
+	// 1..19 Transport layer generic (RFC 4253)
+	SSH2_MSG_DISCONNECT      = 1,
+	SSH2_MSG_IGNORE          = 2,
+	SSH2_MSG_UNIMPLEMENTED   = 3,
+	SSH2_MSG_DEBUG           = 4,
+	SSH2_MSG_SERVICE_REQUEST = 5,
+	SSH2_MSG_SERVICE_ACCEPT  = 6,
 
-#define SSH2_MSG_KEXINIT                20
-#define SSH2_MSG_NEWKEYS                21
+	// 20..29 Algorithm negotiation (RFC 4253)
+	SSH2_MSG_KEXINIT = 20,
+	SSH2_MSG_NEWKEYS = 21,
 
-#define SSH2_MSG_KEXDH_INIT             30
-#define SSH2_MSG_KEXDH_REPLY            31
+	// 30..49 Key excahnge method specific
+	// Diffie-Hellman Key Exchange (RFC 4253)
+	SSH2_MSG_KEXDH_INIT  = 30,
+	SSH2_MSG_KEXDH_REPLY = 31,
 
-#define SSH2_MSG_KEX_DH_GEX_GROUP           31
-#define SSH2_MSG_KEX_DH_GEX_INIT            32
-#define SSH2_MSG_KEX_DH_GEX_REPLY           33
-#define SSH2_MSG_KEX_DH_GEX_REQUEST         34
+	// RFC 4419 - Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol
+	SSH2_MSG_KEX_DH_GEX_GROUP   = 31,
+	SSH2_MSG_KEX_DH_GEX_INIT    = 32,
+	SSH2_MSG_KEX_DH_GEX_REPLY   = 33,
+	SSH2_MSG_KEX_DH_GEX_REQUEST = 34,
 
-#define SSH2_MSG_KEX_ECDH_INIT              30
-#define SSH2_MSG_KEX_ECDH_REPLY             31
+	// RFC 5656 - Elliptic Curve Algorithm Integration in the Secure Shell Transport Layer
+	SSH2_MSG_KEX_ECDH_INIT  = 30,
+	SSH2_MSG_KEX_ECDH_REPLY = 31,
 
-#define SSH2_MSG_USERAUTH_REQUEST            50
-#define SSH2_MSG_USERAUTH_FAILURE            51
-#define SSH2_MSG_USERAUTH_SUCCESS            52
-#define SSH2_MSG_USERAUTH_BANNER             53
+	// User authentication protocol
+	// 50..59 User authentication generic (RFC 4252)
+	SSH2_MSG_USERAUTH_REQUEST = 50,
+	SSH2_MSG_USERAUTH_FAILURE = 51,
+	SSH2_MSG_USERAUTH_SUCCESS = 52,
+	SSH2_MSG_USERAUTH_BANNER  = 53,
 
-#define SSH2_MSG_USERAUTH_PK_OK              60
-#define SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ   60
-#define SSH2_MSG_USERAUTH_INFO_REQUEST          60
-#define SSH2_MSG_USERAUTH_INFO_RESPONSE         61
+	// Public key authentication (RFC 4252)
+	SSH2_MSG_USERAUTH_PK_OK = 60,
 
-#define SSH2_MSG_GLOBAL_REQUEST                  80
-#define SSH2_MSG_REQUEST_SUCCESS                 81
-#define SSH2_MSG_REQUEST_FAILURE                 82
-#define SSH2_MSG_CHANNEL_OPEN                    90
-#define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION       91
-#define SSH2_MSG_CHANNEL_OPEN_FAILURE            92
-#define SSH2_MSG_CHANNEL_WINDOW_ADJUST           93
-#define SSH2_MSG_CHANNEL_DATA                    94
-#define SSH2_MSG_CHANNEL_EXTENDED_DATA           95
-#define SSH2_MSG_CHANNEL_EOF                     96
-#define SSH2_MSG_CHANNEL_CLOSE                   97
-#define SSH2_MSG_CHANNEL_REQUEST                 98
-#define SSH2_MSG_CHANNEL_SUCCESS                 99
-#define SSH2_MSG_CHANNEL_FAILURE                 100
+	// Password authentication (RFC 4252)
+	SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ = 60,
 
+	// RFC 4256 - Generic Message Exchange Authentication for the Secure Shell Protocol (SSH)
+	// Keyboard-interactive authentication
+	SSH2_MSG_USERAUTH_INFO_REQUEST  = 60,
+	SSH2_MSG_USERAUTH_INFO_RESPONSE = 61,
+
+	// Connection protocol
+	// 80..89 Connection protocol generic (RFC 4254)
+	SSH2_MSG_GLOBAL_REQUEST            = 80,
+	SSH2_MSG_REQUEST_SUCCESS           = 81,
+	SSH2_MSG_REQUEST_FAILURE           = 82,
+
+	// 90..127 Channel related messages (RFC 4254)
+	SSH2_MSG_CHANNEL_OPEN              = 90,
+	SSH2_MSG_CHANNEL_OPEN_CONFIRMATION = 91,
+	SSH2_MSG_CHANNEL_OPEN_FAILURE      = 92,
+	SSH2_MSG_CHANNEL_WINDOW_ADJUST     = 93,
+	SSH2_MSG_CHANNEL_DATA              = 94,
+	SSH2_MSG_CHANNEL_EXTENDED_DATA     = 95,
+	SSH2_MSG_CHANNEL_EOF               = 96,
+	SSH2_MSG_CHANNEL_CLOSE             = 97,
+	SSH2_MSG_CHANNEL_REQUEST           = 98,
+	SSH2_MSG_CHANNEL_SUCCESS           = 99,
+	SSH2_MSG_CHANNEL_FAILURE           = 100
+
+	// Reserved for client protocols
+	// 128..191 Reserved
+
+	// Local extensions:
+	// 192..255 Local extensions
+
+} SSH2Message;
+
 /* SSH2 miscellaneous constants */
-#define SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT      1
-#define SSH2_DISCONNECT_PROTOCOL_ERROR                   2
-#define SSH2_DISCONNECT_KEY_EXCHANGE_FAILED              3
-#define SSH2_DISCONNECT_HOST_AUTHENTICATION_FAILED       4
-#define SSH2_DISCONNECT_MAC_ERROR                        5
-#define SSH2_DISCONNECT_COMPRESSION_ERROR                6
-#define SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE            7
-#define SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED   8
-#define SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE          9
-#define SSH2_DISCONNECT_CONNECTION_LOST                  10
-#define SSH2_DISCONNECT_BY_APPLICATION                   11
-#define SSH2_DISCONNECT_TOO_MANY_CONNECTIONS             12
-#define SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER           13
-#define SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE   14
-#define SSH2_DISCONNECT_ILLEGAL_USER_NAME                15
+typedef enum {
+	SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT = 1,
+	SSH2_DISCONNECT_PROTOCOL_ERROR,
+	SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+	SSH2_DISCONNECT_HOST_AUTHENTICATION_FAILED,
+	SSH2_DISCONNECT_MAC_ERROR,
+	SSH2_DISCONNECT_COMPRESSION_ERROR,
+	SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE,
+	SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED,
+	SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE,
+	SSH2_DISCONNECT_CONNECTION_LOST,
+	SSH2_DISCONNECT_BY_APPLICATION,
+	SSH2_DISCONNECT_TOO_MANY_CONNECTIONS,
+	SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER,
+	SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE,
+	SSH2_DISCONNECT_ILLEGAL_USER_NAME
+} SSH2DisconnectMessage;
 
-#define SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED    1
-#define SSH2_OPEN_CONNECT_FAILED                 2
-#define SSH2_OPEN_UNKNOWN_CHANNEL_TYPE           3
-#define SSH2_OPEN_RESOURCE_SHORTAGE              4
+typedef enum {
+	SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED = 1,
+	SSH2_OPEN_CONNECT_FAILED,
+	SSH2_OPEN_UNKNOWN_CHANNEL_TYPE,
+	SSH2_OPEN_RESOURCE_SHORTAGE
+} SSH2ChannelFailReason;
 
 // Terminal Modes
-#define SSH2_TTY_OP_END		0
-#define SSH2_TTY_KEY_VINTR	1
-#define SSH2_TTY_KEY_VQUIT	2
-#define SSH2_TTY_KEY_VERASE	3
-#define SSH2_TTY_KEY_VKILL	4
-#define SSH2_TTY_KEY_VEOF	5
-#define SSH2_TTY_KEY_VEOL	6
-#define SSH2_TTY_KEY_VEOL2	7
-#define SSH2_TTY_KEY_VSTART	8
-#define SSH2_TTY_KEY_VSTOP	9
-#define SSH2_TTY_KEY_VSUSP	10
-#define SSH2_TTY_KEY_VDSUSP	11
-#define SSH2_TTY_KEY_VREPRINT	12
-#define SSH2_TTY_KEY_VWERASE	13
-#define SSH2_TTY_KEY_VLNEXT	14
-#define SSH2_TTY_KEY_VFLUSH	15
-#define SSH2_TTY_KEY_VSWTCH	16
-#define SSH2_TTY_KEY_VSTATUS	17
-#define SSH2_TTY_KEY_VDISCARD	18
-#define SSH2_TTY_OP_IGNPAR	30
-#define SSH2_TTY_OP_PARMRK	31
-#define SSH2_TTY_OP_INPCK	32
-#define SSH2_TTY_OP_ISTRIP	33
-#define SSH2_TTY_OP_INLCR	34
-#define SSH2_TTY_OP_IGNCR	35
-#define SSH2_TTY_OP_ICRNL	36
-#define SSH2_TTY_OP_IUCLC	37
-#define SSH2_TTY_OP_IXON	38
-#define SSH2_TTY_OP_IXANY	39
-#define SSH2_TTY_OP_IXOFF	40
-#define SSH2_TTY_OP_IMAXBEL	41
-#define SSH2_TTY_OP_ISIG	50
-#define SSH2_TTY_OP_ICANON	51
-#define SSH2_TTY_OP_XCASE	52
-#define SSH2_TTY_OP_ECHO	53
-#define SSH2_TTY_OP_ECHOE	54
-#define SSH2_TTY_OP_ECHOK	55
-#define SSH2_TTY_OP_ECHONL	56
-#define SSH2_TTY_OP_NOFLSH	57
-#define SSH2_TTY_OP_TOSTOP	58
-#define SSH2_TTY_OP_IEXTEN	59
-#define SSH2_TTY_OP_ECHOCTL	60
-#define SSH2_TTY_OP_ECHOKE	61
-#define SSH2_TTY_OP_PENDIN	62
-#define SSH2_TTY_OP_OPOST	70
-#define SSH2_TTY_OP_OLCUC	71
-#define SSH2_TTY_OP_ONLCR	72
-#define SSH2_TTY_OP_OCRNL	73
-#define SSH2_TTY_OP_ONOCR	74
-#define SSH2_TTY_OP_ONLRET	75
-#define SSH2_TTY_OP_CS7		90
-#define SSH2_TTY_OP_CS8		91
-#define SSH2_TTY_OP_PARENB	92
-#define SSH2_TTY_OP_PARODD	93
-#define SSH2_TTY_OP_ISPEED	128
-#define SSH2_TTY_OP_OSPEED	129
+typedef enum {
+	SSH2_TTY_OP_END       =   0,
+	SSH2_TTY_KEY_VINTR    =   1,
+	SSH2_TTY_KEY_VQUIT    =   2,
+	SSH2_TTY_KEY_VERASE   =   3,
+	SSH2_TTY_KEY_VKILL    =   4,
+	SSH2_TTY_KEY_VEOF     =   5,
+	SSH2_TTY_KEY_VEOL     =   6,
+	SSH2_TTY_KEY_VEOL2    =   7,
+	SSH2_TTY_KEY_VSTART   =   8,
+	SSH2_TTY_KEY_VSTOP    =   9,
+	SSH2_TTY_KEY_VSUSP    =  10,
+	SSH2_TTY_KEY_VDSUSP   =  11,
+	SSH2_TTY_KEY_VREPRINT =  12,
+	SSH2_TTY_KEY_VWERASE  =  13,
+	SSH2_TTY_KEY_VLNEXT   =  14,
+	SSH2_TTY_KEY_VFLUSH   =  15,
+	SSH2_TTY_KEY_VSWTCH   =  16,
+	SSH2_TTY_KEY_VSTATUS  =  17,
+	SSH2_TTY_KEY_VDISCARD =  18,
+	SSH2_TTY_OP_IGNPAR    =  30,
+	SSH2_TTY_OP_PARMRK    =  31,
+	SSH2_TTY_OP_INPCK     =  32,
+	SSH2_TTY_OP_ISTRIP    =  33,
+	SSH2_TTY_OP_INLCR     =  34,
+	SSH2_TTY_OP_IGNCR     =  35,
+	SSH2_TTY_OP_ICRNL     =  36,
+	SSH2_TTY_OP_IUCLC     =  37,
+	SSH2_TTY_OP_IXON      =  38,
+	SSH2_TTY_OP_IXANY     =  39,
+	SSH2_TTY_OP_IXOFF     =  40,
+	SSH2_TTY_OP_IMAXBEL   =  41,
+	SSH2_TTY_OP_ISIG      =  50,
+	SSH2_TTY_OP_ICANON    =  51,
+	SSH2_TTY_OP_XCASE     =  52,
+	SSH2_TTY_OP_ECHO      =  53,
+	SSH2_TTY_OP_ECHOE     =  54,
+	SSH2_TTY_OP_ECHOK     =  55,
+	SSH2_TTY_OP_ECHONL    =  56,
+	SSH2_TTY_OP_NOFLSH    =  57,
+	SSH2_TTY_OP_TOSTOP    =  58,
+	SSH2_TTY_OP_IEXTEN    =  59,
+	SSH2_TTY_OP_ECHOCTL   =  60,
+	SSH2_TTY_OP_ECHOKE    =  61,
+	SSH2_TTY_OP_PENDIN    =  62,
+	SSH2_TTY_OP_OPOST     =  70,
+	SSH2_TTY_OP_OLCUC     =  71,
+	SSH2_TTY_OP_ONLCR     =  72,
+	SSH2_TTY_OP_OCRNL     =  73,
+	SSH2_TTY_OP_ONOCR     =  74,
+	SSH2_TTY_OP_ONLRET    =  75,
+	SSH2_TTY_OP_CS7       =  90,
+	SSH2_TTY_OP_CS8       =  91,
+	SSH2_TTY_OP_PARENB    =  92,
+	SSH2_TTY_OP_PARODD    =  93,
+	SSH2_TTY_OP_ISPEED    = 128,
+	SSH2_TTY_OP_OSPEED    = 129
+} SSH2TTYMode;
 
 
 // \x83N\x83\x89\x83C\x83A\x83\x93\x83g\x82\xA9\x82\xE7\x83T\x81[\x83o\x82ւ̒\xF1\x88Ď\x96\x8D\x80



Ttssh2-commit メーリングリストの案内