Kea: rrtype.h Source File

| Kea 3.0.0

rrtype.h
Go to the documentation of this file.
1// Copyright (C) 2010-2024 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 RRTYPE_H
8#define RRTYPE_H
9
10#include <stdint.h>
11
12#include <string>
13#include <ostream>
14
15#include <dns/exceptions.h>
16#include <util/buffer.h>
17
18// Solaris x86 defines DS in <sys/regset.h>, which gets pulled in by Boost
19#if defined(__sun) && defined(DS)
20# undef DS
21#endif
22
23namespace isc {
24
25namespace dns {
26
27// forward declarations
28class AbstractMessageRenderer;
29
34 class InvalidRRType : public DNSTextError {
35public:
36 InvalidRRType(const char* file, size_t line, const char* what) :
37 DNSTextError(file, line, what) {}
38};
39
44 class IncompleteRRType : public isc::dns::Exception {
45public:
46 IncompleteRRType(const char* file, size_t line, const char* what) :
47 isc::dns::Exception(file, line, what) {}
48};
49
96 class RRType {
97public:
101
102
107 explicit RRType(uint16_t typecode) : typecode_(typecode) {
108 }
109
135 explicit RRType(const std::string& typestr);
146 explicit RRType(isc::util::InputBuffer& buffer);
149
150
152
156
157
169 const std::string toText() const;
180 void toWire(AbstractMessageRenderer& renderer) const;
190 void toWire(isc::util::OutputBuffer& buffer) const;
192
196
197
202 uint16_t getCode() const {
203 return (typecode_);
204 }
205
206
210
211
219 bool equals(const RRType& other) const {
220 return (typecode_ == other.typecode_);
221 }
222
223 bool operator==(const RRType& other) const {
224 return (equals(other));
225 }
226
233 bool nequals(const RRType& other) const {
234 return (typecode_ != other.typecode_);
235 }
236
237 bool operator!=(const RRType& other) const {
238 return (nequals(other));
239 }
240
256 bool operator<(const RRType& other) const {
257 return (typecode_ < other.typecode_);
258 }
259
260
261 static const RRType& A();
262 static const RRType& NS();
263 static const RRType& SOA();
264 static const RRType& OPT();
265 static const RRType& PTR();
266 static const RRType& TXT();
267 static const RRType& AAAA();
268 static const RRType& RRSIG();
269 static const RRType& DHCID();
270 static const RRType& TKEY();
271 static const RRType& TSIG();
272 static const RRType& ANY();
273
274private:
275 uint16_t typecode_;
276};
277
278inline const RRType&
279RRType::A() {
280 static RRType rrtype(1);
281 return (rrtype);
282}
283
284inline const RRType&
285RRType::NS() {
286 static RRType rrtype(2);
287 return (rrtype);
288}
289
290inline const RRType&
291RRType::SOA() {
292 static RRType rrtype(6);
293 return (rrtype);
294}
295
296inline const RRType&
297RRType::OPT() {
298 static RRType rrtype(41);
299 return (rrtype);
300}
301
302inline const RRType&
303RRType::PTR() {
304 static RRType rrtype(12);
305 return (rrtype);
306}
307
308inline const RRType&
309RRType::TXT() {
310 static RRType rrtype(16);
311 return (rrtype);
312}
313
314inline const RRType&
315RRType::AAAA() {
316 static RRType rrtype(28);
317 return (rrtype);
318}
319
320inline const RRType&
321RRType::RRSIG() {
322 static RRType rrtype(46);
323 return (rrtype);
324}
325
326inline const RRType&
327RRType::DHCID() {
328 static RRType rrtype(49);
329 return (rrtype);
330}
331
332inline const RRType&
333RRType::TKEY() {
334 static RRType rrtype(249);
335 return (rrtype);
336}
337
338inline const RRType&
339RRType::TSIG() {
340 static RRType rrtype(250);
341 return (rrtype);
342}
343
344inline const RRType&
345RRType::ANY() {
346 static RRType rrtype(255);
347 return (rrtype);
348}
349
364std::ostream&
365 operator<<(std::ostream& os, const RRType& rrtype);
366}
367}
368#endif // RRTYPE_H
buffer.h
RRType
The RRType class encapsulates DNS resource record types.
Definition rrtype.h:96
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
isc::dns::AbstractMessageRenderer
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
Definition messagerenderer.h:69
isc::dns::DNSTextError::DNSTextError
DNSTextError(const char *file, size_t line, const char *what)
Definition dns/exceptions.h:36
isc::dns::Exception
Definition dns/exceptions.h:25
isc::dns::Exception::Exception
Exception(const char *file, size_t line, const char *what)
Definition dns/exceptions.h:27
isc::dns::IncompleteRRType::IncompleteRRType
IncompleteRRType(const char *file, size_t line, const char *what)
Definition rrtype.h:46
isc::dns::InvalidRRType::InvalidRRType
InvalidRRType(const char *file, size_t line, const char *what)
Definition rrtype.h:36
isc::dns::RRType
The RRType class encapsulates DNS resource record types.
Definition rrtype.h:96
isc::dns::RRType::getCode
uint16_t getCode() const
Returns the RR type code as a 16-bit unsigned integer.
Definition rrtype.h:202
isc::dns::RRType::TSIG
static const RRType & TSIG()
Definition rrtype.h:339
isc::dns::RRType::RRType
RRType(uint16_t typecode)
Constructor from an integer type code.
Definition rrtype.h:107
isc::dns::RRType::operator<
bool operator<(const RRType &other) const
Less-than comparison for RRType against other.
Definition rrtype.h:256
isc::dns::RRType::ANY
static const RRType & ANY()
Definition rrtype.h:345
isc::dns::RRType::OPT
static const RRType & OPT()
Definition rrtype.h:297
isc::dns::RRType::NS
static const RRType & NS()
Definition rrtype.h:285
isc::dns::RRType::operator==
bool operator==(const RRType &other) const
Same as equals().
Definition rrtype.h:223
isc::dns::RRType::toWire
void toWire(AbstractMessageRenderer &renderer) const
Render the RRType in the wire format.
Definition rrtype.cc:54
isc::dns::RRType::TKEY
static const RRType & TKEY()
Definition rrtype.h:333
isc::dns::RRType::operator!=
bool operator!=(const RRType &other) const
Same as nequals().
Definition rrtype.h:237
isc::dns::RRType::AAAA
static const RRType & AAAA()
Definition rrtype.h:315
isc::dns::RRType::toText
const std::string toText() const
Convert the RRType to a string.
Definition rrtype.cc:44
isc::dns::RRType::equals
bool equals(const RRType &other) const
Return true iff two RRTypes are equal.
Definition rrtype.h:219
isc::dns::RRType::PTR
static const RRType & PTR()
Definition rrtype.h:303
isc::dns::RRType::RRSIG
static const RRType & RRSIG()
Definition rrtype.h:321
isc::dns::RRType::nequals
bool nequals(const RRType &other) const
Return true iff two RRTypes are not equal.
Definition rrtype.h:233
isc::dns::RRType::DHCID
static const RRType & DHCID()
Definition rrtype.h:327
isc::dns::RRType::SOA
static const RRType & SOA()
Definition rrtype.h:291
isc::dns::RRType::TXT
static const RRType & TXT()
Definition rrtype.h:309
isc::dns::RRType::A
static const RRType & A()
Definition rrtype.h:279
isc::util::InputBuffer
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition buffer.h:81
isc::util::OutputBuffer
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition buffer.h:346
exceptions.h
isc::dns
Definition char_string.cc:26
isc::dns::operator<<
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition edns.cc:163
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148