2019-08-07 16:33:29 +00:00
|
|
|
#ifndef LLARP_LINK_FACTORY_HPP
|
|
|
|
#define LLARP_LINK_FACTORY_HPP
|
2019-12-03 17:58:53 +00:00
|
|
|
#include <config/key_manager.hpp>
|
2020-05-01 19:51:15 +00:00
|
|
|
#include <string_view>
|
2019-08-07 16:33:29 +00:00
|
|
|
#include <functional>
|
2019-12-03 17:58:53 +00:00
|
|
|
#include <memory>
|
2019-08-07 16:33:29 +00:00
|
|
|
|
|
|
|
#include <link/server.hpp>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
/// LinkFactory is responsible for returning std::functions that create the
|
|
|
|
/// link layer types
|
|
|
|
struct LinkFactory
|
|
|
|
{
|
|
|
|
enum class LinkType
|
|
|
|
{
|
|
|
|
eLinkUTP,
|
|
|
|
eLinkIWP,
|
|
|
|
eLinkMempipe,
|
|
|
|
eLinkUnknown
|
|
|
|
};
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
using Factory = std::function<LinkLayer_ptr(
|
|
|
|
std::shared_ptr<KeyManager>,
|
|
|
|
GetRCFunc,
|
|
|
|
LinkMessageHandler,
|
|
|
|
SignBufferFunc,
|
|
|
|
SessionEstablishedHandler,
|
|
|
|
SessionRenegotiateHandler,
|
|
|
|
TimeoutHandler,
|
|
|
|
SessionClosedHandler,
|
|
|
|
PumpDoneHandler)>;
|
2019-08-07 16:33:29 +00:00
|
|
|
|
|
|
|
/// get link type by name string
|
|
|
|
/// if invalid returns eLinkUnspec
|
|
|
|
static LinkType
|
2020-05-01 19:51:15 +00:00
|
|
|
TypeFromName(std::string_view name);
|
2019-08-07 16:33:29 +00:00
|
|
|
|
|
|
|
/// turns a link type into a string representation
|
|
|
|
static std::string
|
|
|
|
NameFromType(LinkType t);
|
|
|
|
|
|
|
|
/// obtain a link factory of a certain type
|
|
|
|
static Factory
|
|
|
|
Obtain(LinkType t, bool permitInbound);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace llarp
|
|
|
|
|
2020-05-01 19:51:15 +00:00
|
|
|
#endif
|