---
title: llarp::dns

---

# llarp::dns



## Namespaces

| Name           |
| -------------- |
| **[llarp::dns::bits](Namespaces/namespacellarp_1_1dns_1_1bits.md)**  |
| **[llarp::dns::nm](Namespaces/namespacellarp_1_1dns_1_1nm.md)**  |
| **[llarp::dns::sd](Namespaces/namespacellarp_1_1dns_1_1sd.md)**  |

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::dns::MessageHeader](Classes/structllarp_1_1dns_1_1MessageHeader.md)**  |
| struct | **[llarp::dns::Message](Classes/structllarp_1_1dns_1_1Message.md)**  |
| class | **[llarp::dns::I_Platform](Classes/classllarp_1_1dns_1_1I__Platform.md)** <br>sets dns settings in a platform dependant way  |
| class | **[llarp::dns::Null_Platform](Classes/classllarp_1_1dns_1_1Null__Platform.md)** <br>a dns platform does silently does nothing, successfully  |
| class | **[llarp::dns::Multi_Platform](Classes/classllarp_1_1dns_1_1Multi__Platform.md)** <br>a collection of dns platforms that are tried in order when setting dns  |
| struct | **[llarp::dns::Question](Classes/structllarp_1_1dns_1_1Question.md)**  |
| class | **[llarp::dns::RData](Classes/classllarp_1_1dns_1_1RData.md)**  |
| class | **[llarp::dns::ResourceRecord](Classes/classllarp_1_1dns_1_1ResourceRecord.md)**  |
| class | **[llarp::dns::QueryJob_Base](Classes/classllarp_1_1dns_1_1QueryJob__Base.md)** <br>a job handling 1 dns query  |
| class | **[llarp::dns::PacketSource_Base](Classes/classllarp_1_1dns_1_1PacketSource__Base.md)**  |
| class | **[llarp::dns::PacketSource_Wrapper](Classes/classllarp_1_1dns_1_1PacketSource__Wrapper.md)** <br>a packet source which will override the sendto function of an wrapped packet source to construct a raw ip packet as a reply  |
| class | **[llarp::dns::QueryJob](Classes/classllarp_1_1dns_1_1QueryJob.md)** <br>non complex implementation of [QueryJob_Base](Classes/classllarp_1_1dns_1_1QueryJob__Base.md) for use in things that only ever called on the mainloop thread  |
| class | **[llarp::dns::Resolver_Base](Classes/classllarp_1_1dns_1_1Resolver__Base.md)** <br>handler of dns query hooking intercepts dns for internal processing  |
| class | **[llarp::dns::Server](Classes/classllarp_1_1dns_1_1Server.md)**  |
| class | **[llarp::dns::SRVData](Classes/classllarp_1_1dns_1_1SRVData.md)**  |

## Types

