summaryrefslogtreecommitdiffstats
path: root/src/methods
diff options
context:
space:
mode:
Diffstat (limited to 'src/methods')
-rw-r--r--src/methods/common.c8
-rw-r--r--src/methods/common.h14
2 files changed, 11 insertions, 11 deletions
diff --git a/src/methods/common.c b/src/methods/common.c
index c6d6519..51cd6e8 100644
--- a/src/methods/common.c
+++ b/src/methods/common.c
@@ -37,8 +37,8 @@
void fastd_method_common_init(fastd_method_common_t *session, bool initiator) {
memset(session, 0, sizeof(*session));
- session->valid_till = fastd_in_seconds(KEY_VALID);
- session->refresh_after = fastd_in_seconds(KEY_REFRESH - fastd_rand(0, KEY_REFRESH_SPLAY));
+ session->valid_till = ctx.now + KEY_VALID;
+ session->refresh_after = ctx.now + KEY_REFRESH - fastd_rand(0, KEY_REFRESH_SPLAY);
if (initiator) {
session->send_nonce[COMMON_NONCEBYTES-1] = 3;
@@ -65,7 +65,7 @@ bool fastd_method_is_nonce_valid(const fastd_method_common_t *session, const uin
*age >>= 1;
if (*age >= 0) {
- if (fastd_timed_out(&session->reorder_timeout))
+ if (fastd_timed_out(session->reorder_timeout))
return false;
if (*age > 64)
@@ -89,7 +89,7 @@ bool fastd_method_reorder_check(fastd_peer_t *peer, fastd_method_common_t *sessi
session->receive_reorder_seen |= ((uint64_t)1 << (shift-1));
memcpy(session->receive_nonce, nonce, COMMON_NONCEBYTES);
- session->reorder_timeout = fastd_in_seconds(REORDER_TIME);
+ session->reorder_timeout = ctx.now + REORDER_TIME;
return true;
}
else if (age == 0 || session->receive_reorder_seen & (1 << (age-1))) {
diff --git a/src/methods/common.h b/src/methods/common.h
index 7a06f92..d200931 100644
--- a/src/methods/common.h
+++ b/src/methods/common.h
@@ -46,13 +46,13 @@
/** Common method session state */
typedef struct fastd_method_common {
- struct timespec valid_till; /**< How long the session is valid */
- struct timespec refresh_after; /**< When to try refreshing the session */
+ fastd_timeout_t valid_till; /**< How long the session is valid */
+ fastd_timeout_t refresh_after; /**< When to try refreshing the session */
uint8_t send_nonce[COMMON_NONCEBYTES]; /**< The next nonce to use */
uint8_t receive_nonce[COMMON_NONCEBYTES]; /**< The hightest nonce received to far for this session */
- struct timespec reorder_timeout; /**< How long to packets with a lower sequence number (nonce) than the newest received */
+ fastd_timeout_t reorder_timeout; /**< How long to packets with a lower sequence number (nonce) than the newest received */
uint64_t receive_reorder_seen; /**< Bitmap specifying which of the 64 sequence numbers (nonces) before \a receive_nonce have bit seen */
} fastd_method_common_t;
@@ -71,7 +71,7 @@ static inline bool fastd_method_session_common_is_valid(const fastd_method_commo
if (session->send_nonce[0] == 0xff && session->send_nonce[1] == 0xff)
return false;
- return (!fastd_timed_out(&session->valid_till));
+ return (!fastd_timed_out(session->valid_till));
}
/**
@@ -92,7 +92,7 @@ static inline bool fastd_method_session_common_want_refresh(const fastd_method_c
if (session->send_nonce[0] == 0xff)
return true;
- if (fastd_method_session_common_is_initiator(session) && fastd_timed_out(&session->refresh_after))
+ if (fastd_method_session_common_is_initiator(session) && fastd_timed_out(session->refresh_after))
return true;
return false;
@@ -100,9 +100,9 @@ static inline bool fastd_method_session_common_want_refresh(const fastd_method_c
/** The common \a session_superseded implementation */
static inline void fastd_method_session_common_superseded(fastd_method_common_t *session) {
- struct timespec valid_max = fastd_in_seconds(KEY_VALID_OLD);
+ fastd_timeout_t valid_max = ctx.now + KEY_VALID_OLD;
- if (timespec_after(&session->valid_till, &valid_max))
+ if (valid_max < session->valid_till)
session->valid_till = valid_max;
}