summaryrefslogtreecommitdiff
path: root/ot_udp.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-27 19:15:22 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-10-27 19:15:22 +0100
commit8fb1c09df1540aa3fca1148bed6a08ffc3090669 (patch)
treeeb03f2a9f3eb8e074abc0533aac7f5ab7cd8926c /ot_udp.c
parentdf5557705764d5e8f904a31d549fc037f5b1cf47 (diff)
All OSes now do have a cheap monotonic clock, so no caching thread is needed. Also add some relative time helpers
Diffstat (limited to 'ot_udp.c')
-rw-r--r--ot_udp.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ot_udp.c b/ot_udp.c
index 4e760bb..19a6c7c 100644
--- a/ot_udp.c
+++ b/ot_udp.c
@@ -30,7 +30,7 @@ static void udp_generate_rijndael_round_key(void) {
30 rijndaelKeySetupEnc128(g_rijndael_round_key, (uint8_t *)key); 30 rijndaelKeySetupEnc128(g_rijndael_round_key, (uint8_t *)key);
31 31
32 g_key_of_the_hour[0] = random_uint32(); 32 g_key_of_the_hour[0] = random_uint32();
33 g_hour_of_the_key = g_now_minutes; 33 g_hour_of_the_key = time_now_minutes();
34} 34}
35 35
36/* Generate current and previous connection id for ip */ 36/* Generate current and previous connection id for ip */
@@ -39,14 +39,14 @@ static void udp_make_connectionid(uint32_t connid[2], const ot_ip6 remoteip, int
39 int i; 39 int i;
40 uint32_t current_key_of_the_hour; 40 uint32_t current_key_of_the_hour;
41 41
42 if (g_now_minutes - g_hour_of_the_key >= 60) { 42 if (time_now_minutes() - g_hour_of_the_key >= 60) {
43 uint32_t old_key_of_the_hour = g_key_of_the_hour[0]; 43 uint32_t old_key_of_the_hour = g_key_of_the_hour[0];
44 uint32_t new_key_of_the_hour = random_uint32(); 44 uint32_t new_key_of_the_hour = random_uint32();
45 /* If in the meantime another thread has performed 45 /* If in the meantime another thread has performed
46 key rotation, do not overwrite their results */ 46 key rotation, do not overwrite their results */
47 if (g_now_minutes - g_hour_of_the_key >= 60) { 47 if (time_now_minutes() - g_hour_of_the_key >= 60) {
48 /* Upgrade en bloc */ 48 /* Upgrade en bloc */
49 g_hour_of_the_key = g_now_minutes; 49 g_hour_of_the_key = time_now_minutes();
50 g_key_of_the_hour[0] = new_key_of_the_hour; 50 g_key_of_the_hour[0] = new_key_of_the_hour;
51 g_key_of_the_hour[1] = old_key_of_the_hour; 51 g_key_of_the_hour[1] = old_key_of_the_hour;
52 } 52 }