From RFC1035 section 4.1.4: The compression scheme allows a domain name in a message to be represented as either: More...
#include <DwmDnsLabelSequence.hh>
Public Member Functions | |
| LabelSequence () | |
| Constructs an empty label sequence. | |
| LabelSequence (const std::string &value) | |
Construct a label sequence from given string value. | |
| operator std::string () const | |
| Convert to a string. | |
| uint8_t * | Encode (uint8_t *pkt, uint8_t *ptr, uint16_t pktlen, LabelPositions &lps) const |
Encodes the label sequence into buffer @ pkt of length pktlen, starting at ptr. More... | |
| uint8_t * | Encode (uint8_t *pkt, uint8_t *ptr, uint16_t pktlen) const |
| Encode without compression. Used for NSEC records, for example. | |
| const uint8_t * | Decode (const uint8_t *pkt, const uint8_t *ptr, uint16_t pktlen) |
Decodes the label sequence from buffer pkt of length pktlen, starting at ptr. More... | |
Protected Attributes | |
| std::string | _value |
From RFC1035 section 4.1.4: The compression scheme allows a domain name in a message to be represented as either:
What this means is that a domain name isn't standalone, since it can contain a pointer to elsewhere. Of course this completely defeats encapsulation. I only need the compression facilities when encoding packets. To facilitate encoding, I use an instance of LabelPositions to keep track of potential pointer targets.
| const uint8_t* Dwm::Dns::LabelSequence::Decode | ( | const uint8_t * | pkt, |
| const uint8_t * | ptr, | ||
| uint16_t | pktlen | ||
| ) |
Decodes the label sequence from buffer pkt of length pktlen, starting at ptr.
Returns the address immediately following the encoded label sequence in pkt on success. Throws std::out_of_range if pkt was too short to contain an encoded label sequence.
| uint8_t* Dwm::Dns::LabelSequence::Encode | ( | uint8_t * | pkt, |
| uint8_t * | ptr, | ||
| uint16_t | pktlen, | ||
| LabelPositions & | lps | ||
| ) | const |
Encodes the label sequence into buffer @ pkt of length pktlen, starting at ptr.
Returns the address immediately following the encoded label sequence in pkt on success. Throws std::out_of_range if pkt is too short to contain the encoded label sequence. lps is used for label compression as documented in section 4.1.4 of RFC1035.