Kea 3.3.3
d2_update_message.h
Go to the documentation of this file.
1// Copyright (C) 2013-2026 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 <d2srv/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 <cstdint>
19#include <map>
20
21namespace isc {
22namespace d2 {
23
31public:
32 InvalidZoneSection(const char* file, size_t line, const char* what) :
33 isc::Exception(file, line, what) {}
34};
35
44class InvalidQRFlag : public Exception {
45public:
46 InvalidQRFlag(const char* file, size_t line, const char* what) :
47 isc::Exception(file, line, what) {}
48};
49
55public:
56 NotUpdateMessage(const char* file, size_t line, const char* what) :
57 isc::Exception(file, line, what) {}
58};
59
64class TSIGVerifyError : public Exception {
65public:
66 TSIGVerifyError(const char* file, size_t line, const char* what) :
67 isc::Exception(file, line, what) {}
68};
69
70
71class D2UpdateMessage;
72
74typedef boost::shared_ptr<D2UpdateMessage> D2UpdateMessagePtr;
75
91public:
92
95 enum Direction : uint16_t {
98 };
99
101 enum QRFlag : uint16_t {
104 };
105
124
125public:
138 D2UpdateMessage(const Direction direction = OUTBOUND);
139
145
146private:
147 D2UpdateMessage(const D2UpdateMessage& source);
148 D2UpdateMessage& operator=(const D2UpdateMessage& source);
150
151public:
152
163 QRFlag getQRFlag() const;
164
168 uint16_t getId() const;
169
173 void setId(const uint16_t id);
174
178 const dns::Rcode& getRcode() const;
179
183 void setRcode(const dns::Rcode& rcode);
184
191 unsigned int getRRCount(const UpdateMsgSection section) const;
192
195
196
204 const dns::RRsetIterator beginSection(const UpdateMsgSection section) const;
205
214 const dns::RRsetIterator endSection(const UpdateMsgSection section) const;
216
226 void setZone(const dns::Name& zone, const dns::RRClass& rrclass);
227
231 D2ZonePtr getZone() const;
232
242 void addRRset(const UpdateMsgSection section, const dns::RRsetPtr& rrset);
243
246
247
274 dns::TSIGContext* const tsig_ctx = NULL);
275
302 void fromWire(const void* received_data, size_t bytes_received,
303 dns::TSIGContext* const tsig_context = NULL);
305
306private:
317 static
318 dns::Message::Section ddnsToDnsSection(const UpdateMsgSection section);
319
335 void validateResponse() const;
336
347 dns::Message message_;
348
351 D2ZonePtr zone_;
352
353};
354
355} // namespace d2
356} // namespace isc
357
358#endif // D2_UPDATE_MESSAGE_H
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The D2UpdateMessage encapsulates a DNS Update message.
D2ZonePtr getZone() const
Returns a pointer to the object representing Zone record.
UpdateMsgSection
Identifies sections in the DNS Update Message.
void setId(const uint16_t id)
Sets message ID.
unsigned int getRRCount(const UpdateMsgSection section) const
Returns number of RRsets in the specified message section.
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...
QRFlag
Indicates whether DNS Update message is a REQUEST or RESPONSE.
void fromWire(const void *received_data, size_t bytes_received, dns::TSIGContext *const tsig_context=NULL)
Decode incoming message from the wire format.
Direction
Indicates if the D2UpdateMessage object encapsulates Inbound or Outbound message.
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.
void toWire(dns::AbstractMessageRenderer &renderer, dns::TSIGContext *const tsig_ctx=NULL)
Encode outgoing message into wire format.
QRFlag getQRFlag() const
Returns enum value indicating if the message is a REQUEST or RESPONSE.
void setRcode(const dns::Rcode &rcode)
Sets message RCode.
D2UpdateMessage(const Direction direction=OUTBOUND)
Constructor used to create an instance of the DNS Update Message (either outgoing or incoming).
uint16_t getId() const
Returns message ID.
void addRRset(const UpdateMsgSection section, const dns::RRsetPtr &rrset)
Adds an RRset to the specified section.
void setZone(const dns::Name &zone, const dns::RRClass &rrclass)
Sets the Zone record.
const dns::Rcode & getRcode() const
Returns an object representing message RCode.
InvalidQRFlag(const char *file, size_t line, const char *what)
InvalidZoneSection(const char *file, size_t line, const char *what)
NotUpdateMessage(const char *file, size_t line, const char *what)
TSIGVerifyError(const char *file, size_t line, const char *what)
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
Exception(const char *file, size_t line, const char *what)
The Message class encapsulates a standard DNS message.
Definition message.h:150
Section
Constants to specify sections of a DNS message.
Definition message.h:240
The Name class encapsulates DNS names.
Definition name.h:217
The RRClass class encapsulates DNS resource record classes.
Definition rrclass.h:89
DNS Response Codes (RCODEs) class.
Definition rcode.h:39
TSIG session context.
Definition tsig.h:172
boost::shared_ptr< D2UpdateMessage > D2UpdateMessagePtr
Pointer to the DNS Update Message.
boost::shared_ptr< D2Zone > D2ZonePtr
Definition d2_zone.h:93
boost::shared_ptr< AbstractRRset > RRsetPtr
A pointer-like type pointing to an RRset object.
Definition rrset.h:50
SectionIterator< RRsetPtr > RRsetIterator
Definition message.h:112
Defines the logger used by the top-level component of kea-lfc.