diff --git a/libs/libks/src/dht/c b/libs/libks/src/dht/c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/libks/src/dht/ks_dht.c b/libs/libks/src/dht/ks_dht.c index bf80f55fc1..e0288b61f4 100644 --- a/libs/libks/src/dht/ks_dht.c +++ b/libs/libks/src/dht/ks_dht.c @@ -57,7 +57,7 @@ KS_DECLARE(ks_status_t) ks_dht2_free(ks_dht2_t *dht) /** * */ -KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const uint8_t *nodeid) +KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const ks_dht2_nodeid_raw_t *nodeid) { ks_assert(dht); ks_assert(dht->pool); @@ -392,7 +392,7 @@ KS_DECLARE(ks_status_t) ks_dht2_process_query_ping(ks_dht2_t *dht, ks_sockaddr_t return KS_STATUS_FAIL; } - if (ks_dht2_nodeid_init(&nid, (const uint8_t *)idv) != KS_STATUS_SUCCESS) { + if (ks_dht2_nodeid_init(&nid, (const ks_dht2_nodeid_raw_t *)idv) != KS_STATUS_SUCCESS) { return KS_STATUS_FAIL; } diff --git a/libs/libks/src/dht/ks_dht.h b/libs/libks/src/dht/ks_dht.h index bd087b9c10..e3ce9ead77 100644 --- a/libs/libks/src/dht/ks_dht.h +++ b/libs/libks/src/dht/ks_dht.h @@ -43,8 +43,8 @@ KS_DECLARE(ks_status_t) ks_dht2_alloc(ks_dht2_t **dht, ks_pool_t *pool); KS_DECLARE(ks_status_t) ks_dht2_prealloc(ks_dht2_t *dht, ks_pool_t *pool); KS_DECLARE(ks_status_t) ks_dht2_free(ks_dht2_t *dht); - -KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const uint8_t *nodeid); + +KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const ks_dht2_nodeid_raw_t *nodeid); KS_DECLARE(ks_status_t) ks_dht2_deinit(ks_dht2_t *dht); diff --git a/libs/libks/src/dht/ks_dht_nodeid.c b/libs/libks/src/dht/ks_dht_nodeid.c index d6f00a3c15..af5999c4b3 100644 --- a/libs/libks/src/dht/ks_dht_nodeid.c +++ b/libs/libks/src/dht/ks_dht_nodeid.c @@ -47,7 +47,7 @@ KS_DECLARE(ks_status_t) ks_dht2_nodeid_free(ks_dht2_nodeid_t *nodeid) /** * */ -KS_DECLARE(ks_status_t) ks_dht2_nodeid_init(ks_dht2_nodeid_t *nodeid, const uint8_t *id) +KS_DECLARE(ks_status_t) ks_dht2_nodeid_init(ks_dht2_nodeid_t *nodeid, const ks_dht2_nodeid_raw_t *id) { ks_assert(nodeid); ks_assert(nodeid->pool); @@ -55,7 +55,7 @@ KS_DECLARE(ks_status_t) ks_dht2_nodeid_init(ks_dht2_nodeid_t *nodeid, const uint if (!id) { randombytes_buf(nodeid->id, KS_DHT_NODEID_LENGTH); } else { - memcpy(nodeid->id, id, KS_DHT_NODEID_LENGTH); + memcpy(nodeid->id, id->id, KS_DHT_NODEID_LENGTH); } return KS_STATUS_SUCCESS; diff --git a/libs/libks/src/dht/ks_dht_nodeid.h b/libs/libks/src/dht/ks_dht_nodeid.h index c3c2f8c85f..39705e9e10 100644 --- a/libs/libks/src/dht/ks_dht_nodeid.h +++ b/libs/libks/src/dht/ks_dht_nodeid.h @@ -7,6 +7,11 @@ KS_BEGIN_EXTERN_C #define KS_DHT_NODEID_LENGTH 20 +typedef struct ks_dht2_nodeid_raw_s ks_dht2_nodeid_raw_t; +struct ks_dht2_nodeid_raw_s { + uint8_t id[KS_DHT_NODEID_LENGTH]; +}; + typedef struct ks_dht2_nodeid_s ks_dht2_nodeid_t; struct ks_dht2_nodeid_s { ks_pool_t *pool; @@ -17,7 +22,7 @@ KS_DECLARE(ks_status_t) ks_dht2_nodeid_alloc(ks_dht2_nodeid_t **nodeid, ks_pool_ KS_DECLARE(ks_status_t) ks_dht2_nodeid_prealloc(ks_dht2_nodeid_t *nodeid, ks_pool_t *pool); KS_DECLARE(ks_status_t) ks_dht2_nodeid_free(ks_dht2_nodeid_t *nodeid); -KS_DECLARE(ks_status_t) ks_dht2_nodeid_init(ks_dht2_nodeid_t *nodeid, const uint8_t *id); +KS_DECLARE(ks_status_t) ks_dht2_nodeid_init(ks_dht2_nodeid_t *nodeid, const ks_dht2_nodeid_raw_t *id); KS_DECLARE(ks_status_t) ks_dht2_nodeid_deinit(ks_dht2_nodeid_t *nodeid); KS_END_EXTERN_C