2018-09-02 18:25:42 +00:00
|
|
|
#ifndef LLARP_LINK_SESSION_HPP
|
|
|
|
#define LLARP_LINK_SESSION_HPP
|
|
|
|
|
2018-12-12 00:38:58 +00:00
|
|
|
#include <crypto.hpp>
|
2018-09-02 18:25:42 +00:00
|
|
|
#include <llarp/net.hpp>
|
2018-11-19 22:45:37 +00:00
|
|
|
#include <llarp/types.hpp>
|
2018-12-12 01:55:30 +00:00
|
|
|
#include <router_contact.hpp>
|
|
|
|
|
2018-09-06 11:46:19 +00:00
|
|
|
#include <functional>
|
2018-09-02 18:25:42 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
struct LinkIntroMessage;
|
|
|
|
struct ILinkMessage;
|
2018-09-04 19:15:06 +00:00
|
|
|
struct ILinkLayer;
|
2018-09-02 18:25:42 +00:00
|
|
|
struct ILinkSession
|
|
|
|
{
|
|
|
|
virtual ~ILinkSession(){};
|
|
|
|
|
2018-09-03 13:10:56 +00:00
|
|
|
/// called every event loop tick
|
2018-09-06 11:46:19 +00:00
|
|
|
std::function< void(void) > Pump;
|
2018-09-03 13:10:56 +00:00
|
|
|
|
|
|
|
/// called every timer tick
|
2018-09-06 11:46:19 +00:00
|
|
|
std::function< void(llarp_time_t) > Tick;
|
2018-09-02 18:25:42 +00:00
|
|
|
|
|
|
|
/// send a message buffer to the remote endpoint
|
2018-09-06 11:46:19 +00:00
|
|
|
std::function< bool(llarp_buffer_t) > SendMessageBuffer;
|
2018-09-02 18:25:42 +00:00
|
|
|
|
2018-09-04 12:41:25 +00:00
|
|
|
/// start the connection
|
2018-09-06 11:46:19 +00:00
|
|
|
std::function< void(void) > Start;
|
2018-09-02 18:25:42 +00:00
|
|
|
|
|
|
|
/// send a keepalive to the remote endpoint
|
2018-09-06 11:46:19 +00:00
|
|
|
std::function< bool(void) > SendKeepAlive;
|
2018-09-02 18:25:42 +00:00
|
|
|
|
|
|
|
/// send close message
|
2018-09-06 11:46:19 +00:00
|
|
|
std::function< void(void) > SendClose;
|
2018-09-02 18:25:42 +00:00
|
|
|
|
|
|
|
/// return true if we are established
|
2018-09-06 11:46:19 +00:00
|
|
|
std::function< bool(void) > IsEstablished;
|
2018-09-02 18:25:42 +00:00
|
|
|
|
|
|
|
/// return true if this session has timed out
|
2018-09-06 11:46:19 +00:00
|
|
|
std::function< bool(llarp_time_t) > TimedOut;
|
2018-09-02 18:25:42 +00:00
|
|
|
|
|
|
|
/// get remote public identity key
|
2018-12-10 17:22:59 +00:00
|
|
|
std::function< const byte_t *(void) > GetPubKey;
|
2018-09-07 17:41:49 +00:00
|
|
|
/// get remote address
|
|
|
|
std::function< const Addr &(void) > GetRemoteEndpoint;
|
2018-09-08 15:53:20 +00:00
|
|
|
|
|
|
|
/// handle a valid LIM
|
|
|
|
std::function< bool(const LinkIntroMessage *msg) > GotLIM;
|
2018-09-18 20:56:22 +00:00
|
|
|
|
|
|
|
/// send queue current blacklog
|
|
|
|
std::function< size_t(void) > SendQueueBacklog;
|
2018-09-02 18:25:42 +00:00
|
|
|
};
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|