Kea 3.1.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
29
35public:
36 InvalidRRType(const char* file, size_t line, const char* what) :
37 DNSTextError(file, line, what) {}
38};
39
45public:
46 IncompleteRRType(const char* file, size_t line, const char* what) :
47 isc::dns::Exception(file, line, what) {}
48};
49
96class 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&
280 static RRType rrtype(1);
281 return (rrtype);
282}
283
284inline const RRType&
286 static RRType rrtype(2);
287 return (rrtype);
288}
289
290inline const RRType&
292 static RRType rrtype(6);
293 return (rrtype);
294}
295
296inline const RRType&
298 static RRType rrtype(41);
299 return (rrtype);
300}
301
302inline const RRType&
304 static RRType rrtype(12);
305 return (rrtype);
306}
307
308inline const RRType&
310 static RRType rrtype(16);
311 return (rrtype);
312}
313
314inline const RRType&
316 static RRType rrtype(28);
317 return (rrtype);
318}
319
320inline const RRType&
322 static RRType rrtype(46);
323 return (rrtype);
324}
325
326inline const RRType&
328 static RRType rrtype(49);
329 return (rrtype);
330}
331
332inline const RRType&
334 static RRType rrtype(249);
335 return (rrtype);
336}
337
338inline const RRType&
340 static RRType rrtype(250);
341 return (rrtype);
342}
343
344inline const RRType&
346 static RRType rrtype(255);
347 return (rrtype);
348}
349
364std::ostream&
365operator<<(std::ostream& os, const RRType& rrtype);
366}
367}
368#endif // RRTYPE_H
The RRType class encapsulates DNS resource record types.
Definition rrtype.h:96
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
DNSTextError(const char *file, size_t line, const char *what)
Exception(const char *file, size_t line, const char *what)
IncompleteRRType(const char *file, size_t line, const char *what)
Definition rrtype.h:46
InvalidRRType(const char *file, size_t line, const char *what)
Definition rrtype.h:36
The RRType class encapsulates DNS resource record types.
Definition rrtype.h:96
uint16_t getCode() const
Returns the RR type code as a 16-bit unsigned integer.
Definition rrtype.h:202
static const RRType & TSIG()
Definition rrtype.h:339
RRType(uint16_t typecode)
Constructor from an integer type code.
Definition rrtype.h:107
bool operator<(const RRType &other) const
Less-than comparison for RRType against other.
Definition rrtype.h:256
static const RRType & ANY()
Definition rrtype.h:345
static const RRType & OPT()
Definition rrtype.h:297
static const RRType & NS()
Definition rrtype.h:285
bool operator==(const RRType &other) const
Same as equals().
Definition rrtype.h:223
void toWire(AbstractMessageRenderer &renderer) const
Render the RRType in the wire format.
Definition rrtype.cc:54
static const RRType & TKEY()
Definition rrtype.h:333
bool operator!=(const RRType &other) const
Same as nequals().
Definition rrtype.h:237
static const RRType & AAAA()
Definition rrtype.h:315
const std::string toText() const
Convert the RRType to a string.
Definition rrtype.cc:44
bool equals(const RRType &other) const
Return true iff two RRTypes are equal.
Definition rrtype.h:219
static const RRType & PTR()
Definition rrtype.h:303
static const RRType & RRSIG()
Definition rrtype.h:321
bool nequals(const RRType &other) const
Return true iff two RRTypes are not equal.
Definition rrtype.h:233
static const RRType & DHCID()
Definition rrtype.h:327
static const RRType & SOA()
Definition rrtype.h:291
static const RRType & TXT()
Definition rrtype.h:309
static const RRType & A()
Definition rrtype.h:279
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition buffer.h:81
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition buffer.h:346
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition edns.cc:163
Defines the logger used by the top-level component of kea-lfc.