/src/FreeRDP/libfreerdp/core/errconnect.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /**  | 
2  |  |  * FreeRDP: A Remote Desktop Protocol Implementation  | 
3  |  |  * Error Connect  | 
4  |  |  *  | 
5  |  |  * Copyright 2015 Armin Novak <armin.novak@thincast.com>  | 
6  |  |  * Copyright 2015 Thincast Technologies GmbH  | 
7  |  |  *  | 
8  |  |  * Licensed under the Apache License, Version 2.0 (the "License");  | 
9  |  |  * you may not use this file except in compliance with the License.  | 
10  |  |  * You may obtain a copy of the License at  | 
11  |  |  *  | 
12  |  |  *     http://www.apache.org/licenses/LICENSE-2.0  | 
13  |  |  *  | 
14  |  |  * Unless required by applicable law or agreed to in writing, software  | 
15  |  |  * distributed under the License is distributed on an "AS IS" BASIS,  | 
16  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  | 
17  |  |  * See the License for the specific language governing permissions and  | 
18  |  |  * limitations under the License.  | 
19  |  |  */  | 
20  |  |  | 
21  |  | #include <freerdp/config.h>  | 
22  |  |  | 
23  |  | #include <stdio.h>  | 
24  |  |  | 
25  |  | #include <freerdp/log.h>  | 
26  |  |  | 
27  |  | #include "errinfo.h"  | 
28  |  |  | 
29  |  | #define TAG FREERDP_TAG("core") | 
30  |  |  | 
31  |  | #define ERRCONNECT_DEFINE(_code, category)                                              \  | 
32  |  |   {                                                                                   \ | 
33  |  |     ERRCONNECT_##_code, "ERRCONNECT_" #_code, ERRCONNECT_##_code##_STRING, category \  | 
34  |  |   }  | 
35  |  |  | 
36  |  | /* Protocol-independent codes */  | 
37  |  |  | 
38  |  | #define ERRCONNECT_PRE_CONNECT_FAILED_STRING \  | 
39  |  |   "A configuration error prevented a connection to be established."  | 
40  |  |  | 
41  |  | #define ERRCONNECT_CONNECT_UNDEFINED_STRING "A undefined connection error occurred."  | 
42  |  |  | 
43  |  | #define ERRCONNECT_POST_CONNECT_FAILED_STRING \  | 
44  |  |   "The connection attempt was aborted due to post connect configuration errors."  | 
45  |  |  | 
46  |  | #define ERRCONNECT_DNS_ERROR_STRING "The DNS entry could not be resolved."  | 
47  |  |  | 
48  |  | #define ERRCONNECT_DNS_NAME_NOT_FOUND_STRING "The DNS host name was not found."  | 
49  |  |  | 
50  |  | #define ERRCONNECT_CONNECT_FAILED_STRING "The connection failed."  | 
51  |  |  | 
52  |  | #define ERRCONNECT_MCS_CONNECT_INITIAL_ERROR_STRING "The connection failed at initial MCS connect"  | 
53  |  |  | 
54  |  | #define ERRCONNECT_TLS_CONNECT_FAILED_STRING "The connection failed at TLS connect."  | 
55  |  |  | 
56  |  | #define ERRCONNECT_AUTHENTICATION_FAILED_STRING "An authentication failure aborted the connection."  | 
57  |  |  | 
58  |  | #define ERRCONNECT_INSUFFICIENT_PRIVILEGES_STRING \  | 
59  |  |   "Insufficient privileges to establish a connection."  | 
60  |  |  | 
61  |  | #define ERRCONNECT_CONNECT_CANCELLED_STRING "The connection was cancelled."  | 
62  |  |  | 
63  |  | #define ERRCONNECT_SECURITY_NEGO_CONNECT_FAILED_STRING \  | 
64  |  |   "The connection failed at negotiating security settings."  | 
65  |  |  | 
66  |  | #define ERRCONNECT_CONNECT_TRANSPORT_FAILED_STRING "The connection transport layer failed."  | 
67  |  |  | 
68  |  | #define ERRCONNECT_PASSWORD_EXPIRED_STRING "The password has expired and must be changed."  | 
69  |  |  | 
70  |  | #define ERRCONNECT_PASSWORD_CERTAINLY_EXPIRED_STRING \  | 
71  |  |   "The password has certainly expired and must be changed."  | 
72  |  |  | 
73  |  | #define ERRCONNECT_CLIENT_REVOKED_STRING "The client has been revoked."  | 
74  |  |  | 
75  |  | #define ERRCONNECT_KDC_UNREACHABLE_STRING "The KDC is unreachable."  | 
76  |  |  | 
77  |  | #define ERRCONNECT_ACCOUNT_DISABLED_STRING "The account is disabled."  | 
78  |  |  | 
79  |  | #define ERRCONNECT_PASSWORD_MUST_CHANGE_STRING "The password must be changed."  | 
80  |  |  | 
81  |  | #define ERRCONNECT_LOGON_FAILURE_STRING "Logon failed."  | 
82  |  |  | 
83  |  | #define ERRCONNECT_WRONG_PASSWORD_STRING "Wrong password supplied."  | 
84  |  |  | 
85  |  | #define ERRCONNECT_ACCESS_DENIED_STRING "Access denied."  | 
86  |  |  | 
87  |  | #define ERRCONNECT_ACCOUNT_RESTRICTION_STRING "Account restriction."  | 
88  |  |  | 
89  |  | #define ERRCONNECT_ACCOUNT_LOCKED_OUT_STRING "Account locked out."  | 
90  |  |  | 
91  |  | #define ERRCONNECT_ACCOUNT_EXPIRED_STRING "Account expired."  | 
92  |  |  | 
93  |  | #define ERRCONNECT_LOGON_TYPE_NOT_GRANTED_STRING "Logon type not granted."  | 
94  |  |  | 
95  |  | #define ERRCONNECT_NO_OR_MISSING_CREDENTIALS_STRING "Credentials invalid or missing."  | 
96  |  |  | 
97  |  | #define ERRCONNECT_ACTIVATION_TIMEOUT_STRING "Timeout waiting for activation."  | 
98  |  |  | 
99  |  | /* Special codes */  | 
100  |  | #define ERRCONNECT_SUCCESS_STRING "Success."  | 
101  |  | #define ERRCONNECT_NONE_STRING ""  | 
102  |  |  | 
103  |  | static const ERRINFO ERRCONNECT_CODES[] = { | 
104  |  |   ERRCONNECT_DEFINE(SUCCESS, CAT_NONE),  | 
105  |  |  | 
106  |  |   ERRCONNECT_DEFINE(PRE_CONNECT_FAILED, CAT_CONFIG),  | 
107  |  |   ERRCONNECT_DEFINE(CONNECT_UNDEFINED, CAT_USE),  | 
108  |  |   ERRCONNECT_DEFINE(POST_CONNECT_FAILED, CAT_CONFIG),  | 
109  |  |   ERRCONNECT_DEFINE(DNS_ERROR, CAT_USE),  | 
110  |  |   ERRCONNECT_DEFINE(DNS_NAME_NOT_FOUND, CAT_CONFIG),  | 
111  |  |   ERRCONNECT_DEFINE(CONNECT_FAILED, CAT_USE),  | 
112  |  |   ERRCONNECT_DEFINE(MCS_CONNECT_INITIAL_ERROR, CAT_PROTOCOL),  | 
113  |  |   ERRCONNECT_DEFINE(TLS_CONNECT_FAILED, CAT_USE),  | 
114  |  |   ERRCONNECT_DEFINE(AUTHENTICATION_FAILED, CAT_USE),  | 
115  |  |   ERRCONNECT_DEFINE(INSUFFICIENT_PRIVILEGES, CAT_ADMIN),  | 
116  |  |   ERRCONNECT_DEFINE(CONNECT_CANCELLED, CAT_USE),  | 
117  |  |   ERRCONNECT_DEFINE(SECURITY_NEGO_CONNECT_FAILED, CAT_USE),  | 
118  |  |   ERRCONNECT_DEFINE(CONNECT_TRANSPORT_FAILED, CAT_USE),  | 
119  |  |   ERRCONNECT_DEFINE(PASSWORD_EXPIRED, CAT_ADMIN),  | 
120  |  |   ERRCONNECT_DEFINE(PASSWORD_CERTAINLY_EXPIRED, CAT_ADMIN),  | 
121  |  |   ERRCONNECT_DEFINE(CLIENT_REVOKED, CAT_ADMIN),  | 
122  |  |   ERRCONNECT_DEFINE(KDC_UNREACHABLE, CAT_ADMIN),  | 
123  |  |   ERRCONNECT_DEFINE(ACCOUNT_DISABLED, CAT_ADMIN),  | 
124  |  |   ERRCONNECT_DEFINE(PASSWORD_MUST_CHANGE, CAT_ADMIN),  | 
125  |  |   ERRCONNECT_DEFINE(LOGON_FAILURE, CAT_USE),  | 
126  |  |   ERRCONNECT_DEFINE(WRONG_PASSWORD, CAT_USE),  | 
127  |  |   ERRCONNECT_DEFINE(ACCESS_DENIED, CAT_ADMIN),  | 
128  |  |   ERRCONNECT_DEFINE(ACCOUNT_RESTRICTION, CAT_ADMIN),  | 
129  |  |   ERRCONNECT_DEFINE(ACCOUNT_LOCKED_OUT, CAT_ADMIN),  | 
130  |  |   ERRCONNECT_DEFINE(ACCOUNT_EXPIRED, CAT_ADMIN),  | 
131  |  |   ERRCONNECT_DEFINE(LOGON_TYPE_NOT_GRANTED, CAT_ADMIN),  | 
132  |  |   ERRCONNECT_DEFINE(NO_OR_MISSING_CREDENTIALS, CAT_USE),  | 
133  |  |   ERRCONNECT_DEFINE(ACTIVATION_TIMEOUT, CAT_PROTOCOL),  | 
134  |  |  | 
135  |  |   ERRCONNECT_DEFINE(NONE, CAT_NONE)  | 
136  |  | };  | 
137  |  |  | 
138  |  | const char* freerdp_get_error_connect_string(UINT32 code)  | 
139  | 0  | { | 
140  | 0  |   const ERRINFO* errInfo = NULL;  | 
141  | 0  |   errInfo = &ERRCONNECT_CODES[0];  | 
142  |  | 
  | 
143  | 0  |   while (errInfo->code != ERRCONNECT_NONE)  | 
144  | 0  |   { | 
145  | 0  |     if (code == errInfo->code)  | 
146  | 0  |     { | 
147  | 0  |       return errInfo->info;  | 
148  | 0  |     }  | 
149  |  |  | 
150  | 0  |     errInfo++;  | 
151  | 0  |   }  | 
152  |  |  | 
153  | 0  |   return "ERRCONNECT_UNKNOWN";  | 
154  | 0  | }  | 
155  |  |  | 
156  |  | const char* freerdp_get_error_connect_category(UINT32 code)  | 
157  | 0  | { | 
158  | 0  |   const ERRINFO* errInfo = NULL;  | 
159  | 0  |   errInfo = &ERRCONNECT_CODES[0];  | 
160  |  | 
  | 
161  | 0  |   while (errInfo->code != ERRCONNECT_NONE)  | 
162  | 0  |   { | 
163  | 0  |     if (code == errInfo->code)  | 
164  | 0  |     { | 
165  | 0  |       return errInfo->category;  | 
166  | 0  |     }  | 
167  |  |  | 
168  | 0  |     errInfo++;  | 
169  | 0  |   }  | 
170  |  |  | 
171  | 0  |   return "ERRCONNECT_UNKNOWN";  | 
172  | 0  | }  | 
173  |  |  | 
174  |  | const char* freerdp_get_error_connect_name(UINT32 code)  | 
175  | 2.50k  | { | 
176  | 2.50k  |   const ERRINFO* errInfo = NULL;  | 
177  | 2.50k  |   errInfo = &ERRCONNECT_CODES[0];  | 
178  |  |  | 
179  | 34.6k  |   while (errInfo->code != ERRCONNECT_NONE)  | 
180  | 34.6k  |   { | 
181  | 34.6k  |     if (code == errInfo->code)  | 
182  | 2.50k  |     { | 
183  | 2.50k  |       return errInfo->name;  | 
184  | 2.50k  |     }  | 
185  |  |  | 
186  | 32.1k  |     errInfo++;  | 
187  | 32.1k  |   }  | 
188  |  |  | 
189  | 0  |   return "ERRCONNECT_UNKNOWN";  | 
190  | 2.50k  | }  |