projects
/
project
/
uclient.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3b3e368
)
uclient: Add string error function
author
Daniel Danzberger
<daniel@dd-wrt.com>
Thu, 5 Dec 2019 16:51:58 +0000
(17:51 +0100)
committer
Hauke Mehrtens
<hauke@hauke-m.de>
Sat, 7 Dec 2019 14:00:12 +0000
(15:00 +0100)
This add's the uclient_strerror function, which resolves and error code
to a string message.
Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
uclient.c
patch
|
blob
|
history
uclient.h
patch
|
blob
|
history
diff --git
a/uclient.c
b/uclient.c
index 11371684e8a15cdd8566263d2a3b8b670880b7a2..9f98cbca167f0b5cc419ec1effe542130d1fe6df 100644
(file)
--- a/
uclient.c
+++ b/
uclient.c
@@
-422,3
+422,23
@@
void __hidden uclient_backend_reset_state(struct uclient *cl)
cl->error_code = 0;
uloop_timeout_cancel(&cl->timeout);
}
cl->error_code = 0;
uloop_timeout_cancel(&cl->timeout);
}
+
+const char * uclient_strerror(unsigned err)
+{
+ switch (err) {
+ case UCLIENT_ERROR_UNKNOWN:
+ return "unknown error";
+ case UCLIENT_ERROR_CONNECT:
+ return "connect failed";
+ case UCLIENT_ERROR_TIMEDOUT:
+ return "timeout";
+ case UCLIENT_ERROR_SSL_INVALID_CERT:
+ return "ssl invalid cert";
+ case UCLIENT_ERROR_SSL_CN_MISMATCH:
+ return "ssl cn mismatch";
+ case UCLIENT_ERROR_MISSING_SSL_CONTEXT:
+ return "missing ssl context";
+ default:
+ return "invalid error code";
+ }
+}
diff --git
a/uclient.h
b/uclient.h
index e3695db6409b8069a0081c43ce3abde72b7f20ed..4f37364e55ab805bba7fdca5908bb3d1434e921e 100644
(file)
--- a/
uclient.h
+++ b/
uclient.h
@@
-36,6
+36,7
@@
enum uclient_error_code {
UCLIENT_ERROR_SSL_INVALID_CERT,
UCLIENT_ERROR_SSL_CN_MISMATCH,
UCLIENT_ERROR_MISSING_SSL_CONTEXT,
UCLIENT_ERROR_SSL_INVALID_CERT,
UCLIENT_ERROR_SSL_CN_MISMATCH,
UCLIENT_ERROR_MISSING_SSL_CONTEXT,
+ __UCLIENT_ERROR_MAX
};
union uclient_addr {
};
union uclient_addr {
@@
-126,5
+127,6
@@
int uclient_http_redirect(struct uclient *cl);
int uclient_http_set_ssl_ctx(struct uclient *cl, const struct ustream_ssl_ops *ops,
struct ustream_ssl_ctx *ctx, bool require_validation);
int uclient_http_set_address_family(struct uclient *cl, int af);
int uclient_http_set_ssl_ctx(struct uclient *cl, const struct ustream_ssl_ops *ops,
struct ustream_ssl_ctx *ctx, bool require_validation);
int uclient_http_set_address_family(struct uclient *cl, int af);
+const char *uclient_strerror(unsigned err);
#endif
#endif