From 7b8a9acd7a3a31f5d393c1632d68379f8353e7d1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 21 Apr 2013 01:49:25 +0200 Subject: shell: add interface for link-local addresses to PEER_ADDRESS as well --- src/shell.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/shell.c') diff --git a/src/shell.c b/src/shell.c index c1ecfa8..656c7cc 100644 --- a/src/shell.c +++ b/src/shell.c @@ -96,6 +96,12 @@ bool fastd_shell_exec(fastd_context_t *ctx, const char *command, const char *dir case AF_INET6: inet_ntop(AF_INET6, &peer_addr->in6.sin6_addr, buf, sizeof(buf)); + + if (IN6_IS_ADDR_LINKLOCAL(&peer_addr->in6.sin6_addr)) { + if (if_indextoname(peer_addr->in6.sin6_scope_id, buf+strlen(buf)+1)) + buf[strlen(buf)] = '%'; + } + setenv("PEER_ADDRESS", buf, 1); snprintf(buf, sizeof(buf), "%u", ntohs(peer_addr->in6.sin6_port)); -- cgit v1.2.3