2021-03-09 22:24:35 +00:00
|
|
|
#include "factory.hpp"
|
|
|
|
#include <llarp/iwp/iwp.hpp>
|
2019-08-07 16:33:29 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
LinkFactory::LinkType
|
2020-05-01 19:51:15 +00:00
|
|
|
LinkFactory::TypeFromName(std::string_view str)
|
2019-08-07 16:33:29 +00:00
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
if (str == "iwp")
|
2019-08-07 16:33:29 +00:00
|
|
|
return LinkType::eLinkIWP;
|
2020-04-07 18:38:56 +00:00
|
|
|
if (str == "mempipe")
|
2019-08-07 16:33:29 +00:00
|
|
|
return LinkType::eLinkMempipe;
|
|
|
|
return LinkType::eLinkUnknown;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
LinkFactory::NameFromType(LinkFactory::LinkType tp)
|
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
switch (tp)
|
2019-08-07 16:33:29 +00:00
|
|
|
{
|
|
|
|
case LinkType::eLinkIWP:
|
|
|
|
return "iwp";
|
|
|
|
case LinkType::eLinkMempipe:
|
|
|
|
return "mempipe";
|
|
|
|
default:
|
|
|
|
return "unspec";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LinkFactory::Factory
|
|
|
|
LinkFactory::Obtain(LinkFactory::LinkType tp, bool permitInbound)
|
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
switch (tp)
|
2019-08-07 16:33:29 +00:00
|
|
|
{
|
2019-08-22 20:53:27 +00:00
|
|
|
case LinkType::eLinkIWP:
|
2020-04-07 18:38:56 +00:00
|
|
|
if (permitInbound)
|
2019-08-22 20:53:27 +00:00
|
|
|
return llarp::iwp::NewInboundLink;
|
|
|
|
return llarp::iwp::NewOutboundLink;
|
2019-08-07 16:33:29 +00:00
|
|
|
default:
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
2020-05-01 19:51:15 +00:00
|
|
|
} // namespace llarp
|