---
title: llarp::IPRange

---

# llarp::IPRange





## Public Types

|                | Name           |
| -------------- | -------------- |
| using [huint128_t](Classes/structllarp_1_1huint__t.md) | **[Addr_t](Classes/structllarp_1_1IPRange.md#using-addr-t)**  |

## Public Functions

|                | Name           |
| -------------- | -------------- |
| constexpr | **[IPRange](Classes/structllarp_1_1IPRange.md#function-iprange)**() |
| constexpr | **[IPRange](Classes/structllarp_1_1IPRange.md#function-iprange)**([huint128_t](Classes/structllarp_1_1huint__t.md) address, [huint128_t](Classes/structllarp_1_1huint__t.md) netmask) |
| | **[IPRange](Classes/structllarp_1_1IPRange.md#function-iprange)**(std::string _range) |
| constexpr bool | **[IsV4](Classes/structllarp_1_1IPRange.md#function-isv4)**() const<br>return true if this iprange is in the IPv4 mapping range for containing ipv4 addresses  |
| constexpr int | **[Family](Classes/structllarp_1_1IPRange.md#function-family)**() const<br>get address family  |
| constexpr int | **[HostmaskBits](Classes/structllarp_1_1IPRange.md#function-hostmaskbits)**() const<br>return the number of bits set in the hostmask  |
| constexpr bool | **[intersects_with](Classes/structllarp_1_1IPRange.md#function-intersects-with)**(const [IPRange](Classes/structllarp_1_1IPRange.md) & other) const<br>return true if our range and other intersect  |
| constexpr bool | **[operator*](Classes/structllarp_1_1IPRange.md#function-operator*)**(const [IPRange](Classes/structllarp_1_1IPRange.md) & other) const<br>calls [intersects_with()](Classes/structllarp_1_1IPRange.md#function-intersects-with) |
| constexpr bool | **[Contains](Classes/structllarp_1_1IPRange.md#function-contains)**(const [IPRange](Classes/structllarp_1_1IPRange.md) & other) const<br>return true if the other range is inside ( subset of ) our range  |
| constexpr bool | **[Contains](Classes/structllarp_1_1IPRange.md#function-contains)**(const [Addr_t](Classes/structllarp_1_1huint__t.md) & ip) const<br>return true if ip is contained in this ip range  |
| constexpr bool | **[Contains](Classes/structllarp_1_1IPRange.md#function-contains)**(const [huint32_t](Classes/structllarp_1_1huint__t.md) & ip) const<br>return true if we are a ipv4 range and contains this ip  |
| bool | **[Contains](Classes/structllarp_1_1IPRange.md#function-contains)**(const net::ipaddr_t & ip) const |
| constexpr [huint128_t](Classes/structllarp_1_1huint__t.md) | **[HighestAddr](Classes/structllarp_1_1IPRange.md#function-highestaddr)**() const<br>get the highest address on this range  |
| bool | **[operator<](Classes/structllarp_1_1IPRange.md#function-operator<)**(const [IPRange](Classes/structllarp_1_1IPRange.md) & other) const |
| bool | **[operator==](Classes/structllarp_1_1IPRange.md#function-operator==)**(const [IPRange](Classes/structllarp_1_1IPRange.md) & other) const |
| std::string | **[ToString](Classes/structllarp_1_1IPRange.md#function-tostring)**() const |
| std::string | **[BaseAddressString](Classes/structllarp_1_1IPRange.md#function-baseaddressstring)**() const |
| std::string | **[NetmaskString](Classes/structllarp_1_1IPRange.md#function-netmaskstring)**() const |
| bool | **[FromString](Classes/structllarp_1_1IPRange.md#function-fromstring)**(std::string str) |
| bool | **[BEncode](Classes/structllarp_1_1IPRange.md#function-bencode)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf) const |
| bool | **[BDecode](Classes/structllarp_1_1IPRange.md#function-bdecode)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf) |
| constexpr [IPRange](Classes/structllarp_1_1IPRange.md) | **[V4MappedRange](Classes/structllarp_1_1IPRange.md#function-v4mappedrange)**() |
| constexpr [IPRange](Classes/structllarp_1_1IPRange.md) | **[FromIPv4](Classes/structllarp_1_1IPRange.md#function-fromipv4)**(byte_t a, byte_t b, byte_t c, byte_t d, byte_t mask) |
| [IPRange](Classes/structllarp_1_1IPRange.md) | **[FromIPv4](Classes/structllarp_1_1IPRange.md#function-fromipv4)**(net::ipv4addr_t addr, byte_t mask) |
| std::optional< [IPRange](Classes/structllarp_1_1IPRange.md) > | **[FindPrivateRange](Classes/structllarp_1_1IPRange.md#function-findprivaterange)**(const std::list< [IPRange](Classes/structllarp_1_1IPRange.md) > & excluding)<br>Finds a free private use range not overlapping the given ranges.  |

## Public Attributes

|                | Name           |
| -------------- | -------------- |
| [huint128_t](Classes/structllarp_1_1huint__t.md) | **[addr](Classes/structllarp_1_1IPRange.md#variable-addr)**  |
| [huint128_t](Classes/structllarp_1_1huint__t.md) | **[netmask_bits](Classes/structllarp_1_1IPRange.md#variable-netmask-bits)**  |

## Public Types Documentation

### using Addr_t

```cpp
using llarp::IPRange::Addr_t =  huint128_t;
```


## Public Functions Documentation

### function IPRange

```cpp
inline constexpr IPRange()
```


### function IPRange

```cpp
inline constexpr IPRange(
    huint128_t address,
    huint128_t netmask
)
```


### function IPRange

```cpp
inline explicit IPRange(
    std::string _range
)
```


### function IsV4

```cpp
inline constexpr bool IsV4() const
```

return true if this iprange is in the IPv4 mapping range for containing ipv4 addresses 

### function Family

```cpp
inline constexpr int Family() const
```

get address family 

### function HostmaskBits

```cpp
inline constexpr int HostmaskBits() const
```

return the number of bits set in the hostmask 

### function intersects_with

```cpp
inline constexpr bool intersects_with(
    const IPRange & other
) const
```

return true if our range and other intersect 

### function operator*

```cpp
inline constexpr bool operator*(
    const IPRange & other
) const
```

calls [intersects_with()](Classes/structllarp_1_1IPRange.md#function-intersects-with)

### function Contains

```cpp
inline constexpr bool Contains(
    const IPRange & other
) const
```

return true if the other range is inside ( subset of ) our range 

### function Contains

```cpp
inline constexpr bool Contains(
    const Addr_t & ip
) const
```

return true if ip is contained in this ip range 

### function Contains

```cpp
inline constexpr bool Contains(
    const huint32_t & ip
) const
```

return true if we are a ipv4 range and contains this ip 

### function Contains

```cpp
inline bool Contains(
    const net::ipaddr_t & ip
) const
```


### function HighestAddr

```cpp
inline constexpr huint128_t HighestAddr() const
```

get the highest address on this range 

### function operator<

```cpp
inline bool operator<(
    const IPRange & other
) const
```


### function operator==

```cpp
inline bool operator==(
    const IPRange & other
) const
```


### function ToString

```cpp
inline std::string ToString() const
```


### function BaseAddressString

```cpp
std::string BaseAddressString() const
```


### function NetmaskString

```cpp
std::string NetmaskString() const
```


### function FromString

```cpp
bool FromString(
    std::string str
)
```


### function BEncode

```cpp
bool BEncode(
    llarp_buffer_t * buf
) const
```


### function BDecode

```cpp
bool BDecode(
    llarp_buffer_t * buf
)
```


### function V4MappedRange

```cpp
static inline constexpr IPRange V4MappedRange()
```


### function FromIPv4

```cpp
static inline constexpr IPRange FromIPv4(
    byte_t a,
    byte_t b,
    byte_t c,
    byte_t d,
    byte_t mask
)
```


### function FromIPv4

```cpp
static inline IPRange FromIPv4(
    net::ipv4addr_t addr,
    byte_t mask
)
```


### function FindPrivateRange

```cpp
static std::optional< IPRange > FindPrivateRange(
    const std::list< IPRange > & excluding
)
```

Finds a free private use range not overlapping the given ranges. 

## Public Attributes Documentation

### variable addr

```cpp
huint128_t addr = {0};
```


### variable netmask_bits

```cpp
huint128_t netmask_bits = {0};
```


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

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