2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
2019-03-29 14:30:19 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/constants/link_layer.hpp>
|
|
|
|
#include <llarp/crypto/crypto.hpp>
|
|
|
|
#include <llarp/crypto/encrypted.hpp>
|
|
|
|
#include <llarp/crypto/types.hpp>
|
|
|
|
#include <llarp/link/server.hpp>
|
|
|
|
#include <llarp/config/key_manager.hpp>
|
2021-02-23 10:48:50 +00:00
|
|
|
|
2019-12-03 17:58:53 +00:00
|
|
|
#include <memory>
|
2019-03-29 14:30:19 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/ev/ev.hpp>
|
2021-02-22 13:26:32 +00:00
|
|
|
|
|
|
|
namespace llarp::iwp
|
2019-03-29 14:30:19 +00:00
|
|
|
{
|
2021-02-22 13:26:32 +00:00
|
|
|
struct Session;
|
|
|
|
|
|
|
|
struct LinkLayer final : public ILinkLayer
|
2019-03-29 14:30:19 +00:00
|
|
|
{
|
2021-02-22 13:26:32 +00:00
|
|
|
LinkLayer(
|
|
|
|
std::shared_ptr<KeyManager> keyManager,
|
|
|
|
std::shared_ptr<EventLoop> ev,
|
|
|
|
GetRCFunc getrc,
|
|
|
|
LinkMessageHandler h,
|
|
|
|
SignBufferFunc sign,
|
|
|
|
BeforeConnectFunc_t before,
|
|
|
|
SessionEstablishedHandler est,
|
|
|
|
SessionRenegotiateHandler reneg,
|
|
|
|
TimeoutHandler timeout,
|
|
|
|
SessionClosedHandler closed,
|
|
|
|
PumpDoneHandler pumpDone,
|
|
|
|
WorkerFunc_t dowork,
|
|
|
|
bool permitInbound);
|
|
|
|
|
|
|
|
std::shared_ptr<ILinkSession>
|
|
|
|
NewOutboundSession(const RouterContact& rc, const AddressInfo& ai) override;
|
|
|
|
|
2022-10-13 17:19:25 +00:00
|
|
|
std::string_view
|
2021-02-22 13:26:32 +00:00
|
|
|
Name() const override;
|
|
|
|
|
|
|
|
uint16_t
|
|
|
|
Rank() const override;
|
|
|
|
|
|
|
|
void
|
|
|
|
RecvFrom(const SockAddr& from, ILinkSession::Packet_t pkt) override;
|
|
|
|
|
|
|
|
void
|
|
|
|
WakeupPlaintext();
|
|
|
|
|
2021-07-01 12:30:29 +00:00
|
|
|
std::string
|
|
|
|
PrintableName() const;
|
|
|
|
|
2021-02-22 13:26:32 +00:00
|
|
|
private:
|
|
|
|
void
|
|
|
|
HandleWakeupPlaintext();
|
|
|
|
|
2021-03-02 02:06:20 +00:00
|
|
|
const std::shared_ptr<EventLoopWakeup> m_Wakeup;
|
2021-11-11 21:46:53 +00:00
|
|
|
std::vector<ILinkSession*> m_WakingUp;
|
2021-07-01 12:14:43 +00:00
|
|
|
const bool m_Inbound;
|
2021-02-22 13:26:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using LinkLayer_ptr = std::shared_ptr<LinkLayer>;
|
|
|
|
} // namespace llarp::iwp
|