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

---

# llarp::dns::Message





Inherits from [llarp::dns::Serialize](Classes/structllarp_1_1dns_1_1Serialize.md)

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[Message](Classes/structllarp_1_1dns_1_1Message.md#function-message)**(const [MessageHeader](Classes/structllarp_1_1dns_1_1MessageHeader.md) & hdr) |
| | **[Message](Classes/structllarp_1_1dns_1_1Message.md#function-message)**(const [Question](Classes/structllarp_1_1dns_1_1Question.md) & question) |
| | **[Message](Classes/structllarp_1_1dns_1_1Message.md#function-message)**([Message](Classes/structllarp_1_1dns_1_1Message.md) && other) |
| | **[Message](Classes/structllarp_1_1dns_1_1Message.md#function-message)**(const [Message](Classes/structllarp_1_1dns_1_1Message.md) & other) |
| virtual util::StatusObject | **[ToJSON](Classes/structllarp_1_1dns_1_1Message.md#function-tojson)**() const override<br>convert this whatever into json  |
| void | **[AddNXReply](Classes/structllarp_1_1dns_1_1Message.md#function-addnxreply)**(RR_TTL_t ttl =1) |
| void | **[AddServFail](Classes/structllarp_1_1dns_1_1Message.md#function-addservfail)**(RR_TTL_t ttl =30) |
| void | **[AddMXReply](Classes/structllarp_1_1dns_1_1Message.md#function-addmxreply)**(std::string name, uint16_t priority, RR_TTL_t ttl =1) |
| void | **[AddCNAMEReply](Classes/structllarp_1_1dns_1_1Message.md#function-addcnamereply)**(std::string name, RR_TTL_t ttl =1) |
| void | **[AddINReply](Classes/structllarp_1_1dns_1_1Message.md#function-addinreply)**([llarp::huint128_t](Classes/structllarp_1_1huint__t.md) addr, bool isV6, RR_TTL_t ttl =1) |
| void | **[AddAReply](Classes/structllarp_1_1dns_1_1Message.md#function-addareply)**(std::string name, RR_TTL_t ttl =1) |
| void | **[AddSRVReply](Classes/structllarp_1_1dns_1_1Message.md#function-addsrvreply)**(std::vector< [SRVData](Classes/structllarp_1_1dns_1_1SRVData.md) > records, RR_TTL_t ttl =1) |
| void | **[AddNSReply](Classes/structllarp_1_1dns_1_1Message.md#function-addnsreply)**(std::string name, RR_TTL_t ttl =1) |
| void | **[AddTXTReply](Classes/structllarp_1_1dns_1_1Message.md#function-addtxtreply)**(std::string value, RR_TTL_t ttl =1) |
| virtual bool | **[Encode](Classes/structllarp_1_1dns_1_1Message.md#function-encode)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf) const override<br>encode entity to buffer  |
| virtual bool | **[Decode](Classes/structllarp_1_1dns_1_1Message.md#function-decode)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf) override<br>decode entity from buffer  |
| [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 |

## Public Attributes

|                | Name           |
| -------------- | -------------- |
| MsgID_t | **[hdr_id](Classes/structllarp_1_1dns_1_1Message.md#variable-hdr-id)**  |
| Fields_t | **[hdr_fields](Classes/structllarp_1_1dns_1_1Message.md#variable-hdr-fields)**  |
| std::vector< [Question](Classes/structllarp_1_1dns_1_1Question.md) > | **[questions](Classes/structllarp_1_1dns_1_1Message.md#variable-questions)**  |
| std::vector< [ResourceRecord](Classes/structllarp_1_1dns_1_1ResourceRecord.md) > | **[answers](Classes/structllarp_1_1dns_1_1Message.md#variable-answers)**  |
| std::vector< [ResourceRecord](Classes/structllarp_1_1dns_1_1ResourceRecord.md) > | **[authorities](Classes/structllarp_1_1dns_1_1Message.md#variable-authorities)**  |
| std::vector< [ResourceRecord](Classes/structllarp_1_1dns_1_1ResourceRecord.md) > | **[additional](Classes/structllarp_1_1dns_1_1Message.md#variable-additional)**  |

## Additional inherited members

**Public Functions inherited from [llarp::dns::Serialize](Classes/structllarp_1_1dns_1_1Serialize.md)**

|                | Name           |
| -------------- | -------------- |
| virtual | **[~Serialize](Classes/structllarp_1_1dns_1_1Serialize.md#function-~serialize)**() =0 |


## Public Functions Documentation

### function Message

```cpp
explicit Message(
    const MessageHeader & hdr
)
```


### function Message

```cpp
explicit Message(
    const Question & question
)
```


### function Message

```cpp
Message(
    Message && other
)
```


### function Message

```cpp
Message(
    const Message & other
)
```


### function ToJSON

```cpp
virtual util::StatusObject ToJSON() const override
```

convert this whatever into json 

**Reimplements**: [llarp::dns::Serialize::ToJSON](Classes/structllarp_1_1dns_1_1Serialize.md#function-tojson)


### function AddNXReply

```cpp
void AddNXReply(
    RR_TTL_t ttl =1
)
```


### function AddServFail

```cpp
void AddServFail(
    RR_TTL_t ttl =30
)
```


### function AddMXReply

```cpp
void AddMXReply(
    std::string name,
    uint16_t priority,
    RR_TTL_t ttl =1
)
```


### function AddCNAMEReply

```cpp
void AddCNAMEReply(
    std::string name,
    RR_TTL_t ttl =1
)
```


### function AddINReply

```cpp
void AddINReply(
    llarp::huint128_t addr,
    bool isV6,
    RR_TTL_t ttl =1
)
```


### function AddAReply

```cpp
void AddAReply(
    std::string name,
    RR_TTL_t ttl =1
)
```


### function AddSRVReply

```cpp
void AddSRVReply(
    std::vector< SRVData > records,
    RR_TTL_t ttl =1
)
```


### function AddNSReply

```cpp
void AddNSReply(
    std::string name,
    RR_TTL_t ttl =1
)
```


### function AddTXTReply

```cpp
void AddTXTReply(
    std::string value,
    RR_TTL_t ttl =1
)
```


### function Encode

```cpp
virtual bool Encode(
    llarp_buffer_t * buf
) const override
```

encode entity to buffer 

**Reimplements**: [llarp::dns::Serialize::Encode](Classes/structllarp_1_1dns_1_1Serialize.md#function-encode)


### function Decode

```cpp
virtual bool Decode(
    llarp_buffer_t * buf
) override
```

decode entity from buffer 

**Reimplements**: [llarp::dns::Serialize::Decode](Classes/structllarp_1_1dns_1_1Serialize.md#function-decode)


### function ToBuffer

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


### function ToString

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


## Public Attributes Documentation

### variable hdr_id

```cpp
MsgID_t hdr_id;
```


### variable hdr_fields

```cpp
Fields_t hdr_fields;
```


### 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 2022-09-01 at 18:16:52 +0000