summaryrefslogtreecommitdiffstats
path: root/src/fastd.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-03-06 21:29:34 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-03-06 21:29:34 +0100
commit1d18f972554c8bad0f08b3ff6727c87586e97094 (patch)
treeae3fc39553ecd87ed85b22860640d2859e9aa092 /src/fastd.c
parentd4686dd79799c09faee49e1645f9b3c39ce1e993 (diff)
downloadfastd-1d18f972554c8bad0f08b3ff6727c87586e97094.tar
fastd-1d18f972554c8bad0f08b3ff6727c87586e97094.zip
Reorganized type definitions
Diffstat (limited to 'src/fastd.c')
-rw-r--r--src/fastd.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/fastd.c b/src/fastd.c
index fdd3f5c..e0a03ad 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -317,7 +317,8 @@ static void configure(fastd_context *ctx, fastd_config *conf, int argc, char *ar
}
}
- if (conf->bind_addr_in.sin_family == AF_UNSPEC && conf->bind_addr_in6.sin6_family == AF_UNSPEC) {
+ if (conf->n_floating && conf->bind_addr_in.sin_family == AF_UNSPEC
+ && conf->bind_addr_in6.sin6_family == AF_UNSPEC) {
conf->bind_addr_in.sin_family = AF_INET;
conf->bind_addr_in6.sin6_family = AF_INET6;
}
@@ -347,6 +348,10 @@ static void init_peers(fastd_context *ctx) {
fastd_peer_add(ctx, peer_conf);
}
+static void update_time(fastd_context *ctx) {
+ clock_gettime(CLOCK_MONOTONIC, &ctx->now);
+}
+
static void handle_tasks(fastd_context *ctx) {
fastd_task *task;
while ((task = fastd_task_get(ctx)) != NULL) {
@@ -565,6 +570,8 @@ static void handle_input(fastd_context *ctx) {
if (ret < 0)
exit_errno(ctx, "poll");
+ update_time(ctx);
+
if (fds[0].revents & POLLIN)
handle_tun(ctx);
if (fds[1].revents & POLLIN)
@@ -582,6 +589,8 @@ int main(int argc, char *argv[]) {
configure(&ctx, &conf, argc, argv);
ctx.conf = &conf;
+ update_time(&ctx);
+
init_peers(&ctx);
init_tuntap(&ctx);