diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-12-13 18:02:39 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-12-13 18:02:39 +0100 |
commit | 766a0c145dad84b9af35b2bebc032be71509b3df (patch) | |
tree | a3fc10504338df57c208aa938b6db8b1d2c661b1 | |
parent | 505eb464948d32f9ae5d7f8d48d89dde98972930 (diff) | |
download | fastd-766a0c145dad84b9af35b2bebc032be71509b3df.tar fastd-766a0c145dad84b9af35b2bebc032be71509b3df.zip |
Always convert v4-mapped IPv6 addresses to IPv4 addresses
-rw-r--r-- | src/config.c | 6 | ||||
-rw-r--r-- | src/config.y | 2 | ||||
-rw-r--r-- | src/resolve.c | 1 |
3 files changed, 7 insertions, 2 deletions
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; |