---
title: llarp::layers::platform::PlatformLayer
summary: responsible for bridging the os and the flow layer. 

---

# llarp::layers::platform::PlatformLayer



responsible for bridging the os and the flow layer. 


`#include <platform_layer.hpp>`

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[PlatformLayer](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-platformlayer)**(const [PlatformLayer](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md) & ) =delete |
| | **[PlatformLayer](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-platformlayer)**([PlatformLayer](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md) && ) =delete |
| | **[PlatformLayer](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-platformlayer)**([AbstractRouter](Classes/structllarp_1_1AbstractRouter.md) & router, [flow::FlowLayer](Classes/classllarp_1_1layers_1_1flow_1_1FlowLayer.md) & flow_layer, const [NetworkConfig](Classes/structllarp_1_1NetworkConfig.md) & netconf) |
| void | **[start](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-start)**() |
| void | **[stop](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-stop)**() |
| std::shared_ptr< [vpn::NetworkInterface](Classes/classllarp_1_1vpn_1_1NetworkInterface.md) > | **[vpn_interface](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-vpn-interface)**() const |
| [vpn::IRouteManager](Classes/classllarp_1_1vpn_1_1IRouteManager.md) * | **[route_manager](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-route-manager)**() const |
| void | **[os_traffic](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-os-traffic)**(std::vector< [OSTraffic](Classes/structllarp_1_1layers_1_1platform_1_1OSTraffic.md) > && pkts)<br>called each time we get a bunch of os traffic.  |
| void | **[flow_traffic](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-flow-traffic)**(std::vector< [flow::FlowTraffic](Classes/structllarp_1_1layers_1_1flow_1_1FlowTraffic.md) > && traff)<br>give the platform layer flow layer traffic to write to the os.  |
| void | **[map_remote](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-map-remote)**(std::string name, std::string auth, std::vector< [IPRange](Classes/structllarp_1_1IPRange.md) > ranges, std::optional< [PlatformAddr](Classes/structllarp_1_1layers_1_1platform_1_1PlatformAddr.md) > src =std::nullopt, std::function< void(std::optional< [flow::FlowInfo](Classes/structllarp_1_1layers_1_1flow_1_1FlowInfo.md) >, std::string)> result_handler =nullptr) |
| void | **[map_exit](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-map-exit)**(std::string name, std::string auth, std::vector< [IPRange](Classes/structllarp_1_1IPRange.md) > ranges, std::function< void(bool, std::string)> result_handler)<br>calls map_remote() for exits  |
| void | **[unmap_exit](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-unmap-exit)**([flow::FlowAddr](Classes/classllarp_1_1layers_1_1flow_1_1FlowAddr.md) remote, std::optional< [IPRange](Classes/structllarp_1_1IPRange.md) > range =std::nullopt)<br>unmap an exit from a range  |
| void | **[unmap_all_exits_on_range](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-unmap-all-exits-on-range)**([IPRange](Classes/structllarp_1_1IPRange.md) range)<br>unmap every exit that is mapped to this range.  |
| [PlatformStats](Classes/structllarp_1_1layers_1_1platform_1_1PlatformStats.md) | **[current_stats](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-current-stats)**() const |

## Protected Functions

