summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-07-09 13:40:36 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-07-09 20:36:39 +0000
commitc8697ccc20e12b0f4a2394c10f01ce147eeca269 (patch)
tree88a2fbf4455b9fdfc58d15865340b1a184191483 /toxcore/DHT.c
parent751d0948abfd69629d32fabb1f505ff7ad7fb078 (diff)
Move `load_state` and its helper functions to their own module.
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 6c104a73..fe3c1159 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -31,6 +31,7 @@
31#include "logger.h" 31#include "logger.h"
32#include "network.h" 32#include "network.h"
33#include "ping.h" 33#include "ping.h"
34#include "state.h"
34#include "util.h" 35#include "util.h"
35 36
36#include <assert.h> 37#include <assert.h>
@@ -2887,7 +2888,7 @@ int dht_connect_after_load(DHT *dht)
2887 return 0; 2888 return 0;
2888} 2889}
2889 2890
2890static int dht_load_state_callback(void *outer, const uint8_t *data, uint32_t length, uint16_t type) 2891static State_Load_Status dht_load_state_callback(void *outer, const uint8_t *data, uint32_t length, uint16_t type)
2891{ 2892{
2892 DHT *dht = (DHT *)outer; 2893 DHT *dht = (DHT *)outer;
2893 2894
@@ -2918,7 +2919,7 @@ static int dht_load_state_callback(void *outer, const uint8_t *data, uint32_t le
2918 break; 2919 break;
2919 } 2920 }
2920 2921
2921 return 0; 2922 return STATE_LOAD_STATUS_CONTINUE;
2922} 2923}
2923 2924
2924/* Load the DHT from data of size size. 2925/* Load the DHT from data of size size.
@@ -2935,7 +2936,7 @@ int dht_load(DHT *dht, const uint8_t *data, uint32_t length)
2935 lendian_to_host32(&data32, data); 2936 lendian_to_host32(&data32, data);
2936 2937
2937 if (data32 == DHT_STATE_COOKIE_GLOBAL) { 2938 if (data32 == DHT_STATE_COOKIE_GLOBAL) {
2938 return load_state(dht_load_state_callback, dht->log, dht, data + cookie_len, 2939 return state_load(dht->log, dht_load_state_callback, dht, data + cookie_len,
2939 length - cookie_len, DHT_STATE_COOKIE_TYPE); 2940 length - cookie_len, DHT_STATE_COOKIE_TYPE);
2940 } 2941 }
2941 } 2942 }