1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/include/llarp/pathbuilder.h

63 lines
1.6 KiB
C
Raw Normal View History

2018-06-19 00:03:50 +02:00
#ifndef LLARP_PATHFINDER_H_
#define LLARP_PATHFINDER_H_
#include <llarp/buffer.h>
#include <llarp/path.h>
/**
* path_base.h
*
* path api functions
*/
2018-06-19 00:05:02 +02:00
/// forard declare
struct llarp_router;
struct llarp_dht_context;
2018-06-19 00:03:50 +02:00
2018-06-19 00:05:02 +02:00
// fwd declr
struct llarp_pathbuilder_context;
2018-06-19 00:03:50 +02:00
2018-06-19 00:05:02 +02:00
/// alloc
struct llarp_pathbuilder_context*
llarp_pathbuilder_context_new(struct llarp_router* router,
struct llarp_dht_context* dht, size_t numpaths,
size_t defaultNumHops);
2018-06-19 00:05:02 +02:00
/// dealloc
void
llarp_pathbuilder_context_free(struct llarp_pathbuilder_context* ctx);
2018-06-19 00:03:50 +02:00
2018-06-19 00:05:02 +02:00
// fwd declr
struct llarp_pathbuild_job;
2018-06-19 00:03:50 +02:00
2018-06-19 00:05:02 +02:00
/// response callback
typedef void (*llarp_pathbuilder_hook)(struct llarp_pathbuild_job*);
// select hop function (user, nodedb, prevhop, result, hopnnumber) called in
// logic thread
2018-07-25 03:54:37 +02:00
typedef bool (*llarp_pathbuilder_select_hop_func)(void*, struct llarp_nodedb*,
2018-06-20 14:34:48 +02:00
struct llarp_rc*,
2018-06-19 00:05:02 +02:00
struct llarp_rc*, size_t);
2018-06-19 00:03:50 +02:00
2018-06-19 00:05:02 +02:00
// request struct
struct llarp_pathbuild_job
{
// opaque pointer for user data
void* user;
// router context (set by llarp_pathbuilder_build_path)
struct llarp_router* router;
// context
struct llarp_pathbuilder_context* context;
// path hop selection
llarp_pathbuilder_select_hop_func selectHop;
2018-06-19 19:11:24 +02:00
// called when the path build started
llarp_pathbuilder_hook pathBuildStarted;
2018-06-19 00:05:02 +02:00
// path
struct llarp_path_hops hops;
};
2018-06-19 00:03:50 +02:00
2018-06-19 00:05:02 +02:00
/// request func
// or find_path but thought pathfinder_find_path was a bit redundant
void
llarp_pathbuilder_build_path(struct llarp_pathbuild_job* job);
2018-06-19 00:03:50 +02:00
#endif