summaryrefslogtreecommitdiff
path: root/toxcore/assoc.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/assoc.h')
-rw-r--r--toxcore/assoc.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/toxcore/assoc.h b/toxcore/assoc.h
index 0fdff4fe..bc27e62c 100644
--- a/toxcore/assoc.h
+++ b/toxcore/assoc.h
@@ -21,21 +21,21 @@ typedef struct Assoc Assoc;
21 21
22/* custom distance handler, if it's not ID-distance based 22/* custom distance handler, if it's not ID-distance based
23 * return values exactly like id_closest() */ 23 * return values exactly like id_closest() */
24typedef int (*Assoc_distance_relative_callback)(Assoc *assoc, void *callback_data, uint8_t *client_id, 24typedef int (*Assoc_distance_relative_callback)(const Assoc *assoc, void *callback_data, const uint8_t *client_id,
25 uint8_t *client_id1, uint8_t *client_id2); 25 const uint8_t *client_id1, const uint8_t *client_id2);
26 26
27#define DISTANCE_INDEX_DISTANCE_BITS 44 27#define DISTANCE_INDEX_DISTANCE_BITS 44
28 28
29/* absolute distance: can be same for different client_id_check values 29/* absolute distance: can be same for different client_id_check values
30 * return value should have DISTANCE_INDEX_DISTANCE_BITS valid bits */ 30 * return value should have DISTANCE_INDEX_DISTANCE_BITS valid bits */
31typedef uint64_t (*Assoc_distance_absolute_callback)(Assoc *assoc, void *callback_data, 31typedef uint64_t (*Assoc_distance_absolute_callback)(const Assoc *assoc, void *callback_data,
32 uint8_t *client_id_ref, uint8_t *client_id_check); 32 const uint8_t *client_id_ref, const uint8_t *client_id_check);
33 33
34/*****************************************************************************/ 34/*****************************************************************************/
35 35
36/* Central entry point for new associations: add a new candidate to the cache 36/* Central entry point for new associations: add a new candidate to the cache
37 * returns 1 if entry is stored, 2 if existing entry was updated, 0 else */ 37 * returns 1 if entry is stored, 2 if existing entry was updated, 0 else */
38uint8_t Assoc_add_entry(Assoc *assoc, uint8_t *id, IPPTs *ippts_send, IP_Port *ipp_recv, uint8_t used); 38uint8_t Assoc_add_entry(Assoc *assoc, const uint8_t *id, const IPPTs *ippts_send, const IP_Port *ipp_recv, uint8_t used);
39 39
40/*****************************************************************************/ 40/*****************************************************************************/
41 41
@@ -72,7 +72,7 @@ uint8_t Assoc_get_close_entries(Assoc *assoc, Assoc_close_entries *close_entries
72/*****************************************************************************/ 72/*****************************************************************************/
73 73
74/* create: default sizes (6, 5 => 320 entries) */ 74/* create: default sizes (6, 5 => 320 entries) */
75Assoc *new_Assoc_default(uint8_t *public_id); 75Assoc *new_Assoc_default(const uint8_t *public_id);
76 76
77/* create: customized sizes 77/* create: customized sizes
78 * total is (2^bits) * entries 78 * total is (2^bits) * entries
@@ -81,10 +81,10 @@ Assoc *new_Assoc_default(uint8_t *public_id);
81 * 81 *
82 * preferably bits should be large and entries small to ensure spread 82 * preferably bits should be large and entries small to ensure spread
83 * in the search space (e. g. 5, 5 is preferable to 2, 41) */ 83 * in the search space (e. g. 5, 5 is preferable to 2, 41) */
84Assoc *new_Assoc(size_t bits, size_t entries, uint8_t *public_id); 84Assoc *new_Assoc(size_t bits, size_t entries, const uint8_t *public_id);
85 85
86/* public_id changed (loaded), update which entry isn't stored */ 86/* public_id changed (loaded), update which entry isn't stored */
87void Assoc_self_client_id_changed(Assoc *assoc, uint8_t *public_id); 87void Assoc_self_client_id_changed(Assoc *assoc, const uint8_t *public_id);
88 88
89/* every 45s send out a getnodes() for a "random" bucket */ 89/* every 45s send out a getnodes() for a "random" bucket */
90#define ASSOC_BUCKET_REFRESH 45 90#define ASSOC_BUCKET_REFRESH 45
@@ -97,7 +97,7 @@ void do_Assoc(Assoc *assoc, DHT *dht);
97void kill_Assoc(Assoc *assoc); 97void kill_Assoc(Assoc *assoc);
98 98
99#ifdef LOGGING 99#ifdef LOGGING
100void Assoc_status(Assoc *assoc); 100void Assoc_status(const Assoc *assoc);
101#endif /* LOGGING */ 101#endif /* LOGGING */
102 102
103#endif /* !__ASSOC_H__ */ 103#endif /* !__ASSOC_H__ */