2018-06-25 15:12:08 +00:00
|
|
|
#ifndef LLARP_PATHSET_HPP
|
|
|
|
#define LLARP_PATHSET_HPP
|
|
|
|
|
|
|
|
#include <llarp/path_types.hpp>
|
|
|
|
#include <map>
|
|
|
|
#include <tuple>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace path
|
|
|
|
{
|
|
|
|
enum PathStatus
|
|
|
|
{
|
|
|
|
ePathBuilding,
|
|
|
|
ePathEstablished,
|
|
|
|
ePathTimeout,
|
|
|
|
ePathExpired
|
|
|
|
};
|
|
|
|
// forward declare
|
|
|
|
struct Path;
|
|
|
|
|
|
|
|
/// a set of paths owned by an entity
|
|
|
|
struct PathSet
|
|
|
|
{
|
|
|
|
/// construct
|
|
|
|
/// @params numPaths the number of paths to maintain
|
|
|
|
PathSet(size_t numPaths);
|
|
|
|
|
2018-06-29 16:02:39 +00:00
|
|
|
/// tick owned paths
|
|
|
|
void
|
|
|
|
Tick(llarp_time_t now, llarp_router* r);
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
void
|
|
|
|
RemovePath(Path* path);
|
|
|
|
|
|
|
|
void
|
|
|
|
HandlePathBuilt(Path* path);
|
|
|
|
|
|
|
|
void
|
|
|
|
AddPath(Path* path);
|
|
|
|
|
|
|
|
Path*
|
|
|
|
GetByUpstream(const RouterID& remote, const PathID_t& rxid);
|
|
|
|
|
|
|
|
void
|
|
|
|
ExpirePaths(llarp_time_t now);
|
|
|
|
|
|
|
|
size_t
|
|
|
|
NumInStatus(PathStatus st) const;
|
|
|
|
|
|
|
|
/// return true if we should build another path
|
|
|
|
bool
|
|
|
|
ShouldBuildMore() const;
|
|
|
|
|
|
|
|
private:
|
2018-06-26 14:52:19 +00:00
|
|
|
typedef std::pair< RouterID, PathID_t > PathInfo_t;
|
|
|
|
typedef std::map< PathInfo_t, Path* > PathMap_t;
|
2018-06-25 15:12:08 +00:00
|
|
|
|
|
|
|
size_t m_NumPaths;
|
2018-06-26 14:52:19 +00:00
|
|
|
PathMap_t m_Paths;
|
2018-06-25 15:12:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace path
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|