added seclog_hex

This commit is contained in:
Nikos Mavrogiannopoulos
2015-02-12 21:43:40 +01:00
parent b6ef99b443
commit d348caacc2
2 changed files with 29 additions and 0 deletions

View File

@@ -28,6 +28,7 @@
#include <vpn.h>
#include <worker.h>
#include <main.h>
#include <sec-mod.h>
char *human_addr2(const struct sockaddr *sa, socklen_t salen,
void *_buf, size_t buflen, unsigned full)
@@ -224,3 +225,28 @@ void oclog_hex(const worker_st* ws, int priority,
return;
}
void seclog_hex(const struct sec_mod_st* sec, 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 && sec->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;
}
seclog(sec, priority, "%s %s", prefix, buf);
return;
}

View File

@@ -94,6 +94,9 @@ void cleanup_client_entries(sec_mod_st *sec);
}
#endif
void seclog_hex(const struct sec_mod_st* sec, int priority,
const char *prefix, uint8_t* bin, unsigned bin_size, unsigned b64);
void sec_auth_init(sec_mod_st *sec, struct cfg_st *config);
void sec_auth_reinit(sec_mod_st *sec, struct cfg_st *config);