2 #include "rocksock_internal.h"
8 #include "rocksock_ssl_internal.h"
11 #ifdef ROCKSOCK_FILENAME
12 static const char rs_errorMap
[][3] = {
13 "0" , "1" , "2" , "3" , "4" , "5" , "6" , "7",
14 "8" , "9" , "10", "11", "12", "13", "14", "15",
15 "16", "17", "18", "19", "20", "21", "22", "23",
16 "24", "25", "26", "27"
21 static const char* rs_errorMap
[] = {
25 "NULL pointer passed",
26 //RS_E_EXCEED_PROXY_LIMIT,
27 "exceeding maximum number of proxies",
29 "can not establish SSL connection, since library was not compiled with USE_SSL define",
31 "socket is not set up, maybe you should call connect first",
33 "timeout reached on operation",
35 "supplied buffer is too small",
37 "generic SSL error, see STDERR",
39 "SOCKS4 authentication not implemented",
40 // RS_E_SOCKS5_AUTH_EXCEEDSIZE
41 "maximum length for SOCKS5 servername/password/username is 255",
43 "SOCKS4 is not compatible with IPv6",
44 // RS_E_PROXY_UNEXPECTED_RESPONSE
45 "the proxy sent an unexpected response",
46 // RS_E_TARGETPROXY_CONNECT_FAILED
47 "could not connect to target proxy",
48 // RS_E_PROXY_AUTH_FAILED
49 "proxy authentication failed or authd not enabled",
50 //RS_E_HIT_READTIMEOUT = 14,
51 "timeout reached on read operation",
52 //RS_E_HIT_WRITETIMEOUT = 15,
53 "timeout reached on write operation",
54 //RS_E_HIT_CONNECTTIMEOUT = 16,
55 "timeout reached on connect operation",
56 //RS_E_PROXY_GENERAL_FAILURE = 17,
57 "proxy general failure",
58 //RS_E_TARGETPROXY_NET_UNREACHABLE = 18,
59 "proxy-target: net unreachable",
60 //RS_E_TARGETPROXY_HOST_UNREACHABLE = 19,
61 "proxy-target: host unreachable",
62 //RS_E_TARGETPROXY_CONN_REFUSED = 20,
63 "proxy-target: connection refused",
64 //RS_E_TARGETPROXY_TTL_EXPIRED = 21,
65 "proxy-target: TTL expired",
66 //RS_E_PROXY_COMMAND_NOT_SUPPORTED = 22,
67 "proxy: command not supported",
68 //RS_E_PROXY_ADDRESSTYPE_NOT_SUPPORTED = 23,
69 "proxy: addresstype not supported",
70 //RS_E_REMOTE_DISCONNECTED = 24,
71 "remote socket closed connection",
72 //RS_E_NO_PROXYSTORAGE = 25,
73 "no proxy storage assigned",
74 //RS_E_HOSTNAME_TOO_LONG = 26,
75 "hostname exceeds 255 chars",
76 //RS_E_INVALID_PROXY_URL = 27,
77 "invalid proxy URL string"
82 const char* rocksock_strerror(rocksock
*sock
) {
83 int error
= sock
->lasterror
.error
;
84 switch(sock
->lasterror
.errortype
) {
85 #ifndef NO_DNS_SUPPORT
87 return gai_strerror(error
);
90 if (error
< RS_E_MAX_ERROR
)
91 return rs_errorMap
[error
];
94 return strerror(error
);
97 const char *tmp
= rocksock_ssl_strerror(sock
, error
);
98 if(!tmp
) return rs_errorMap
[RS_E_SSL_GENERIC
];