diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-01-26 06:00:04 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-01-26 06:00:04 +0100 |
commit | 26cf96bea0e07df934c807b78c2d77383556c1ce (patch) | |
tree | fffd28e2ea258df38422dcdfe169b9a4b3b27049 /src/peer.c | |
parent | 76d955efa5fcd46fd325015d6cd3a389f8d9bb93 (diff) | |
download | fastd-26cf96bea0e07df934c807b78c2d77383556c1ce.tar fastd-26cf96bea0e07df934c807b78c2d77383556c1ce.zip |
Switch to the new timeout helpers where possible
Diffstat (limited to 'src/peer.c')
-rw-r--r-- | src/peer.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -219,6 +219,8 @@ static void setup_peer(fastd_context_t *ctx, fastd_peer_t *peer) { peer->last_handshake_response_timeout = ctx->now; peer->last_handshake_response_address.sa.sa_family = AF_UNSPEC; + peer->establish_handshake_timeout = ctx->now; + if (!peer->protocol_state) ctx->conf->protocol->init_peer_state(ctx, peer); @@ -565,7 +567,7 @@ fastd_peer_t* fastd_peer_add_temporary(fastd_context_t *ctx) { ctx->peers_temp = peer; peer->group = ctx->peer_group; - peer->seen = ctx->now; + fastd_peer_seen(ctx, peer); pr_debug(ctx, "adding temporary peer"); @@ -678,7 +680,7 @@ void fastd_peer_eth_addr_add(fastd_context_t *ctx, fastd_peer_t *peer, fastd_eth if (cmp == 0) { ctx->eth_addr[cur].peer = peer; - ctx->eth_addr[cur].seen = ctx->now; + ctx->eth_addr[cur].timeout = fastd_in_seconds(ctx, ctx->conf->eth_addr_stale_time); return; /* We're done here. */ } else if (cmp < 0) { @@ -703,7 +705,7 @@ void fastd_peer_eth_addr_add(fastd_context_t *ctx, fastd_peer_t *peer, fastd_eth for (i = ctx->n_eth_addr-1; i > min; i--) ctx->eth_addr[i] = ctx->eth_addr[i-1]; - ctx->eth_addr[min] = (fastd_peer_eth_addr_t){ addr, peer, ctx->now }; + ctx->eth_addr[min] = (fastd_peer_eth_addr_t){ addr, peer, fastd_in_seconds(ctx, ctx->conf->eth_addr_stale_time) }; pr_debug(ctx, "learned new MAC address %E on peer %P", &addr, peer); } @@ -712,7 +714,7 @@ void fastd_peer_eth_addr_cleanup(fastd_context_t *ctx) { size_t i, deleted = 0; for (i = 0; i < ctx->n_eth_addr; i++) { - if (timespec_diff(&ctx->now, &ctx->eth_addr[i].seen) > (int)ctx->conf->eth_addr_stale_time*1000) { + if (fastd_timed_out(ctx, &ctx->eth_addr[i].timeout)) { deleted++; pr_debug(ctx, "MAC address %E not seen for more than %u seconds, removing", &ctx->eth_addr[i].addr, ctx->conf->eth_addr_stale_time); |