lokinet/llarp/link/session.hpp

68 lines
1.6 KiB
C++
Raw Normal View History

#ifndef LLARP_LINK_SESSION_HPP
#define LLARP_LINK_SESSION_HPP
2018-12-12 00:38:58 +00:00
#include <crypto.hpp>
#include <net.hpp>
2018-12-12 01:55:30 +00:00
#include <router_contact.hpp>
#include <types.hpp>
2018-12-12 01:55:30 +00:00
2018-09-06 11:46:19 +00:00
#include <functional>
namespace llarp
{
struct LinkIntroMessage;
struct ILinkMessage;
2018-09-04 19:15:06 +00:00
struct ILinkLayer;
struct ILinkSession
{
virtual ~ILinkSession(){};
/// called every event loop tick
2018-09-06 11:46:19 +00:00
std::function< void(void) > Pump;
/// called every timer tick
2018-09-06 11:46:19 +00:00
std::function< void(llarp_time_t) > Tick;
/// send a message buffer to the remote endpoint
2018-09-06 11:46:19 +00:00
std::function< bool(llarp_buffer_t) > SendMessageBuffer;
/// start the connection
2018-09-06 11:46:19 +00:00
std::function< void(void) > Start;
/// send a keepalive to the remote endpoint
2018-09-06 11:46:19 +00:00
std::function< bool(void) > SendKeepAlive;
/// send close message
2018-09-06 11:46:19 +00:00
std::function< void(void) > SendClose;
/// return true if we are established
2018-09-06 11:46:19 +00:00
std::function< bool(void) > IsEstablished;
/// return true if this session has timed out
2018-09-06 11:46:19 +00:00
std::function< bool(llarp_time_t) > TimedOut;
/// get remote public identity key
std::function< const byte_t *(void) > GetPubKey;
2018-09-07 17:41:49 +00:00
/// get remote address
std::function< Addr(void) > GetRemoteEndpoint;
// get remote rc
2018-12-17 22:43:16 +00:00
std::function< llarp::RouterContact(void) > GetRemoteRC;
/// handle a valid LIM
std::function< bool(const LinkIntroMessage *msg) > GotLIM;
/// send queue current blacklog
std::function< size_t(void) > SendQueueBacklog;
/// get parent link layer
std::function< ILinkLayer *(void) > GetLinkLayer;
/// renegotiate session when we have a new RC locally
std::function< bool(void) > RenegotiateSession;
};
} // namespace llarp
#endif