FS-9775: Resolved conflicts during merge
This commit is contained in:
parent
0302eca52a
commit
4f4656055c
|
@ -13,7 +13,8 @@ libks_la_SOURCES += src/ks_time.c src/ks_printf.c src/ks_hash.c src/ks_q.c src/k
|
|||
libks_la_SOURCES += src/ks_ssl.c src/kws.c src/ks_rng.c
|
||||
libks_la_SOURCES += src/utp/utp_api.cpp src/utp/utp_callbacks.cpp src/utp/utp_hash.cpp src/utp/utp_internal.cpp
|
||||
libks_la_SOURCES += src/utp/utp_packedsockaddr.cpp src/utp/utp_utils.cpp src/ks_bencode.c
|
||||
libks_la_SOURCES += src/dht/ks_dht.c src/dht/ks_dht_endpoint.c src/dht/ks_dht_nodeid.c src/dht/ks_dht_message.c src/dht/ks_dht_transaction.c src/dht/ks_dht_bucket.c
|
||||
libks_la_SOURCES += src/dht/ks_dht.c src/dht/ks_dht_endpoint.c src/dht/ks_dht_node.c src/dht/ks_dht_message.c src/dht/ks_dht_transaction.c
|
||||
libks_la_SOURCES += src/dht/ks_dht_bucket.c
|
||||
libks_la_SOURCES += crypt/aeskey.c crypt/aestab.c crypt/sha2.c crypt/twofish.c crypt/aes_modes.c crypt/aescrypt.c crypt/twofish_cfb.c
|
||||
#aes.h aescpp.h brg_endian.h aesopt.h aestab.h brg_types.h sha2.h twofish.h
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ KS_DECLARE(ks_status_t) ks_dht2_utility_compact_address(ks_sockaddr_t *address,
|
|||
uint8_t *buffer,
|
||||
ks_size_t *buffer_length,
|
||||
ks_size_t buffer_size);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_utility_compact_node(ks_dht2_nodeid_raw_t *nodeid,
|
||||
KS_DECLARE(ks_status_t) ks_dht2_utility_compact_node(ks_dht2_nodeid_t *nodeid,
|
||||
ks_sockaddr_t *address,
|
||||
uint8_t *buffer,
|
||||
ks_size_t *buffer_length,
|
||||
|
@ -33,7 +33,7 @@ KS_DECLARE(ks_status_t) ks_dht2_send_error(ks_dht2_t *dht,
|
|||
long long errorcode,
|
||||
const char *errorstr);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_send_ping(ks_dht2_t *dht, ks_sockaddr_t *raddr);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_send_findnode(ks_dht2_t *dht, ks_sockaddr_t *raddr, ks_dht2_nodeid_raw_t *targetid);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_send_findnode(ks_dht2_t *dht, ks_sockaddr_t *raddr, ks_dht2_nodeid_t *targetid);
|
||||
|
||||
KS_DECLARE(ks_status_t) ks_dht2_process(ks_dht2_t *dht, ks_sockaddr_t *raddr);
|
||||
|
||||
|
@ -57,6 +57,16 @@ KS_DECLARE(ks_status_t) ks_dht2_endpoint_free(ks_dht2_endpoint_t *endpoint);
|
|||
KS_DECLARE(ks_status_t) ks_dht2_endpoint_init(ks_dht2_endpoint_t *endpoint, const ks_sockaddr_t *addr, ks_socket_t sock);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_endpoint_deinit(ks_dht2_endpoint_t *endpoint);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_node_alloc(ks_dht2_node_t **node, ks_pool_t *pool);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_node_prealloc(ks_dht2_node_t *node, ks_pool_t *pool);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_node_free(ks_dht2_node_t *node);
|
||||
|
||||
KS_DECLARE(ks_status_t) ks_dht2_node_init(ks_dht2_node_t *node, const ks_dht2_nodeid_t *id, const ks_sockaddr_t *addr);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_node_deinit(ks_dht2_node_t *node);
|
||||
|
||||
|
||||
KS_END_EXTERN_C
|
||||
|
||||
|
|
|
@ -56,7 +56,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 ks_dht2_nodeid_raw_t *nodeid)
|
||||
KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const ks_dht2_nodeid_t *nodeid)
|
||||
{
|
||||
ks_assert(dht);
|
||||
ks_assert(dht->pool);
|
||||
|
@ -64,14 +64,12 @@ KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const ks_dht2_nodeid_raw_t
|
|||
dht->autoroute = KS_FALSE;
|
||||
dht->autoroute_port = 0;
|
||||
|
||||
if (ks_dht2_nodeid_prealloc(&dht->nodeid, dht->pool) != KS_STATUS_SUCCESS) {
|
||||
return KS_STATUS_FAIL;
|
||||
if (!nodeid) {
|
||||
randombytes_buf(dht->nodeid, KS_DHT_NODEID_SIZE);
|
||||
} else {
|
||||
memcpy(dht->nodeid, nodeid, KS_DHT_NODEID_SIZE);
|
||||
}
|
||||
|
||||
if (ks_dht2_nodeid_init(&dht->nodeid, nodeid) != KS_STATUS_SUCCESS) {
|
||||
return KS_STATUS_FAIL;
|
||||
}
|
||||
|
||||
ks_hash_create(&dht->registry_type, KS_HASH_MODE_DEFAULT, KS_HASH_FLAG_RWLOCK | KS_HASH_FLAG_DUP_CHECK, dht->pool);
|
||||
ks_dht2_register_type(dht, "q", ks_dht2_process_query);
|
||||
ks_dht2_register_type(dht, "r", ks_dht2_process_response);
|
||||
|
@ -163,8 +161,6 @@ KS_DECLARE(ks_status_t) ks_dht2_deinit(ks_dht2_t *dht)
|
|||
dht->registry_error = NULL;
|
||||
}
|
||||
|
||||
ks_dht2_nodeid_deinit(&dht->nodeid);
|
||||
|
||||
dht->autoroute = KS_FALSE;
|
||||
dht->autoroute_port = 0;
|
||||
|
||||
|
@ -383,7 +379,7 @@ KS_DECLARE(ks_status_t) ks_dht2_utility_compact_address(ks_sockaddr_t *address,
|
|||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_utility_compact_node(ks_dht2_nodeid_raw_t *nodeid,
|
||||
KS_DECLARE(ks_status_t) ks_dht2_utility_compact_node(ks_dht2_nodeid_t *nodeid,
|
||||
ks_sockaddr_t *address,
|
||||
uint8_t *buffer,
|
||||
ks_size_t *buffer_length,
|
||||
|
@ -395,13 +391,13 @@ KS_DECLARE(ks_status_t) ks_dht2_utility_compact_node(ks_dht2_nodeid_raw_t *nodei
|
|||
ks_assert(buffer_size);
|
||||
ks_assert(address->family == AF_INET || address->family == AF_INET6);
|
||||
|
||||
if (*buffer_length + KS_DHT_NODEID_LENGTH > buffer_size) {
|
||||
if (*buffer_length + KS_DHT_NODEID_SIZE > buffer_size) {
|
||||
ks_log(KS_LOG_DEBUG, "Insufficient space remaining for compacting\n");
|
||||
return KS_STATUS_FAIL;
|
||||
}
|
||||
|
||||
memcpy(buffer + (*buffer_length), (void *)nodeid, KS_DHT_NODEID_LENGTH);
|
||||
*buffer_length += KS_DHT_NODEID_LENGTH;
|
||||
memcpy(buffer + (*buffer_length), (void *)nodeid, KS_DHT_NODEID_SIZE);
|
||||
*buffer_length += KS_DHT_NODEID_SIZE;
|
||||
|
||||
return ks_dht2_utility_compact_address(address, buffer, buffer_length, buffer_size);
|
||||
}
|
||||
|
@ -653,7 +649,7 @@ KS_DECLARE(ks_status_t) ks_dht2_send_ping(ks_dht2_t *dht, ks_sockaddr_t *raddr)
|
|||
return KS_STATUS_FAIL;
|
||||
}
|
||||
|
||||
ben_dict_set(a, ben_blob("id", 2), ben_blob(dht->nodeid.id, KS_DHT_NODEID_LENGTH));
|
||||
ben_dict_set(a, ben_blob("id", 2), ben_blob(dht->nodeid, KS_DHT_NODEID_SIZE));
|
||||
|
||||
ks_log(KS_LOG_DEBUG, "Sending message query ping\n");
|
||||
ks_q_push(dht->send_q, (void *)message);
|
||||
|
@ -664,7 +660,7 @@ KS_DECLARE(ks_status_t) ks_dht2_send_ping(ks_dht2_t *dht, ks_sockaddr_t *raddr)
|
|||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_send_findnode(ks_dht2_t *dht, ks_sockaddr_t *raddr, ks_dht2_nodeid_raw_t *targetid)
|
||||
KS_DECLARE(ks_status_t) ks_dht2_send_findnode(ks_dht2_t *dht, ks_sockaddr_t *raddr, ks_dht2_nodeid_t *targetid)
|
||||
{
|
||||
ks_dht2_message_t *message = NULL;
|
||||
struct bencode *a = NULL;
|
||||
|
@ -677,8 +673,8 @@ KS_DECLARE(ks_status_t) ks_dht2_send_findnode(ks_dht2_t *dht, ks_sockaddr_t *rad
|
|||
return KS_STATUS_FAIL;
|
||||
}
|
||||
|
||||
ben_dict_set(a, ben_blob("id", 2), ben_blob(dht->nodeid.id, KS_DHT_NODEID_LENGTH));
|
||||
ben_dict_set(a, ben_blob("target", 6), ben_blob(targetid->id, KS_DHT_NODEID_LENGTH));
|
||||
ben_dict_set(a, ben_blob("id", 2), ben_blob(dht->nodeid, KS_DHT_NODEID_SIZE));
|
||||
ben_dict_set(a, ben_blob("target", 6), ben_blob(targetid, KS_DHT_NODEID_SIZE));
|
||||
|
||||
ks_log(KS_LOG_DEBUG, "Sending message query find_node\n");
|
||||
ks_q_push(dht->send_q, (void *)message);
|
||||
|
@ -928,7 +924,7 @@ KS_DECLARE(ks_status_t) ks_dht2_process_query_ping(ks_dht2_t *dht, ks_dht2_messa
|
|||
|
||||
//idv = ben_str_val(id);
|
||||
idv_len = ben_str_len(id);
|
||||
if (idv_len != KS_DHT_NODEID_LENGTH) {
|
||||
if (idv_len != KS_DHT_NODEID_SIZE) {
|
||||
ks_log(KS_LOG_DEBUG, "Message args 'id' value has an unexpected size of %d\n", idv_len);
|
||||
return KS_STATUS_FAIL;
|
||||
}
|
||||
|
@ -950,7 +946,7 @@ KS_DECLARE(ks_status_t) ks_dht2_process_query_ping(ks_dht2_t *dht, ks_dht2_messa
|
|||
goto done;
|
||||
}
|
||||
|
||||
ben_dict_set(r, ben_blob("id", 2), ben_blob(dht->nodeid.id, KS_DHT_NODEID_LENGTH));
|
||||
ben_dict_set(r, ben_blob("id", 2), ben_blob(dht->nodeid, KS_DHT_NODEID_SIZE));
|
||||
|
||||
ks_log(KS_LOG_DEBUG, "Sending message response ping\n");
|
||||
ks_q_push(dht->send_q, (void *)response);
|
||||
|
@ -998,7 +994,7 @@ KS_DECLARE(ks_status_t) ks_dht2_process_query_findnode(ks_dht2_t *dht, ks_dht2_m
|
|||
|
||||
idv = ben_str_val(id);
|
||||
idv_len = ben_str_len(id);
|
||||
if (idv_len != KS_DHT_NODEID_LENGTH) {
|
||||
if (idv_len != KS_DHT_NODEID_SIZE) {
|
||||
ks_log(KS_LOG_DEBUG, "Message args 'id' value has an unexpected size of %d\n", idv_len);
|
||||
return KS_STATUS_FAIL;
|
||||
}
|
||||
|
@ -1012,7 +1008,7 @@ KS_DECLARE(ks_status_t) ks_dht2_process_query_findnode(ks_dht2_t *dht, ks_dht2_m
|
|||
|
||||
//targetv = ben_str_val(target);
|
||||
targetv_len = ben_str_len(target);
|
||||
if (targetv_len != KS_DHT_NODEID_LENGTH) {
|
||||
if (targetv_len != KS_DHT_NODEID_SIZE) {
|
||||
ks_log(KS_LOG_DEBUG, "Message args 'target' value has an unexpected size of %d\n", targetv_len);
|
||||
return KS_STATUS_FAIL;
|
||||
}
|
||||
|
@ -1044,7 +1040,7 @@ KS_DECLARE(ks_status_t) ks_dht2_process_query_findnode(ks_dht2_t *dht, ks_dht2_m
|
|||
// @todo get closest nodes to target from route table
|
||||
|
||||
// @todo compact into buffer
|
||||
if (ks_dht2_utility_compact_node((ks_dht2_nodeid_raw_t *)idv, &message->raddr, buffer, &buffer_length, sizeof(buffer)) != KS_STATUS_SUCCESS) {
|
||||
if (ks_dht2_utility_compact_node((ks_dht2_nodeid_t *)idv, &message->raddr, buffer, &buffer_length, sizeof(buffer)) != KS_STATUS_SUCCESS) {
|
||||
return KS_STATUS_FAIL;
|
||||
}
|
||||
|
||||
|
@ -1061,7 +1057,7 @@ KS_DECLARE(ks_status_t) ks_dht2_process_query_findnode(ks_dht2_t *dht, ks_dht2_m
|
|||
goto done;
|
||||
}
|
||||
|
||||
ben_dict_set(r, ben_blob("id", 2), ben_blob(dht->nodeid.id, KS_DHT_NODEID_LENGTH));
|
||||
ben_dict_set(r, ben_blob("id", 2), ben_blob(dht->nodeid, KS_DHT_NODEID_SIZE));
|
||||
// @todo populate nodes/nodes6
|
||||
ben_dict_set(r, ben_blob("nodes", 5), ben_blob(buffer, buffer_length));
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ KS_BEGIN_EXTERN_C
|
|||
#define KS_DHT_DEFAULT_PORT 5309
|
||||
#define KS_DHT_RECV_BUFFER_SIZE 0xFFFF
|
||||
|
||||
#define KS_DHT_NODEID_LENGTH 20
|
||||
#define KS_DHT_NODEID_SIZE 20
|
||||
|
||||
#define KS_DHT_MESSAGE_TRANSACTIONID_MAX_SIZE 20
|
||||
#define KS_DHT_MESSAGE_TYPE_MAX_SIZE 20
|
||||
|
@ -21,8 +21,10 @@ KS_BEGIN_EXTERN_C
|
|||
#define KS_DHT_TRANSACTION_EXPIRATION_DELAY 30
|
||||
|
||||
typedef struct ks_dht2_s ks_dht2_t;
|
||||
typedef struct ks_dht2_nodeid_s ks_dht2_nodeid_t;
|
||||
typedef struct ks_dht2_nodeid_raw_s ks_dht2_nodeid_raw_t;
|
||||
//typedef struct ks_dht2_nodeid_s ks_dht2_nodeid_t;
|
||||
//typedef struct ks_dht2_nodeid_raw_s ks_dht2_nodeid_raw_t;
|
||||
typedef uint8_t ks_dht2_nodeid_t[KS_DHT_NODEID_SIZE];
|
||||
typedef struct ks_dht2_node_s ks_dht2_node_t;
|
||||
typedef struct ks_dht2_message_s ks_dht2_message_t;
|
||||
typedef struct ks_dht2_endpoint_s ks_dht2_endpoint_t;
|
||||
typedef struct ks_dht2_transaction_s ks_dht2_transaction_t;
|
||||
|
@ -30,13 +32,13 @@ typedef struct ks_dht2_transaction_s ks_dht2_transaction_t;
|
|||
|
||||
typedef ks_status_t (*ks_dht2_message_callback_t)(ks_dht2_t *dht, ks_dht2_message_t *message);
|
||||
|
||||
struct ks_dht2_nodeid_raw_s {
|
||||
uint8_t id[KS_DHT_NODEID_LENGTH];
|
||||
};
|
||||
|
||||
struct ks_dht2_nodeid_s {
|
||||
struct ks_dht2_node_s {
|
||||
ks_pool_t *pool;
|
||||
uint8_t id[KS_DHT_NODEID_LENGTH];
|
||||
ks_dht2_nodeid_t id;
|
||||
ks_sockaddr_t *addr4;
|
||||
ks_sockaddr_t *addr6;
|
||||
ks_size_t addr4_length;
|
||||
ks_size_t addr6_length;
|
||||
};
|
||||
|
||||
struct ks_dht2_message_s {
|
||||
|
@ -103,7 +105,7 @@ 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 ks_dht2_nodeid_raw_t *nodeid);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const ks_dht2_nodeid_t *nodeid);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_deinit(ks_dht2_t *dht);
|
||||
|
||||
KS_DECLARE(ks_status_t) ks_dht2_autoroute(ks_dht2_t *dht, ks_bool_t autoroute, ks_port_t port);
|
||||
|
@ -115,16 +117,6 @@ KS_DECLARE(void) ks_dht2_pulse(ks_dht2_t *dht, int32_t timeout);
|
|||
KS_DECLARE(ks_status_t) ks_dht2_register_type(ks_dht2_t *dht, const char *value, ks_dht2_message_callback_t callback);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_register_query(ks_dht2_t *dht, const char *value, ks_dht2_message_callback_t callback);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_nodeid_alloc(ks_dht2_nodeid_t **nodeid, ks_pool_t *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 ks_dht2_nodeid_raw_t *id);
|
||||
KS_DECLARE(ks_status_t) ks_dht2_nodeid_deinit(ks_dht2_nodeid_t *nodeid);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
#include "ks_dht.h"
|
||||
#include "ks_dht-int.h"
|
||||
#include "sodium.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_node_alloc(ks_dht2_node_t **node, ks_pool_t *pool)
|
||||
{
|
||||
ks_dht2_node_t *n;
|
||||
|
||||
ks_assert(node);
|
||||
ks_assert(pool);
|
||||
|
||||
*node = n = ks_pool_alloc(pool, sizeof(ks_dht2_node_t));
|
||||
n->pool = pool;
|
||||
|
||||
return KS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_node_prealloc(ks_dht2_node_t *node, ks_pool_t *pool)
|
||||
{
|
||||
ks_assert(node);
|
||||
ks_assert(pool);
|
||||
|
||||
node->pool = pool;
|
||||
|
||||
return KS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_node_free(ks_dht2_node_t *node)
|
||||
{
|
||||
ks_assert(node);
|
||||
|
||||
ks_dht2_node_deinit(node);
|
||||
ks_pool_free(node->pool, node);
|
||||
|
||||
return KS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_node_init(ks_dht2_node_t *node, const ks_dht2_nodeid_t *id, const ks_sockaddr_t *addr)
|
||||
{
|
||||
ks_assert(node);
|
||||
ks_assert(node->pool);
|
||||
ks_assert(id);
|
||||
ks_assert(addr);
|
||||
|
||||
return KS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_node_deinit(ks_dht2_node_t *node)
|
||||
{
|
||||
ks_assert(node);
|
||||
|
||||
return KS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
|
||||
*/
|
|
@ -1,85 +0,0 @@
|
|||
#include "ks_dht.h"
|
||||
#include "ks_dht-int.h"
|
||||
#include "sodium.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_nodeid_alloc(ks_dht2_nodeid_t **nodeid, ks_pool_t *pool)
|
||||
{
|
||||
ks_dht2_nodeid_t *nid;
|
||||
|
||||
ks_assert(nodeid);
|
||||
ks_assert(pool);
|
||||
|
||||
*nodeid = nid = ks_pool_alloc(pool, sizeof(ks_dht2_nodeid_t));
|
||||
nid->pool = pool;
|
||||
|
||||
return KS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_nodeid_prealloc(ks_dht2_nodeid_t *nodeid, ks_pool_t *pool)
|
||||
{
|
||||
ks_assert(nodeid);
|
||||
ks_assert(pool);
|
||||
|
||||
nodeid->pool = pool;
|
||||
|
||||
return KS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_nodeid_free(ks_dht2_nodeid_t *nodeid)
|
||||
{
|
||||
ks_assert(nodeid);
|
||||
|
||||
ks_dht2_nodeid_deinit(nodeid);
|
||||
ks_pool_free(nodeid->pool, nodeid);
|
||||
|
||||
return KS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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);
|
||||
|
||||
if (!id) {
|
||||
randombytes_buf(nodeid->id, KS_DHT_NODEID_LENGTH);
|
||||
} else {
|
||||
memcpy(nodeid->id, id->id, KS_DHT_NODEID_LENGTH);
|
||||
}
|
||||
|
||||
return KS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KS_DECLARE(ks_status_t) ks_dht2_nodeid_deinit(ks_dht2_nodeid_t *nodeid)
|
||||
{
|
||||
ks_assert(nodeid);
|
||||
|
||||
return KS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
|
||||
*/
|
Loading…
Reference in New Issue