Browse Source

added to one branch in n2n-sock-to-string conversion (#1024)

pull/1026/head
Logan oos Even 2 years ago
committed by GitHub
parent
commit
eff5f56d21
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/n2n.c

8
src/n2n.c

@ -712,14 +712,18 @@ extern int str2mac (uint8_t * outmac /* 6 bytes */, const char * s) {
extern char * sock_to_cstr (n2n_sock_str_t out, extern char * sock_to_cstr (n2n_sock_str_t out,
const n2n_sock_t * sock) { const n2n_sock_t * sock) {
if(NULL == out) { if(NULL == out) {
return NULL; return NULL;
} }
memset(out, 0, N2N_SOCKBUF_SIZE); memset(out, 0, N2N_SOCKBUF_SIZE);
if(AF_INET6 == sock->family) { if(AF_INET6 == sock->family) {
/* INET6 not written yet */ char tmp[sizeof(n2n_sock_str_t)];
snprintf(out, N2N_SOCKBUF_SIZE, "XXXX:%hu", sock->port);
tmp[0] = '\0';
inet_ntop(AF_INET6, sock->addr.v6, tmp, sizeof(n2n_sock_str_t));
snprintf(out, N2N_SOCKBUF_SIZE, "%s:%hu", tmp[0] ? tmp : "", sock->port);
return out; return out;
} else { } else {
const uint8_t * a = sock->addr.v4; const uint8_t * a = sock->addr.v4;

Loading…
Cancel
Save