---
title: llarp::dns::Message

---

# llarp::dns::Message





## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[Message](Classes/structllarp_1_1dns_1_1Message.md#function-message)**([byte_view_t](Namespaces/namespacellarp.md#typedef-byte-view-t) & raw)<br>constructs a dns message from a raw dns wire protocol message.  |
| | **[Message](Classes/structllarp_1_1dns_1_1Message.md#function-message)**() =default |
| | **[Message](Classes/structllarp_1_1dns_1_1Message.md#function-message)**(const [Message](Classes/structllarp_1_1dns_1_1Message.md) & ) =default |
| | **[Message](Classes/structllarp_1_1dns_1_1Message.md#function-message)**([Message](Classes/structllarp_1_1dns_1_1Message.md) && ) =default |
| [Message](Classes/structllarp_1_1dns_1_1Message.md) & | **[operator=](Classes/structllarp_1_1dns_1_1Message.md#function-operator=)**(const [Message](Classes/structllarp_1_1dns_1_1Message.md) & ) =default |
| [Message](Classes/structllarp_1_1dns_1_1Message.md) & | **[operator=](Classes/structllarp_1_1dns_1_1Message.md#function-operator=)**([Message](Classes/structllarp_1_1dns_1_1Message.md) && ) =default |
| [Message](Classes/structllarp_1_1dns_1_1Message.md) & | **[nx](Classes/structllarp_1_1dns_1_1Message.md#function-nx)**()<br>mark as not found.  |
| [Message](Classes/structllarp_1_1dns_1_1Message.md) & | **[servfail](Classes/structllarp_1_1dns_1_1Message.md#function-servfail)**()<br>mark as servfail.  |
| [bstring_t](Namespaces/namespacellarp.md#using-bstring-t) | **[encode_dns](Classes/structllarp_1_1dns_1_1Message.md#function-encode-dns)**() const<br>encodes this dns message to dns wire protocol.  |
| util::StatusObject | **[to_json](Classes/structllarp_1_1dns_1_1Message.md#function-to-json)**() const |
| [OwnedBuffer](Classes/structllarp_1_1OwnedBuffer.md) | **[ToBuffer](Classes/structllarp_1_1dns_1_1Message.md#function-tobuffer)**() const |
| std::string | **[ToString](Classes/structllarp_1_1dns_1_1Message.md#function-tostring)**() const |
| template <typename... Args_t\> <br>void | **[add_reply](Classes/structllarp_1_1dns_1_1Message.md#function-add-reply)**(RRType rr_type, Args_t &&... args) |
| void | **[AddNSReply](Classes/structllarp_1_1dns_1_1Message.md#function-addnsreply)**(std::string_view txt, uint32_t ttl =1) |
| void | **[AddTXTReply](Classes/structllarp_1_1dns_1_1Message.md#function-addtxtreply)**(std::string_view txt, uint32_t ttl =1) |
| void | **[AddMXReply](Classes/structllarp_1_1dns_1_1Message.md#function-addmxreply)**(std::string_view name, uint32_t ttl =1) |
| void | **[AddCNAMEReply](Classes/structllarp_1_1dns_1_1Message.md#function-addcnamereply)**(std::string_view name, uint32_t ttl =1) |
| void | **[AddPTRReply](Classes/structllarp_1_1dns_1_1Message.md#function-addptrreply)**(std::string_view name, uint32_t ttl =1) |
| void | **[AddAReply](Classes/structllarp_1_1dns_1_1Message.md#function-addareply)**(net::ipv4addr_t ip, uint32_t ttl =1) |
| void | **[AddSRVReply](Classes/structllarp_1_1dns_1_1Message.md#function-addsrvreply)**(const std::vector< [dns::SRVData](Classes/classllarp_1_1dns_1_1SRVData.md) > & recs, uint32_t ttl =1) |
| void | **[rr_add_ipaddr](Classes/structllarp_1_1dns_1_1Message.md#function-rr-add-ipaddr)**(net::ipaddr_t ip, uint32_t ttl =1) |
| void | **[AddINReply](Classes/structllarp_1_1dns_1_1Message.md#function-addinreply)**(std::string_view addr, uint32_t ttl =1) |

## Public Attributes

|                | Name           |
| -------------- | -------------- |
| [MessageHeader](Classes/structllarp_1_1dns_1_1MessageHeader.md) | **[hdr](Classes/structllarp_1_1dns_1_1Message.md#variable-hdr)**  |
| std::vector< [Question](Classes/structllarp_1_1dns_1_1Question.md) > | **[questions](Classes/structllarp_1_1dns_1_1Message.md#variable-questions)**  |
| std::vector< [ResourceRecord](Classes/classllarp_1_1dns_1_1ResourceRecord.md) > | **[answers](Classes/structllarp_1_1dns_1_1Message.md#variable-answers)**  |
| std::vector< [ResourceRecord](Classes/classllarp_1_1dns_1_1ResourceRecord.md) > | **[authorities](Classes/structllarp_1_1dns_1_1Message.md#variable-authorities)**  |
| std::vector< [ResourceRecord](Classes/classllarp_1_1dns_1_1ResourceRecord.md) > | **[additional](Classes/structllarp_1_1dns_1_1Message.md#variable-additional)**  |

## Public Functions Documentation

### function Message

```cpp
explicit Message(
    byte_view_t & raw
)
```

constructs a dns message from a raw dns wire protocol message. 

raw is modified to contain any remaining data. 


### function Message

```cpp
Message() =default
```


### function Message

```cpp
Message(
    const Message & 
) =default
```


### function Message

```cpp
Message(
    Message && 
) =default
```


### function operator=

```cpp
Message & operator=(
    const Message & 
) =default
```


### function operator=

```cpp
Message & operator=(
    Message && 
) =default
```


### function nx

```cpp
Message & nx()
```

mark as not found. 

### function servfail

```cpp
Message & servfail()
```

mark as servfail. 

### function encode_dns

```cpp
bstring_t encode_dns() const
```

encodes this dns message to dns wire protocol. 

### function to_json

```cpp
util::StatusObject to_json() const
```


### function ToBuffer

```cpp
inline OwnedBuffer ToBuffer() const
```


### function ToString

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


### function add_reply

```cpp
template <typename... Args_t>
inline void add_reply(
    RRType rr_type,
    Args_t &&... args
)
```


### function AddNSReply

```cpp
inline void AddNSReply(
    std::string_view txt,
    uint32_t ttl =1
)
```


### function AddTXTReply

```cpp
inline void AddTXTReply(
    std::string_view txt,
    uint32_t ttl =1
)
```


### function AddMXReply

```cpp
inline void AddMXReply(
    std::string_view name,
    uint32_t ttl =1
)
```


### function AddCNAMEReply

```cpp
inline void AddCNAMEReply(
    std::string_view name,
    uint32_t ttl =1
)
```


### function AddPTRReply

```cpp
inline void AddPTRReply(
    std::string_view name,
    uint32_t ttl =1
)
```


### function AddAReply

```cpp
inline void AddAReply(
    net::ipv4addr_t ip,
    uint32_t ttl =1
)
```


### function AddSRVReply

```cpp
inline void AddSRVReply(
    const std::vector< dns::SRVData > & recs,
    uint32_t ttl =1
)
```


### function rr_add_ipaddr

```cpp
inline void rr_add_ipaddr(
    net::ipaddr_t ip,
    uint32_t ttl =1
)
```


### function AddINReply

```cpp
inline void AddINReply(
    std::string_view addr,
    uint32_t ttl =1
)
```


## Public Attributes Documentation

### variable hdr

```cpp
MessageHeader hdr;
```


### variable questions

```cpp
std::vector< Question > questions;
```


### variable answers

```cpp
std::vector< ResourceRecord > answers;
```


### variable authorities

```cpp
std::vector< ResourceRecord > authorities;
```


### variable additional

```cpp
std::vector< ResourceRecord > additional;
```


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

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