|                | Name           |
| -------------- | -------------- |
| enum class uint16_t | **[RRType](Namespaces/namespacellarp_1_1dns.md#enum-rrtype)** { SRV = 33, AAAA = 28, TXT = 16, MX = 15, PTR = 12, CNAME = 5, NS = 2, A = 1}<br>resource record types enum.  |
| using std::conditional_t< false, [nm::Platform](Classes/classllarp_1_1dns_1_1nm_1_1Platform.md), [Null_Platform](Classes/classllarp_1_1dns_1_1Null__Platform.md) > | **[NM_Platform_t](Namespaces/namespacellarp_1_1dns.md#using-nm-platform-t)**  |
| using std::conditional_t< [llarp::platform::has_systemd](Namespaces/namespacellarp_1_1platform.md#variable-has-systemd), [sd::Platform](Classes/classllarp_1_1dns_1_1sd_1_1Platform.md), [Null_Platform](Classes/classllarp_1_1dns_1_1Null__Platform.md) > | **[SD_Platform_t](Namespaces/namespacellarp_1_1dns.md#using-sd-platform-t)**  |
| using std::tuple< std::string, uint16_t, uint16_t, uint16_t, std::string > | **[SRVTuple](Namespaces/namespacellarp_1_1dns.md#using-srvtuple)**  |
| using std::string | **[name_t](Namespaces/namespacellarp_1_1dns.md#using-name-t)**  |

## Functions

|                | Name           |
| -------------- | -------------- |
| bool | **[is_lokinet_tld](Namespaces/namespacellarp_1_1dns.md#function-is-lokinet-tld)**(std::string_view str)<br>return true if this tld is a lokinet tld.  |
| std::optional< [huint128_t](Classes/structllarp_1_1huint__t.md) > | **[DecodePTR](Namespaces/namespacellarp_1_1dns.md#function-decodeptr)**(std::string_view name) |
| bool | **[NameIsReserved](Namespaces/namespacellarp_1_1dns.md#function-nameisreserved)**(std::string_view name) |
| [bstring_t](Namespaces/namespacellarp.md#using-bstring-t) | **[encode_dns_labels](Namespaces/namespacellarp_1_1dns.md#function-encode-dns-labels)**(std::vector< std::string_view > labels)<br>encode a series of dns labels into dns wire protocol.  |
| [bstring_t](Namespaces/namespacellarp.md#using-bstring-t) | **[encode_dns_labels](Namespaces/namespacellarp_1_1dns.md#function-encode-dns-labels)**(std::vector< std::string > labels)<br>encode a series of dns labels into dns wire protocol.  |
| [bstring_t](Namespaces/namespacellarp.md#using-bstring-t) | **[encode_dns_name](Namespaces/namespacellarp_1_1dns.md#function-encode-dns-name)**(std::string_view name)<br>encode a dns name in dotted form and encode it to dns wire protocol.  |
| std::vector< std::string > | **[decode_dns_labels](Namespaces/namespacellarp_1_1dns.md#function-decode-dns-labels)**([byte_view_t](Namespaces/namespacellarp.md#typedef-byte-view-t) & buf)<br>decode dns lables from dns wire protocol  |
| std::vector< std::string_view > | **[decode_dns_label_views](Namespaces/namespacellarp_1_1dns.md#function-decode-dns-label-views)**([byte_view_t](Namespaces/namespacellarp.md#typedef-byte-view-t) & buf)<br>decode dns lables from dns wire protocol, no copy version.  |
| template <typename T \> <br>auto | **[split_dns_name](Namespaces/namespacellarp_1_1dns.md#function-split-dns-name)**(const T & name)<br>named helper functiopn to split a dns name into labels.  |
| std::optional< RRType > | **[get_rr_type](Namespaces/namespacellarp_1_1dns.md#function-get-rr-type)**(uint16_t i) |
| std::string | **[ToString](Namespaces/namespacellarp_1_1dns.md#function-tostring)**(RRType t) |
| bool | **[decode_name](Namespaces/namespacellarp_1_1dns.md#function-decode-name)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf, name_t & name)<br>decode name from buffer  |
| bool | **[encode_name](Namespaces/namespacellarp_1_1dns.md#function-encode-name)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf, const name_t & name)<br>encode name to buffer  |

## Attributes

|                | Name           |
| -------------- | -------------- |
| constexpr auto | **[max_dns_label_size](Namespaces/namespacellarp_1_1dns.md#variable-max-dns-label-size)** <br>the max size of one dns label in bytes.  |
| constexpr auto | **[qTypePTR](Namespaces/namespacellarp_1_1dns.md#variable-qtypeptr)**  |
| constexpr auto | **[qTypeA](Namespaces/namespacellarp_1_1dns.md#variable-qtypea)**  |
| constexpr auto | **[qTypeAAAA](Namespaces/namespacellarp_1_1dns.md#variable-qtypeaaaa)**  |
| constexpr auto | **[qTypeSRV](Namespaces/namespacellarp_1_1dns.md#variable-qtypesrv)**  |
| constexpr auto | **[qTypeCNAME](Namespaces/namespacellarp_1_1dns.md#variable-qtypecname)**  |
| constexpr auto | **[qTypeMX](Namespaces/namespacellarp_1_1dns.md#variable-qtypemx)**  |
| constexpr auto | **[qTypeNS](Namespaces/namespacellarp_1_1dns.md#variable-qtypens)**  |

## Types Documentation

### enum RRType

| Enumerator | Value | Description |
| ---------- | ----- | ----------- |
| SRV | 33|   |
| AAAA | 28|   |
| TXT | 16|   |
| MX | 15|   |
| PTR | 12|   |
| CNAME | 5|   |
| NS | 2|   |
| A | 1|   |



resource record types enum. 

### using NM_Platform_t

```cpp
using llarp::dns::NM_Platform_t = typedef std::conditional_t<false, nm::Platform, Null_Platform>;
```


### using SD_Platform_t

```cpp
using llarp::dns::SD_Platform_t = typedef std::conditional_t<llarp::platform::has_systemd, sd::Platform, Null_Platform>;
```


### using SRVTuple

```cpp
using llarp::dns::SRVTuple = typedef std::tuple<std::string, uint16_t, uint16_t, uint16_t, std::string>;
```


### using name_t

```cpp
using llarp::dns::name_t = typedef std::string;
```



## Functions Documentation

### function is_lokinet_tld

```cpp
inline bool is_lokinet_tld(
    std::string_view str
)
```

return true if this tld is a lokinet tld. 

### function DecodePTR

```cpp
std::optional< huint128_t > DecodePTR(
    std::string_view name
)
```


### function NameIsReserved

```cpp
bool NameIsReserved(
    std::string_view name
)
```


### function encode_dns_labels

```cpp
bstring_t encode_dns_labels(
    std::vector< std::string_view > labels
)
```

encode a series of dns labels into dns wire protocol. 

### function encode_dns_labels

```cpp
bstring_t encode_dns_labels(
    std::vector< std::string > labels
)
```

encode a series of dns labels into dns wire protocol. 

### function encode_dns_name

```cpp
bstring_t encode_dns_name(
    std::string_view name
)
```

encode a dns name in dotted form and encode it to dns wire protocol. 

### function decode_dns_labels

```cpp
std::vector< std::string > decode_dns_labels(
    byte_view_t & buf
)
```

decode dns lables from dns wire protocol 

### function decode_dns_label_views

```cpp
std::vector< std::string_view > decode_dns_label_views(
    byte_view_t & buf
)
```

decode dns lables from dns wire protocol, no copy version. 

### function split_dns_name

```cpp
template <typename T >
auto split_dns_name(
    const T & name
)
```

named helper functiopn to split a dns name into labels. 

### function get_rr_type

```cpp
std::optional< RRType > get_rr_type(
    uint16_t i
)
```


### function ToString

```cpp
std::string ToString(
    RRType t
)
```


### function decode_name

```cpp
bool decode_name(
    llarp_buffer_t * buf,
    name_t & name
)
```

decode name from buffer 

### function encode_name

```cpp
bool encode_name(
    llarp_buffer_t * buf,
    const name_t & name
)
```

encode name to buffer 


## Attributes Documentation

### variable max_dns_label_size

```cpp
constexpr auto max_dns_label_size = 63;
```

the max size of one dns label in bytes. 

### variable qTypePTR

```cpp
constexpr auto qTypePTR = to_underlying(RRType::PTR);
```


### variable qTypeA

```cpp
constexpr auto qTypeA = to_underlying(RRType::A);
```


### variable qTypeAAAA

```cpp
constexpr auto qTypeAAAA = to_underlying(RRType::AAAA);
```


### variable qTypeSRV

```cpp
constexpr auto qTypeSRV = to_underlying(RRType::SRV);
```


### variable qTypeCNAME

```cpp
constexpr auto qTypeCNAME = to_underlying(RRType::CNAME);
```


### variable qTypeMX

```cpp
constexpr auto qTypeMX = to_underlying(RRType::MX);
```


### variable qTypeNS

```cpp
constexpr auto qTypeNS = to_underlying(RRType::NS);
```





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

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