27#ifndef ASYNC_DNS_RESOURCE_RECORD_INCLUDED
28#define ASYNC_DNS_RESOURCE_RECORD_INCLUDED
119class DnsResourceRecord
138 using List = std::vector<std::unique_ptr<DnsResourceRecord>>;
155 static const std::map<Type, std::string> type_map = {
159 static const std::string UNKNOWN =
"?";
160 const auto& it = type_map.find(
type);
161 if (it == type_map.end())
196 return (
classId() == other.classId()) &&
197 (
type() == other.type()) &&
198 (
name() == other.name());
234 std::ostringstream os;
279template <
typename Derived>
286 using List = std::vector<std::unique_ptr<Derived>>;
302 return new Derived(
static_cast<Derived const&
>(*
this));
314 const auto& lhs =
static_cast<const Derived&
>(*this);
315 const auto& rhs =
static_cast<const Derived&
>(other);
325 virtual const Type type(
void)
const override {
return Derived::staticType(); }
340class DnsResourceRecordA :
public DnsResourceRecordCRTP<DnsResourceRecordA>
369 (
ip() == other.ip());
378 std::ostringstream os;
393 const Ip&
ip(
void)
const {
return m_ip; }
411class DnsResourceRecordPTR :
public DnsResourceRecordCRTP<DnsResourceRecordPTR>
441 (
dname() == other.dname());
450 std::ostringstream os;
483class DnsResourceRecordCNAME :
484 public DnsResourceRecordCRTP<DnsResourceRecordCNAME>
514 (
cname() == other.cname());
523 std::ostringstream os;
579class DnsResourceRecordSRV :
580 public DnsResourceRecordCRTP<DnsResourceRecordSRV>
617 (
prio() == other.prio()) &&
618 (
weight() == other.weight()) &&
619 (
port() == other.port()) &&
620 (
target() == other.target());
629 std::ostringstream os;
Platform independent representation of an IP address.
A class for representing an A DNS resource record.
static const Type staticType(void)
The type for this specific class.
const Ip & ip(void) const
The IP address for this record.
void setIp(const Ip &ip)
Set the IP address for this record.
DnsResourceRecordA(const Name &name, Ttl ttl, const Ip &ip=Ip())
Constructor.
virtual std::string toString(void) const
The string representation of this record.
virtual bool operator==(const DnsResourceRecordA &other) const
Equality comparison operator.
A class for representing a CNAME DNS resource record.
virtual bool operator==(const DnsResourceRecordCNAME &other) const
Equality comparison operator.
const CName & cname(void) const
The FQDN for this record.
static const Type staticType(void)
The type for this specific class.
DnsResourceRecordCNAME(const Name &name, Ttl ttl, const CName &cname="")
Constructor.
virtual std::string toString(void) const
The string representation of this record.
void setName(const CName &cname)
Set the FQDN for this record.
A CRTP class for adding some type dependent functions.
DnsResourceRecordCRTP(const Name &name, Ttl ttl)
Constructor.
virtual bool operator==(const Derived &other) const =0
std::vector< std::unique_ptr< Derived > > List
The type for a list of resource records.
virtual bool operator==(const DnsResourceRecord &other) const
Equality comparison operator.
virtual const Type type(void) const override
The type of record.
virtual DnsResourceRecord * clone(void) const
Clone this class.
A class for representing a PTR DNS resource record.
virtual bool operator==(const DnsResourceRecordPTR &other) const
Equality comparison operator.
DnsResourceRecordPTR(const Name &name, Ttl ttl, const DName &dname="")
Constructor.
const DName & dname(void) const
The FQDN for this record.
static const Type staticType(void)
The type for this specific class.
virtual std::string toString(void) const
The string representation of this record.
void setName(const DName &dname)
Set the FQDN for this record.
A class for representing a SRV DNS resource record.
Prio prio(void) const
The prio for this record.
Port port(void) const
The network port for this record.
void setPrio(Prio prio)
Set the prio for this record.
DnsResourceRecordSRV(const Name &name, Ttl ttl, Prio prio, Weight weight, Port port, const Target &target)
Constructor.
Weight weight(void) const
The weight for this record.
void setWeight(Weight weight)
Set the weight for this record.
const Target & target(void) const
The FQDN for this record.
void setTarget(const Target &target)
Set the FQDN for this record.
virtual std::string toString(void) const
The string representation of this record.
static const Type staticType(void)
The type for this specific class.
void setPort(Port port)
Set the network port for this record.
virtual bool operator==(const DnsResourceRecordSRV &other) const
Equality comparison operator.
The base class for representing a DNS resource record.
const std::string & typeStr(void) const
The type of record as a string.
static constexpr Ttl MAX_TTL
The maximum allowed value for a TTL.
DnsResourceRecord(const Name &name, Ttl ttl)
Constructor.
virtual ~DnsResourceRecord(void)
Destructor.
virtual std::string toString(void) const
The string representation of this record.
const Name & name(void) const
The name of this record.
std::vector< std::unique_ptr< DnsResourceRecord > > List
The type for a list of resource records.
virtual bool operator==(const DnsResourceRecord &other) const
Equality comparison operator.
virtual DnsResourceRecord * clone(void) const =0
Clone this class.
static const std::string & typeToString(Type type)
The type for this specific class represented as a string.
void setName(const Name &name)
Set the name for this record.
virtual const Type type(void) const =0
The type of record.
const char * classStr(void) const
The DNS class for the record as a string.
Class classId(void) const
The DNS class for the record.
Ttl ttl(void) const
The TTL for this record.
void setTtl(Ttl ttl)
Set the TTL for this record.
static const Type staticType(void)
The type for this specific class.
A class for representing an IP address in an OS independent way.
Namespace for the asynchronous programming classes.