summaryrefslogtreecommitdiffstats
path: root/src/config.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.y')
-rw-r--r--src/config.y42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/config.y b/src/config.y
index 97d2f97..fde2873 100644
--- a/src/config.y
+++ b/src/config.y
@@ -397,29 +397,39 @@ peer_statement: TOK_REMOTE peer_remote ';'
;
peer_remote: TOK_ADDR4 port {
- free(conf->peers->hostname);
- conf->peers->hostname = NULL;
+ fastd_remote_config_t **remote = &conf->peers->remotes;
+ while (*remote)
+ remote = &(*remote)->next;
- 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);
+ *remote = calloc(1, sizeof(fastd_remote_config_t));
+
+ (*remote)->address.in.sin_family = AF_INET;
+ (*remote)->address.in.sin_addr = $1;
+ (*remote)->address.in.sin_port = htons($2);
+ fastd_peer_address_simplify(&(*remote)->address);
}
| TOK_ADDR6 port {
- free(conf->peers->hostname);
- conf->peers->hostname = NULL;
+ fastd_remote_config_t **remote = &conf->peers->remotes;
+ while (*remote)
+ remote = &(*remote)->next;
+
+ *remote = calloc(1, sizeof(fastd_remote_config_t));
- 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);
+ (*remote)->address.in6.sin6_family = AF_INET6;
+ (*remote)->address.in6.sin6_addr = $1;
+ (*remote)->address.in6.sin6_port = htons($2);
+ fastd_peer_address_simplify(&(*remote)->address);
}
| maybe_af TOK_STRING port maybe_float {
- free(conf->peers->hostname);
+ fastd_remote_config_t **remote = &conf->peers->remotes;
+ while (*remote)
+ remote = &(*remote)->next;
+
+ *remote = calloc(1, sizeof(fastd_remote_config_t));
- conf->peers->hostname = strdup($2->str);
- conf->peers->address.sa.sa_family = $1;
- conf->peers->address.in.sin_port = htons($3);
+ (*remote)->hostname = strdup($2->str);
+ (*remote)->address.sa.sa_family = $1;
+ (*remote)->address.in.sin_port = htons($3);
conf->peers->floating = conf->peers->dynamic_float_deprecated = $4;
}
;