From b78d55b69ed9d9c88d12f0159e78973ad0d70b49 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 26 Jan 2014 08:55:35 +0100 Subject: Allow scoped IPv6 addresses for remotes using the usual notation --- src/config.y | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/config.y') diff --git a/src/config.y b/src/config.y index a14794f..b7243a5 100644 --- a/src/config.y +++ b/src/config.y @@ -47,6 +47,10 @@ struct in_addr addr4; struct in6_addr addr6; fastd_peer_address_t addr; + struct { + struct in6_addr addr; + char ifname[IFNAMSIZ]; + } addr6_scoped; const char *error; } @@ -60,6 +64,7 @@ %token TOK_ADDR4 %token TOK_ADDR6 +%token TOK_ADDR6_SCOPED %token TOK_ADDRESSES %token TOK_ANY @@ -468,6 +473,26 @@ peer_remote: TOK_ADDR4 port { (*remote)->address.in6.sin6_port = htons($2); fastd_peer_address_simplify(&(*remote)->address); } + | TOK_ADDR6_SCOPED port { + char addrbuf[INET6_ADDRSTRLEN]; + size_t addrlen; + fastd_remote_config_t **remote = &conf->peers->remotes; + while (*remote) + remote = &(*remote)->next; + + inet_ntop(AF_INET6, &$1.addr, addrbuf, sizeof(addrbuf)); + addrlen = strlen(addrbuf); + + *remote = calloc(1, sizeof(fastd_remote_config_t)); + + (*remote)->hostname = malloc(addrlen + strlen($1.ifname) + 2); + memcpy((*remote)->hostname, addrbuf, addrlen); + (*remote)->hostname[addrlen] = '%'; + strcpy((*remote)->hostname+addrlen+1, $1.ifname); + + (*remote)->address.sa.sa_family = AF_INET6; + (*remote)->address.in.sin_port = htons($2); + } | maybe_af TOK_STRING port maybe_float { fastd_remote_config_t **remote = &conf->peers->remotes; while (*remote) -- cgit v1.2.3