summaryrefslogtreecommitdiffstats
path: root/src/protocols
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-08-24 16:07:50 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-08-24 16:07:50 +0200
commit1ae3aae35193dce25e5534b12a46011ec7912bb4 (patch)
tree85d452b2a9cc23f081de7b2f3054801d6d9ea554 /src/protocols
parent4c0623a080c77ed54fa9fec47c2ab982385cb9a9 (diff)
downloadfastd-1ae3aae35193dce25e5534b12a46011ec7912bb4.tar
fastd-1ae3aae35193dce25e5534b12a46011ec7912bb4.zip
Use simple int64_t timestamps in ms instead of timespecs
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c2
-rw-r--r--src/protocols/ec25519_fhmqvc/handshake.c14
-rw-r--r--src/protocols/ec25519_fhmqvc/handshake.h8
-rw-r--r--src/protocols/ec25519_fhmqvc/state.c4
4 files changed, 14 insertions, 14 deletions
diff --git a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c
index 080c555..8528074 100644
--- a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c
+++ b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c
@@ -172,7 +172,7 @@ static void session_send(fastd_peer_t *peer, fastd_buffer_t buffer, protocol_ses
}
fastd_send(peer->sock, &peer->local_address, &peer->address, peer, send_buffer, stat_size);
- peer->keepalive_timeout = fastd_in_seconds(KEEPALIVE_TIMEOUT);
+ peer->keepalive_timeout = ctx.now + KEEPALIVE_TIMEOUT;
}
/** Encrypts and sends a packet to a peer */
diff --git a/src/protocols/ec25519_fhmqvc/handshake.c b/src/protocols/ec25519_fhmqvc/handshake.c
index 8f468cd..94aa338 100644
--- a/src/protocols/ec25519_fhmqvc/handshake.c
+++ b/src/protocols/ec25519_fhmqvc/handshake.c
@@ -177,7 +177,7 @@ static bool establish(fastd_peer_t *peer, const fastd_method_info_t *method, fas
return false;
}
- peer->establish_handshake_timeout = fastd_in_seconds(MIN_HANDSHAKE_INTERVAL);
+ peer->establish_handshake_timeout = ctx.now + MIN_HANDSHAKE_INTERVAL;
fastd_peer_seen(peer);
fastd_peer_set_established(peer);
@@ -567,8 +567,8 @@ static fastd_peer_t * add_dynamic(fastd_socket_t *sock, const fastd_peer_address
/** Is called when a handshake from a dynamic peer is received */
static bool handle_dynamic(fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr,
fastd_peer_t *peer, const fastd_handshake_t *handshake, const fastd_method_info_t *method) {
- if (handshake->type > 2 || !fastd_timed_out(&peer->verify_timeout))
- return !fastd_timed_out(&peer->verify_valid_timeout);
+ if (handshake->type > 2 || !fastd_timed_out(peer->verify_timeout))
+ return !fastd_timed_out(peer->verify_valid_timeout);
verify_data_t verify_data;
memset(&verify_data, 0, sizeof(verify_data));
@@ -597,7 +597,7 @@ void fastd_protocol_ec25519_fhmqvc_handle_verify_return(fastd_peer_t *peer, fast
const verify_data_t *data = protocol_data;
- peer->last_handshake_response_timeout = fastd_in_seconds(MIN_HANDSHAKE_INTERVAL);
+ peer->last_handshake_response_timeout = ctx.now + MIN_HANDSHAKE_INTERVAL;
peer->last_handshake_response_address = *remote_addr;
respond_handshake(sock, local_addr, remote_addr, peer, &data->peer_handshake_key, method);
}
@@ -652,7 +652,7 @@ void fastd_protocol_ec25519_fhmqvc_handshake_handle(fastd_socket_t *sock, const
return;
}
- if (!fastd_timed_out(&peer->establish_handshake_timeout)) {
+ if (!fastd_timed_out(peer->establish_handshake_timeout)) {
pr_debug("received repeated handshakes from %P[%I], ignoring", peer, remote_addr);
return;
}
@@ -675,7 +675,7 @@ void fastd_protocol_ec25519_fhmqvc_handshake_handle(fastd_socket_t *sock, const
memcpy(&peer_handshake_key, handshake->records[RECORD_SENDER_HANDSHAKE_KEY].data, PUBLICKEYBYTES);
if (handshake->type == 1) {
- if (!fastd_timed_out(&peer->last_handshake_response_timeout)
+ if (!fastd_timed_out(peer->last_handshake_response_timeout)
&& fastd_peer_address_equal(remote_addr, &peer->last_handshake_response_address)) {
pr_debug("not responding to repeated handshake from %P[%I]", peer, remote_addr);
return;
@@ -683,7 +683,7 @@ void fastd_protocol_ec25519_fhmqvc_handshake_handle(fastd_socket_t *sock, const
pr_verbose("received handshake from %P[%I]%s%s", peer, remote_addr, handshake->peer_version ? " using fastd " : "", handshake->peer_version ?: "");
- peer->last_handshake_response_timeout = fastd_in_seconds(MIN_HANDSHAKE_INTERVAL);
+ peer->last_handshake_response_timeout = ctx.now + MIN_HANDSHAKE_INTERVAL;
peer->last_handshake_response_address = *remote_addr;
respond_handshake(sock, local_addr, remote_addr, peer, &peer_handshake_key, method);
return;
diff --git a/src/protocols/ec25519_fhmqvc/handshake.h b/src/protocols/ec25519_fhmqvc/handshake.h
index a05e542..7779858 100644
--- a/src/protocols/ec25519_fhmqvc/handshake.h
+++ b/src/protocols/ec25519_fhmqvc/handshake.h
@@ -50,8 +50,8 @@ typedef struct handshake_key {
*/
uint64_t serial;
- struct timespec preferred_till; /**< Specifies how long this keypair will be used for new handshakes */
- struct timespec valid_till; /**< Specifies how long handshakes using this keypair will be answered */
+ fastd_timeout_t preferred_till; /**< Specifies how long this keypair will be used for new handshakes */
+ fastd_timeout_t valid_till; /**< Specifies how long handshakes using this keypair will be answered */
keypair_t key; /**< The actual keypair */
} handshake_key_t;
@@ -69,10 +69,10 @@ struct fastd_protocol_state {
/** Checks if a handshake keypair is currently valid */
static inline bool is_handshake_key_valid(const handshake_key_t *handshake_key) {
- return !fastd_timed_out(&handshake_key->valid_till);
+ return !fastd_timed_out(handshake_key->valid_till);
}
/** Checks if a handshake keypair is currently peferred */
static inline bool is_handshake_key_preferred(const handshake_key_t *handshake_key) {
- return !fastd_timed_out(&handshake_key->preferred_till);
+ return !fastd_timed_out(handshake_key->preferred_till);
}
diff --git a/src/protocols/ec25519_fhmqvc/state.c b/src/protocols/ec25519_fhmqvc/state.c
index d4a2a0e..79bb6e2 100644
--- a/src/protocols/ec25519_fhmqvc/state.c
+++ b/src/protocols/ec25519_fhmqvc/state.c
@@ -72,8 +72,8 @@ void fastd_protocol_ec25519_fhmqvc_maintenance(void) {
new_handshake_key(&ctx.protocol_state->handshake_key.key);
- ctx.protocol_state->handshake_key.preferred_till = fastd_in_seconds(15);
- ctx.protocol_state->handshake_key.valid_till = fastd_in_seconds(30);
+ ctx.protocol_state->handshake_key.preferred_till = ctx.now + 15000;
+ ctx.protocol_state->handshake_key.valid_till = ctx.now + 30000;
}
}