Kea 2.5.7
rrclass.h
Go to the documentation of this file.
1
7
8// Copyright (C) 2010-2021 Internet Systems Consortium, Inc. ("ISC")
9//
10// This Source Code Form is subject to the terms of the Mozilla Public
11// License, v. 2.0. If a copy of the MPL was not distributed with this
12// file, You can obtain one at http://mozilla.org/MPL/2.0/.
13
14#ifndef RRCLASS_H
15#define RRCLASS_H 1
16
17#include <stdint.h>
18
19#include <string>
20#include <ostream>
21
22#include <dns/exceptions.h>
23
24#include <boost/optional.hpp>
25
26// Undefine the macro IN which is defined in some operating systems
27// but conflicts the IN RR class.
28
29#ifdef IN
30#undef IN
31#endif
32
33namespace isc {
34namespace util {
35class InputBuffer;
36class OutputBuffer;
37}
38
39namespace dns {
40
41// forward declarations
42class AbstractMessageRenderer;
43
49public:
50 InvalidRRClass(const char* file, size_t line, const char* what) :
51 DNSTextError(file, line, what) {}
52};
53
59public:
60 IncompleteRRClass(const char* file, size_t line, const char* what) :
61 isc::dns::Exception(file, line, what) {}
62};
63
98class RRClass {
99public:
103
104
109 explicit RRClass(uint16_t classcode) : classcode_(classcode) {}
135 explicit RRClass(const std::string& class_str);
146 explicit RRClass(isc::util::InputBuffer& buffer);
147
180 static RRClass* createFromText(const std::string& class_str);
181
184
185
187
191
192
204 const std::string toText() const;
216 void toWire(AbstractMessageRenderer& renderer) const;
226 void toWire(isc::util::OutputBuffer& buffer) const;
228
232
233
238 uint16_t getCode() const { return (classcode_); }
240
244
245
253 bool equals(const RRClass& other) const
254 { return (classcode_ == other.classcode_); }
256 bool operator==(const RRClass& other) const { return (equals(other)); }
257
264 bool nequals(const RRClass& other) const
265 { return (classcode_ != other.classcode_); }
267 bool operator!=(const RRClass& other) const { return (nequals(other)); }
268
284 bool operator<(const RRClass& other) const
285 { return (classcode_ < other.classcode_); }
286
287 // BEGIN_WELL_KNOWN_CLASS_DECLARATIONS
288 static const RRClass& ANY();
289 static const RRClass& CH();
290 static const RRClass& HS();
291 static const RRClass& IN();
292 static const RRClass& NONE();
293 // END_WELL_KNOWN_CLASS_DECLARATIONS
294
295private:
296 uint16_t classcode_;
297};
298
299// BEGIN_WELL_KNOWN_CLASS_DEFINITIONS
300inline const RRClass&
302 static RRClass rrclass(255);
303 return (rrclass);
304}
305
306inline const RRClass&
308 static RRClass rrclass(3);
309 return (rrclass);
310}
311
312inline const RRClass&
314 static RRClass rrclass(4);
315 return (rrclass);
316}
317
318inline const RRClass&
320 static RRClass rrclass(1);
321 return (rrclass);
322}
323
324inline const RRClass&
326 static RRClass rrclass(254);
327 return (rrclass);
328}
329
330// END_WELL_KNOWN_CLASS_DEFINITIONS
331
346std::ostream&
347operator<<(std::ostream& os, const RRClass& rrclass);
348}
349}
350#endif // RRCLASS_H
351
352// Local Variables:
353// mode: c++
354// End:
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...
Base class for all sorts of text parse errors.
A standard DNS module exception that is thrown if an RRClass object is being constructed from a incom...
Definition: rrclass.h:58
IncompleteRRClass(const char *file, size_t line, const char *what)
Definition: rrclass.h:60
A standard DNS module exception that is thrown if an RRClass object is being constructed from an unre...
Definition: rrclass.h:48
InvalidRRClass(const char *file, size_t line, const char *what)
Definition: rrclass.h:50
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
bool operator!=(const RRClass &other) const
Same as nequals().
Definition: rrclass.h:267
static const RRClass & ANY()
Definition: rrclass.h:301
static const RRClass & NONE()
Definition: rrclass.h:325
bool operator==(const RRClass &other) const
Same as equals().
Definition: rrclass.h:256
static const RRClass & CH()
Definition: rrclass.h:307
uint16_t getCode() const
Returns the RR class code as a 16-bit unsigned integer.
Definition: rrclass.h:238
void toWire(AbstractMessageRenderer &renderer) const
Render the RRClass in the wire format.
Definition: rrclass.cc:54
static const RRClass & HS()
Definition: rrclass.h:313
static RRClass * createFromText(const std::string &class_str)
A separate factory of RRClass from text.
Definition: rrclass.cc:59
bool operator<(const RRClass &other) const
Less-than comparison for RRClass against other.
Definition: rrclass.h:284
static const RRClass & IN()
Definition: rrclass.h:319
bool nequals(const RRClass &other) const
Return true iff two RRClasses are not equal.
Definition: rrclass.h:264
const std::string toText() const
Convert the RRClass to a string.
Definition: rrclass.cc:44
RRClass(uint16_t classcode)
Constructor from an integer class code.
Definition: rrclass.h:109
bool equals(const RRClass &other) const
Return true iff two RRClasses are equal.
Definition: rrclass.h:253
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:294
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition: edns.cc:172
Defines the logger used by the top-level component of kea-lfc.