summaryrefslogtreecommitdiffstats
path: root/src/config.y
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-10-29 22:21:47 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-10-29 22:21:47 +0100
commit078b835209bd22b5cf3f497f2b06f3fad0a078ca (patch)
tree2704129741073ce83345cc3305fbf51a988d2842 /src/config.y
parentf5462bd63a1f6fc8879341c3eacd60e9824dec24 (diff)
downloadfastd-078b835209bd22b5cf3f497f2b06f3fad0a078ca.tar
fastd-078b835209bd22b5cf3f497f2b06f3fad0a078ca.zip
Add support for multiple binds
Diffstat (limited to 'src/config.y')
-rw-r--r--src/config.y37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/config.y b/src/config.y
index 2b1af0f..d87c151 100644
--- a/src/config.y
+++ b/src/config.y
@@ -187,21 +187,32 @@ log_level: TOK_FATAL { $$ = LOG_CRIT; }
interface: TOK_STRING { free(conf->ifname); conf->ifname = strdup($1->str); }
;
-bind: TOK_ADDR maybe_port {
- conf->bind_addr_in.sin_family = AF_INET;
- conf->bind_addr_in.sin_addr = $1;
- conf->bind_addr_in.sin_port = htons($2);
+bind_new: {
+ fastd_bind_address *addr = calloc(1, sizeof(fastd_bind_address));
+ addr->next = conf->bind_addrs;
+ conf->bind_addrs = addr;
}
- | TOK_ADDR6 maybe_port {
- conf->bind_addr_in6.sin6_family = AF_INET6;
- conf->bind_addr_in6.sin6_addr = $1;
- conf->bind_addr_in6.sin6_port = htons($2);
+
+bind: bind_new TOK_ADDR maybe_port {
+ conf->bind_addrs->addr.in.sin_family = AF_INET;
+ conf->bind_addrs->addr.in.sin_addr = $2;
+ conf->bind_addrs->addr.in.sin_port = htons($3);
+ if (!conf->bind_addr_default_v4)
+ conf->bind_addr_default_v4 = conf->bind_addrs;
+ }
+ | bind_new TOK_ADDR6 maybe_port {
+ conf->bind_addrs->addr.in6.sin6_family = AF_INET6;
+ conf->bind_addrs->addr.in6.sin6_addr = $2;
+ conf->bind_addrs->addr.in6.sin6_port = htons($3);
+ if (!conf->bind_addr_default_v6)
+ conf->bind_addr_default_v6 = conf->bind_addrs;
}
- | TOK_ANY maybe_port {
- conf->bind_addr_in.sin_addr.s_addr = htonl(INADDR_ANY);
- conf->bind_addr_in.sin_port = htons($2);
- conf->bind_addr_in6.sin6_addr = in6addr_any;
- conf->bind_addr_in6.sin6_port = htons($2);
+ | bind_new TOK_ANY maybe_port {
+ conf->bind_addrs->addr.in.sin_port = htons($3);
+ if (!conf->bind_addr_default_v4)
+ conf->bind_addr_default_v4 = conf->bind_addrs;
+ if (!conf->bind_addr_default_v6)
+ conf->bind_addr_default_v6 = conf->bind_addrs;
}
;