From 766a0c145dad84b9af35b2bebc032be71509b3df Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 13 Dec 2012 18:02:39 +0100 Subject: Always convert v4-mapped IPv6 addresses to IPv4 addresses --- src/config.c | 6 ++++-- src/config.y | 2 ++ src/resolve.c | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/config.c b/src/config.c index 09a0adc..8ae1ca6 100644 --- a/src/config.c +++ b/src/config.c @@ -236,10 +236,12 @@ void fastd_config_bind_address(fastd_context *ctx, fastd_config *conf, const fas addr->addr = *address; addr->bindtodev = bindtodev ? strdup(bindtodev) : NULL; - if (address->sa.sa_family != AF_INET6 && (default_v4 || !conf->bind_addr_default_v4)) + fastd_peer_address_simplify(&addr->addr); + + if (addr->addr.sa.sa_family != AF_INET6 && (default_v4 || !conf->bind_addr_default_v4)) conf->bind_addr_default_v4 = addr; - if (address->sa.sa_family != AF_INET && (default_v6 || !conf->bind_addr_default_v6)) + if (addr->addr.sa.sa_family != AF_INET && (default_v6 || !conf->bind_addr_default_v6)) conf->bind_addr_default_v6 = addr; } diff --git a/src/config.y b/src/config.y index d576b91..66912a2 100644 --- a/src/config.y +++ b/src/config.y @@ -347,6 +347,7 @@ peer_remote: TOK_ADDR4 port { conf->peers->address.in.sin_family = AF_INET; conf->peers->address.in.sin_addr = $1; conf->peers->address.in.sin_port = htons($2); + fastd_peer_address_simplify(&conf->peers->address); } | TOK_ADDR6 port { free(conf->peers->hostname); @@ -355,6 +356,7 @@ peer_remote: TOK_ADDR4 port { conf->peers->address.in6.sin6_family = AF_INET6; conf->peers->address.in6.sin6_addr = $1; conf->peers->address.in6.sin6_port = htons($2); + fastd_peer_address_simplify(&conf->peers->address); } | maybe_af TOK_STRING port maybe_float { free(conf->peers->hostname); diff --git a/src/resolve.c b/src/resolve.c index a0a9312..642fd67 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -78,6 +78,7 @@ static void* resolve_peer(void *varg) { if (!error) { pr_verbose(arg->ctx, "resolved host `%s' successfully", arg->hostname); memcpy(&ret.addr, res->ai_addr, res->ai_addrlen); + fastd_peer_address_simplify(&ret.addr); } else { ret.addr.sa.sa_family = AF_UNSPEC; -- cgit v1.2.3