---
title: llarp::layers::platform::OSTraffic_IO_Base

---

# llarp::layers::platform::OSTraffic_IO_Base





## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[OSTraffic_IO_Base](Classes/classllarp_1_1layers_1_1platform_1_1OSTraffic__IO__Base.md#function-ostraffic-io-base)**(const EventLoop_ptr & ) |
| constexpr const [PlatformAddr](Classes/structllarp_1_1layers_1_1platform_1_1PlatformAddr.md) & | **[our_platform_addr](Classes/classllarp_1_1layers_1_1platform_1_1OSTraffic__IO__Base.md#function-our-platform-addr)**() const<br>get the platform address of the underlying device managed.  |
| void | **[attach](Classes/classllarp_1_1layers_1_1platform_1_1OSTraffic__IO__Base.md#function-attach)**(std::shared_ptr< [vpn::NetworkInterface](Classes/classllarp_1_1vpn_1_1NetworkInterface.md) > netif, std::shared_ptr< [EventLoopWakeup](Classes/classllarp_1_1EventLoopWakeup.md) > wakeup_recv)<br>attach to a vpn interface.  |
| std::vector< [OSTraffic](Classes/structllarp_1_1layers_1_1platform_1_1OSTraffic.md) > | **[read_platform_traffic](Classes/classllarp_1_1layers_1_1platform_1_1OSTraffic__IO__Base.md#function-read-platform-traffic)**()<br>read from the os.  |
| void | **[write_platform_traffic](Classes/classllarp_1_1layers_1_1platform_1_1OSTraffic__IO__Base.md#function-write-platform-traffic)**(std::vector< [OSTraffic](Classes/structllarp_1_1layers_1_1platform_1_1OSTraffic.md) > && traff)<br>write traffic to the os.  |
| void | **[detach](Classes/classllarp_1_1layers_1_1platform_1_1OSTraffic__IO__Base.md#function-detach)**()<br>stop all future io and detach from event loop.  |

## Protected Attributes

|                | Name           |
| -------------- | -------------- |
| std::weak_ptr< [EventLoop](Classes/classllarp_1_1EventLoop.md) > | **[_loop](Classes/classllarp_1_1layers_1_1platform_1_1OSTraffic__IO__Base.md#variable--loop)**  |
| std::shared_ptr< [vpn::NetworkInterface](Classes/classllarp_1_1vpn_1_1NetworkInterface.md) > | **[_netif](Classes/classllarp_1_1layers_1_1platform_1_1OSTraffic__IO__Base.md#variable--netif)**  |

## Public Functions Documentation

### function OSTraffic_IO_Base

```cpp
explicit OSTraffic_IO_Base(
    const EventLoop_ptr & 
)
```


### function our_platform_addr

```cpp
inline constexpr const PlatformAddr & our_platform_addr() const
```

get the platform address of the underlying device managed. 

### function attach

```cpp
void attach(
    std::shared_ptr< vpn::NetworkInterface > netif,
    std::shared_ptr< EventLoopWakeup > wakeup_recv
)
```

attach to a vpn interface. 

sets up io handlers. idempotently wakes up wakeup_recv when we get packets read. 


### function read_platform_traffic

```cpp
std::vector< OSTraffic > read_platform_traffic()
```

read from the os. 

this MUST NOT have any internal userland buffering from previous calls to [read_platform_traffic()](Classes/classllarp_1_1layers_1_1platform_1_1OSTraffic__IO__Base.md#function-read-platform-traffic). 


### function write_platform_traffic

```cpp
void write_platform_traffic(
    std::vector< OSTraffic > && traff
)
```

write traffic to the os. 

### function detach

```cpp
void detach()
```

stop all future io and detach from event loop. 

## Protected Attributes Documentation

### variable _loop

```cpp
std::weak_ptr< EventLoop > _loop;
```


### variable _netif

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


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

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