diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-01-26 09:23:00 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-01-26 09:23:00 +0100 |
commit | 534ae7240bc5cad6edb9fd160cdb0ff0eb4778de (patch) | |
tree | 9d77fdd80b3fb5da130de1c55b5f96406814447a /src/log.c | |
parent | b78d55b69ed9d9c88d12f0159e78973ad0d70b49 (diff) | |
download | fastd-534ae7240bc5cad6edb9fd160cdb0ff0eb4778de.tar fastd-534ae7240bc5cad6edb9fd160cdb0ff0eb4778de.zip |
Add support for link-local bind addresses
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -68,11 +68,11 @@ static size_t snprint_peer_address(const fastd_context_t *ctx, char *buffer, siz if (inet_ntop(AF_INET6, &address->in6.sin6_addr, addr_buf, sizeof(addr_buf))) { if (IN6_IS_ADDR_LINKLOCAL(&address->in6.sin6_addr)) { char ifname_buf[IF_NAMESIZE]; - return snprintf_safe(buffer, size, "[%s%%%s]:%u", addr_buf, if_indextoname(address->in6.sin6_scope_id, ifname_buf), ntohs(address->in6.sin6_port)); - } - else { - return snprintf_safe(buffer, size, "[%s]:%u", addr_buf, ntohs(address->in6.sin6_port)); + if (if_indextoname(address->in6.sin6_scope_id, ifname_buf)) + return snprintf_safe(buffer, size, "[%s%%%s]:%u", addr_buf, if_indextoname(address->in6.sin6_scope_id, ifname_buf), ntohs(address->in6.sin6_port)); } + + return snprintf_safe(buffer, size, "[%s]:%u", addr_buf, ntohs(address->in6.sin6_port)); } else return 0; |