---
title: llarp::iwp::LinkLayer

---

# llarp::iwp::LinkLayer





Inherits from [llarp::ILinkLayer](Classes/structllarp_1_1ILinkLayer.md)

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[LinkLayer](Classes/structllarp_1_1iwp_1_1LinkLayer.md#function-linklayer)**(std::shared_ptr< [KeyManager](Classes/structllarp_1_1KeyManager.md) > keyManager, std::shared_ptr< [EventLoop](Classes/classllarp_1_1EventLoop.md) > ev, [GetRCFunc](Namespaces/namespacellarp.md#using-getrcfunc) getrc, [LinkMessageHandler](Namespaces/namespacellarp.md#using-linkmessagehandler) h, [SignBufferFunc](Namespaces/namespacellarp.md#using-signbufferfunc) sign, [BeforeConnectFunc_t](Namespaces/namespacellarp.md#using-beforeconnectfunc-t) before, [SessionEstablishedHandler](Namespaces/namespacellarp.md#using-sessionestablishedhandler) est, [SessionRenegotiateHandler](Namespaces/namespacellarp.md#using-sessionrenegotiatehandler) reneg, [TimeoutHandler](Namespaces/namespacellarp.md#using-timeouthandler) timeout, [SessionClosedHandler](Namespaces/namespacellarp.md#using-sessionclosedhandler) closed, [PumpDoneHandler](Namespaces/namespacellarp.md#using-pumpdonehandler) pumpDone, [WorkerFunc_t](Namespaces/namespacellarp.md#using-workerfunc-t) dowork, bool permitInbound) |
| virtual std::shared_ptr< [ILinkSession](Classes/structllarp_1_1ILinkSession.md) > | **[NewOutboundSession](Classes/structllarp_1_1iwp_1_1LinkLayer.md#function-newoutboundsession)**(const [RouterContact](Classes/structllarp_1_1RouterContact.md) & rc, const [AddressInfo](Classes/structllarp_1_1AddressInfo.md) & ai) override |
| virtual std::string_view | **[Name](Classes/structllarp_1_1iwp_1_1LinkLayer.md#function-name)**() const override |
| virtual uint16_t | **[Rank](Classes/structllarp_1_1iwp_1_1LinkLayer.md#function-rank)**() const override |
| virtual void | **[RecvFrom](Classes/structllarp_1_1iwp_1_1LinkLayer.md#function-recvfrom)**(const [SockAddr](Classes/structllarp_1_1SockAddr.md) & from, ILinkSession::Packet_t pkt) override |
| void | **[WakeupPlaintext](Classes/structllarp_1_1iwp_1_1LinkLayer.md#function-wakeupplaintext)**() |
| std::string | **[PrintableName](Classes/structllarp_1_1iwp_1_1LinkLayer.md#function-printablename)**() const |

## Additional inherited members

**Protected Types inherited from [llarp::ILinkLayer](Classes/structllarp_1_1ILinkLayer.md)**

|                | Name           |
| -------------- | -------------- |
| using [util::NullLock](Classes/structllarp_1_1util_1_1NullLock.md) | **[Lock_t](Classes/structllarp_1_1ILinkLayer.md#using-lock-t)**  |
| using [util::NullMutex](Classes/structllarp_1_1util_1_1NullMutex.md) | **[Mutex_t](Classes/structllarp_1_1ILinkLayer.md#using-mutex-t)**  |
| using std::unordered_multimap< [RouterID](Classes/structllarp_1_1RouterID.md), std::shared_ptr< [ILinkSession](Classes/structllarp_1_1ILinkSession.md) > > | **[AuthedLinks](Classes/structllarp_1_1ILinkLayer.md#using-authedlinks)**  |
| using std::unordered_map< [SockAddr](Classes/structllarp_1_1SockAddr.md), std::shared_ptr< [ILinkSession](Classes/structllarp_1_1ILinkSession.md) > > | **[Pending](Classes/structllarp_1_1ILinkLayer.md#using-pending)**  |

**Public Functions inherited from [llarp::ILinkLayer](Classes/structllarp_1_1ILinkLayer.md)**

|                | Name           |
| -------------- | -------------- |
| | **[ILinkLayer](Classes/structllarp_1_1ILinkLayer.md#function-ilinklayer)**(std::shared_ptr< [KeyManager](Classes/structllarp_1_1KeyManager.md) > keyManager, [GetRCFunc](Namespaces/namespacellarp.md#using-getrcfunc) getrc, [LinkMessageHandler](Namespaces/namespacellarp.md#using-linkmessagehandler) handler, [SignBufferFunc](Namespaces/namespacellarp.md#using-signbufferfunc) signFunc, [BeforeConnectFunc_t](Namespaces/namespacellarp.md#using-beforeconnectfunc-t) before, [SessionEstablishedHandler](Namespaces/namespacellarp.md#using-sessionestablishedhandler) sessionEstablish, [SessionRenegotiateHandler](Namespaces/namespacellarp.md#using-sessionrenegotiatehandler) renegotiate, [TimeoutHandler](Namespaces/namespacellarp.md#using-timeouthandler) timeout, [SessionClosedHandler](Namespaces/namespacellarp.md#using-sessionclosedhandler) closed, [PumpDoneHandler](Namespaces/namespacellarp.md#using-pumpdonehandler) pumpDone, [WorkerFunc_t](Namespaces/namespacellarp.md#using-workerfunc-t) doWork) |
| virtual | **[~ILinkLayer](Classes/structllarp_1_1ILinkLayer.md#function-~ilinklayer)**() =default |
| llarp_time_t | **[Now](Classes/structllarp_1_1ILinkLayer.md#function-now)**() const<br>get current time via event loop  |
| bool | **[HasSessionTo](Classes/structllarp_1_1ILinkLayer.md#function-hassessionto)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & pk) |
| void | **[ForEachSession](Classes/structllarp_1_1ILinkLayer.md#function-foreachsession)**(std::function< void(const [ILinkSession](Classes/structllarp_1_1ILinkSession.md) *)> visit, bool randomize =false) const |
| void | **[ForEachSession](Classes/structllarp_1_1ILinkLayer.md#function-foreachsession)**(std::function< void([ILinkSession](Classes/structllarp_1_1ILinkSession.md) *)> visit) |
| void | **[UnmapAddr](Classes/structllarp_1_1ILinkLayer.md#function-unmapaddr)**(const [SockAddr](Classes/structllarp_1_1SockAddr.md) & addr) |
| void | **[SendTo_LL](Classes/structllarp_1_1ILinkLayer.md#function-sendto-ll)**(const [SockAddr](Classes/structllarp_1_1SockAddr.md) & to, const [llarp_buffer_t](Classes/structllarp__buffer__t.md) & pkt) |
| void | **[Bind](Classes/structllarp_1_1ILinkLayer.md#function-bind)**([AbstractRouter](Classes/structllarp_1_1AbstractRouter.md) * router, [SockAddr](Classes/structllarp_1_1SockAddr.md) addr) |
| std::shared_ptr< [ILinkSession](Classes/structllarp_1_1ILinkSession.md) > | **[FindSessionByPubkey](Classes/structllarp_1_1ILinkLayer.md#function-findsessionbypubkey)**([RouterID](Classes/structllarp_1_1RouterID.md) pk)<br>fetch a session by the identity pubkey it claims  |
| virtual void | **[Pump](Classes/structllarp_1_1ILinkLayer.md#function-pump)**() |
| bool | **[PickAddress](Classes/structllarp_1_1ILinkLayer.md#function-pickaddress)**(const [RouterContact](Classes/structllarp_1_1RouterContact.md) & rc, [AddressInfo](Classes/structllarp_1_1AddressInfo.md) & picked) const |
| bool | **[TryEstablishTo](Classes/structllarp_1_1ILinkLayer.md#function-tryestablishto)**([RouterContact](Classes/structllarp_1_1RouterContact.md) rc) |
| bool | **[Start](Classes/structllarp_1_1ILinkLayer.md#function-start)**() |
| virtual void | **[Stop](Classes/structllarp_1_1ILinkLayer.md#function-stop)**() |
| util::StatusObject | **[ExtractStatus](Classes/structllarp_1_1ILinkLayer.md#function-extractstatus)**() const |
| void | **[CloseSessionTo](Classes/structllarp_1_1ILinkLayer.md#function-closesessionto)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & remote) |
| void | **[KeepAliveSessionTo](Classes/structllarp_1_1ILinkLayer.md#function-keepalivesessionto)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & remote) |
| virtual bool | **[SendTo](Classes/structllarp_1_1ILinkLayer.md#function-sendto)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & remote, const [llarp_buffer_t](Classes/structllarp__buffer__t.md) & buf, [ILinkSession::CompletionHandler](Classes/structllarp_1_1ILinkSession.md#using-completionhandler) completed, uint16_t priority) |
| virtual bool | **[GetOurAddressInfo](Classes/structllarp_1_1ILinkLayer.md#function-getouraddressinfo)**([AddressInfo](Classes/structllarp_1_1AddressInfo.md) & addr) const |
| bool | **[VisitSessionByPubkey](Classes/structllarp_1_1ILinkLayer.md#function-visitsessionbypubkey)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & pk, std::function< bool([ILinkSession](Classes/structllarp_1_1ILinkSession.md) *)> visit) |
| const byte_t * | **[TransportPubKey](Classes/structllarp_1_1ILinkLayer.md#function-transportpubkey)**() const |
| const [SecretKey](Classes/structllarp_1_1SecretKey.md) & | **[RouterEncryptionSecret](Classes/structllarp_1_1ILinkLayer.md#function-routerencryptionsecret)**() const |
| const [SecretKey](Classes/structllarp_1_1SecretKey.md) & | **[TransportSecretKey](Classes/structllarp_1_1ILinkLayer.md#function-transportsecretkey)**() const |
| bool | **[IsCompatable](Classes/structllarp_1_1ILinkLayer.md#function-iscompatable)**(const [llarp::RouterContact](Classes/structllarp_1_1RouterContact.md) & other) const |
| bool | **[MapAddr](Classes/structllarp_1_1ILinkLayer.md#function-mapaddr)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & pk, [ILinkSession](Classes/structllarp_1_1ILinkSession.md) * s) |
| void | **[Tick](Classes/structllarp_1_1ILinkLayer.md#function-tick)**(llarp_time_t now) |
| bool | **[operator<](Classes/structllarp_1_1ILinkLayer.md#function-operator<)**(const [ILinkLayer](Classes/structllarp_1_1ILinkLayer.md) & other) const |
| size_t | **[NumberOfPendingSessions](Classes/structllarp_1_1ILinkLayer.md#function-numberofpendingsessions)**() const<br>called by link session to remove a pending session who is timed out  |
| std::optional< int > | **[GetUDPFD](Classes/structllarp_1_1ILinkLayer.md#function-getudpfd)**() const |
| [AbstractRouter](Classes/structllarp_1_1AbstractRouter.md) * | **[Router](Classes/structllarp_1_1ILinkLayer.md#function-router)**() const |
| const [SockAddr](Classes/structllarp_1_1SockAddr.md) & | **[LocalSocketAddr](Classes/structllarp_1_1ILinkLayer.md#function-localsocketaddr)**() const<br>Get the local sock addr we are bound on.  |

**Protected Functions inherited from [llarp::ILinkLayer](Classes/structllarp_1_1ILinkLayer.md)**

|                | Name           |
| -------------- | -------------- |
| bool | **[PutSession](Classes/structllarp_1_1ILinkLayer.md#function-putsession)**(const std::shared_ptr< [ILinkSession](Classes/structllarp_1_1ILinkSession.md) > & s) |
| | **[DECLARE_LOCK](Classes/structllarp_1_1ILinkLayer.md#function-declare-lock)**([Mutex_t](Classes/structllarp_1_1util_1_1NullMutex.md) , m_AuthedLinksMutex , ACQUIRED_BEFORE(m_PendingMutex) ) |
| AuthedLinks m_AuthedLinks | **[GUARDED_BY](Classes/structllarp_1_1ILinkLayer.md#function-guarded-by)**(m_AuthedLinksMutex ) |
| | **[DECLARE_LOCK](Classes/structllarp_1_1ILinkLayer.md#function-declare-lock)**([Mutex_t](Classes/structllarp_1_1util_1_1NullMutex.md) , m_PendingMutex , ACQUIRED_AFTER(m_AuthedLinksMutex) ) |
| Pending m_Pending | **[GUARDED_BY](Classes/structllarp_1_1ILinkLayer.md#function-guarded-by)**(m_PendingMutex ) |

**Public Attributes inherited from [llarp::ILinkLayer](Classes/structllarp_1_1ILinkLayer.md)**

|                | Name           |
| -------------- | -------------- |
| [LinkMessageHandler](Namespaces/namespacellarp.md#using-linkmessagehandler) | **[HandleMessage](Classes/structllarp_1_1ILinkLayer.md#variable-handlemessage)**  |
| [TimeoutHandler](Namespaces/namespacellarp.md#using-timeouthandler) | **[HandleTimeout](Classes/structllarp_1_1ILinkLayer.md#variable-handletimeout)**  |
| [SignBufferFunc](Namespaces/namespacellarp.md#using-signbufferfunc) | **[Sign](Classes/structllarp_1_1ILinkLayer.md#variable-sign)**  |
| [GetRCFunc](Namespaces/namespacellarp.md#using-getrcfunc) | **[GetOurRC](Classes/structllarp_1_1ILinkLayer.md#variable-getourrc)**  |
| [BeforeConnectFunc_t](Namespaces/namespacellarp.md#using-beforeconnectfunc-t) | **[BeforeConnect](Classes/structllarp_1_1ILinkLayer.md#variable-beforeconnect)**  |
| [SessionEstablishedHandler](Namespaces/namespacellarp.md#using-sessionestablishedhandler) | **[SessionEstablished](Classes/structllarp_1_1ILinkLayer.md#variable-sessionestablished)**  |
| [SessionClosedHandler](Namespaces/namespacellarp.md#using-sessionclosedhandler) | **[SessionClosed](Classes/structllarp_1_1ILinkLayer.md#variable-sessionclosed)**  |
| [SessionRenegotiateHandler](Namespaces/namespacellarp.md#using-sessionrenegotiatehandler) | **[SessionRenegotiate](Classes/structllarp_1_1ILinkLayer.md#variable-sessionrenegotiate)**  |
| [PumpDoneHandler](Namespaces/namespacellarp.md#using-pumpdonehandler) | **[PumpDone](Classes/structllarp_1_1ILinkLayer.md#variable-pumpdone)**  |
| std::shared_ptr< [KeyManager](Classes/structllarp_1_1KeyManager.md) > | **[keyManager](Classes/structllarp_1_1ILinkLayer.md#variable-keymanager)**  |
| [WorkerFunc_t](Namespaces/namespacellarp.md#using-workerfunc-t) | **[QueueWork](Classes/structllarp_1_1ILinkLayer.md#variable-queuework)**  |

**Protected Attributes inherited from [llarp::ILinkLayer](Classes/structllarp_1_1ILinkLayer.md)**

|                | Name           |
| -------------- | -------------- |
| [AbstractRouter](Classes/structllarp_1_1AbstractRouter.md) * | **[m_Router](Classes/structllarp_1_1ILinkLayer.md#variable-m-router)**  |
| [SockAddr](Classes/structllarp_1_1SockAddr.md) | **[m_ourAddr](Classes/structllarp_1_1ILinkLayer.md#variable-m-ouraddr)**  |
| std::shared_ptr< [llarp::UDPHandle](Classes/structllarp_1_1UDPHandle.md) > | **[m_udp](Classes/structllarp_1_1ILinkLayer.md#variable-m-udp)**  |
| [SecretKey](Classes/structllarp_1_1SecretKey.md) | **[m_SecretKey](Classes/structllarp_1_1ILinkLayer.md#variable-m-secretkey)**  |
| std::unordered_map< [SockAddr](Classes/structllarp_1_1SockAddr.md), [RouterID](Classes/structllarp_1_1RouterID.md) > | **[m_AuthedAddrs](Classes/structllarp_1_1ILinkLayer.md#variable-m-authedaddrs)**  |
| std::unordered_map< [SockAddr](Classes/structllarp_1_1SockAddr.md), llarp_time_t > | **[m_RecentlyClosed](Classes/structllarp_1_1ILinkLayer.md#variable-m-recentlyclosed)**  |


## Public Functions Documentation

### function LinkLayer

```cpp
LinkLayer(
    std::shared_ptr< KeyManager > keyManager,
    std::shared_ptr< EventLoop > ev,
    GetRCFunc getrc,
    LinkMessageHandler h,
    SignBufferFunc sign,
    BeforeConnectFunc_t before,
    SessionEstablishedHandler est,
    SessionRenegotiateHandler reneg,
    TimeoutHandler timeout,
    SessionClosedHandler closed,
    PumpDoneHandler pumpDone,
    WorkerFunc_t dowork,
    bool permitInbound
)
```


### function NewOutboundSession

```cpp
virtual std::shared_ptr< ILinkSession > NewOutboundSession(
    const RouterContact & rc,
    const AddressInfo & ai
) override
```


**Reimplements**: [llarp::ILinkLayer::NewOutboundSession](Classes/structllarp_1_1ILinkLayer.md#function-newoutboundsession)


### function Name

```cpp
virtual std::string_view Name() const override
```


**Reimplements**: [llarp::ILinkLayer::Name](Classes/structllarp_1_1ILinkLayer.md#function-name)


### function Rank

```cpp
virtual uint16_t Rank() const override
```


**Reimplements**: [llarp::ILinkLayer::Rank](Classes/structllarp_1_1ILinkLayer.md#function-rank)


### function RecvFrom

```cpp
virtual void RecvFrom(
    const SockAddr & from,
    ILinkSession::Packet_t pkt
) override
```


**Reimplements**: [llarp::ILinkLayer::RecvFrom](Classes/structllarp_1_1ILinkLayer.md#function-recvfrom)


### function WakeupPlaintext

```cpp
void WakeupPlaintext()
```


### function PrintableName

```cpp
std::string PrintableName() const
```


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

Updated on 2025-01-26 at 05:10:09 +0000