|                | Name           |
| -------------- | -------------- |
| void | **[on_io](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#function-on-io)**()<br>called once per event loop tick after platform layer event loop polled for and consumed io.  |

## Public Attributes

|                | Name           |
| -------------- | -------------- |
| const std::shared_ptr< [DNSZone](Classes/classllarp_1_1layers_1_1platform_1_1DNSZone.md) > | **[dns](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#variable-dns)** <br>all dns RR we have for our local self.  |
| [AddrMapper](Classes/classllarp_1_1layers_1_1platform_1_1AddrMapper.md) | **[addr_mapper](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#variable-addr-mapper)** <br>holds address mapping state.  |

## Protected Attributes

|                | Name           |
| -------------- | -------------- |
| [AbstractRouter](Classes/structllarp_1_1AbstractRouter.md) & | **[_router](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#variable--router)**  |
| [flow::FlowLayer](Classes/classllarp_1_1layers_1_1flow_1_1FlowLayer.md) & | **[_flow_layer](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#variable--flow-layer)**  |
| std::shared_ptr< [EventLoopWakeup](Classes/classllarp_1_1EventLoopWakeup.md) > | **[_os_send](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#variable--os-send)** <br>called to wake up the loop after we sent things out on the network  |
| std::shared_ptr< [EventLoopWakeup](Classes/classllarp_1_1EventLoopWakeup.md) > | **[_os_recv](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#variable--os-recv)** <br>called to wake up the loop to read os traffic  |
| [NetworkConfig](Classes/structllarp_1_1NetworkConfig.md) | **[_netconf](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#variable--netconf)**  |
| std::shared_ptr< [DNSQueryHandler](Classes/classllarp_1_1layers_1_1platform_1_1DNSQueryHandler.md) > | **[_dns_query_handler](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#variable--dns-query-handler)** <br>handler of dns queries.  |
| std::weak_ptr< [vpn::NetworkInterface](Classes/classllarp_1_1vpn_1_1NetworkInterface.md) > | **[_netif](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#variable--netif)**  |
| [OSTraffic_IO_Base](Classes/classllarp_1_1layers_1_1platform_1_1OSTraffic__IO__Base.md) | **[_io](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#variable--io)**  |

## Friends

|                | Name           |
| -------------- | -------------- |
| struct | **[platform_io_wakeup_handler](Classes/classllarp_1_1layers_1_1platform_1_1PlatformLayer.md#friend-platform-io-wakeup-handler)**  |

## Public Functions Documentation

### function PlatformLayer

```cpp
PlatformLayer(
    const PlatformLayer & 
) =delete
```


### function PlatformLayer

```cpp
PlatformLayer(
    PlatformLayer && 
) =delete
```


### function PlatformLayer

```cpp
PlatformLayer(
    AbstractRouter & router,
    flow::FlowLayer & flow_layer,
    const NetworkConfig & netconf
)
```


### function start

```cpp
void start()
```


### function stop

```cpp
void stop()
```


### function vpn_interface

```cpp
std::shared_ptr< vpn::NetworkInterface > vpn_interface() const
```


### function route_manager

```cpp
vpn::IRouteManager * route_manager() const
```


### function os_traffic

```cpp
void os_traffic(
    std::vector< OSTraffic > && pkts
)
```

called each time we get a bunch of os traffic. 

### function flow_traffic

```cpp
void flow_traffic(
    std::vector< flow::FlowTraffic > && traff
)
```

give the platform layer flow layer traffic to write to the os. 

### function map_remote

```cpp
void map_remote(
    std::string name,
    std::string auth,
    std::vector< IPRange > ranges,
    std::optional< PlatformAddr > src =std::nullopt,
    std::function< void(std::optional< flow::FlowInfo >, std::string)> result_handler =nullptr
)
```


### function map_exit

```cpp
void map_exit(
    std::string name,
    std::string auth,
    std::vector< IPRange > ranges,
    std::function< void(bool, std::string)> result_handler
)
```

calls map_remote() for exits 

### function unmap_exit

```cpp
void unmap_exit(
    flow::FlowAddr remote,
    std::optional< IPRange > range =std::nullopt
)
```

unmap an exit from a range 

### function unmap_all_exits_on_range

```cpp
void unmap_all_exits_on_range(
    IPRange range
)
```

unmap every exit that is mapped to this range. 

### function current_stats

```cpp
PlatformStats current_stats() const
```


## Protected Functions Documentation

### function on_io

```cpp
void on_io()
```

called once per event loop tick after platform layer event loop polled for and consumed io. 

## Public Attributes Documentation

### variable dns

```cpp
const std::shared_ptr< DNSZone > dns;
```

all dns RR we have for our local self. 

### variable addr_mapper

```cpp
AddrMapper addr_mapper;
```

holds address mapping state. 

## Protected Attributes Documentation

### variable _router

```cpp
AbstractRouter & _router;
```


### variable _flow_layer

```cpp
flow::FlowLayer & _flow_layer;
```


### variable _os_send

```cpp
std::shared_ptr< EventLoopWakeup > _os_send;
```

called to wake up the loop after we sent things out on the network 

### variable _os_recv

```cpp
std::shared_ptr< EventLoopWakeup > _os_recv;
```

called to wake up the loop to read os traffic 

### variable _netconf

```cpp
NetworkConfig _netconf;
```


### variable _dns_query_handler

```cpp
std::shared_ptr< DNSQueryHandler > _dns_query_handler;
```

handler of dns queries. 

### variable _netif

```cpp
std::weak_ptr< vpn::NetworkInterface > _netif;
```


### variable _io

```cpp
OSTraffic_IO_Base _io;
```


## Friends

### friend platform_io_wakeup_handler

```cpp
friend struct platform_io_wakeup_handler(
    platform_io_wakeup_handler 
);
```


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

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