DwmDns-0.1.0
Dwm::Dns::MessageHeader Class Reference

Encapsulates a DNS message header. More...

#include <DwmDnsMessageHeader.hh>

Public Member Functions

 MessageHeader ()
 constructor
 
bool operator== (const MessageHeader &messageHeader) const
 Equal-to operator. Mostly here for unit tests.
 
void Clear ()
 Clears the message header.
 
uint16_t Id () const
 Returns the message ID.
 
uint16_t Id (uint16_t id)
 Sets and returns the message ID.
 
bool IsResponse () const
 Returns true if the message is a response, false if the message is a query. More...
 
bool IsResponse (bool isResponse)
 If isResponse is true, sets the message to be a response. More...
 
uint8_t OpCode () const
 Returns the OPCODE.
 
uint8_t OpCode (uint8_t opcode)
 Sets and returns the OPCODE.
 
bool IsAuthoritativeAnswer () const
 Returns true if the message is authoritative. More...
 
bool IsAuthoritativeAnswer (bool isAuthoritative)
 If isAuthoritative is true, sets a response message as authoritative. More...
 
bool IsTruncated () const
 Returns true if the message was truncated.
 
bool IsTruncated (bool isTruncated)
 If isTruncated is true, set the truncated bit in the header, indicating the message (a response) was truncated. More...
 
bool RecursionDesired () const
 Returns true if recursion is desired.
 
bool RecursionDesired (bool recursionDesired)
 Sets the recursion desired bit in the header. More...
 
bool RecursionAvailable () const
 Returns the recursion available bit in the header.
 
bool RecursionAvailable (bool recursionAvailable)
 Sets and returns the recursion available bit in the header.
 
uint8_t Z () const
 
uint8_t Z (uint8_t z)
 
uint8_t ResponseCode () const
 Returns the response code.
 
uint8_t ResponseCode (uint8_t responseCode)
 Sets and returns the response code.
 
uint16_t QuestionCount () const
 Returns the question count.
 
uint16_t QuestionCount (uint16_t questionCount)
 Sets and returns the question count.
 
uint16_t AnswerCount () const
 Returns the answer count, i.e. More...
 
uint16_t AnswerCount (uint16_t answerCount)
 Sets and returns the answer count, i.e. More...
 
uint16_t AuthorityCount () const
 Returns the authority count, i.e. More...
 
uint16_t AuthorityCount (uint16_t authorityCount)
 Sets and returns the authority count, i.e. More...
 
uint16_t AdditionalCount () const
 Returns the additional count, i.e. More...
 
uint16_t AdditionalCount (uint16_t additionalCount)
 Sets and returns the additional count, i.e. More...
 
uint8_t * Encode (uint8_t *pkt, uint8_t *ptr, uint16_t pktlen) const
 Encodes the header for transport. More...
 
const uint8_t * Decode (const uint8_t *pkt, const uint8_t *ptr, uint16_t pktlen)
 Decodes the encoded header starting at ptr inside a buffer pkt of length pktlen. More...
 

Detailed Description

Encapsulates a DNS message header.

See RFC1035 for details.

Member Function Documentation

◆ AdditionalCount() [1/2]

uint16_t Dwm::Dns::MessageHeader::AdditionalCount ( ) const

Returns the additional count, i.e.

the number of resource records in the additional section of the message.

◆ AdditionalCount() [2/2]

uint16_t Dwm::Dns::MessageHeader::AdditionalCount ( uint16_t  additionalCount)

Sets and returns the additional count, i.e.

the number of resource records in the additional section of the message.

◆ AnswerCount() [1/2]

uint16_t Dwm::Dns::MessageHeader::AnswerCount ( ) const

Returns the answer count, i.e.

the number of records in the authority section of the message.

◆ AnswerCount() [2/2]

uint16_t Dwm::Dns::MessageHeader::AnswerCount ( uint16_t  answerCount)

Sets and returns the answer count, i.e.

the number of records in the authority section of the message.

◆ AuthorityCount() [1/2]

uint16_t Dwm::Dns::MessageHeader::AuthorityCount ( ) const

Returns the authority count, i.e.

the number of resource records in the authority sectino of the message.

◆ AuthorityCount() [2/2]

uint16_t Dwm::Dns::MessageHeader::AuthorityCount ( uint16_t  authorityCount)

Sets and returns the authority count, i.e.

the number of resource records in the authority sectino of the message.

◆ Decode()

const uint8_t* Dwm::Dns::MessageHeader::Decode ( const uint8_t *  pkt,
const uint8_t *  ptr,
uint16_t  pktlen 
)

Decodes the encoded header starting at ptr inside a buffer pkt of length pktlen.

Returns the address jsut beyond the encoded header in pkt on success. Throws std::out_of_range if pkt was too short to contain an encoded header.

◆ Encode()

uint8_t* Dwm::Dns::MessageHeader::Encode ( uint8_t *  pkt,
uint8_t *  ptr,
uint16_t  pktlen 
) const

Encodes the header for transport.

pkt must point to the start of a buffer of length pktlen, and the encoded header will be placed at ptr. Returns the address just beyond the end of the encoded header in buf on success. Throws std::out_of_range if there is not enough space in pkt to contain the encoded header.

◆ IsAuthoritativeAnswer() [1/2]

bool Dwm::Dns::MessageHeader::IsAuthoritativeAnswer ( ) const

Returns true if the message is authoritative.

Only valid for responses.

◆ IsAuthoritativeAnswer() [2/2]

bool Dwm::Dns::MessageHeader::IsAuthoritativeAnswer ( bool  isAuthoritative)

If isAuthoritative is true, sets a response message as authoritative.

◆ IsResponse() [1/2]

bool Dwm::Dns::MessageHeader::IsResponse ( ) const

Returns true if the message is a response, false if the message is a query.

◆ IsResponse() [2/2]

bool Dwm::Dns::MessageHeader::IsResponse ( bool  isResponse)

If isResponse is true, sets the message to be a response.

Else sets the message to be a query.

◆ IsTruncated()

bool Dwm::Dns::MessageHeader::IsTruncated ( bool  isTruncated)

If isTruncated is true, set the truncated bit in the header, indicating the message (a response) was truncated.

◆ RecursionDesired()

bool Dwm::Dns::MessageHeader::RecursionDesired ( bool  recursionDesired)

Sets the recursion desired bit in the header.

If recursion is desired, recursionDesired should be true.


The documentation for this class was generated from the following file: