13 #include <boost/lexical_cast.hpp>
29 using boost::lexical_cast;
49 const unsigned int VERSION_SHIFT = 16;
50 const unsigned int EXTRCODE_SHIFT = 24;
51 const uint32_t VERSION_MASK = 0x00ff0000;
52 const uint32_t EXTFLAG_DO = 0x00008000;
57 udp_size_(
Message::DEFAULT_MAX_UDPSIZE),
62 "failed to construct EDNS: unsupported version: " <<
63 static_cast<unsigned int>(version_));
69 version_((ttl.getValue() & VERSION_MASK) >> VERSION_SHIFT)
73 "EDNS is being created with incompatible RR type: "
79 static_cast<unsigned int>(version_));
87 dnssec_aware_ = ((ttl.
getValue() & EXTFLAG_DO) != 0);
93 string ret =
"; EDNS: version: ";
95 ret += lexical_cast<
string>(
static_cast<int>(
getVersion()));
100 ret +=
"; udp: " + lexical_cast<
string>(
getUDPSize()) +
"\n";
108 template <
typename Output>
110 toWireCommon(Output& output,
const uint8_t
version,
111 const uint16_t udp_size,
const bool dnssec_aware,
112 const uint8_t extended_rcode)
115 uint32_t extrcode_flags = extended_rcode << EXTRCODE_SHIFT;
116 extrcode_flags |= (version << VERSION_SHIFT) & VERSION_MASK;
118 extrcode_flags |= EXTFLAG_DO;
127 edns_rrset->toWire(output);
135 const uint8_t extended_rcode)
const
144 return (toWireCommon(renderer, version_, udp_size_, dnssec_aware_,
150 const uint8_t extended_rcode)
const
152 return (toWireCommon(buffer, version_, udp_size_, dnssec_aware_,
160 uint8_t& extended_rcode)
163 EDNS* edns =
new EDNS(name, rrclass, rrtype, ttl, rdata);
166 extended_rcode = ttl.
getValue() >> EXTRCODE_SHIFT;
The Name class encapsulates DNS names.
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
uint16_t getUDPSize() const
Returns the maximum payload size of UDP messages for the sender of the message containing this EDNS...
boost::shared_ptr< const Rdata > ConstRdataPtr
The Rdata class is an abstract base class that provides a set of common interfaces to manipulate conc...
uint16_t getCode() const
Returns the RR class code as a 16-bit unsigned integer.
static const RRType & OPT()
The Message class encapsulates a standard DNS message.
bool getDNSSECAwareness() const
Returns whether the message sender is DNSSEC aware.
The RRClass class encapsulates DNS resource record classes.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
uint8_t getVersion() const
Returns the version of EDNS.
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
EDNS(const uint8_t version=SUPPORTED_VERSION)
Constructor with the EDNS version.
static const Name & ROOT_NAME()
Root name (i.e. ".").
The RRTTL class encapsulates TTLs used in DNS resource records.
The EDNS class represents the EDNS OPT RR defined in RFC2671.
int version()
returns Kea hooks version.
EDNS * createEDNSFromRR(const Name &name, const RRClass &rrclass, const RRType &rrtype, const RRTTL &ttl, const Rdata &rdata, uint8_t &extended_rcode)
Create a new EDNS object from a set of RR parameters, also providing the extended RCODE value...
uint32_t getValue() const
Returns the TTL value as a 32-bit unsigned integer.
std::string toText() const
Convert the EDNS to a string.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Defines the logger used by the top-level component of kea-dhcp-ddns.
static const uint8_t SUPPORTED_VERSION
The highest EDNS version this implementation supports.
The RRType class encapsulates DNS resource record types.
size_t getLength() const
Return the length of data written in the internal buffer.
boost::shared_ptr< AbstractRRset > RRsetPtr
A pointer-like type pointing to an RRset object.
virtual size_t getLengthLimit() const =0
Return the maximum length of rendered data that can fit in the corresponding DNS message without trun...
unsigned int toWire(AbstractMessageRenderer &renderer, const uint8_t extended_rcode) const
Render the EDNS in the wire format.