summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-01-11 10:56:11 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-01-11 10:56:11 +0100
commit9e434460030cc7a9919671ca3843ff4c0a8ea17e (patch)
tree3b762e5ea64b3f033c200f9a9e9ded6ee6fd3d2b
parent676c75fb1826a2d24c4ec3a929b1c1634787c9a5 (diff)
downloadfastd-9e434460030cc7a9919671ca3843ff4c0a8ea17e.tar
fastd-9e434460030cc7a9919671ca3843ff4c0a8ea17e.zip
config: allow ipv4/ipv6 keywords before static addresses
-rw-r--r--src/config.y30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/config.y b/src/config.y
index 35b8901..bd106e7 100644
--- a/src/config.y
+++ b/src/config.y
@@ -458,41 +458,41 @@ peer_statement: TOK_REMOTE peer_remote ';'
| TOK_INCLUDE peer_include ';'
;
-peer_remote: TOK_ADDR4 port {
+peer_remote: maybe_ipv4 TOK_ADDR4 port {
fastd_remote_t remote = {};
remote.address.in.sin_family = AF_INET;
- remote.address.in.sin_addr = $1;
- remote.address.in.sin_port = htons($2);
+ remote.address.in.sin_addr = $2;
+ remote.address.in.sin_port = htons($3);
fastd_peer_address_simplify(&remote.address);
VECTOR_ADD(state->peer->remotes, remote);
}
- | TOK_ADDR6 port {
+ | maybe_ipv6 TOK_ADDR6 port {
fastd_remote_t remote = {};
remote.address.in6.sin6_family = AF_INET6;
- remote.address.in6.sin6_addr = $1;
- remote.address.in6.sin6_port = htons($2);
+ remote.address.in6.sin6_addr = $2;
+ remote.address.in6.sin6_port = htons($3);
fastd_peer_address_simplify(&remote.address);
VECTOR_ADD(state->peer->remotes, remote);
}
- | TOK_ADDR6_SCOPED port {
+ | maybe_ipv6 TOK_ADDR6_SCOPED port {
char addrbuf[INET6_ADDRSTRLEN];
size_t addrlen;
- inet_ntop(AF_INET6, &$1.addr, addrbuf, sizeof(addrbuf));
+ inet_ntop(AF_INET6, &$2.addr, addrbuf, sizeof(addrbuf));
addrlen = strlen(addrbuf);
fastd_remote_t remote = {};
- remote.hostname = fastd_alloc(addrlen + strlen($1.ifname) + 2);
+ remote.hostname = fastd_alloc(addrlen + strlen($2.ifname) + 2);
memcpy(remote.hostname, addrbuf, addrlen);
remote.hostname[addrlen] = '%';
- strcpy(remote.hostname+addrlen+1, $1.ifname);
+ strcpy(remote.hostname+addrlen+1, $2.ifname);
remote.address.sa.sa_family = AF_INET6;
- remote.address.in.sin_port = htons($2);
+ remote.address.in.sin_port = htons($3);
VECTOR_ADD(state->peer->remotes, remote);
}
@@ -587,6 +587,14 @@ maybe_af: TOK_IPV4 { $$ = AF_INET; }
| { $$ = AF_UNSPEC; }
;
+maybe_ipv4: TOK_IPV4
+ |
+ ;
+
+maybe_ipv6: TOK_IPV6
+ |
+ ;
+
sync_def_sync: sync { $$ = $1; }
| { $$ = true; }
;