---
title: llarp/link/session.hpp

---

# llarp/link/session.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::SessionStats](Classes/structllarp_1_1SessionStats.md)**  |
| struct | **[llarp::ILinkSession](Classes/structllarp_1_1ILinkSession.md)**  |




## Source code

```cpp
#pragma once

#include <llarp/crypto/types.hpp>
#include <llarp/net/net.hpp>
#include <llarp/ev/ev.hpp>
#include <llarp/router_contact.hpp>
#include <llarp/util/types.hpp>

#include <functional>

namespace llarp
{
  struct LinkIntroMessage;
  struct ILinkMessage;
  struct ILinkLayer;

  struct SessionStats
  {
    // rate
    uint64_t currentRateRX = 0;
    uint64_t currentRateTX = 0;

    uint64_t totalPacketsRX = 0;

    uint64_t totalAckedTX = 0;
    uint64_t totalDroppedTX = 0;
    uint64_t totalInFlightTX = 0;
  };

  struct ILinkSession
  {
    virtual ~ILinkSession() = default;

    enum class DeliveryStatus
    {
      eDeliverySuccess = 0,
      eDeliveryDropped = 1
    };

    virtual void
    OnLinkEstablished(ILinkLayer*){};

    virtual void
    Pump() = 0;

    virtual void Tick(llarp_time_t) = 0;

    using CompletionHandler = std::function<void(DeliveryStatus)>;

    using Packet_t = std::vector<byte_t>;
    using Message_t = std::vector<byte_t>;

    virtual bool
    SendMessageBuffer(Message_t, CompletionHandler handler, uint16_t priority) = 0;

    virtual void
    Start() = 0;

    virtual void
    Close() = 0;

    virtual bool
    Recv_LL(Packet_t)
    {
      return true;
    }

    virtual bool
    SendKeepAlive() = 0;

    virtual bool
    IsEstablished() const = 0;

    virtual bool
    TimedOut(llarp_time_t now) const = 0;

    virtual PubKey
    GetPubKey() const = 0;

    virtual bool
    IsInbound() const = 0;

    virtual const SockAddr&
    GetRemoteEndpoint() const = 0;

    // get remote rc
    virtual RouterContact
    GetRemoteRC() const = 0;

    bool
    IsRelay() const;

    std::function<bool(const LinkIntroMessage* msg)> GotLIM;

    virtual size_t
    SendQueueBacklog() const = 0;

    virtual ILinkLayer*
    GetLinkLayer() const = 0;

    virtual bool
    RenegotiateSession() = 0;

    virtual bool
    ShouldPing() const = 0;

    virtual SessionStats
    GetSessionStats() const = 0;

    virtual util::StatusObject
    ExtractStatus() const = 0;

    virtual void
    HandlePlaintext() = 0;
  };
}  // namespace llarp
```


-------------------------------

Updated on 2023-01-20 at 23:19:39 +0000
