---
title: llarp::LinkManager

---

# llarp::LinkManager





Inherits from [llarp::ILinkManager](Classes/structllarp_1_1ILinkManager.md)

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[~LinkManager](Classes/structllarp_1_1LinkManager.md#function-~linkmanager)**() override =default |
| virtual LinkLayer_ptr | **[GetCompatibleLink](Classes/structllarp_1_1LinkManager.md#function-getcompatiblelink)**(const [RouterContact](Classes/structllarp_1_1RouterContact.md) & rc) const override |
| virtual [IOutboundSessionMaker](Classes/structllarp_1_1IOutboundSessionMaker.md) * | **[GetSessionMaker](Classes/structllarp_1_1LinkManager.md#function-getsessionmaker)**() const override |
| virtual bool | **[SendTo](Classes/structllarp_1_1LinkManager.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) override |
| virtual bool | **[HasSessionTo](Classes/structllarp_1_1LinkManager.md#function-hassessionto)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & remote) const override |
| virtual bool | **[HasOutboundSessionTo](Classes/structllarp_1_1LinkManager.md#function-hasoutboundsessionto)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & remote) const override |
| virtual std::optional< bool > | **[SessionIsClient](Classes/structllarp_1_1LinkManager.md#function-sessionisclient)**([RouterID](Classes/structllarp_1_1RouterID.md) remote) const override<br>return true if the session with this pubkey is a client return false if the session with this pubkey is a router return std::nullopt we have no session with this pubkey  |
| virtual void | **[DeregisterPeer](Classes/structllarp_1_1LinkManager.md#function-deregisterpeer)**([RouterID](Classes/structllarp_1_1RouterID.md) remote) override<br>close all connections to this peer remove all link layer commits  |
| virtual void | **[PumpLinks](Classes/structllarp_1_1LinkManager.md#function-pumplinks)**() override |
| virtual void | **[AddLink](Classes/structllarp_1_1LinkManager.md#function-addlink)**(LinkLayer_ptr link, bool inbound =false) override |
| virtual bool | **[StartLinks](Classes/structllarp_1_1LinkManager.md#function-startlinks)**() override |
| virtual void | **[Stop](Classes/structllarp_1_1LinkManager.md#function-stop)**() override |
| virtual void | **[PersistSessionUntil](Classes/structllarp_1_1LinkManager.md#function-persistsessionuntil)**(const [RouterID](Classes/structllarp_1_1RouterID.md) & remote, llarp_time_t until) override |
| virtual void | **[ForEachPeer](Classes/structllarp_1_1LinkManager.md#function-foreachpeer)**(std::function< void(const [ILinkSession](Classes/structllarp_1_1ILinkSession.md) *, bool)> visit, bool randomize =false) const override |
| virtual void | **[ForEachPeer](Classes/structllarp_1_1LinkManager.md#function-foreachpeer)**(std::function< void([ILinkSession](Classes/structllarp_1_1ILinkSession.md) *)> visit) override |
| virtual void | **[ForEachInboundLink](Classes/structllarp_1_1LinkManager.md#function-foreachinboundlink)**(std::function< void(LinkLayer_ptr)> visit) const override |
| virtual void | **[ForEachOutboundLink](Classes/structllarp_1_1LinkManager.md#function-foreachoutboundlink)**(std::function< void(LinkLayer_ptr)> visit) const override |
| virtual size_t | **[NumberOfConnectedRouters](Classes/structllarp_1_1LinkManager.md#function-numberofconnectedrouters)**() const override |
| virtual size_t | **[NumberOfConnectedClients](Classes/structllarp_1_1LinkManager.md#function-numberofconnectedclients)**() const override |
| virtual size_t | **[NumberOfPendingConnections](Classes/structllarp_1_1LinkManager.md#function-numberofpendingconnections)**() const override |
| virtual bool | **[GetRandomConnectedRouter](Classes/structllarp_1_1LinkManager.md#function-getrandomconnectedrouter)**([RouterContact](Classes/structllarp_1_1RouterContact.md) & router) const override |
| virtual void | **[CheckPersistingSessions](Classes/structllarp_1_1LinkManager.md#function-checkpersistingsessions)**(llarp_time_t now) override |
| virtual void | **[updatePeerDb](Classes/structllarp_1_1LinkManager.md#function-updatepeerdb)**(std::shared_ptr< [PeerDb](Classes/structllarp_1_1PeerDb.md) > peerDb) override |
| virtual util::StatusObject | **[ExtractStatus](Classes/structllarp_1_1LinkManager.md#function-extractstatus)**() const override |
| void | **[Init](Classes/structllarp_1_1LinkManager.md#function-init)**([IOutboundSessionMaker](Classes/structllarp_1_1IOutboundSessionMaker.md) * sessionMaker) |

## Additional inherited members

**Public Functions inherited from [llarp::ILinkManager](Classes/structllarp_1_1ILinkManager.md)**

|                | Name           |
| -------------- | -------------- |
| virtual | **[~ILinkManager](Classes/structllarp_1_1ILinkManager.md#function-~ilinkmanager)**() =default |


## Public Functions Documentation

### function ~LinkManager

```cpp
~LinkManager() override =default
```


### function GetCompatibleLink

```cpp
virtual LinkLayer_ptr GetCompatibleLink(
    const RouterContact & rc
) const override
```


**Reimplements**: [llarp::ILinkManager::GetCompatibleLink](Classes/structllarp_1_1ILinkManager.md#function-getcompatiblelink)


### function GetSessionMaker

```cpp
virtual IOutboundSessionMaker * GetSessionMaker() const override
```


**Reimplements**: [llarp::ILinkManager::GetSessionMaker](Classes/structllarp_1_1ILinkManager.md#function-getsessionmaker)


### function SendTo

```cpp
virtual bool SendTo(
    const RouterID & remote,
    const llarp_buffer_t & buf,
    ILinkSession::CompletionHandler completed,
    uint16_t priority
) override
```


**Reimplements**: [llarp::ILinkManager::SendTo](Classes/structllarp_1_1ILinkManager.md#function-sendto)


### function HasSessionTo

```cpp
virtual bool HasSessionTo(
    const RouterID & remote
) const override
```


**Reimplements**: [llarp::ILinkManager::HasSessionTo](Classes/structllarp_1_1ILinkManager.md#function-hassessionto)


### function HasOutboundSessionTo

```cpp
virtual bool HasOutboundSessionTo(
    const RouterID & remote
) const override
```


**Reimplements**: [llarp::ILinkManager::HasOutboundSessionTo](Classes/structllarp_1_1ILinkManager.md#function-hasoutboundsessionto)


### function SessionIsClient

```cpp
virtual std::optional< bool > SessionIsClient(
    RouterID remote
) const override
```

return true if the session with this pubkey is a client return false if the session with this pubkey is a router return std::nullopt we have no session with this pubkey 

**Reimplements**: [llarp::ILinkManager::SessionIsClient](Classes/structllarp_1_1ILinkManager.md#function-sessionisclient)


### function DeregisterPeer

```cpp
virtual void DeregisterPeer(
    RouterID remote
) override
```

close all connections to this peer remove all link layer commits 

**Reimplements**: [llarp::ILinkManager::DeregisterPeer](Classes/structllarp_1_1ILinkManager.md#function-deregisterpeer)


### function PumpLinks

```cpp
virtual void PumpLinks() override
```


**Reimplements**: [llarp::ILinkManager::PumpLinks](Classes/structllarp_1_1ILinkManager.md#function-pumplinks)


### function AddLink

```cpp
virtual void AddLink(
    LinkLayer_ptr link,
    bool inbound =false
) override
```


**Reimplements**: [llarp::ILinkManager::AddLink](Classes/structllarp_1_1ILinkManager.md#function-addlink)


### function StartLinks

```cpp
virtual bool StartLinks() override
```


**Reimplements**: [llarp::ILinkManager::StartLinks](Classes/structllarp_1_1ILinkManager.md#function-startlinks)


### function Stop

```cpp
virtual void Stop() override
```


**Reimplements**: [llarp::ILinkManager::Stop](Classes/structllarp_1_1ILinkManager.md#function-stop)


### function PersistSessionUntil

```cpp
virtual void PersistSessionUntil(
    const RouterID & remote,
    llarp_time_t until
) override
```


**Reimplements**: [llarp::ILinkManager::PersistSessionUntil](Classes/structllarp_1_1ILinkManager.md#function-persistsessionuntil)


### function ForEachPeer

```cpp
virtual void ForEachPeer(
    std::function< void(const ILinkSession *, bool)> visit,
    bool randomize =false
) const override
```


**Reimplements**: [llarp::ILinkManager::ForEachPeer](Classes/structllarp_1_1ILinkManager.md#function-foreachpeer)


### function ForEachPeer

```cpp
virtual void ForEachPeer(
    std::function< void(ILinkSession *)> visit
) override
```


**Reimplements**: [llarp::ILinkManager::ForEachPeer](Classes/structllarp_1_1ILinkManager.md#function-foreachpeer)


### function ForEachInboundLink

```cpp
virtual void ForEachInboundLink(
    std::function< void(LinkLayer_ptr)> visit
) const override
```


**Reimplements**: [llarp::ILinkManager::ForEachInboundLink](Classes/structllarp_1_1ILinkManager.md#function-foreachinboundlink)


### function ForEachOutboundLink

```cpp
virtual void ForEachOutboundLink(
    std::function< void(LinkLayer_ptr)> visit
) const override
```


**Reimplements**: [llarp::ILinkManager::ForEachOutboundLink](Classes/structllarp_1_1ILinkManager.md#function-foreachoutboundlink)


### function NumberOfConnectedRouters

```cpp
virtual size_t NumberOfConnectedRouters() const override
```


**Reimplements**: [llarp::ILinkManager::NumberOfConnectedRouters](Classes/structllarp_1_1ILinkManager.md#function-numberofconnectedrouters)


### function NumberOfConnectedClients

```cpp
virtual size_t NumberOfConnectedClients() const override
```


**Reimplements**: [llarp::ILinkManager::NumberOfConnectedClients](Classes/structllarp_1_1ILinkManager.md#function-numberofconnectedclients)


### function NumberOfPendingConnections

```cpp
virtual size_t NumberOfPendingConnections() const override
```


**Reimplements**: [llarp::ILinkManager::NumberOfPendingConnections](Classes/structllarp_1_1ILinkManager.md#function-numberofpendingconnections)


### function GetRandomConnectedRouter

```cpp
virtual bool GetRandomConnectedRouter(
    RouterContact & router
) const override
```


**Reimplements**: [llarp::ILinkManager::GetRandomConnectedRouter](Classes/structllarp_1_1ILinkManager.md#function-getrandomconnectedrouter)


### function CheckPersistingSessions

```cpp
virtual void CheckPersistingSessions(
    llarp_time_t now
) override
```


**Reimplements**: [llarp::ILinkManager::CheckPersistingSessions](Classes/structllarp_1_1ILinkManager.md#function-checkpersistingsessions)


### function updatePeerDb

```cpp
virtual void updatePeerDb(
    std::shared_ptr< PeerDb > peerDb
) override
```


**Reimplements**: [llarp::ILinkManager::updatePeerDb](Classes/structllarp_1_1ILinkManager.md#function-updatepeerdb)


### function ExtractStatus

```cpp
virtual util::StatusObject ExtractStatus() const override
```


**Reimplements**: [llarp::ILinkManager::ExtractStatus](Classes/structllarp_1_1ILinkManager.md#function-extractstatus)


### function Init

```cpp
void Init(
    IOutboundSessionMaker * sessionMaker
)
```


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

Updated on 2023-03-06 at 20:36:34 +0000