2018-06-18 22:03:50 +00: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-18 22:05:02 +00:00
|
|
|
/// forard declare
|
|
|
|
struct llarp_router;
|
|
|
|
struct llarp_dht_context;
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-18 22:05:02 +00:00
|
|
|
// fwd declr
|
|
|
|
struct llarp_pathbuilder_context;
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-18 22:05:02 +00:00
|
|
|
/// alloc
|
|
|
|
struct llarp_pathbuilder_context*
|
|
|
|
llarp_pathbuilder_context_new(struct llarp_router* router,
|
2018-07-19 21:08:11 +00:00
|
|
|
struct llarp_dht_context* dht, size_t numpaths,
|
|
|
|
size_t defaultNumHops);
|
2018-06-18 22:05:02 +00:00
|
|
|
/// dealloc
|
|
|
|
void
|
|
|
|
llarp_pathbuilder_context_free(struct llarp_pathbuilder_context* ctx);
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-18 22:05:02 +00:00
|
|
|
// fwd declr
|
|
|
|
struct llarp_pathbuild_job;
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-18 22:05:02 +00:00
|
|
|
/// response callback
|
|
|
|
typedef void (*llarp_pathbuilder_hook)(struct llarp_pathbuild_job*);
|
2018-07-19 21:08:11 +00:00
|
|
|
// select hop function (user, nodedb, prevhop, result, hopnnumber) called in
|
|
|
|
// logic thread
|
2018-07-25 01:54:37 +00:00
|
|
|
typedef bool (*llarp_pathbuilder_select_hop_func)(void*, struct llarp_nodedb*,
|
2018-06-20 12:34:48 +00:00
|
|
|
struct llarp_rc*,
|
2018-06-18 22:05:02 +00:00
|
|
|
struct llarp_rc*, size_t);
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-18 22:05:02 +00: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 17:11:24 +00:00
|
|
|
// called when the path build started
|
|
|
|
llarp_pathbuilder_hook pathBuildStarted;
|
2018-06-18 22:05:02 +00:00
|
|
|
// path
|
|
|
|
struct llarp_path_hops hops;
|
|
|
|
};
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-18 22:05:02 +00: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-18 22:03:50 +00:00
|
|
|
|
|
|
|
#endif
|