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

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.
 
ResourceRecordoperator= (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.
 

Detailed Description

Encapsulates a DNS resource record.

See RFC1035 for details.

Member Enumeration Documentation

◆ ClassEnum

Resource record classes.

Enumerator
k_classCH 

Internet.

k_classHS 

CHAOS.

k_classUNKNOWN 

Hesiod.

◆ TypeEnum

Resource record types.

Enumerator
k_typeNS 

host address

k_typeMD 

authoritative nameserver

k_typeMF 

mail destination (old, use MX)

k_typeCNAME 

mail forwarder (obsolete, use MX)

k_typeSOA 

canonical name for an alias

k_typeMB 

marks the start of a zone of authority

k_typeMG 

mailbox domain name (EXPERIMENTAL)

k_typeMR 

mail group member (EXPERIMENTAL)

k_typeNULL 

mail rename domain name (EXPERIMENTAL)

k_typeWKS 

null RR (EXPERIMENTAL)

k_typePTR 

well known service description

k_typeHINFO 

domain name pointer

k_typeMINFO 

host information

k_typeMX 

mailbox or mail list information

k_typeTXT 

mail exchange

k_typeRP 

text strings

k_typeKEY 

Responsible Person (RFC1183)

k_typeAAAA 

public key (RFC2535)

k_typeLOC 

host IPv6 address (RFC3596)

k_typeSRV 

location (LOC) (RFC1876)

k_typeCERT 

server selection (RFC2782)

k_typeOPT 

certificate (RFC4398)

k_typeDS 

OPT (for EDNS, RFC6891)

k_typeSSHFP 

DS (RFC4034)

k_typeRRSIG 

SSH fingerprint (RFC4255)

k_typeNSEC 

RRSIG (RFC4034)

k_typeDNSKEY 

NSEC (RFC4034)

k_typeDHCID 

DNSKEY (RFC4034)

k_typeNSEC3 

DHCID (RFC4701)

k_typeNSEC3PARAM 

NSEC3 (RFC5155)

k_typeTLSA 

NSEC3PARAM (RFC5155)

k_typeSMIMEA 

TLSA (RFC6698)

k_typeCDS 

SMIMEA (RFC8162)

k_typeCDNSKEY 

CDS (RFC7344)

k_typeOPENPGPKEY 

CDNSKEY (RFC7344)

k_typeSPF 

OPENPGPKEY (RFC7929)

k_typeURI 

RFC4408 but obsoleted in RFC7208.

k_typeCAA 

URI (RFC7553)

k_typeUNKNOWN 

cert. authority auth. (RFC6844)

Member Function Documentation

◆ Data()

template<typename T >
const T* Dwm::Dns::ResourceRecord::Data ( const T &  rrdata,
uint16_t  rrClass = k_classIN,
uint16_t  rrType = T::k_rrtype 
)
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).

◆ Decode()

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.

◆ Encode()

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.


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