From bf2e8c8cd6601bcd030f83cae4a640132d4cba4d Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sun, 16 Nov 2014 12:34:30 +0100 Subject: [PATCH] added oclog_hex() --- src/log.c | 25 +++++++++++++++++++++++++ src/worker.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/src/log.c b/src/log.c index 33fb7b91..f885081a 100644 --- a/src/log.c +++ b/src/log.c @@ -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; +} diff --git a/src/worker.h b/src/worker.h index f0e03001..f1f0c507 100644 --- a/src/worker.h +++ b/src/worker.h @@ -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);