---
title: llarp::net::Platform
summary: network platform (all methods virtual so it can be mocked by unit tests) 

---

# llarp::net::Platform



network platform (all methods virtual so it can be mocked by unit tests) 


`#include <net.hpp>`

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[Platform](Classes/classllarp_1_1net_1_1Platform.md#function-platform)**() =default |
| virtual | **[~Platform](Classes/classllarp_1_1net_1_1Platform.md#function-~platform)**() =default |
| | **[Platform](Classes/classllarp_1_1net_1_1Platform.md#function-platform)**(const [Platform](Classes/classllarp_1_1net_1_1Platform.md) & ) =delete |
| | **[Platform](Classes/classllarp_1_1net_1_1Platform.md#function-platform)**([Platform](Classes/classllarp_1_1net_1_1Platform.md) && ) =delete |
| virtual std::optional< [SockAddr](Classes/structllarp_1_1SockAddr.md) > | **[AllInterfaces](Classes/classllarp_1_1net_1_1Platform.md#function-allinterfaces)**([SockAddr](Classes/structllarp_1_1SockAddr.md) pubaddr) const =0 |
| [SockAddr](Classes/structllarp_1_1SockAddr.md) | **[Wildcard](Classes/classllarp_1_1net_1_1Platform.md#function-wildcard)**(int af =AF_INET) const |
| [SockAddr](Classes/structllarp_1_1SockAddr.md) | **[WildcardWithPort](Classes/classllarp_1_1net_1_1Platform.md#function-wildcardwithport)**(port_t port, int af =AF_INET) const |
| virtual std::string | **[LoopbackInterfaceName](Classes/classllarp_1_1net_1_1Platform.md#function-loopbackinterfacename)**() const =0 |
| virtual bool | **[HasInterfaceAddress](Classes/classllarp_1_1net_1_1Platform.md#function-hasinterfaceaddress)**(ipaddr_t ip) const =0 |
| bool | **[IsLoopbackAddress](Classes/classllarp_1_1net_1_1Platform.md#function-isloopbackaddress)**(ipaddr_t ip) const<br>return true if ip is considered a loopback address  |
| bool | **[IsWildcardAddress](Classes/classllarp_1_1net_1_1Platform.md#function-iswildcardaddress)**(ipaddr_t ip) const<br>return true if ip is considered a wildcard address  |
| virtual std::optional< std::string > | **[GetBestNetIF](Classes/classllarp_1_1net_1_1Platform.md#function-getbestnetif)**(int af =AF_INET) const =0 |
| std::optional< [SockAddr](Classes/structllarp_1_1SockAddr.md) > | **[MaybeInferPublicAddr](Classes/classllarp_1_1net_1_1Platform.md#function-maybeinferpublicaddr)**(port_t default_port, int af =AF_INET) const |
| virtual std::optional< [IPRange](Classes/structllarp_1_1IPRange.md) > | **[FindFreeRange](Classes/classllarp_1_1net_1_1Platform.md#function-findfreerange)**() const =0 |
| virtual std::optional< std::string > | **[FindFreeTun](Classes/classllarp_1_1net_1_1Platform.md#function-findfreetun)**() const =0 |
| virtual std::optional< [SockAddr](Classes/structllarp_1_1SockAddr.md) > | **[GetInterfaceAddr](Classes/classllarp_1_1net_1_1Platform.md#function-getinterfaceaddr)**(std::string_view ifname, int af =AF_INET) const =0 |
| std::optional< [huint128_t](Classes/structllarp_1_1huint__t.md) > | **[GetInterfaceIPv6Address](Classes/classllarp_1_1net_1_1Platform.md#function-getinterfaceipv6address)**(std::string_view ifname) const |
| bool | **[IsBogon](Classes/classllarp_1_1net_1_1Platform.md#function-isbogon)**(const [SockAddr](Classes/structllarp_1_1SockAddr.md) & addr) const |
| bool | **[IsBogonRange](Classes/classllarp_1_1net_1_1Platform.md#function-isbogonrange)**(const [IPRange](Classes/structllarp_1_1IPRange.md) & range) const |
| bool | **[IsBogonIP](Classes/classllarp_1_1net_1_1Platform.md#function-isbogonip)**(const net::ipaddr_t & addr) const |
| bool | **[IsBogonIP](Classes/classllarp_1_1net_1_1Platform.md#function-isbogonip)**(const [huint128_t](Classes/structllarp_1_1huint__t.md) & addr) const |
| virtual std::optional< int > | **[GetInterfaceIndex](Classes/classllarp_1_1net_1_1Platform.md#function-getinterfaceindex)**(ipaddr_t ip) const =0 |
| virtual std::vector< [InterfaceInfo](Classes/structllarp_1_1net_1_1InterfaceInfo.md) > | **[AllNetworkInterfaces](Classes/classllarp_1_1net_1_1Platform.md#function-allnetworkinterfaces)**() const =0<br>returns a vector holding all of our network interfaces  |
| const [Platform](Classes/classllarp_1_1net_1_1Platform.md) * | **[Default_ptr](Classes/classllarp_1_1net_1_1Platform.md#function-default-ptr)**()<br>get a pointer to our signleton instance used by main lokinet unit test mocks will not call this  |

## Public Functions Documentation

### function Platform

```cpp
Platform() =default
```


### function ~Platform

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


### function Platform

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


### function Platform

```cpp
Platform(
    Platform && 
) =delete
```


### function AllInterfaces

```cpp
virtual std::optional< SockAddr > AllInterfaces(
    SockAddr pubaddr
) const =0
```


### function Wildcard

```cpp
inline SockAddr Wildcard(
    int af =AF_INET
) const
```


### function WildcardWithPort

```cpp
inline SockAddr WildcardWithPort(
    port_t port,
    int af =AF_INET
) const
```


### function LoopbackInterfaceName

```cpp
virtual std::string LoopbackInterfaceName() const =0
```


### function HasInterfaceAddress

```cpp
virtual bool HasInterfaceAddress(
    ipaddr_t ip
) const =0
```


### function IsLoopbackAddress

```cpp
inline bool IsLoopbackAddress(
    ipaddr_t ip
) const
```

return true if ip is considered a loopback address 

### function IsWildcardAddress

```cpp
inline bool IsWildcardAddress(
    ipaddr_t ip
) const
```

return true if ip is considered a wildcard address 

### function GetBestNetIF

```cpp
virtual std::optional< std::string > GetBestNetIF(
    int af =AF_INET
) const =0
```


### function MaybeInferPublicAddr

```cpp
inline std::optional< SockAddr > MaybeInferPublicAddr(
    port_t default_port,
    int af =AF_INET
) const
```


### function FindFreeRange

```cpp
virtual std::optional< IPRange > FindFreeRange() const =0
```


### function FindFreeTun

```cpp
virtual std::optional< std::string > FindFreeTun() const =0
```


### function GetInterfaceAddr

```cpp
virtual std::optional< SockAddr > GetInterfaceAddr(
    std::string_view ifname,
    int af =AF_INET
) const =0
```


### function GetInterfaceIPv6Address

```cpp
inline std::optional< huint128_t > GetInterfaceIPv6Address(
    std::string_view ifname
) const
```


### function IsBogon

```cpp
inline bool IsBogon(
    const SockAddr & addr
) const
```


### function IsBogonRange

```cpp
inline bool IsBogonRange(
    const IPRange & range
) const
```


### function IsBogonIP

```cpp
inline bool IsBogonIP(
    const net::ipaddr_t & addr
) const
```


### function IsBogonIP

```cpp
inline bool IsBogonIP(
    const huint128_t & addr
) const
```


### function GetInterfaceIndex

```cpp
virtual std::optional< int > GetInterfaceIndex(
    ipaddr_t ip
) const =0
```


### function AllNetworkInterfaces

```cpp
virtual std::vector< InterfaceInfo > AllNetworkInterfaces() const =0
```

returns a vector holding all of our network interfaces 

### function Default_ptr

```cpp
static const Platform * Default_ptr()
```

get a pointer to our signleton instance used by main lokinet unit test mocks will not call this 

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

Updated on 2023-01-09 at 16:43:38 +0000