diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/DHT.c | 78 | ||||
-rw-r--r-- | toxcore/DHT.h | 12 | ||||
-rw-r--r-- | toxcore/Messenger.c | 20 | ||||
-rw-r--r-- | toxcore/Messenger.h | 6 | ||||
-rw-r--r-- | toxcore/tox.c | 4 |
5 files changed, 60 insertions, 60 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index ac43371e..5041cc4e 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -2335,54 +2335,54 @@ void DHT_save(DHT *dht, uint8_t *data) | |||
2335 | 2335 | ||
2336 | static void DHT_bootstrap_loaded_clients(DHT *dht) | 2336 | static void DHT_bootstrap_loaded_clients(DHT *dht) |
2337 | { | 2337 | { |
2338 | uint32_t i; | 2338 | uint32_t i; |
2339 | 2339 | ||
2340 | Client_data *client_list = dht->loaded_clients_list; | 2340 | Client_data *client_list = dht->loaded_clients_list; |
2341 | uint32_t client_count = dht->loaded_num_clients; | 2341 | uint32_t client_count = dht->loaded_num_clients; |
2342 | 2342 | ||
2343 | for (i = 0; i < client_count; ++i) { | 2343 | for (i = 0; i < client_count; ++i) { |
2344 | if (client_list[i].assoc4.timestamp != 0) | 2344 | if (client_list[i].assoc4.timestamp != 0) |
2345 | DHT_bootstrap(dht, client_list[i].assoc4.ip_port, client_list[i].client_id); | 2345 | DHT_bootstrap(dht, client_list[i].assoc4.ip_port, client_list[i].client_id); |
2346 | 2346 | ||
2347 | if (client_list[i].assoc6.timestamp != 0) | 2347 | if (client_list[i].assoc6.timestamp != 0) |
2348 | DHT_bootstrap(dht, client_list[i].assoc6.ip_port, client_list[i].client_id); | 2348 | DHT_bootstrap(dht, client_list[i].assoc6.ip_port, client_list[i].client_id); |
2349 | } | 2349 | } |
2350 | } | 2350 | } |
2351 | 2351 | ||
2352 | static void getnodes_of_loaded_friend_clients(DHT *dht) | 2352 | static void getnodes_of_loaded_friend_clients(DHT *dht) |
2353 | { | 2353 | { |
2354 | uint32_t i, j; | 2354 | uint32_t i, j; |
2355 | 2355 | ||
2356 | DHT_Friend *friend_list = dht->loaded_friends_list; | 2356 | DHT_Friend *friend_list = dht->loaded_friends_list; |
2357 | uint32_t friend_count = dht->loaded_num_friends; | 2357 | uint32_t friend_count = dht->loaded_num_friends; |
2358 | 2358 | ||
2359 | for (i = 0; i < friend_count; ++i) { | 2359 | for (i = 0; i < friend_count; ++i) { |
2360 | for (j = 0; j < MAX_FRIEND_CLIENTS; ++j) { | 2360 | for (j = 0; j < MAX_FRIEND_CLIENTS; ++j) { |
2361 | Client_data *client = &friend_list[i].client_list[j]; | 2361 | Client_data *client = &friend_list[i].client_list[j]; |
2362 | 2362 | ||
2363 | if (client->assoc4.timestamp != 0) | 2363 | if (client->assoc4.timestamp != 0) |
2364 | getnodes(dht, client->assoc4.ip_port, client->client_id, friend_list[i].client_id, NULL); | 2364 | getnodes(dht, client->assoc4.ip_port, client->client_id, friend_list[i].client_id, NULL); |
2365 | 2365 | ||
2366 | if (client->assoc6.timestamp != 0) | 2366 | if (client->assoc6.timestamp != 0) |
2367 | getnodes(dht, client->assoc6.ip_port, client->client_id, friend_list[i].client_id, NULL); | 2367 | getnodes(dht, client->assoc6.ip_port, client->client_id, friend_list[i].client_id, NULL); |
2368 | } | 2368 | } |
2369 | } | 2369 | } |
2370 | } | 2370 | } |
2371 | 2371 | ||
2372 | /* Start sending packets after DHT loaded_friends_list and loaded_clients_list are set */ | 2372 | /* Start sending packets after DHT loaded_friends_list and loaded_clients_list are set */ |
2373 | int DHT_connect_after_load(DHT *dht) | 2373 | int DHT_connect_after_load(DHT *dht) |
2374 | { | 2374 | { |
2375 | if(dht == NULL || dht->loaded_friends_list == NULL || dht->loaded_clients_list == NULL) | 2375 | if(dht == NULL || dht->loaded_friends_list == NULL || dht->loaded_clients_list == NULL) |
2376 | return -1; | 2376 | return -1; |
2377 | 2377 | ||
2378 | getnodes_of_loaded_friend_clients(dht); | 2378 | getnodes_of_loaded_friend_clients(dht); |
2379 | DHT_bootstrap_loaded_clients(dht); | 2379 | DHT_bootstrap_loaded_clients(dht); |
2380 | 2380 | ||
2381 | // Loaded lists were allocd, free them | 2381 | // Loaded lists were allocd, free them |
2382 | free(dht->loaded_friends_list); | 2382 | free(dht->loaded_friends_list); |
2383 | free(dht->loaded_clients_list); | 2383 | free(dht->loaded_clients_list); |
2384 | 2384 | ||
2385 | return 0; | 2385 | return 0; |
2386 | } | 2386 | } |
2387 | 2387 | ||
2388 | static int dht_load_state_callback(void *outer, const uint8_t *data, uint32_t length, uint16_t type) | 2388 | static int dht_load_state_callback(void *outer, const uint8_t *data, uint32_t length, uint16_t type) |
@@ -2399,11 +2399,11 @@ static int dht_load_state_callback(void *outer, const uint8_t *data, uint32_t le | |||
2399 | DHT_Friend *friend_list = (DHT_Friend *)data; | 2399 | DHT_Friend *friend_list = (DHT_Friend *)data; |
2400 | num = length / sizeof(DHT_Friend); | 2400 | num = length / sizeof(DHT_Friend); |
2401 | 2401 | ||
2402 | // Copy to loaded_friends_list | 2402 | // Copy to loaded_friends_list |
2403 | dht->loaded_friends_list = calloc(num, sizeof(DHT_Friend)); | 2403 | dht->loaded_friends_list = calloc(num, sizeof(DHT_Friend)); |
2404 | for(i = 0; i < num; i++) | 2404 | for(i = 0; i < num; i++) |
2405 | memcpy(&(dht->loaded_friends_list[i]), &(friend_list[i]), sizeof(DHT_Friend)); | 2405 | memcpy(&(dht->loaded_friends_list[i]), &(friend_list[i]), sizeof(DHT_Friend)); |
2406 | dht->loaded_num_friends = num; | 2406 | dht->loaded_num_friends = num; |
2407 | 2407 | ||
2408 | } /* localize declarations */ | 2408 | } /* localize declarations */ |
2409 | 2409 | ||
@@ -2417,11 +2417,11 @@ static int dht_load_state_callback(void *outer, const uint8_t *data, uint32_t le | |||
2417 | num = length / sizeof(Client_data); | 2417 | num = length / sizeof(Client_data); |
2418 | Client_data *client_list = (Client_data *)data; | 2418 | Client_data *client_list = (Client_data *)data; |
2419 | 2419 | ||
2420 | // Copy to loaded_clients_list | 2420 | // Copy to loaded_clients_list |
2421 | dht->loaded_clients_list = calloc(num, sizeof(Client_data)); | 2421 | dht->loaded_clients_list = calloc(num, sizeof(Client_data)); |
2422 | for(i = 0; i < num; i++) | 2422 | for(i = 0; i < num; i++) |
2423 | memcpy(&(dht->loaded_clients_list[i]), &(client_list[i]), sizeof(Client_data)); | 2423 | memcpy(&(dht->loaded_clients_list[i]), &(client_list[i]), sizeof(Client_data)); |
2424 | dht->loaded_num_clients = num; | 2424 | dht->loaded_num_clients = num; |
2425 | 2425 | ||
2426 | } /* localize declarations */ | 2426 | } /* localize declarations */ |
2427 | 2427 | ||
diff --git a/toxcore/DHT.h b/toxcore/DHT.h index 1ead6f5e..bbba6209 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h | |||
@@ -200,12 +200,12 @@ typedef struct { | |||
200 | DHT_Friend *friends_list; | 200 | DHT_Friend *friends_list; |
201 | uint16_t num_friends; | 201 | uint16_t num_friends; |
202 | 202 | ||
203 | // Used after loading of file (tox_load), but no longer needed after connect (tox_connect) | 203 | // Used after loading of file (tox_load), but no longer needed after connect (tox_connect) |
204 | // Unsure if friends_list and num_friends could just be used instead? | 204 | // Unsure if friends_list and num_friends could just be used instead? |
205 | DHT_Friend *loaded_friends_list; | 205 | DHT_Friend *loaded_friends_list; |
206 | uint32_t loaded_num_friends; | 206 | uint32_t loaded_num_friends; |
207 | Client_data *loaded_clients_list; | 207 | Client_data *loaded_clients_list; |
208 | uint32_t loaded_num_clients; | 208 | uint32_t loaded_num_clients; |
209 | 209 | ||
210 | Shared_Keys shared_keys_recv; | 210 | Shared_Keys shared_keys_recv; |
211 | Shared_Keys shared_keys_sent; | 211 | Shared_Keys shared_keys_sent; |
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index e138b23e..a6bfbc8a 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -2862,20 +2862,20 @@ int messenger_load(Messenger *m, const uint8_t *data, uint32_t length) | |||
2862 | /* Connect after loading messenger from file */ | 2862 | /* Connect after loading messenger from file */ |
2863 | int messenger_connect(Messenger *m) | 2863 | int messenger_connect(Messenger *m) |
2864 | { | 2864 | { |
2865 | int i; | 2865 | int i; |
2866 | 2866 | ||
2867 | if(m == NULL) | 2867 | if(m == NULL) |
2868 | return -1; | 2868 | return -1; |
2869 | 2869 | ||
2870 | DHT *dht = m->dht; | 2870 | DHT *dht = m->dht; |
2871 | if(DHT_connect_after_load(dht) == -1) | 2871 | if(DHT_connect_after_load(dht) == -1) |
2872 | return -1; | 2872 | return -1; |
2873 | 2873 | ||
2874 | for (i = 0; i < NUM_SAVED_TCP_RELAYS; ++i) { | 2874 | for (i = 0; i < NUM_SAVED_TCP_RELAYS; ++i) { |
2875 | add_tcp_relay(m->net_crypto, m->loaded_relays[i].ip_port, m->loaded_relays[i].client_id); | 2875 | add_tcp_relay(m->net_crypto, m->loaded_relays[i].ip_port, m->loaded_relays[i].client_id); |
2876 | } | 2876 | } |
2877 | 2877 | ||
2878 | return 0; | 2878 | return 0; |
2879 | } | 2879 | } |
2880 | 2880 | ||
2881 | /* Return the number of friends in the instance m. | 2881 | /* Return the number of friends in the instance m. |
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 520fc460..ee3c3fa5 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h | |||
@@ -219,9 +219,9 @@ typedef struct Messenger { | |||
219 | 219 | ||
220 | uint64_t last_LANdiscovery; | 220 | uint64_t last_LANdiscovery; |
221 | 221 | ||
222 | // Relays loaded from config | 222 | // Relays loaded from config |
223 | // 8 should be NUM_SAVED_TCP_RELAYS but it is defined in c file | 223 | // 8 should be NUM_SAVED_TCP_RELAYS but it is defined in c file |
224 | Node_format loaded_relays[8]; | 224 | Node_format loaded_relays[8]; |
225 | 225 | ||
226 | void (*friend_message)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *); | 226 | void (*friend_message)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *); |
227 | void *friend_message_userdata; | 227 | void *friend_message_userdata; |
diff --git a/toxcore/tox.c b/toxcore/tox.c index 2b412ce8..73bbe1c6 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -932,6 +932,6 @@ int tox_load(Tox *tox, const uint8_t *data, uint32_t length) | |||
932 | /* Connect after loading the messenger from file */ | 932 | /* Connect after loading the messenger from file */ |
933 | int tox_connect(Tox *tox) | 933 | int tox_connect(Tox *tox) |
934 | { | 934 | { |
935 | Messenger *m = tox; | 935 | Messenger *m = tox; |
936 | return messenger_connect(m); | 936 | return messenger_connect(m); |
937 | } | 937 | } |