summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-04-21 01:49:25 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-04-21 01:49:25 +0200
commit7b8a9acd7a3a31f5d393c1632d68379f8353e7d1 (patch)
tree7126ffa0af27dddde06c973fb3f880fcf2851f8b
parentdc9fa15a48ef572a4bd26e9449a65c59d1d495ce (diff)
downloadfastd-7b8a9acd7a3a31f5d393c1632d68379f8353e7d1.tar
fastd-7b8a9acd7a3a31f5d393c1632d68379f8353e7d1.zip
shell: add interface for link-local addresses to PEER_ADDRESS as well
-rw-r--r--src/shell.c6
1 files changed, 6 insertions, 0 deletions
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));