added oclog_hex()

This commit is contained in:
Nikos Mavrogiannopoulos
2014-11-16 12:34:30 +01:00
parent 6103f5066d
commit bf2e8c8cd6
2 changed files with 28 additions and 0 deletions

View File

@@ -199,3 +199,28 @@ void mslog_hex(const main_server_st * s, const struct proc_st* proc,
return;
}
void oclog_hex(const worker_st* ws, int priority,
const char *prefix, uint8_t* bin, unsigned bin_size, unsigned b64)
{
char buf[512];
int ret;
size_t buf_size;
gnutls_datum_t data = {bin, bin_size};
if (priority == LOG_DEBUG && ws->config->debug == 0)
return;
if (b64) {
base64_encode((char*)bin, bin_size, (char*)buf, sizeof(buf));
} else {
buf_size = sizeof(buf);
ret = gnutls_hex_encode(&data, buf, &buf_size);
if (ret < 0)
return;
}
_oclog(ws, priority, "%s %s", prefix, buf);
return;
}

View File

@@ -262,6 +262,9 @@ void __attribute__ ((format(printf, 3, 4)))
# define oclog _oclog
#endif
void oclog_hex(const worker_st* ws, int priority,
const char *prefix, uint8_t* bin, unsigned bin_size, unsigned b64);
int complete_vpn_info(worker_st * ws,
struct vpn_st* vinfo);
unsigned check_if_default_route(char **routes, unsigned routes_size);