Encapsulates a DNS resource record. More...
#include <DwmDnsResourceRecord.hh>
Public Types | |
| enum | TypeEnum { k_typeA = 1, k_typeNS = 2, k_typeMD = 3, k_typeMF = 4, k_typeCNAME = 5, k_typeSOA = 6, k_typeMB = 7, k_typeMG = 8, k_typeMR = 9, k_typeNULL = 10, k_typeWKS = 11, k_typePTR = 12, k_typeHINFO = 13, k_typeMINFO = 14, k_typeMX = 15, k_typeTXT = 16, k_typeRP = 17, k_typeKEY = 25, k_typeAAAA = 28, k_typeLOC = 29, k_typeSRV = 33, k_typeCERT = 37, k_typeOPT = 41, k_typeDS = 43, k_typeSSHFP = 44, k_typeRRSIG = 46, k_typeNSEC = 47, k_typeDNSKEY = 48, k_typeDHCID = 49, k_typeNSEC3 = 50, k_typeNSEC3PARAM = 51, k_typeTLSA = 52, k_typeSMIMEA = 53, k_typeCDS = 59, k_typeCDNSKEY = 60, k_typeOPENPGPKEY = 61, k_typeSPF = 99, k_typeURI = 256, k_typeCAA = 257, k_typeUNKNOWN = 0xFFFF } |
| Resource record types. More... | |
| enum | ClassEnum { k_classIN = 1, k_classCH = 3, k_classHS = 4, k_classUNKNOWN = 0xFFFF } |
| Resource record classes. More... | |
Public Member Functions | |
| ResourceRecord () | |
| Default constructor. | |
| ResourceRecord (const ResourceRecord &rr) | |
| Copy constructor. | |
| ResourceRecord & | operator= (const ResourceRecord &rr) |
| operator = | |
| ~ResourceRecord ()=default | |
| Destructor. | |
| bool | operator== (const ResourceRecord &rr) const |
| Equal-to operator, mostly for unit testing. | |
| const std::string & | Name () const |
| Returns the contained domain name. | |
| const std::string & | Name (const std::string &name) |
| Sets and returns the contained domain name. | |
| TypeEnum | Type () const |
| Returns the contained type. | |
| TypeEnum | Type (TypeEnum typeEnum) |
| Sets and returns the contained type. | |
| uint16_t | Class () const |
| Returns the contained class. | |
| uint16_t | Class (uint16_t cl) |
| Sets and returns the contained class. | |
| uint32_t | TTL () const |
| Returns the TTL. | |
| uint32_t | TTL (uint32_t ttl) |
| Sets and returns the TTL. | |
| uint8_t * | Encode (uint8_t *pkt, uint8_t *ptr, uint16_t pktlen, LabelPositions &lps) const |
Encodes the resource record into buffer @ pkt of length pktlen, starting at ptr. More... | |
| const uint8_t * | Decode (const uint8_t *pkt, const uint8_t *ptr, uint16_t pktlen) |
Decodes the resource record from buffer pkt of length pktlen, starting at ptr. More... | |
| template<typename T > | |
| const T * | Data () const |
| Returns a pointer to const of the contained RRDATA. | |
| template<typename T > | |
| const T * | Data (const T &rrdata, uint16_t rrClass=k_classIN, uint16_t rrType=T::k_rrtype) |
| Sets and returns the RRDATA of the resource record. More... | |
| template<typename T > | |
| T * | Data () |
| Returns a pointer to mutable contained RRDATA. | |
Static Public Member Functions | |
| static std::string | TypeName (uint16_t rrtype) |
| Returns the mnemonic for the given resource record type @ rrtype. | |
| static std::string | ClassName (uint16_t rrclass) |
| Returns the mnemonic for the given recource record class @ rrclass. | |
Protected Member Functions | |
| std::ostream & | PrintData (std::ostream &os) const |
Protected Attributes | |
| std::string | _name |
| TypeEnum | _type |
| uint16_t | _class |
| uint32_t | _ttl |
| MY_VARIANT< RRDataA, RRDataNS, RRDataCNAME, RRDataSOA, RRDataMB, RRDataMG, RRDataMR, RRDataPTR, RRDataHINFO, RRDataMINFO, RRDataMX, RRDataTXT, RRDataRP, RRDataKEY, RRDataAAAA, RRDataLOC, RRDataSRV, RRDataCERT, RRDataDS, RRDataSSHFP, RRDataRRSIG, RRDataNSEC, RRDataDNSKEY, RRDataDHCID, RRDataNSEC3, RRDataNSEC3PARAM, RRDataTLSA, RRDataSMIMEA, RRDataOPENPGPKEY, RRDataURI, RRDataCAA, RRDataUnknown > | _rrdata |
Static Protected Attributes | |
| static std::map< uint16_t, std::string > | _classNames |
| static std::map< uint16_t, std::string > | _typeNames |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const ResourceRecord &rr) |
| Prints the resource record to an ostream in human readable form. | |
Encapsulates a DNS resource record.
See RFC1035 for details.
Resource record types.
|
inline |
Sets and returns the RRDATA of the resource record.
Note that this should normally only be called with one or two arguments, which means we're using a known RRDATA encoding. If you specify the third argument (resource record type), it MUST be a type that we don't handle and rrdata must be RRDataUnknown (which is just a blob stored in a strong).
| const uint8_t* Dwm::Dns::ResourceRecord::Decode | ( | const uint8_t * | pkt, |
| const uint8_t * | ptr, | ||
| uint16_t | pktlen | ||
| ) |
Decodes the resource record from buffer pkt of length pktlen, starting at ptr.
Returns the address immediately following the encoded DHCID resource record data in pkt on success. Throws std::out_of_range if pkt was too short to contain an encoded resource record.
| uint8_t* Dwm::Dns::ResourceRecord::Encode | ( | uint8_t * | pkt, |
| uint8_t * | ptr, | ||
| uint16_t | pktlen, | ||
| LabelPositions & | lps | ||
| ) | const |
Encodes the resource record into buffer @ pkt of length pktlen, starting at ptr.
Returns the address immediately following the encoded resource record in pkt on success. Throws std::out_of_range if pkt is too short to contain the encoded resource record.