2019-03-29 15:17:49 +00:00
|
|
|
#ifndef LLARP_IWP_LINKLAYER_HPP
|
|
|
|
#define LLARP_IWP_LINKLAYER_HPP
|
2019-03-29 14:30:19 +00:00
|
|
|
|
|
|
|
#include <constants/link_layer.hpp>
|
|
|
|
#include <crypto/crypto.hpp>
|
|
|
|
#include <crypto/encrypted.hpp>
|
|
|
|
#include <crypto/types.hpp>
|
|
|
|
#include <link/server.hpp>
|
2019-09-05 14:57:01 +00:00
|
|
|
#include <util/thread/thread_pool.hpp>
|
2019-12-03 17:58:53 +00:00
|
|
|
#include <config/key_manager.hpp>
|
|
|
|
|
|
|
|
#include <memory>
|
2019-03-29 14:30:19 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace iwp
|
|
|
|
{
|
|
|
|
struct LinkLayer final : public ILinkLayer
|
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
LinkLayer(
|
|
|
|
std::shared_ptr<KeyManager> keyManager,
|
|
|
|
GetRCFunc getrc,
|
|
|
|
LinkMessageHandler h,
|
|
|
|
SignBufferFunc sign,
|
|
|
|
SessionEstablishedHandler est,
|
|
|
|
SessionRenegotiateHandler reneg,
|
|
|
|
TimeoutHandler timeout,
|
|
|
|
SessionClosedHandler closed,
|
|
|
|
PumpDoneHandler pumpDone,
|
|
|
|
bool permitInbound);
|
2019-03-29 14:30:19 +00:00
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
~LinkLayer() override;
|
2019-04-02 09:03:53 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
std::shared_ptr<ILinkSession>
|
|
|
|
NewOutboundSession(const RouterContact& rc, const AddressInfo& ai) override;
|
2019-03-29 14:30:19 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
const char*
|
2019-03-29 14:30:19 +00:00
|
|
|
Name() const override;
|
|
|
|
|
|
|
|
uint16_t
|
|
|
|
Rank() const override;
|
|
|
|
|
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
RecvFrom(const Addr& from, ILinkSession::Packet_t pkt) override;
|
2019-03-29 14:30:19 +00:00
|
|
|
|
2019-08-23 11:32:52 +00:00
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
MapAddr(const RouterID& pk, ILinkSession* s) override;
|
2019-08-23 11:32:52 +00:00
|
|
|
|
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
UnmapAddr(const Addr& addr);
|
2019-08-23 11:32:52 +00:00
|
|
|
|
2019-09-05 14:57:01 +00:00
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
QueueWork(std::function<void(void)> work);
|
2019-09-05 14:57:01 +00:00
|
|
|
|
2019-03-29 14:30:19 +00:00
|
|
|
private:
|
2020-04-07 18:38:56 +00:00
|
|
|
std::unordered_map<Addr, RouterID, Addr::Hash> m_AuthedAddrs;
|
2019-08-22 20:53:27 +00:00
|
|
|
const bool permitInbound;
|
2019-03-29 14:30:19 +00:00
|
|
|
};
|
2019-08-22 20:53:27 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
using LinkLayer_ptr = std::shared_ptr<LinkLayer>;
|
2019-03-29 14:30:19 +00:00
|
|
|
} // namespace iwp
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|