diff options
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; |