diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 4f129d5d..b5c0d693 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c @@ -26,9 +26,9 @@ static inline IP get_loopback(void) #endif return ip; } -static void do_onion(Onion *onion) +static void do_onion(Mono_Time *mono_time, Onion *onion) { - mono_time_update(onion->mono_time); + mono_time_update(mono_time); networking_poll(onion->net, nullptr); do_dht(onion->dht); @@ -229,16 +229,16 @@ static void test_basic(void) handled_test_1 = 0; do { - do_onion(onion1); - do_onion(onion2); + do_onion(mono_time1, onion1); + do_onion(mono_time2, onion2); } while (handled_test_1 == 0); networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE_OLD, &handle_test_2, onion1); handled_test_2 = 0; do { - do_onion(onion1); - do_onion(onion2); + do_onion(mono_time1, onion1); + do_onion(mono_time2, onion2); } while (handled_test_2 == 0); Onion_Announce *onion1_a = new_onion_announce(log1, mono_time1, onion1->dht); @@ -260,8 +260,8 @@ static void test_basic(void) handled_test_3 = 0; do { - do_onion(onion1); - do_onion(onion2); + do_onion(mono_time1, onion1); + do_onion(mono_time2, onion2); c_sleep(50); } while (handled_test_3 == 0); @@ -278,8 +278,8 @@ static void test_basic(void) dht_get_self_public_key(onion1->dht), s); do { - do_onion(onion1); - do_onion(onion2); + do_onion(mono_time1, onion1); + do_onion(mono_time2, onion2); c_sleep(50); } while (memcmp(onion_announce_entry_public_key(onion2_a, ONION_ANNOUNCE_MAX_ENTRIES - 2), dht_get_self_public_key(onion1->dht), @@ -303,8 +303,8 @@ static void test_basic(void) handled_test_4 = 0; do { - do_onion(onion1); - do_onion(onion2); + do_onion(mono_time1, onion1); + do_onion(mono_time2, onion2); c_sleep(50); } while (handled_test_4 == 0); diff --git a/toxcore/onion.c b/toxcore/onion.c index 9e327fc0..25218a00 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c @@ -641,7 +641,7 @@ void set_callback_handle_recv_1(Onion *onion, onion_recv_1_cb *function, void *o onion->callback_object = object; } -Onion *new_onion(const Logger *log, Mono_Time *mono_time, DHT *dht) +Onion *new_onion(const Logger *log, const Mono_Time *mono_time, DHT *dht) { if (dht == nullptr) { return nullptr; diff --git a/toxcore/onion.h b/toxcore/onion.h index cb32cf17..24a95fe1 100644 --- a/toxcore/onion.h +++ b/toxcore/onion.h @@ -17,7 +17,7 @@ typedef int onion_recv_1_cb(void *object, const IP_Port *dest, const uint8_t *da typedef struct Onion { const Logger *log; - Mono_Time *mono_time; + const Mono_Time *mono_time; DHT *dht; Networking_Core *net; uint8_t secret_symmetric_key[CRYPTO_SYMMETRIC_KEY_SIZE]; @@ -143,7 +143,7 @@ non_null(1) nullable(2, 3) void set_callback_handle_recv_1(Onion *onion, onion_recv_1_cb *function, void *object); non_null() -Onion *new_onion(const Logger *log, Mono_Time *mono_time, DHT *dht); +Onion *new_onion(const Logger *log, const Mono_Time *mono_time, DHT *dht); non_null() void kill_onion(Onion *onion); diff --git a/toxcore/onion_announce.c b/toxcore/onion_announce.c index f0c1f727..1b781a80 100644 --- a/toxcore/onion_announce.c +++ b/toxcore/onion_announce.c @@ -44,7 +44,7 @@ typedef struct Onion_Announce_Entry { struct Onion_Announce { const Logger *log; - Mono_Time *mono_time; + const Mono_Time *mono_time; DHT *dht; Networking_Core *net; Onion_Announce_Entry entries[ONION_ANNOUNCE_MAX_ENTRIES]; @@ -648,7 +648,7 @@ static int handle_data_request(void *object, const IP_Port *source, const uint8_ return 0; } -Onion_Announce *new_onion_announce(const Logger *log, Mono_Time *mono_time, DHT *dht) +Onion_Announce *new_onion_announce(const Logger *log, const Mono_Time *mono_time, DHT *dht) { if (dht == nullptr) { return nullptr; diff --git a/toxcore/onion_announce.h b/toxcore/onion_announce.h index f81defe3..32ad3cd8 100644 --- a/toxcore/onion_announce.h +++ b/toxcore/onion_announce.h @@ -128,7 +128,7 @@ void onion_announce_extra_data_callback(Onion_Announce *onion_a, uint16_t extra_ pack_extra_data_cb *extra_data_callback, void *extra_data_object); non_null() -Onion_Announce *new_onion_announce(const Logger *log, Mono_Time *mono_time, DHT *dht); +Onion_Announce *new_onion_announce(const Logger *log, const Mono_Time *mono_time, DHT *dht); non_null() void kill_onion_announce(Onion_Announce *onion_a); diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 3600a45d..6345937e 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c @@ -98,7 +98,7 @@ typedef struct Onion_Data_Handler { } Onion_Data_Handler; struct Onion_Client { - Mono_Time *mono_time; + const Mono_Time *mono_time; const Logger *logger; DHT *dht; @@ -1920,7 +1920,7 @@ void do_onion_client(Onion_Client *onion_c) onion_c->last_run = mono_time_get(onion_c->mono_time); } -Onion_Client *new_onion_client(const Logger *logger, Mono_Time *mono_time, Net_Crypto *c) +Onion_Client *new_onion_client(const Logger *logger, const Mono_Time *mono_time, Net_Crypto *c) { if (c == nullptr) { return nullptr; diff --git a/toxcore/onion_client.h b/toxcore/onion_client.h index d541982e..ad68bd08 100644 --- a/toxcore/onion_client.h +++ b/toxcore/onion_client.h @@ -197,7 +197,7 @@ non_null() void do_onion_client(Onion_Client *onion_c); non_null() -Onion_Client *new_onion_client(const Logger *logger, Mono_Time *mono_time, Net_Crypto *c); +Onion_Client *new_onion_client(const Logger *logger, const Mono_Time *mono_time, Net_Crypto *c); non_null() void kill_onion_client(Onion_Client *onion_c);