Kea  1.9.9-git
edns.h
Go to the documentation of this file.
1 // Copyright (C) 2010-2015 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef EDNS_H
8 #define EDNS_H 1
9 
10 #include <stdint.h>
11 
12 #include <boost/shared_ptr.hpp>
13 
14 #include <ostream>
15 
16 #include <dns/rdata.h>
17 
18 namespace isc {
19 namespace util {
20 class OutputBuffer;
21 }
22 
23 namespace dns {
24 
25 class EDNS;
26 class Name;
27 class AbstractMessageRenderer;
28 class RRClass;
29 class RRTTL;
30 class RRType;
31 class Rcode;
32 
34 typedef boost::shared_ptr<EDNS> EDNSPtr;
35 
37 typedef boost::shared_ptr<const EDNS> ConstEDNSPtr;
38 
123 class EDNS {
124 public:
136 
137  explicit EDNS(const uint8_t version = SUPPORTED_VERSION);
159 
214  EDNS(const Name& name, const RRClass& rrclass, const RRType& rrtype,
215  const RRTTL& ttl, const rdata::Rdata& rdata);
217 
221 
222  uint8_t getVersion() const { return (version_); }
226 
231  uint16_t getUDPSize() const { return (udp_size_); }
232 
246  void setUDPSize(const uint16_t udp_size) { udp_size_ = udp_size; }
247 
253  bool getDNSSECAwareness() const { return (dnssec_aware_); }
254 
264  void setDNSSECAwareness(const bool is_aware) { dnssec_aware_ = is_aware; }
266 
270 
271  unsigned int toWire(AbstractMessageRenderer& renderer,
310  const uint8_t extended_rcode) const;
311 
318  unsigned int toWire(isc::util::OutputBuffer& buffer,
319  const uint8_t extended_rcode) const;
320 
342  std::string toText() const;
344 
345  // TBD: This method is currently not implemented. We'll eventually need
346  // something like this.
347  //void addOption();
348 
349 public:
351  static const uint8_t SUPPORTED_VERSION = 0;
352 private:
353  // We may eventually want to migrate to pimpl, especially when we support
354  // EDNS options. In this initial implementation, we keep it simple.
355  const uint8_t version_;
356  uint16_t udp_size_;
357  bool dnssec_aware_;
358 };
359 
416 EDNS* createEDNSFromRR(const Name& name, const RRClass& rrclass,
417  const RRType& rrtype, const RRTTL& ttl,
418  const rdata::Rdata& rdata, uint8_t& extended_rcode);
419 
430 std::ostream& operator<<(std::ostream& os, const EDNS& edns);
431 }
432 }
433 #endif // EDNS_H
434 
435 // Local Variables:
436 // mode: c++
437 // End:
The Name class encapsulates DNS names.
Definition: name.h:223
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition: edns.cc:172
boost::shared_ptr< const EDNS > ConstEDNSPtr
A pointer-like type pointing to an immutable EDNS object.
Definition: edns.h:37
uint16_t getUDPSize() const
Returns the maximum payload size of UDP messages for the sender of the message containing this EDNS...
Definition: edns.h:231
The Rdata class is an abstract base class that provides a set of common interfaces to manipulate conc...
Definition: rdata.h:123
DNS Response Codes (RCODEs) class.
Definition: rcode.h:40
bool getDNSSECAwareness() const
Returns whether the message sender is DNSSEC aware.
Definition: edns.h:253
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
uint8_t getVersion() const
Returns the version of EDNS.
Definition: edns.h:225
boost::shared_ptr< EDNS > EDNSPtr
A pointer-like type pointing to an EDNS object.
Definition: edns.h:31
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.
Definition: edns.cc:55
The RRTTL class encapsulates TTLs used in DNS resource records.
Definition: rrttl.h:55
The EDNS class represents the EDNS OPT RR defined in RFC2671.
Definition: edns.h:123
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...
Definition: edns.cc:157
void setUDPSize(const uint16_t udp_size)
Specify the maximum payload size of UDP messages that use this EDNS.
Definition: edns.h:246
std::string toText() const
Convert the EDNS to a string.
Definition: edns.cc:92
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
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.
Definition: edns.h:351
The RRType class encapsulates DNS resource record types.
Definition: rrtype.h:106
unsigned int toWire(AbstractMessageRenderer &renderer, const uint8_t extended_rcode) const
Render the EDNS in the wire format.
Definition: edns.cc:134
void setDNSSECAwareness(const bool is_aware)
Specifies whether the sender of the message containing this EDNS is DNSSEC aware. ...
Definition: edns.h:264