From 289a3ee320781b7811851d476e81f49b5d08d28b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 20 Apr 2013 18:53:10 +0200 Subject: Always include interface name for link-local addresses --- src/printf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/printf.c') 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 +#include 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; -- cgit v1.2.3