Kea: rcode.h Source File

| Kea 3.2.0-git

rcode.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2024 Internet Systems Consortium, Inc. ("ISC")
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9#include <stdint.h>
10
11#include <ostream>
12
13#ifndef RCODE_H
14#define RCODE_H
15
16namespace isc {
17namespace dns {
18
40 class Rcode {
41public:
43 enum CodeValue {
44 NOERROR_CODE = 0,
45 FORMERR_CODE = 1,
46 SERVFAIL_CODE = 2,
47 NXDOMAIN_CODE = 3,
48 NOTIMP_CODE = 4,
49 REFUSED_CODE = 5,
50 YXDOMAIN_CODE = 6,
51 YXRRSET_CODE = 7,
52 NXRRSET_CODE = 8,
53 NOTAUTH_CODE = 9,
54 NOTZONE_CODE = 10,
55 RESERVED11_CODE = 11,
56 RESERVED12_CODE = 12,
57 RESERVED13_CODE = 13,
58 RESERVED14_CODE = 14,
59 RESERVED15_CODE = 15,
60 BADVERS_CODE = 16
61 };
62
71
72
80 explicit Rcode(const uint16_t code);
81
98 Rcode(const uint8_t code, const uint8_t extended_code);
100
106 uint16_t getCode() const {
107 return (code_);
108 }
109
119 uint8_t getExtendedCode() const;
120
129 bool equals(const Rcode& other) const {
130 return (code_ == other.code_);
131 }
132
134 bool operator==(const Rcode& other) const {
135 return (equals(other));
136 }
137
144 bool nequals(const Rcode& other) const {
145 return (code_ != other.code_);
146 }
147
149 bool operator!=(const Rcode& other) const {
150 return (nequals(other));
151 }
152
166 std::string toText() const;
167
169 static const Rcode& NOERROR();
170
172 static const Rcode& FORMERR();
173
175 static const Rcode& SERVFAIL();
176
178 static const Rcode& NXDOMAIN();
179
181 static const Rcode& NOTIMP();
182
184 static const Rcode& REFUSED();
185
187 static const Rcode& YXDOMAIN();
188
190 static const Rcode& YXRRSET();
191
193 static const Rcode& NXRRSET();
194
196 static const Rcode& NOTAUTH();
197
199 static const Rcode& NOTZONE();
200
203 static const Rcode& RESERVED11();
204
207 static const Rcode& RESERVED12();
208
211 static const Rcode& RESERVED13();
212
215 static const Rcode& RESERVED14();
216
219 static const Rcode& RESERVED15();
220
222 static const Rcode& BADVERS();
223private:
224 uint16_t code_;
225};
226
227inline const Rcode&
228Rcode::NOERROR() {
229 static Rcode c(0);
230 return (c);
231}
232
233inline const Rcode&
234Rcode::FORMERR() {
235 static Rcode c(1);
236 return (c);
237}
238
239inline const Rcode&
240Rcode::SERVFAIL() {
241 static Rcode c(2);
242 return (c);
243}
244
245inline const Rcode&
246Rcode::NXDOMAIN() {
247 static Rcode c(3);
248 return (c);
249}
250
251inline const Rcode&
252Rcode::NOTIMP() {
253 static Rcode c(4);
254 return (c);
255}
256
257inline const Rcode&
258Rcode::REFUSED() {
259 static Rcode c(5);
260 return (c);
261}
262
263inline const Rcode&
264Rcode::YXDOMAIN() {
265 static Rcode c(6);
266 return (c);
267}
268
269inline const Rcode&
270Rcode::YXRRSET() {
271 static Rcode c(7);
272 return (c);
273}
274
275inline const Rcode&
276Rcode::NXRRSET() {
277 static Rcode c(8);
278 return (c);
279}
280
281inline const Rcode&
282Rcode::NOTAUTH() {
283 static Rcode c(9);
284 return (c);
285}
286
287inline const Rcode&
288Rcode::NOTZONE() {
289 static Rcode c(10);
290 return (c);
291}
292
293inline const Rcode&
294Rcode::RESERVED11() {
295 static Rcode c(11);
296 return (c);
297}
298
299inline const Rcode&
300Rcode::RESERVED12() {
301 static Rcode c(12);
302 return (c);
303}
304
305inline const Rcode&
306Rcode::RESERVED13() {
307 static Rcode c(13);
308 return (c);
309}
310
311inline const Rcode&
312Rcode::RESERVED14() {
313 static Rcode c(14);
314 return (c);
315}
316
317inline const Rcode&
318Rcode::RESERVED15() {
319 static Rcode c(15);
320 return (c);
321}
322
323inline const Rcode&
324Rcode::BADVERS() {
325 static Rcode c(16);
326 return (c);
327}
328
339std::ostream& operator<<(std::ostream& os, const Rcode& rcode);
340}
341}
342#endif // RCODE_H
isc::dns::Rcode
DNS Response Codes (RCODEs) class.
Definition rcode.h:40
isc::dns::Rcode::RESERVED13
static const Rcode & RESERVED13()
A constant object for a reserved (code 13) Rcode.
Definition rcode.h:306
isc::dns::Rcode::operator==
bool operator==(const Rcode &other) const
Same as equals().
Definition rcode.h:134
isc::dns::Rcode::Rcode
Rcode(const uint16_t code)
Constructor from the code value.
Definition rcode.cc:58
isc::dns::Rcode::NOERROR
static const Rcode & NOERROR()
A constant object for the NOERROR Rcode (see Rcode::NOERROR_CODE).
Definition rcode.h:228
isc::dns::Rcode::RESERVED11
static const Rcode & RESERVED11()
A constant object for a reserved (code 11) Rcode.
Definition rcode.h:294
isc::dns::Rcode::FORMERR
static const Rcode & FORMERR()
A constant object for the FORMERR Rcode (see Rcode::FORMERR_CODE).
Definition rcode.h:234
isc::dns::Rcode::RESERVED14
static const Rcode & RESERVED14()
A constant object for a reserved (code 14) Rcode.
Definition rcode.h:312
isc::dns::Rcode::NXRRSET
static const Rcode & NXRRSET()
A constant object for the NXRRSET Rcode (see Rcode::NXRRSET_CODE).
Definition rcode.h:276
isc::dns::Rcode::toText
std::string toText() const
Convert the Rcode to a string.
Definition rcode.cc:80
isc::dns::Rcode::NXDOMAIN
static const Rcode & NXDOMAIN()
A constant object for the NXDOMAIN Rcode (see Rcode::NXDOMAIN_CODE).
Definition rcode.h:246
isc::dns::Rcode::NOTIMP
static const Rcode & NOTIMP()
A constant object for the NOTIMP Rcode (see Rcode::NOTIMP_CODE).
Definition rcode.h:252
isc::dns::Rcode::operator!=
bool operator!=(const Rcode &other) const
Same as nequals().
Definition rcode.h:149
isc::dns::Rcode::getCode
uint16_t getCode() const
Returns the Rcode code value.
Definition rcode.h:106
isc::dns::Rcode::BADVERS
static const Rcode & BADVERS()
A constant object for the BADVERS Rcode (see Rcode::BADVERS_CODE).
Definition rcode.h:324
isc::dns::Rcode::equals
bool equals(const Rcode &other) const
Return true iff two Rcodes are equal.
Definition rcode.h:129
isc::dns::Rcode::YXRRSET
static const Rcode & YXRRSET()
A constant object for the YXRRSET Rcode (see Rcode::YXRRSET_CODE).
Definition rcode.h:270
isc::dns::Rcode::RESERVED12
static const Rcode & RESERVED12()
A constant object for a reserved (code 12) Rcode.
Definition rcode.h:300
isc::dns::Rcode::RESERVED15
static const Rcode & RESERVED15()
A constant object for a reserved (code 15) Rcode.
Definition rcode.h:318
isc::dns::Rcode::nequals
bool nequals(const Rcode &other) const
Return true iff two Rcodes are not equal.
Definition rcode.h:144
isc::dns::Rcode::NOTAUTH
static const Rcode & NOTAUTH()
A constant object for the NOTAUTH Rcode (see Rcode::NOTAUTH_CODE).
Definition rcode.h:282
isc::dns::Rcode::SERVFAIL
static const Rcode & SERVFAIL()
A constant object for the SERVFAIL Rcode (see Rcode::SERVFAIL_CODE).
Definition rcode.h:240
isc::dns::Rcode::getExtendedCode
uint8_t getExtendedCode() const
Returns the upper 8-bit of the Rcode code value.
Definition rcode.cc:75
isc::dns::Rcode::NOTZONE
static const Rcode & NOTZONE()
A constant object for the NOTZONE Rcode (see Rcode::NOTZONE_CODE).
Definition rcode.h:288
isc::dns::Rcode::REFUSED
static const Rcode & REFUSED()
A constant object for the REFUSED Rcode (see Rcode::REFUSED_CODE).
Definition rcode.h:258
isc::dns::Rcode::CodeValue
CodeValue
Constants for pre-defined RCODE values.
Definition rcode.h:43
isc::dns::Rcode::YXRRSET_CODE
@ YXRRSET_CODE
7: RRset unexpectedly exists (RFC2136)
Definition rcode.h:51
isc::dns::Rcode::RESERVED15_CODE
@ RESERVED15_CODE
15: Reserved for future use (RFC1035)
Definition rcode.h:59
isc::dns::Rcode::NOTIMP_CODE
@ NOTIMP_CODE
4: Not Implemented (RFC1035)
Definition rcode.h:48
isc::dns::Rcode::NXRRSET_CODE
@ NXRRSET_CODE
8: RRset should exist but not (RFC2136)
Definition rcode.h:52
isc::dns::Rcode::RESERVED12_CODE
@ RESERVED12_CODE
12: Reserved for future use (RFC1035)
Definition rcode.h:56
isc::dns::Rcode::FORMERR_CODE
@ FORMERR_CODE
1: Format error (RFC1035)
Definition rcode.h:45
isc::dns::Rcode::SERVFAIL_CODE
@ SERVFAIL_CODE
2: Server failure (RFC1035)
Definition rcode.h:46
isc::dns::Rcode::RESERVED13_CODE
@ RESERVED13_CODE
13: Reserved for future use (RFC1035)
Definition rcode.h:57
isc::dns::Rcode::RESERVED11_CODE
@ RESERVED11_CODE
11: Reserved for future use (RFC1035)
Definition rcode.h:55
isc::dns::Rcode::RESERVED14_CODE
@ RESERVED14_CODE
14: Reserved for future use (RFC1035)
Definition rcode.h:58
isc::dns::Rcode::NXDOMAIN_CODE
@ NXDOMAIN_CODE
3: Name Error (RFC1035)
Definition rcode.h:47
isc::dns::Rcode::REFUSED_CODE
@ REFUSED_CODE
5: Refused (RFC1035)
Definition rcode.h:49
isc::dns::Rcode::YXDOMAIN_CODE
@ YXDOMAIN_CODE
6: Name unexpectedly exists (RFC2136)
Definition rcode.h:50
isc::dns::Rcode::NOTZONE_CODE
@ NOTZONE_CODE
10: Name is not within the zone (RFC2136)
Definition rcode.h:54
isc::dns::Rcode::NOTAUTH_CODE
@ NOTAUTH_CODE
9: Server isn't authoritative (RFC2136)
Definition rcode.h:53
isc::dns::Rcode::NOERROR_CODE
@ NOERROR_CODE
0: No error (RFC1035)
Definition rcode.h:44
isc::dns::Rcode::BADVERS_CODE
@ BADVERS_CODE
16: EDNS version not implemented (RFC2671)
Definition rcode.h:60
isc::dns::Rcode::YXDOMAIN
static const Rcode & YXDOMAIN()
A constant object for the YXDOMAIN Rcode (see Rcode::YXDOMAIN_CODE).
Definition rcode.h:264
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 check_exists_add.cc:18