---
title: llarp::dns

---

# llarp::dns



## Namespaces

| Name           |
| -------------- |
| **[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)**  |
| struct | **[llarp::dns::ResourceRecord](Classes/structllarp_1_1dns_1_1ResourceRecord.md)**  |
| struct | **[llarp::dns::Serialize](Classes/structllarp_1_1dns_1_1Serialize.md)** <br>base type for serializable dns entities  |
| 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)**  |
| struct | **[llarp::dns::SRVData](Classes/structllarp_1_1dns_1_1SRVData.md)**  |
| class | **[llarp::dns::UnboundResolver](Classes/classllarp_1_1dns_1_1UnboundResolver.md)**  |

## Types

|                | Name           |
| -------------- | -------------- |
| using uint16_t | **[MsgID_t](Namespaces/namespacellarp_1_1dns.md#using-msgid-t)**  |
| using uint16_t | **[Fields_t](Namespaces/namespacellarp_1_1dns.md#using-fields-t)**  |
| using uint16_t | **[Count_t](Namespaces/namespacellarp_1_1dns.md#using-count-t)**  |
| 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 uint16_t | **[QType_t](Namespaces/namespacellarp_1_1dns.md#using-qtype-t)**  |
| using uint16_t | **[QClass_t](Namespaces/namespacellarp_1_1dns.md#using-qclass-t)**  |
| using uint16_t | **[RRClass_t](Namespaces/namespacellarp_1_1dns.md#using-rrclass-t)**  |
| using uint16_t | **[RRType_t](Namespaces/namespacellarp_1_1dns.md#using-rrtype-t)**  |
| using std::vector< byte_t > | **[RR_RData_t](Namespaces/namespacellarp_1_1dns.md#using-rr-rdata-t)**  |
| using uint32_t | **[RR_TTL_t](Namespaces/namespacellarp_1_1dns.md#using-rr-ttl-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)**  |
| typedef std::tuple< std::string, uint16_t, uint16_t, uint16_t, std::string > | **[SRVTuple](Namespaces/namespacellarp_1_1dns.md#typedef-srvtuple)**  |
| using std::string | **[name_t](Namespaces/namespacellarp_1_1dns.md#using-name-t)**  |
| using std::function< void(const [SockAddr](Classes/structllarp_1_1SockAddr.md) &reply_to, const [SockAddr](Classes/structllarp_1_1SockAddr.md) &from_resolver, [OwnedBuffer](Classes/structllarp_1_1OwnedBuffer.md) buf)> | **[ReplyFunction](Namespaces/namespacellarp_1_1dns.md#using-replyfunction)**  |
| using std::function< void(const [SockAddr](Classes/structllarp_1_1SockAddr.md) &reply_to, const [SockAddr](Classes/structllarp_1_1SockAddr.md) &from_resolver, [Message](Classes/structllarp_1_1dns_1_1Message.md) msg)> | **[FailFunction](Namespaces/namespacellarp_1_1dns.md#using-failfunction)**  |
| using [Null_Platform](Classes/classllarp_1_1dns_1_1Null__Platform.md) | **[Win32_Platform_t](Namespaces/namespacellarp_1_1dns.md#using-win32-platform-t)**  |

## Functions

|                | Name           |
| -------------- | -------------- |
| std::optional< [Message](Classes/structllarp_1_1dns_1_1Message.md) > | **[MaybeParseDNSMessage](Namespaces/namespacellarp_1_1dns.md#function-maybeparsednsmessage)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) buf) |
| std::optional< std::string > | **[DecodeName](Namespaces/namespacellarp_1_1dns.md#function-decodename)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf, bool trimTrailingDot =false)<br>decode name from buffer; return nullopt on failure  |
| bool | **[EncodeNameTo](Namespaces/namespacellarp_1_1dns.md#function-encodenameto)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf, std::string_view name)<br>encode name to buffer  |
| 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) |
| bool | **[EncodeRData](Namespaces/namespacellarp_1_1dns.md#function-encoderdata)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf, const std::vector< byte_t > & rdata) |
| bool | **[DecodeRData](Namespaces/namespacellarp_1_1dns.md#function-decoderdata)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf, std::vector< byte_t > & rdata) |
| 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 uint16_t | **[qTypeSRV](Namespaces/namespacellarp_1_1dns.md#variable-qtypesrv)**  |
| constexpr uint16_t | **[qTypeAAAA](Namespaces/namespacellarp_1_1dns.md#variable-qtypeaaaa)**  |
| constexpr uint16_t | **[qTypeTXT](Namespaces/namespacellarp_1_1dns.md#variable-qtypetxt)**  |
| constexpr uint16_t | **[qTypeMX](Namespaces/namespacellarp_1_1dns.md#variable-qtypemx)**  |
| constexpr uint16_t | **[qTypePTR](Namespaces/namespacellarp_1_1dns.md#variable-qtypeptr)**  |
| constexpr uint16_t | **[qTypeCNAME](Namespaces/namespacellarp_1_1dns.md#variable-qtypecname)**  |
| constexpr uint16_t | **[qTypeNS](Namespaces/namespacellarp_1_1dns.md#variable-qtypens)**  |
| constexpr uint16_t | **[qTypeA](Namespaces/namespacellarp_1_1dns.md#variable-qtypea)**  |
| constexpr uint16_t | **[qClassIN](Namespaces/namespacellarp_1_1dns.md#variable-qclassin)**  |
| constexpr uint16_t | **[flags_QR](Namespaces/namespacellarp_1_1dns.md#variable-flags-qr)**  |
| constexpr uint16_t | **[flags_AA](Namespaces/namespacellarp_1_1dns.md#variable-flags-aa)**  |
| constexpr uint16_t | **[flags_TC](Namespaces/namespacellarp_1_1dns.md#variable-flags-tc)**  |
| constexpr uint16_t | **[flags_RD](Namespaces/namespacellarp_1_1dns.md#variable-flags-rd)**  |
| constexpr uint16_t | **[flags_RA](Namespaces/namespacellarp_1_1dns.md#variable-flags-ra)**  |
| constexpr uint16_t | **[flags_RCODENameError](Namespaces/namespacellarp_1_1dns.md#variable-flags-rcodenameerror)**  |
| constexpr uint16_t | **[flags_RCODEServFail](Namespaces/namespacellarp_1_1dns.md#variable-flags-rcodeservfail)**  |
| constexpr uint16_t | **[flags_RCODENoError](Namespaces/namespacellarp_1_1dns.md#variable-flags-rcodenoerror)**  |

## Types Documentation

### using MsgID_t

```cpp
using llarp::dns::MsgID_t = typedef uint16_t;
```


### using Fields_t

```cpp
using llarp::dns::Fields_t = typedef uint16_t;
```


### using Count_t

```cpp
using llarp::dns::Count_t = typedef uint16_t;
```


### using NM_Platform_t

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


### using QType_t

```cpp
using llarp::dns::QType_t = typedef uint16_t;
```


### using QClass_t

```cpp
using llarp::dns::QClass_t = typedef uint16_t;
```


### using RRClass_t

```cpp
using llarp::dns::RRClass_t = typedef uint16_t;
```


### using RRType_t

```cpp
using llarp::dns::RRType_t = typedef uint16_t;
```


### using RR_RData_t

```cpp
using llarp::dns::RR_RData_t = typedef std::vector<byte_t>;
```


### using RR_TTL_t

```cpp
using llarp::dns::RR_TTL_t = typedef uint32_t;
```


### using SD_Platform_t

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


### typedef SRVTuple

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


### using name_t

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


### using ReplyFunction

```cpp
using llarp::dns::ReplyFunction = typedef std::function<void(const SockAddr& reply_to, const SockAddr& from_resolver, OwnedBuffer buf)>;
```


### using FailFunction

```cpp
using llarp::dns::FailFunction = typedef std::function<void(const SockAddr& reply_to, const SockAddr& from_resolver, Message msg)>;
```


### using Win32_Platform_t

```cpp
using llarp::dns::Win32_Platform_t = typedef Null_Platform;
```



## Functions Documentation

### function MaybeParseDNSMessage

```cpp
std::optional< Message > MaybeParseDNSMessage(
    llarp_buffer_t buf
)
```


### function DecodeName

```cpp
std::optional< std::string > DecodeName(
    llarp_buffer_t * buf,
    bool trimTrailingDot =false
)
```

decode name from buffer; return nullopt on failure 

### function EncodeNameTo

```cpp
bool EncodeNameTo(
    llarp_buffer_t * buf,
    std::string_view name
)
```

encode name to buffer 

### function DecodePTR

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


### function NameIsReserved

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


### function EncodeRData

```cpp
bool EncodeRData(
    llarp_buffer_t * buf,
    const std::vector< byte_t > & rdata
)
```


### function DecodeRData

```cpp
bool DecodeRData(
    llarp_buffer_t * buf,
    std::vector< byte_t > & rdata
)
```


### 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 qTypeSRV

```cpp
constexpr uint16_t qTypeSRV = 33;
```


### variable qTypeAAAA

```cpp
constexpr uint16_t qTypeAAAA = 28;
```


### variable qTypeTXT

```cpp
constexpr uint16_t qTypeTXT = 16;
```


### variable qTypeMX

```cpp
constexpr uint16_t qTypeMX = 15;
```


### variable qTypePTR

```cpp
constexpr uint16_t qTypePTR = 12;
```


### variable qTypeCNAME

```cpp
constexpr uint16_t qTypeCNAME = 5;
```


### variable qTypeNS

```cpp
constexpr uint16_t qTypeNS = 2;
```


### variable qTypeA

```cpp
constexpr uint16_t qTypeA = 1;
```


### variable qClassIN

```cpp
constexpr uint16_t qClassIN = 1;
```


### variable flags_QR

```cpp
constexpr uint16_t flags_QR = (1 << 15);
```


### variable flags_AA

```cpp
constexpr uint16_t flags_AA = (1 << 10);
```


### variable flags_TC

```cpp
constexpr uint16_t flags_TC = (1 << 9);
```


### variable flags_RD

```cpp
constexpr uint16_t flags_RD = (1 << 8);
```


### variable flags_RA

```cpp
constexpr uint16_t flags_RA = (1 << 7);
```


### variable flags_RCODENameError

```cpp
constexpr uint16_t flags_RCODENameError = (3);
```


### variable flags_RCODEServFail

```cpp
constexpr uint16_t flags_RCODEServFail = (2);
```


### variable flags_RCODENoError

```cpp
constexpr uint16_t flags_RCODENoError = (0);
```





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

Updated on 2022-09-10 at 18:17:13 +0000