2018-01-25 17:24:33 +01:00
|
|
|
#ifndef LLARP_H_
|
|
|
|
#define LLARP_H_
|
2018-06-01 16:08:54 +02:00
|
|
|
#include <llarp/dht.h>
|
2018-01-25 17:24:33 +01:00
|
|
|
#include <llarp/ev.h>
|
2018-04-30 20:18:18 +02:00
|
|
|
#include <llarp/logic.h>
|
2018-05-22 17:54:19 +02:00
|
|
|
#include <llarp/mem.h>
|
2018-05-11 01:32:46 +02:00
|
|
|
#include <llarp/nodedb.h>
|
2018-05-22 17:54:19 +02:00
|
|
|
#include <llarp/router.h>
|
|
|
|
#include <llarp/version.h>
|
2018-05-27 20:03:10 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-06-19 11:44:53 +02:00
|
|
|
/// llarp application context for C api
|
2018-05-27 20:03:10 +02:00
|
|
|
struct llarp_main;
|
|
|
|
|
2018-06-19 11:44:53 +02:00
|
|
|
/// initialize application context and load config
|
2018-05-27 21:13:25 +02:00
|
|
|
struct llarp_main *
|
2018-06-06 14:49:46 +02:00
|
|
|
llarp_main_init(const char *fname, bool multiProcess);
|
2018-05-27 20:03:10 +02:00
|
|
|
|
2018-06-19 11:44:53 +02:00
|
|
|
/// handle signal for main context
|
2018-05-27 20:03:10 +02:00
|
|
|
void
|
|
|
|
llarp_main_signal(struct llarp_main *ptr, int sig);
|
|
|
|
|
2018-06-23 16:56:59 +02:00
|
|
|
/// setup main context
|
|
|
|
int
|
|
|
|
llarp_main_setup(struct llarp_main *ptr);
|
|
|
|
|
2018-06-19 11:44:53 +02:00
|
|
|
/// run main context
|
2018-05-27 20:03:10 +02:00
|
|
|
int
|
|
|
|
llarp_main_run(struct llarp_main *ptr);
|
|
|
|
|
2018-07-03 13:25:36 +02:00
|
|
|
void
|
|
|
|
llarp_main_abort(struct llarp_main *ptr);
|
|
|
|
|
2018-06-19 11:44:53 +02:00
|
|
|
/// load nodeDB into memory
|
|
|
|
int
|
|
|
|
llarp_main_loadDatabase(struct llarp_main *ptr);
|
|
|
|
|
|
|
|
/// iterator on nodedb entries
|
|
|
|
int
|
|
|
|
llarp_main_iterateDatabase(struct llarp_main *ptr, struct llarp_nodedb_iter i);
|
|
|
|
|
|
|
|
/// put RC into nodeDB
|
|
|
|
bool
|
|
|
|
llarp_main_putDatabase(struct llarp_main *ptr, struct llarp_rc *rc);
|
|
|
|
|
2018-06-23 16:56:59 +02:00
|
|
|
/// get RC from nodeDB
|
2018-06-21 13:11:55 +02:00
|
|
|
struct llarp_rc *
|
|
|
|
llarp_main_getDatabase(struct llarp_main *ptr, byte_t *pk);
|
|
|
|
|
2018-06-28 13:31:15 +02:00
|
|
|
// fwd declr
|
|
|
|
struct check_online_request;
|
|
|
|
|
|
|
|
/// check_online_request hook definition
|
|
|
|
typedef void (*check_online_request_hook_func)(struct check_online_request *);
|
|
|
|
|
2018-06-29 14:15:15 +02:00
|
|
|
struct check_online_request
|
|
|
|
{
|
2018-06-28 13:31:15 +02:00
|
|
|
struct llarp_main *ptr;
|
|
|
|
struct llarp_router_lookup_job *job;
|
|
|
|
bool online;
|
|
|
|
size_t nodes;
|
|
|
|
bool first;
|
|
|
|
check_online_request_hook_func hook;
|
|
|
|
};
|
|
|
|
|
2018-06-23 16:56:59 +02:00
|
|
|
/// get RC from DHT
|
|
|
|
void
|
2018-06-28 13:31:15 +02:00
|
|
|
llarp_main_queryDHT(struct check_online_request *request);
|
|
|
|
|
|
|
|
struct llarp_rc *
|
|
|
|
llarp_main_getLocalRC(struct llarp_main *ptr);
|
2018-06-21 13:11:55 +02:00
|
|
|
|
2018-05-27 20:03:10 +02:00
|
|
|
void
|
2018-05-27 21:13:25 +02:00
|
|
|
llarp_main_free(struct llarp_main *ptr);
|
2018-05-27 20:03:10 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2018-01-25 17:24:33 +01:00
|
|
|
#endif
|