2018-02-01 17:06:49 +00:00
|
|
|
#ifndef LLARP_DHT_H_
|
|
|
|
#define LLARP_DHT_H_
|
2018-05-25 09:17:08 +00:00
|
|
|
|
2018-06-01 14:08:54 +00:00
|
|
|
#include <llarp/buffer.h>
|
|
|
|
|
2018-05-25 09:17:08 +00:00
|
|
|
/**
|
|
|
|
* dht.h
|
|
|
|
*
|
|
|
|
* DHT functions
|
|
|
|
*/
|
|
|
|
|
2018-02-01 17:06:49 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-02-01 17:07:01 +00:00
|
|
|
struct llarp_dht_context;
|
2018-02-01 17:06:49 +00:00
|
|
|
|
2018-05-25 09:17:08 +00:00
|
|
|
/// allocator
|
2018-05-22 15:54:19 +00:00
|
|
|
struct llarp_dht_context*
|
|
|
|
llarp_dht_context_new();
|
2018-05-25 09:17:08 +00:00
|
|
|
|
|
|
|
/// deallocator
|
2018-05-22 15:54:19 +00:00
|
|
|
void
|
|
|
|
llarp_dht_context_free(struct llarp_dht_context* dht);
|
2018-02-01 17:06:49 +00:00
|
|
|
|
2018-06-01 14:08:54 +00:00
|
|
|
struct llarp_dht_msg;
|
|
|
|
|
|
|
|
/// handler function
|
|
|
|
/// f(outmsg, inmsg)
|
|
|
|
/// returns true if outmsg has been filled otherwise returns false
|
|
|
|
typedef bool (*llarp_dht_msg_handler)(struct llarp_dht_msg*,
|
|
|
|
struct llarp_dht_msg*);
|
|
|
|
|
|
|
|
void
|
|
|
|
llarp_dht_context_set_our_key(struct llarp_dht_context* ctx, const byte_t* key);
|
|
|
|
|
|
|
|
// override dht message handler with custom handler
|
|
|
|
void
|
|
|
|
llarp_dht_set_msg_handler(struct llarp_dht_context* ctx,
|
|
|
|
llarp_dht_msg_handler func);
|
|
|
|
|
2018-02-01 17:06:49 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|