From 988922bdeb94dd83e61ed387b29187ac4c9936e0 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Mon, 28 Oct 2013 15:52:46 -0400 Subject: Removed some now useless code. --- toxcore/DHT.c | 69 ----------------------------------------------------------- toxcore/DHT.h | 26 ---------------------- 2 files changed, 95 deletions(-) diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 60e8b88f..2f468632 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c @@ -1706,75 +1706,6 @@ void kill_DHT(DHT *dht) free(dht); } -/* Get the size of the DHT (for saving). */ -uint32_t DHT_size_old(DHT *dht) -{ - return sizeof(dht->close_clientlist) + sizeof(DHT_Friend) * dht->num_friends; -} - -/* Save the DHT in data where data is an array of size DHT_size(). */ -void DHT_save_old(DHT *dht, uint8_t *data) -{ - memcpy(data, dht->close_clientlist, sizeof(dht->close_clientlist)); - memcpy(data + sizeof(dht->close_clientlist), dht->friends_list, sizeof(DHT_Friend) * dht->num_friends); -} - -/* Load the DHT from data of size size. - * - * return -1 if failure. - * return 0 if success. - */ -int DHT_load_old(DHT *dht, uint8_t *data, uint32_t size) -{ - size_t clientlist_oldsize = sizeof(Client_data_old) * LCLIENT_LIST; - - if (size < clientlist_oldsize) { -#ifdef DEBUG - fprintf(stderr, "DHT_load: Expected at least %u bytes, got %u.\n", sizeof(dht->close_clientlist), size); -#endif - return -1; - } - - uint32_t friendlistsize = size - clientlist_oldsize; - - if (friendlistsize % sizeof(DHT_Friend_old) != 0) { -#ifdef DEBUG - fprintf(stderr, "DHT_load: Expected a multiple of %u, got %u.\n", sizeof(DHT_Friend), friendlistsize); -#endif - return -1; - } - - uint32_t i, j; - Client_data_old *client; - uint16_t friends_num = friendlistsize / sizeof(DHT_Friend_old); - - if (friends_num != 0) { - DHT_Friend_old *tempfriends_list = (DHT_Friend_old *)(data + sizeof(dht->close_clientlist)); - - for (i = 0; i < friends_num; ++i) { - DHT_addfriend(dht, tempfriends_list[i].client_id); - - for (j = 0; j < MAX_FRIEND_CLIENTS; ++j) { - client = &tempfriends_list[i].client_list[j]; - - if (client->assoc.timestamp != 0) - getnodes(dht, client->assoc.ip_port, client->client_id, tempfriends_list[i].client_id, NULL); - } - } - } - - Client_data_old *tempclose_clientlist = (Client_data_old *)data; - - for (i = 0; i < LCLIENT_LIST; ++i) { - if (tempclose_clientlist[i].assoc.timestamp != 0) - DHT_bootstrap(dht, tempclose_clientlist[i].assoc.ip_port, - tempclose_clientlist[i].client_id ); - } - - return 0; -} - - /* new DHT format for load/save, more robust and forward compatible */ #define DHT_STATE_COOKIE_GLOBAL 0x159000d diff --git a/toxcore/DHT.h b/toxcore/DHT.h index b3ab5f89..ac02710f 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h @@ -48,11 +48,6 @@ typedef struct { uint64_t ret_timestamp; } IPPTsPng; -typedef struct { - uint8_t client_id[CLIENT_ID_SIZE]; - IPPTsPng assoc; -} Client_data_old; /* required to load old state files */ - typedef struct { uint8_t client_id[CLIENT_ID_SIZE]; IPPTsPng assoc4; @@ -86,18 +81,6 @@ typedef struct { uint64_t testing_timestamp; } Hardening; -typedef struct { - uint8_t client_id[CLIENT_ID_SIZE]; - Client_data_old client_list[MAX_FRIEND_CLIENTS]; - - /* Time at which the last get_nodes request was sent. */ - uint64_t lastgetnode; - - Hardening hardening; - /* Symetric NAT hole punching stuff. */ - NAT nat; -} DHT_Friend_old; /* required to load old state files */ - typedef struct { uint8_t client_id[CLIENT_ID_SIZE]; Client_data client_list[MAX_FRIEND_CLIENTS]; @@ -249,15 +232,6 @@ DHT *new_DHT(Net_Crypto *c); void kill_DHT(DHT *dht); -/* Load the DHT from data of size size. - * old/new: version of config file - * - * return -1 if failure. - * return 0 if success. - */ -int DHT_load_old(DHT *dht, uint8_t *data, uint32_t size); -int DHT_load_new(DHT *dht, uint8_t *data, uint32_t size); - /* return 0 if we are not connected to the DHT. * return 1 if we are. */ -- cgit v1.2.3