| Kea 3.0.2-git

rrclass.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 RRCLASS_H
8#define RRCLASS_H
9
10#include <util/buffer.h>
11
12#include <stdint.h>
13
14#include <string>
15#include <ostream>
16
17#include <dns/exceptions.h>
18
19#include <boost/optional.hpp>
20
21// Undefine the macro IN which is defined in some operating systems
22// but conflicts the IN RR class.
23
24#ifdef IN
25#undef IN
26#endif
27
28 namespace isc {
29
30 namespace dns {
31
32// forward declarations
33 class AbstractMessageRenderer;
34
39 class InvalidRRClass : public DNSTextError {
40 public:
41 InvalidRRClass(const char* file, size_t line, const char* what) :
42 DNSTextError(file, line, what) {}
43};
44
49 class IncompleteRRClass : public isc::dns::Exception {
50 public:
51 IncompleteRRClass(const char* file, size_t line, const char* what) :
52 isc::dns::Exception(file, line, what) {}
53};
54
89 class RRClass {
90 public:
94
95
100 explicit RRClass(uint16_t classcode) : classcode_(classcode) {
101 }
102
127 explicit RRClass(const std::string& class_str);
138 explicit RRClass(isc::util::InputBuffer& buffer);
139
171 static RRClass* createFromText(const std::string& class_str);
172
175
176
178
182
183
195 const std::string toText() const;
207 void toWire(AbstractMessageRenderer& renderer) const;
217 void toWire(isc::util::OutputBuffer& buffer) const;
219
223
224
229 uint16_t getCode() const {
230 return (classcode_);
231 }
232
233
237
238
246 bool equals(const RRClass& other) const {
247 return (classcode_ == other.classcode_);
248 }
249
251 bool operator==(const RRClass& other) const {
252 return (equals(other));
253 }
254
261 bool nequals(const RRClass& other) const {
262 return (classcode_ != other.classcode_);
263 }
264
265 bool operator!=(const RRClass& other) const {
266 return (nequals(other));
267 }
268
284 bool operator<(const RRClass& other) const {
285 return (classcode_ < other.classcode_);
286 }
287
288 static const RRClass& ANY();
289 static const RRClass& IN();
290 static const RRClass& CH();
291 static const RRClass& NONE();
292
293 private:
294 uint16_t classcode_;
295};
296
297 inline const RRClass&
298 RRClass::ANY() {
299 static RRClass rrclass(255);
300 return (rrclass);
301}
302
303 inline const RRClass&
304 RRClass::IN() {
305 static RRClass rrclass(1);
306 return (rrclass);
307}
308
309 inline const RRClass&
310 RRClass::CH() {
311 static RRClass rrclass(3);
312 return (rrclass);
313}
314
315 inline const RRClass&
316 RRClass::NONE() {
317 static RRClass rrclass(254);
318 return (rrclass);
319}
320
335std::ostream&
336 operator<<(std::ostream& os, const RRClass& rrclass);
337}
338}
339#endif // RRCLASS_H
buffer.h
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::IncompleteRRClass::IncompleteRRClass
IncompleteRRClass(const char *file, size_t line, const char *what)
Definition rrclass.h:51
isc::dns::InvalidRRClass::InvalidRRClass
InvalidRRClass(const char *file, size_t line, const char *what)
Definition rrclass.h:41
isc::dns::RRClass
The RRClass class encapsulates DNS resource record classes.
Definition rrclass.h:89
isc::dns::RRClass::operator!=
bool operator!=(const RRClass &other) const
Same as nequals().
Definition rrclass.h:265
isc::dns::RRClass::ANY
static const RRClass & ANY()
Definition rrclass.h:298
isc::dns::RRClass::NONE
static const RRClass & NONE()
Definition rrclass.h:316
isc::dns::RRClass::operator==
bool operator==(const RRClass &other) const
Same as equals().
Definition rrclass.h:251
isc::dns::RRClass::CH
static const RRClass & CH()
Definition rrclass.h:310
isc::dns::RRClass::getCode
uint16_t getCode() const
Returns the RR class code as a 16-bit unsigned integer.
Definition rrclass.h:229
isc::dns::RRClass::toWire
void toWire(AbstractMessageRenderer &renderer) const
Render the RRClass in the wire format.
Definition rrclass.cc:53
isc::dns::RRClass::createFromText
static RRClass * createFromText(const std::string &class_str)
A separate factory of RRClass from text.
Definition rrclass.cc:58
isc::dns::RRClass::operator<
bool operator<(const RRClass &other) const
Less-than comparison for RRClass against other.
Definition rrclass.h:284
isc::dns::RRClass::IN
static const RRClass & IN()
Definition rrclass.h:304
isc::dns::RRClass::nequals
bool nequals(const RRClass &other) const
Return true iff two RRClasses are not equal.
Definition rrclass.h:261
isc::dns::RRClass::toText
const std::string toText() const
Convert the RRClass to a string.
Definition rrclass.cc:43
isc::dns::RRClass::RRClass
RRClass(uint16_t classcode)
Constructor from an integer class code.
Definition rrclass.h:100
isc::dns::RRClass::equals
bool equals(const RRClass &other) const
Return true iff two RRClasses are equal.
Definition rrclass.h:246
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