lokinet/llarp/link/session.hpp

71 lines
1.8 KiB
C++
Raw Normal View History

#ifndef LLARP_LINK_SESSION_HPP
#define LLARP_LINK_SESSION_HPP
#include <crypto/types.hpp>
#include <net/net.hpp>
2018-12-12 01:55:30 +00:00
#include <router_contact.hpp>
#include <util/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 : public util::IStateful
{
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
std::function< bool(const 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
2019-01-05 13:45:05 +00:00
std::function< PubKey(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;
2019-03-18 12:25:32 +00:00
/// return true if we should send an explicit keepalive message
std::function< bool(void) > ShouldPing;
};
} // namespace llarp
#endif