forked from cy384/ssheven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssheven-debug.c
202 lines (195 loc) · 5.95 KB
/
ssheven-debug.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
* ssheven
*
* Copyright (c) 2021 by cy384 <[email protected]>
* See LICENSE file for details
*/
#include <OpenTransport.h>
#include <OpenTptInternet.h>
#include <libssh2.h>
/* convert libssh2 errors into strings */
const char* libssh2_error_string(int i)
{
switch (i)
{
case LIBSSH2_ERROR_NONE:
return "no error (LIBSSH2_ERROR_NONE)";
case LIBSSH2_ERROR_BANNER_RECV:
return "LIBSSH2_ERROR_BANNER_RECV";
case LIBSSH2_ERROR_BANNER_SEND:
return "LIBSSH2_ERROR_BANNER_SEND";
case LIBSSH2_ERROR_INVALID_MAC:
return "LIBSSH2_ERROR_INVALID_MAC";
case LIBSSH2_ERROR_KEX_FAILURE:
return "LIBSSH2_ERROR_KEX_FAILURE";
case LIBSSH2_ERROR_ALLOC:
return "LIBSSH2_ERROR_ALLOC";
case LIBSSH2_ERROR_SOCKET_SEND:
return "LIBSSH2_ERROR_SOCKET_SEND";
case LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE:
return "LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE";
case LIBSSH2_ERROR_TIMEOUT:
return "LIBSSH2_ERROR_TIMEOUT";
case LIBSSH2_ERROR_HOSTKEY_INIT:
return "LIBSSH2_ERROR_HOSTKEY_INIT";
case LIBSSH2_ERROR_HOSTKEY_SIGN:
return "LIBSSH2_ERROR_HOSTKEY_SIGN";
case LIBSSH2_ERROR_DECRYPT:
return "LIBSSH2_ERROR_DECRYPT";
case LIBSSH2_ERROR_SOCKET_DISCONNECT:
return "LIBSSH2_ERROR_SOCKET_DISCONNECT";
case LIBSSH2_ERROR_PROTO:
return "LIBSSH2_ERROR_PROTO";
case LIBSSH2_ERROR_PASSWORD_EXPIRED:
return "LIBSSH2_ERROR_PASSWORD_EXPIRED";
case LIBSSH2_ERROR_FILE:
return "LIBSSH2_ERROR_FILE";
case LIBSSH2_ERROR_METHOD_NONE:
return "LIBSSH2_ERROR_METHOD_NONE";
case LIBSSH2_ERROR_AUTHENTICATION_FAILED:
return "LIBSSH2_ERROR_AUTHENTICATION_FAILED";
case LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED:
return "LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED";
case LIBSSH2_ERROR_CHANNEL_OUTOFORDER:
return "LIBSSH2_ERROR_CHANNEL_OUTOFORDER";
case LIBSSH2_ERROR_CHANNEL_FAILURE:
return "LIBSSH2_ERROR_CHANNEL_FAILURE";
case LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED:
return "LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED";
case LIBSSH2_ERROR_CHANNEL_UNKNOWN:
return "LIBSSH2_ERROR_CHANNEL_UNKNOWN";
case LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED:
return "LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED";
case LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED:
return "LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED";
case LIBSSH2_ERROR_CHANNEL_CLOSED:
return "LIBSSH2_ERROR_CHANNEL_CLOSED";
case LIBSSH2_ERROR_CHANNEL_EOF_SENT:
return "LIBSSH2_ERROR_CHANNEL_EOF_SENT";
case LIBSSH2_ERROR_SCP_PROTOCOL:
return "LIBSSH2_ERROR_SCP_PROTOCOL";
case LIBSSH2_ERROR_ZLIB:
return "LIBSSH2_ERROR_ZLIB";
case LIBSSH2_ERROR_SOCKET_TIMEOUT:
return "LIBSSH2_ERROR_SOCKET_TIMEOUT";
case LIBSSH2_ERROR_SFTP_PROTOCOL:
return "LIBSSH2_ERROR_SFTP_PROTOCOL";
case LIBSSH2_ERROR_REQUEST_DENIED:
return "LIBSSH2_ERROR_REQUEST_DENIED";
case LIBSSH2_ERROR_METHOD_NOT_SUPPORTED:
return "LIBSSH2_ERROR_METHOD_NOT_SUPPORTED";
case LIBSSH2_ERROR_INVAL:
return "LIBSSH2_ERROR_INVAL";
case LIBSSH2_ERROR_INVALID_POLL_TYPE:
return "LIBSSH2_ERROR_INVALID_POLL_TYPE";
case LIBSSH2_ERROR_PUBLICKEY_PROTOCOL:
return "LIBSSH2_ERROR_PUBLICKEY_PROTOCOL";
case LIBSSH2_ERROR_EAGAIN:
return "LIBSSH2_ERROR_EAGAIN";
case LIBSSH2_ERROR_BUFFER_TOO_SMALL:
return "LIBSSH2_ERROR_BUFFER_TOO_SMALL";
case LIBSSH2_ERROR_BAD_USE:
return "LIBSSH2_ERROR_BAD_USE";
case LIBSSH2_ERROR_COMPRESS:
return "LIBSSH2_ERROR_COMPRESS";
case LIBSSH2_ERROR_OUT_OF_BOUNDARY:
return "LIBSSH2_ERROR_OUT_OF_BOUNDARY";
case LIBSSH2_ERROR_AGENT_PROTOCOL:
return "LIBSSH2_ERROR_AGENT_PROTOCOL";
case LIBSSH2_ERROR_SOCKET_RECV:
return "LIBSSH2_ERROR_SOCKET_RECV";
case LIBSSH2_ERROR_ENCRYPT:
return "LIBSSH2_ERROR_ENCRYPT";
case LIBSSH2_ERROR_BAD_SOCKET:
return "LIBSSH2_ERROR_BAD_SOCKET";
case LIBSSH2_ERROR_KNOWN_HOSTS:
return "LIBSSH2_ERROR_KNOWN_HOSTS";
case LIBSSH2_ERROR_CHANNEL_WINDOW_FULL:
return "LIBSSH2_ERROR_CHANNEL_WINDOW_FULL";
case LIBSSH2_ERROR_KEYFILE_AUTH_FAILED:
return "LIBSSH2_ERROR_KEYFILE_AUTH_FAILED";
default:
return "LIBSSH2 unknown error number";
}
return "libssh2_error_string should never return from here";
}
/* convert OT event types into strings */
const char* OT_event_string(int i)
{
switch (i)
{
case T_LISTEN:
return "T_LISTEN";
case T_CONNECT:
return "T_CONNECT";
case T_DATA:
return "T_DATA";
case T_EXDATA:
return "T_EXDATA";
case T_DISCONNECT:
return "T_DISCONNECT";
case T_ERROR:
return "T_ERROR";
case T_UDERR:
return "T_UDERR";
case T_ORDREL:
return "T_ORDREL";
case T_GODATA:
return "T_GODATA";
case T_GOEXDATA:
return "T_GOEXDATA";
case T_REQUEST:
return "T_REQUEST";
case T_REPLY:
return "T_REPLY";
case T_PASSCON:
return "T_PASSCON";
case T_RESET:
return "T_RESET";
case T_BINDCOMPLETE:
return "T_BINDCOMPLETE";
case T_UNBINDCOMPLETE:
return "T_UNBINDCOMPLETE";
case T_ACCEPTCOMPLETE:
return "T_ACCEPTCOMPLETE";
case T_REPLYCOMPLETE:
return "T_REPLYCOMPLETE";
case T_DISCONNECTCOMPLETE:
return "T_DISCONNECTCOMPLETE";
case T_OPTMGMTCOMPLETE:
return "T_OPTMGMTCOMPLETE";
case T_OPENCOMPLETE:
return "T_OPENCOMPLETE";
case T_GETPROTADDRCOMPLETE:
return "T_GETPROTADDRCOMPLETE";
case T_RESOLVEADDRCOMPLETE:
return "T_RESOLVEADDRCOMPLETE";
case T_GETINFOCOMPLETE:
return "T_GETINFOCOMPLETE";
case T_SYNCCOMPLETE:
return "T_SYNCCOMPLETE";
case T_MEMORYRELEASED:
return "T_MEMORYRELEASED";
case T_REGNAMECOMPLETE:
return "T_REGNAMECOMPLETE";
case T_DELNAMECOMPLETE:
return "T_DELNAMECOMPLETE";
case T_LKUPNAMECOMPLETE:
return "T_LKUPNAMECOMPLETE";
case T_LKUPNAMERESULT:
return "T_LKUPNAMERESULT";
case kOTProviderIsDisconnected:
return "kOTProviderIsDisconnected";
case kOTSyncIdleEvent:
return "kOTSyncIdleEvent";
case kOTProviderIsReconnected:
return "kOTProviderIsReconnected";
case kOTProviderWillClose:
return "kOTProviderWillClose";
case kOTProviderIsClosed:
return "kOTProviderIsClosed";
default:
return "unknown OT event type";
}
return "OTLook_string should never return from here";
}