diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-04-20 18:53:10 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-04-20 18:53:10 +0200 |
commit | 289a3ee320781b7811851d476e81f49b5d08d28b (patch) | |
tree | dcbb9e142802709df62477e9742b02ffe0d7a5ba /src/printf.c | |
parent | 3fcb880682a02e1952eb710a5952a0d7f92f41e1 (diff) | |
download | fastd-289a3ee320781b7811851d476e81f49b5d08d28b.tar fastd-289a3ee320781b7811851d476e81f49b5d08d28b.zip |
Always include interface name for link-local addresses
Diffstat (limited to 'src/printf.c')
-rw-r--r-- | src/printf.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/printf.c b/src/printf.c index d5f47ee..99c577b 100644 --- a/src/printf.c +++ b/src/printf.c @@ -28,6 +28,7 @@ #include "peer.h" #include <arpa/inet.h> +#include <net/if.h> static inline int snprintf_safe(char *buffer, size_t size, const char *format, ...) { @@ -60,8 +61,15 @@ static int snprint_peer_address(const fastd_context_t *ctx, char *buffer, size_t case AF_INET6: if (!bind_address && ctx->conf->hide_ip_addresses) return snprintf_safe(buffer, size, "[hidden]:%u", ntohs(address->in.sin_port)); - if (inet_ntop(AF_INET6, &address->in6.sin6_addr, addr_buf, sizeof(addr_buf))) - return snprintf_safe(buffer, size, "[%s]:%u", addr_buf, ntohs(address->in6.sin6_port)); + 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)); + } + } else return 0; |