---
title: llarp::Context

---

# llarp::Context





Inherited by [llarp::apple::Context](Classes/structllarp_1_1apple_1_1Context.md), [tooling::HiveContext](Classes/structtooling_1_1HiveContext.md)

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[Context](Classes/structllarp_1_1Context.md#function-context)**() |
| virtual | **[~Context](Classes/structllarp_1_1Context.md#function-~context)**() =default |
| void | **[Setup](Classes/structllarp_1_1Context.md#function-setup)**(const [RuntimeOptions](Classes/structllarp_1_1RuntimeOptions.md) & opts) |
| int | **[Run](Classes/structllarp_1_1Context.md#function-run)**(const [RuntimeOptions](Classes/structllarp_1_1RuntimeOptions.md) & opts) |
| void | **[HandleSignal](Classes/structllarp_1_1Context.md#function-handlesignal)**(int sig) |
| void | **[Configure](Classes/structllarp_1_1Context.md#function-configure)**(std::shared_ptr< [Config](Classes/structllarp_1_1Config.md) > conf)<br>Configure given the specified config.  |
| void | **[Reload](Classes/structllarp_1_1Context.md#function-reload)**()<br>handle SIGHUP  |
| bool | **[IsUp](Classes/structllarp_1_1Context.md#function-isup)**() const |
| bool | **[LooksAlive](Classes/structllarp_1_1Context.md#function-looksalive)**() const |
| bool | **[IsStopping](Classes/structllarp_1_1Context.md#function-isstopping)**() const |
| void | **[CloseAsync](Classes/structllarp_1_1Context.md#function-closeasync)**()<br>close async  |
| void | **[Wait](Classes/structllarp_1_1Context.md#function-wait)**()<br>wait until closed and done  |
| bool | **[CallSafe](Classes/structllarp_1_1Context.md#function-callsafe)**(std::function< void(void)> f)<br>call a function in logic thread return true if queued for calling return false if not queued for calling  |
| virtual std::shared_ptr< [AbstractRouter](Classes/structllarp_1_1AbstractRouter.md) > | **[makeRouter](Classes/structllarp_1_1Context.md#function-makerouter)**(const std::shared_ptr< [EventLoop](Classes/classllarp_1_1EventLoop.md) > & loop)<br>Creates a router.  |
| virtual std::shared_ptr< [NodeDB](Classes/classllarp_1_1NodeDB.md) > | **[makeNodeDB](Classes/structllarp_1_1Context.md#function-makenodedb)**()<br>create the nodedb given our current configs  |
| virtual std::shared_ptr< [llarp::vpn::Platform](Classes/classllarp_1_1vpn_1_1Platform.md) > | **[makeVPNPlatform](Classes/structllarp_1_1Context.md#function-makevpnplatform)**()<br>create the vpn platform for use in creating network interfaces  |

## Public Attributes

|                | Name           |
| -------------- | -------------- |
| std::shared_ptr< [Crypto](Classes/structllarp_1_1Crypto.md) > | **[crypto](Classes/structllarp_1_1Context.md#variable-crypto)**  |
| std::shared_ptr< [CryptoManager](Classes/structllarp_1_1CryptoManager.md) > | **[cryptoManager](Classes/structllarp_1_1Context.md#variable-cryptomanager)**  |
| std::shared_ptr< [AbstractRouter](Classes/structllarp_1_1AbstractRouter.md) > | **[router](Classes/structllarp_1_1Context.md#variable-router)**  |
| std::shared_ptr< [EventLoop](Classes/classllarp_1_1EventLoop.md) > | **[loop](Classes/structllarp_1_1Context.md#variable-loop)**  |
| std::shared_ptr< [NodeDB](Classes/classllarp_1_1NodeDB.md) > | **[nodedb](Classes/structllarp_1_1Context.md#variable-nodedb)**  |
| int | **[androidFD](Classes/structllarp_1_1Context.md#variable-androidfd)**  |

## Protected Attributes

|                | Name           |
| -------------- | -------------- |
| std::shared_ptr< [Config](Classes/structllarp_1_1Config.md) > | **[config](Classes/structllarp_1_1Context.md#variable-config)**  |

## Public Functions Documentation

### function Context

```cpp
Context()
```


### function ~Context

```cpp
virtual ~Context() =default
```


### function Setup

```cpp
void Setup(
    const RuntimeOptions & opts
)
```


### function Run

```cpp
int Run(
    const RuntimeOptions & opts
)
```


### function HandleSignal

```cpp
void HandleSignal(
    int sig
)
```


### function Configure

```cpp
void Configure(
    std::shared_ptr< Config > conf
)
```

Configure given the specified config. 

### function Reload

```cpp
void Reload()
```

handle SIGHUP 

### function IsUp

```cpp
bool IsUp() const
```


### function LooksAlive

```cpp
bool LooksAlive() const
```


### function IsStopping

```cpp
bool IsStopping() const
```


### function CloseAsync

```cpp
void CloseAsync()
```

close async 

### function Wait

```cpp
void Wait()
```

wait until closed and done 

### function CallSafe

```cpp
bool CallSafe(
    std::function< void(void)> f
)
```

call a function in logic thread return true if queued for calling return false if not queued for calling 

### function makeRouter

```cpp
virtual std::shared_ptr< AbstractRouter > makeRouter(
    const std::shared_ptr< EventLoop > & loop
)
```

Creates a router. 

**Reimplemented by**: [llarp::apple::Context::makeRouter](Classes/structllarp_1_1apple_1_1Context.md#function-makerouter)


Can be overridden to allow a different class of router to be created instead. Defaults to [llarp::Router](Classes/structllarp_1_1Router.md). 


### function makeNodeDB

```cpp
virtual std::shared_ptr< NodeDB > makeNodeDB()
```

create the nodedb given our current configs 

### function makeVPNPlatform

```cpp
virtual std::shared_ptr< llarp::vpn::Platform > makeVPNPlatform()
```

create the vpn platform for use in creating network interfaces 

**Reimplemented by**: [llarp::apple::Context::makeVPNPlatform](Classes/structllarp_1_1apple_1_1Context.md#function-makevpnplatform)


## Public Attributes Documentation

### variable crypto

```cpp
std::shared_ptr< Crypto > crypto = nullptr;
```


### variable cryptoManager

```cpp
std::shared_ptr< CryptoManager > cryptoManager = nullptr;
```


### variable router

```cpp
std::shared_ptr< AbstractRouter > router = nullptr;
```


### variable loop

```cpp
std::shared_ptr< EventLoop > loop = nullptr;
```


### variable nodedb

```cpp
std::shared_ptr< NodeDB > nodedb = nullptr;
```


### variable androidFD

```cpp
int androidFD = -1;
```


## Protected Attributes Documentation

### variable config

```cpp
std::shared_ptr< Config > config = nullptr;
```


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

Updated on 2023-04-27 at 04:17:17 +0000