FreeRDP
Loading...
Searching...
No Matches
errconnect.c
1
21#include <freerdp/config.h>
22
23#include <stdio.h>
24
25#include <freerdp/log.h>
26
27#include "errinfo.h"
28
29#define ERRCONNECT_DEFINE(_code, category) \
30 { \
31 ERRCONNECT_##_code, "ERRCONNECT_" #_code, ERRCONNECT_##_code##_STRING, category \
32 }
33
34/* Protocol-independent codes */
35
36#define ERRCONNECT_PRE_CONNECT_FAILED_STRING \
37 "A configuration error prevented a connection to be established."
38
39#define ERRCONNECT_CONNECT_UNDEFINED_STRING "A undefined connection error occurred."
40
41#define ERRCONNECT_POST_CONNECT_FAILED_STRING \
42 "The connection attempt was aborted due to post connect configuration errors."
43
44#define ERRCONNECT_DNS_ERROR_STRING "The DNS entry could not be resolved."
45
46#define ERRCONNECT_DNS_NAME_NOT_FOUND_STRING "The DNS host name was not found."
47
48#define ERRCONNECT_CONNECT_FAILED_STRING "The connection failed."
49
50#define ERRCONNECT_MCS_CONNECT_INITIAL_ERROR_STRING "The connection failed at initial MCS connect"
51
52#define ERRCONNECT_TLS_CONNECT_FAILED_STRING "The connection failed at TLS connect."
53
54#define ERRCONNECT_AUTHENTICATION_FAILED_STRING "An authentication failure aborted the connection."
55
56#define ERRCONNECT_INSUFFICIENT_PRIVILEGES_STRING \
57 "Insufficient privileges to establish a connection."
58
59#define ERRCONNECT_CONNECT_CANCELLED_STRING "The connection was cancelled."
60
61#define ERRCONNECT_SECURITY_NEGO_CONNECT_FAILED_STRING \
62 "The connection failed at negotiating security settings."
63
64#define ERRCONNECT_CONNECT_TRANSPORT_FAILED_STRING "The connection transport layer failed."
65
66#define ERRCONNECT_PASSWORD_EXPIRED_STRING "The password has expired and must be changed."
67
68#define ERRCONNECT_PASSWORD_CERTAINLY_EXPIRED_STRING \
69 "The password has certainly expired and must be changed."
70
71#define ERRCONNECT_CLIENT_REVOKED_STRING "The client has been revoked."
72
73#define ERRCONNECT_KDC_UNREACHABLE_STRING "The KDC is unreachable."
74
75#define ERRCONNECT_ACCOUNT_DISABLED_STRING "The account is disabled."
76
77#define ERRCONNECT_PASSWORD_MUST_CHANGE_STRING "The password must be changed."
78
79#define ERRCONNECT_LOGON_FAILURE_STRING "Logon failed."
80
81#define ERRCONNECT_WRONG_PASSWORD_STRING "Wrong password supplied."
82
83#define ERRCONNECT_ACCESS_DENIED_STRING "Access denied."
84
85#define ERRCONNECT_ACCOUNT_RESTRICTION_STRING "Account restriction."
86
87#define ERRCONNECT_ACCOUNT_LOCKED_OUT_STRING "Account locked out."
88
89#define ERRCONNECT_ACCOUNT_EXPIRED_STRING "Account expired."
90
91#define ERRCONNECT_LOGON_TYPE_NOT_GRANTED_STRING "Logon type not granted."
92
93#define ERRCONNECT_NO_OR_MISSING_CREDENTIALS_STRING "Credentials invalid or missing."
94
95#define ERRCONNECT_ACTIVATION_TIMEOUT_STRING "Timeout waiting for activation."
96
97#define ERRCONNECT_TARGET_BOOTING_STRING "Starting your VM. It may take up to 5 minutes."
98
99#define ERRCONNECT_HYBRID_REQUIRED_BY_SERVER_STRING \
100 "The server requires Network Level Authentication, but it is not enabled."
101
102#define ERRCONNECT_NTLM_BLOCKED_STRING \
103 "Authentication failed. This may be due to NTLM authentication being blocked by the " \
104 "server's security policy, or a CredSSP encryption oracle mismatch."
105
106/* Special codes */
107#define ERRCONNECT_SUCCESS_STRING "Success."
108#define ERRCONNECT_NONE_STRING ""
109
110static const ERRINFO ERRCONNECT_CODES[] = {
111 ERRCONNECT_DEFINE(SUCCESS, CAT_NONE),
112
113 ERRCONNECT_DEFINE(PRE_CONNECT_FAILED, CAT_CONFIG),
114 ERRCONNECT_DEFINE(CONNECT_UNDEFINED, CAT_USE),
115 ERRCONNECT_DEFINE(POST_CONNECT_FAILED, CAT_CONFIG),
116 ERRCONNECT_DEFINE(DNS_ERROR, CAT_USE),
117 ERRCONNECT_DEFINE(DNS_NAME_NOT_FOUND, CAT_CONFIG),
118 ERRCONNECT_DEFINE(CONNECT_FAILED, CAT_USE),
119 ERRCONNECT_DEFINE(MCS_CONNECT_INITIAL_ERROR, CAT_PROTOCOL),
120 ERRCONNECT_DEFINE(TLS_CONNECT_FAILED, CAT_USE),
121 ERRCONNECT_DEFINE(AUTHENTICATION_FAILED, CAT_USE),
122 ERRCONNECT_DEFINE(INSUFFICIENT_PRIVILEGES, CAT_ADMIN),
123 ERRCONNECT_DEFINE(CONNECT_CANCELLED, CAT_USE),
124 ERRCONNECT_DEFINE(SECURITY_NEGO_CONNECT_FAILED, CAT_USE),
125 ERRCONNECT_DEFINE(CONNECT_TRANSPORT_FAILED, CAT_USE),
126 ERRCONNECT_DEFINE(PASSWORD_EXPIRED, CAT_ADMIN),
127 ERRCONNECT_DEFINE(PASSWORD_CERTAINLY_EXPIRED, CAT_ADMIN),
128 ERRCONNECT_DEFINE(CLIENT_REVOKED, CAT_ADMIN),
129 ERRCONNECT_DEFINE(KDC_UNREACHABLE, CAT_ADMIN),
130 ERRCONNECT_DEFINE(ACCOUNT_DISABLED, CAT_ADMIN),
131 ERRCONNECT_DEFINE(PASSWORD_MUST_CHANGE, CAT_ADMIN),
132 ERRCONNECT_DEFINE(LOGON_FAILURE, CAT_USE),
133 ERRCONNECT_DEFINE(WRONG_PASSWORD, CAT_USE),
134 ERRCONNECT_DEFINE(ACCESS_DENIED, CAT_ADMIN),
135 ERRCONNECT_DEFINE(ACCOUNT_RESTRICTION, CAT_ADMIN),
136 ERRCONNECT_DEFINE(ACCOUNT_LOCKED_OUT, CAT_ADMIN),
137 ERRCONNECT_DEFINE(ACCOUNT_EXPIRED, CAT_ADMIN),
138 ERRCONNECT_DEFINE(LOGON_TYPE_NOT_GRANTED, CAT_ADMIN),
139 ERRCONNECT_DEFINE(NO_OR_MISSING_CREDENTIALS, CAT_USE),
140 ERRCONNECT_DEFINE(ACTIVATION_TIMEOUT, CAT_PROTOCOL),
141 ERRCONNECT_DEFINE(TARGET_BOOTING, CAT_ADMIN),
142 ERRCONNECT_DEFINE(HYBRID_REQUIRED_BY_SERVER, CAT_CONFIG),
143 ERRCONNECT_DEFINE(NTLM_BLOCKED, CAT_CONFIG),
144
145 ERRCONNECT_DEFINE(NONE, CAT_NONE)
146};
147
148const char* freerdp_get_error_connect_string(UINT32 code)
149{
150 const ERRINFO* errInfo = nullptr;
151 errInfo = &ERRCONNECT_CODES[0];
152
153 while (errInfo->code != ERRCONNECT_NONE)
154 {
155 if (code == errInfo->code)
156 {
157 return errInfo->info;
158 }
159
160 errInfo++;
161 }
162
163 return "ERRCONNECT_UNKNOWN";
164}
165
166const char* freerdp_get_error_connect_category(UINT32 code)
167{
168 const ERRINFO* errInfo = nullptr;
169 errInfo = &ERRCONNECT_CODES[0];
170
171 while (errInfo->code != ERRCONNECT_NONE)
172 {
173 if (code == errInfo->code)
174 {
175 return errInfo->category;
176 }
177
178 errInfo++;
179 }
180
181 return "ERRCONNECT_UNKNOWN";
182}
183
184const char* freerdp_get_error_connect_name(UINT32 code)
185{
186 const ERRINFO* errInfo = nullptr;
187 errInfo = &ERRCONNECT_CODES[0];
188
189 while (errInfo->code != ERRCONNECT_NONE)
190 {
191 if (code == errInfo->code)
192 {
193 return errInfo->name;
194 }
195
196 errInfo++;
197 }
198
199 return "ERRCONNECT_UNKNOWN";
200}