Kea  1.5.0
d2_update_message.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2015,2017 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 D2_UPDATE_MESSAGE_H
8 #define D2_UPDATE_MESSAGE_H
9 
10 #include <d2/d2_zone.h>
11 #include <dns/message.h>
12 #include <dns/name.h>
13 #include <dns/rcode.h>
14 #include <dns/rrclass.h>
15 #include <dns/rrset.h>
16 #include <dns/tsig.h>
17 
18 #include <map>
19 
20 namespace isc {
21 namespace d2 {
22 
29 class InvalidZoneSection : public Exception {
30 public:
31  InvalidZoneSection(const char* file, size_t line, const char* what) :
32  isc::Exception(file, line, what) {}
33 };
34 
43 class InvalidQRFlag : public Exception {
44 public:
45  InvalidQRFlag(const char* file, size_t line, const char* what) :
46  isc::Exception(file, line, what) {}
47 };
48 
53 class NotUpdateMessage : public Exception {
54 public:
55  NotUpdateMessage(const char* file, size_t line, const char* what) :
56  isc::Exception(file, line, what) {}
57 };
58 
63 class TSIGVerifyError : public Exception {
64 public:
65  TSIGVerifyError(const char* file, size_t line, const char* what) :
66  isc::Exception(file, line, what) {}
67 };
68 
69 
70 class D2UpdateMessage;
71 
73 typedef boost::shared_ptr<D2UpdateMessage> D2UpdateMessagePtr;
74 
90 public:
91 
94  enum Direction {
96  OUTBOUND
97  };
98 
100  enum QRFlag {
102  RESPONSE
103  };
104 
122  };
123 
124 public:
137  D2UpdateMessage(const Direction direction = OUTBOUND);
138 
144 
145 private:
146  D2UpdateMessage(const D2UpdateMessage& source);
147  D2UpdateMessage& operator=(const D2UpdateMessage& source);
149 
150 public:
151 
162  QRFlag getQRFlag() const;
163 
167  uint16_t getId() const;
168 
172  void setId(const uint16_t id);
173 
177  const dns::Rcode& getRcode() const;
178 
182  void setRcode(const dns::Rcode& rcode);
183 
190  unsigned int getRRCount(const UpdateMsgSection section) const;
191 
194 
195  const dns::RRsetIterator beginSection(const UpdateMsgSection section) const;
204 
213  const dns::RRsetIterator endSection(const UpdateMsgSection section) const;
215 
225  void setZone(const dns::Name& zone, const dns::RRClass& rrclass);
226 
230  D2ZonePtr getZone() const;
231 
241  void addRRset(const UpdateMsgSection section, const dns::RRsetPtr& rrset);
242 
245 
246  void toWire(dns::AbstractMessageRenderer& renderer,
273  dns::TSIGContext* const tsig_ctx = NULL);
274 
301  void fromWire(const void* received_data, size_t bytes_received,
302  dns::TSIGContext* const tsig_context = NULL);
304 
305 private:
316  static
317  dns::Message::Section ddnsToDnsSection(const UpdateMsgSection section);
318 
334  void validateResponse() const;
335 
346  dns::Message message_;
347 
350  D2ZonePtr zone_;
351 
352 };
353 
354 } // namespace d2
355 } // namespace isc
356 
357 #endif // D2_UPDATE_MESSAGE_H
d2_zone.h
isc::d2::D2UpdateMessage::getRcode
const dns::Rcode & getRcode() const
Returns an object representing message RCode.
Definition: d2_update_message.cc:50
isc::dns::RRsetPtr
boost::shared_ptr< AbstractRRset > RRsetPtr
A pointer-like type pointing to an RRset object.
Definition: rrset.h:47
isc::d2::D2UpdateMessage::setRcode
void setRcode(const dns::Rcode &rcode)
Sets message RCode.
Definition: d2_update_message.cc:55
isc::d2::D2UpdateMessage::SECTION_ZONE
@ SECTION_ZONE
Definition: d2_update_message.h:118
isc::d2::D2UpdateMessage::REQUEST
@ REQUEST
Definition: d2_update_message.h:101
isc::d2::D2UpdateMessage::fromWire
void fromWire(const void *received_data, size_t bytes_received, dns::TSIGContext *const tsig_context=NULL)
Decode incoming message from the wire format.
Definition: d2_update_message.cc:124
isc::d2::D2UpdateMessage::setZone
void setZone(const dns::Name &zone, const dns::RRClass &rrclass)
Sets the Zone record.
Definition: d2_update_message.cc:75
name.h
isc::d2::D2UpdateMessage::getRRCount
unsigned int getRRCount(const UpdateMsgSection section) const
Returns number of RRsets in the specified message section.
Definition: d2_update_message.cc:60
isc::d2::D2UpdateMessage::endSection
const dns::RRsetIterator endSection(const UpdateMsgSection section) const
Return iterators pointing to the end of the list of RRsets, which belong to the specified section.
Definition: d2_update_message.cc:70
isc::dns::SectionIterator
SectionIterator is a templated class to provide standard-compatible iterators for Questions and RRset...
Definition: message.h:91
isc::d2::D2UpdateMessage::beginSection
const dns::RRsetIterator beginSection(const UpdateMsgSection section) const
Return iterators pointing to the beginning of the list of RRsets, which belong to the specified secti...
Definition: d2_update_message.cc:65
rrclass.h
isc::dns::AbstractMessageRenderer
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
Definition: messagerenderer.h:68
isc::d2::D2UpdateMessage::getId
uint16_t getId() const
Returns message ID.
Definition: d2_update_message.cc:39
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition: exceptions/exceptions.cc:32
message.h
rrset.h
isc::dns::Name
The Name class encapsulates DNS names.
Definition: name.h:223
isc::d2::D2UpdateMessage::getQRFlag
QRFlag getQRFlag() const
Returns enum value indicating if the message is a REQUEST or RESPONSE.
Definition: d2_update_message.cc:33
isc::d2::D2UpdateMessage::SECTION_PREREQUISITE
@ SECTION_PREREQUISITE
Definition: d2_update_message.h:119
isc::d2::D2UpdateMessage::RESPONSE
@ RESPONSE
Definition: d2_update_message.h:102
isc::dns::Exception
Definition: dns/exceptions.h:25
isc::d2::D2UpdateMessage::INBOUND
@ INBOUND
Definition: d2_update_message.h:95
tsig.h
isc::d2::D2UpdateMessage::toWire
void toWire(dns::AbstractMessageRenderer &renderer, dns::TSIGContext *const tsig_ctx=NULL)
Encode outgoing message into wire format.
Definition: d2_update_message.cc:105
isc::d2::InvalidZoneSection::InvalidZoneSection
InvalidZoneSection(const char *file, size_t line, const char *what)
Definition: d2_update_message.h:31
isc::d2::NotUpdateMessage
Exception indicating that the parsed message is not DNS Update.
Definition: d2_update_message.h:53
isc::d2::D2UpdateMessage::addRRset
void addRRset(const UpdateMsgSection section, const dns::RRsetPtr &rrset)
Adds an RRset to the specified section.
Definition: d2_update_message.cc:95
isc::d2::D2UpdateMessage::SECTION_UPDATE
@ SECTION_UPDATE
Definition: d2_update_message.h:120
isc::d2::NotUpdateMessage::NotUpdateMessage
NotUpdateMessage(const char *file, size_t line, const char *what)
Definition: d2_update_message.h:55
isc::d2::D2UpdateMessage::D2UpdateMessage
D2UpdateMessage(const Direction direction=OUTBOUND)
Constructor used to create an instance of the DNS Update Message (either outgoing or incoming).
Definition: d2_update_message.cc:20
isc::d2::D2UpdateMessage::setId
void setId(const uint16_t id)
Sets message ID.
Definition: d2_update_message.cc:44
isc::d2::D2UpdateMessage::Direction
Direction
Indicates if the D2UpdateMessage object encapsulates Inbound or Outbound message.
Definition: d2_update_message.h:94
isc::d2::InvalidQRFlag::InvalidQRFlag
InvalidQRFlag(const char *file, size_t line, const char *what)
Definition: d2_update_message.h:45
isc::d2::InvalidQRFlag
Exception indicating that QR flag has invalid value.
Definition: d2_update_message.h:43
isc::d2::D2UpdateMessage::SECTION_ADDITIONAL
@ SECTION_ADDITIONAL
Definition: d2_update_message.h:121
isc::d2::TSIGVerifyError
Exception indicating that a signed, inbound message failed to verify.
Definition: d2_update_message.h:63
isc::d2::D2UpdateMessage
The D2UpdateMessage encapsulates a DNS Update message.
Definition: d2_update_message.h:89
isc::dns::Message
The Message class encapsulates a standard DNS message.
Definition: message.h:143
rcode.h
isc::d2::TSIGVerifyError::TSIGVerifyError
TSIGVerifyError(const char *file, size_t line, const char *what)
Definition: d2_update_message.h:65
isc::d2::InvalidZoneSection
Exception indicating that Zone section contains invalid content.
Definition: d2_update_message.h:29
isc::d2::D2UpdateMessage::UpdateMsgSection
UpdateMsgSection
Identifies sections in the DNS Update Message.
Definition: d2_update_message.h:117
isc::d2::D2UpdateMessage::getZone
D2ZonePtr getZone() const
Returns a pointer to the object representing Zone record.
Definition: d2_update_message.cc:90
isc::dns::Message::Section
Section
Constants to specify sections of a DNS message.
Definition: message.h:233
isc::dns::RRClass
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
isc::d2::D2UpdateMessagePtr
boost::shared_ptr< D2UpdateMessage > D2UpdateMessagePtr
Pointer to the DNS Update Message.
Definition: d2_update_message.h:70
isc::d2::D2UpdateMessage::OUTBOUND
@ OUTBOUND
Definition: d2_update_message.h:96
isc::d2::D2ZonePtr
boost::shared_ptr< D2Zone > D2ZonePtr
Definition: d2_zone.h:93
isc::dns::TSIGContext
TSIG session context.
Definition: tsig.h:172
isc::dns::Rcode
DNS Response Codes (RCODEs) class.
Definition: rcode.h:40
isc::d2::D2UpdateMessage::QRFlag
QRFlag
Indicates whether DNS Update message is a REQUEST or RESPONSE.
Definition: d2_update_message.h:100