diff options
-rw-r--r-- | src/config.l | 1 | ||||
-rw-r--r-- | src/config.y | 9 | ||||
-rw-r--r-- | src/peer.c | 6 | ||||
-rw-r--r-- | src/peer.h | 3 |
4 files changed, 16 insertions, 3 deletions
diff --git a/src/config.l b/src/config.l index 4f7dd7f..c4b20ab 100644 --- a/src/config.l +++ b/src/config.l @@ -93,6 +93,7 @@ forward { UPDATE_LOCATION; return TOK_FORWARD; } yes { UPDATE_LOCATION; return TOK_YES; } no { UPDATE_LOCATION; return TOK_NO; } port { UPDATE_LOCATION; return TOK_PORT; } +float { UPDATE_LOCATION; return TOK_FLOAT; } [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} { UPDATE_LOCATION; diff --git a/src/config.y b/src/config.y index ec2aabe..07774d1 100644 --- a/src/config.y +++ b/src/config.y @@ -94,6 +94,7 @@ %token TOK_YES %token TOK_NO %token TOK_PORT +%token TOK_FLOAT %token <addr> TOK_ADDR %token <addr6> TOK_ADDR6 @@ -117,6 +118,7 @@ %type <num> maybe_port %type <str> maybe_as %type <num> maybe_af +%type <boolean> maybe_float %% start: START_CONFIG config @@ -294,12 +296,13 @@ peer_remote: TOK_ADDR port { conf->peers->address.in6.sin6_addr = $1; conf->peers->address.in6.sin6_port = htons($2); } - | maybe_af TOK_STRING port { + | maybe_af TOK_STRING port maybe_float { free(conf->peers->hostname); conf->peers->hostname = strdup($2->str); conf->peers->address.sa.sa_family = $1; conf->peers->address.in.sin_port = htons($3); + conf->peers->dynamic_float = $4; } ; @@ -351,6 +354,10 @@ maybe_af: TOK_IPV4 { $$ = AF_INET; } | { $$ = AF_UNSPEC; } ; +maybe_float: TOK_FLOAT { $$ = true; } + | { $$ = false; } + ; + boolean: TOK_YES { $$ = true; } | TOK_NO { $$ = false; } ; @@ -189,7 +189,7 @@ static inline void setup_peer(fastd_context *ctx, fastd_peer *peer) { if (!peer->protocol_state) ctx->conf->protocol->init_peer_state(ctx, peer); - if (!fastd_peer_is_floating(peer)) + if (!fastd_peer_is_floating(peer) || fastd_peer_is_dynamic(peer)) fastd_task_schedule_handshake(ctx, peer, 0); } @@ -215,6 +215,7 @@ fastd_peer_config* fastd_peer_config_new(fastd_context *ctx, fastd_config *conf) peer->hostname = NULL; memset(&peer->address, 0, sizeof(fastd_peer_address)); + peer->dynamic_float = false; peer->config_source_dir = NULL; @@ -310,6 +311,9 @@ bool fastd_peer_config_equal(const fastd_peer_config *peer1, const fastd_peer_co if (!strequal(peer1->hostname, peer2->hostname)) return false; + if(peer1->dynamic_float != peer2->dynamic_float) + return false; + if (!fastd_peer_address_equal(&peer1->address, &peer2->address)) return false; @@ -62,6 +62,7 @@ struct _fastd_peer_config { char *hostname; fastd_peer_address address; + bool dynamic_float; char *key; fastd_protocol_peer_config *protocol_config; @@ -92,7 +93,7 @@ const fastd_eth_addr* fastd_get_source_address(const fastd_context *ctx, fastd_b const fastd_eth_addr* fastd_get_dest_address(const fastd_context *ctx, fastd_buffer buffer); static inline bool fastd_peer_config_is_floating(const fastd_peer_config *config) { - return (config->hostname == NULL && config->address.sa.sa_family == AF_UNSPEC); + return ((config->hostname == NULL && config->address.sa.sa_family == AF_UNSPEC) || config->dynamic_float); } static inline bool fastd_peer_config_is_dynamic(const fastd_peer_config *config) { |