lokinet/llarp/link/session.hpp

93 lines
1.9 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;
2019-04-19 15:10:26 +00:00
struct ILinkSession
{
virtual ~ILinkSession()
{
}
2019-04-02 09:03:53 +00:00
/// hook for utp for when we have established a connection
virtual void
OnLinkEstablished(ILinkLayer *p) = 0;
/// called every event loop tick
2019-04-02 09:03:53 +00:00
virtual void
Pump() = 0;
/// called every timer tick
2019-04-02 09:03:53 +00:00
virtual void Tick(llarp_time_t) = 0;
/// send a message buffer to the remote endpoint
2019-04-02 09:03:53 +00:00
virtual bool
SendMessageBuffer(const llarp_buffer_t &) = 0;
/// start the connection
2019-04-02 09:03:53 +00:00
virtual void
Start() = 0;
2019-04-02 09:03:53 +00:00
virtual void
Close() = 0;
2019-04-02 09:03:53 +00:00
/// send a keepalive to the remote endpoint
virtual bool
SendKeepAlive() = 0;
/// return true if we are established
2019-04-02 09:03:53 +00:00
virtual bool
IsEstablished() = 0;
/// return true if this session has timed out
2019-04-02 09:03:53 +00:00
virtual bool
TimedOut(llarp_time_t now) const = 0;
/// get remote public identity key
2019-04-02 09:03:53 +00:00
virtual PubKey
GetPubKey() const = 0;
2018-09-07 17:41:49 +00:00
/// get remote address
2019-04-02 09:03:53 +00:00
virtual Addr
GetRemoteEndpoint() const = 0;
// get remote rc
2019-04-02 09:03:53 +00:00
virtual RouterContact
GetRemoteRC() const = 0;
/// handle a valid LIM
std::function< bool(const LinkIntroMessage *msg) > GotLIM;
/// send queue current blacklog
2019-04-02 09:03:53 +00:00
virtual size_t
SendQueueBacklog() const = 0;
/// get parent link layer
2019-04-02 09:03:53 +00:00
virtual ILinkLayer *
GetLinkLayer() const = 0;
/// renegotiate session when we have a new RC locally
2019-04-02 09:03:53 +00:00
virtual bool
RenegotiateSession() = 0;
2019-03-18 12:25:32 +00:00
/// return true if we should send an explicit keepalive message
2019-04-02 09:03:53 +00:00
virtual bool
ShouldPing() const = 0;
2019-04-19 15:10:26 +00:00
virtual util::StatusObject
ExtractStatus() const = 0;
};
} // namespace llarp
#endif