Kea 3.3.3
rcode.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2026 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 <cstdint>
10#include <ostream>
11
12#ifndef RCODE_H
13#define RCODE_H
14
15namespace isc {
16namespace dns {
17
39class Rcode {
40public:
61
70
71
79 explicit Rcode(const uint16_t code);
80
97 Rcode(const uint8_t code, const uint8_t extended_code);
99
105 uint16_t getCode() const {
106 return (code_);
107 }
108
118 uint8_t getExtendedCode() const;
119
128 bool equals(const Rcode& other) const {
129 return (code_ == other.code_);
130 }
131
133 bool operator==(const Rcode& other) const {
134 return (equals(other));
135 }
136
143 bool nequals(const Rcode& other) const {
144 return (code_ != other.code_);
145 }
146
148 bool operator!=(const Rcode& other) const {
149 return (nequals(other));
150 }
151
165 std::string toText() const;
166
168 static const Rcode& NOERROR();
169
171 static const Rcode& FORMERR();
172
174 static const Rcode& SERVFAIL();
175
177 static const Rcode& NXDOMAIN();
178
180 static const Rcode& NOTIMP();
181
183 static const Rcode& REFUSED();
184
186 static const Rcode& YXDOMAIN();
187
189 static const Rcode& YXRRSET();
190
192 static const Rcode& NXRRSET();
193
195 static const Rcode& NOTAUTH();
196
198 static const Rcode& NOTZONE();
199
202 static const Rcode& RESERVED11();
203
206 static const Rcode& RESERVED12();
207
210 static const Rcode& RESERVED13();
211
214 static const Rcode& RESERVED14();
215
218 static const Rcode& RESERVED15();
219
221 static const Rcode& BADVERS();
222private:
223 uint16_t code_;
224};
225
226inline const Rcode&
228 static Rcode c(0);
229 return (c);
230}
231
232inline const Rcode&
234 static Rcode c(1);
235 return (c);
236}
237
238inline const Rcode&
240 static Rcode c(2);
241 return (c);
242}
243
244inline const Rcode&
246 static Rcode c(3);
247 return (c);
248}
249
250inline const Rcode&
252 static Rcode c(4);
253 return (c);
254}
255
256inline const Rcode&
258 static Rcode c(5);
259 return (c);
260}
261
262inline const Rcode&
264 static Rcode c(6);
265 return (c);
266}
267
268inline const Rcode&
270 static Rcode c(7);
271 return (c);
272}
273
274inline const Rcode&
276 static Rcode c(8);
277 return (c);
278}
279
280inline const Rcode&
282 static Rcode c(9);
283 return (c);
284}
285
286inline const Rcode&
288 static Rcode c(10);
289 return (c);
290}
291
292inline const Rcode&
294 static Rcode c(11);
295 return (c);
296}
297
298inline const Rcode&
300 static Rcode c(12);
301 return (c);
302}
303
304inline const Rcode&
306 static Rcode c(13);
307 return (c);
308}
309
310inline const Rcode&
312 static Rcode c(14);
313 return (c);
314}
315
316inline const Rcode&
318 static Rcode c(15);
319 return (c);
320}
321
322inline const Rcode&
324 static Rcode c(16);
325 return (c);
326}
327
338std::ostream& operator<<(std::ostream& os, const Rcode& rcode);
339}
340}
341#endif // RCODE_H
DNS Response Codes (RCODEs) class.
Definition rcode.h:39
static const Rcode & RESERVED13()
A constant object for a reserved (code 13) Rcode.
Definition rcode.h:305
bool operator==(const Rcode &other) const
Same as equals().
Definition rcode.h:133
Rcode(const uint16_t code)
Constructor from the code value.
Definition rcode.cc:58
static const Rcode & NOERROR()
A constant object for the NOERROR Rcode (see Rcode::NOERROR_CODE).
Definition rcode.h:227
static const Rcode & RESERVED11()
A constant object for a reserved (code 11) Rcode.
Definition rcode.h:293
static const Rcode & FORMERR()
A constant object for the FORMERR Rcode (see Rcode::FORMERR_CODE).
Definition rcode.h:233
static const Rcode & RESERVED14()
A constant object for a reserved (code 14) Rcode.
Definition rcode.h:311
CodeValue
Constants for pre-defined RCODE values.
Definition rcode.h:42
@ YXRRSET_CODE
7: RRset unexpectedly exists (RFC2136)
Definition rcode.h:50
@ RESERVED15_CODE
15: Reserved for future use (RFC1035)
Definition rcode.h:58
@ NOTIMP_CODE
4: Not Implemented (RFC1035)
Definition rcode.h:47
@ NXRRSET_CODE
8: RRset should exist but not (RFC2136)
Definition rcode.h:51
@ RESERVED12_CODE
12: Reserved for future use (RFC1035)
Definition rcode.h:55
@ FORMERR_CODE
1: Format error (RFC1035)
Definition rcode.h:44
@ SERVFAIL_CODE
2: Server failure (RFC1035)
Definition rcode.h:45
@ RESERVED13_CODE
13: Reserved for future use (RFC1035)
Definition rcode.h:56
@ RESERVED11_CODE
11: Reserved for future use (RFC1035)
Definition rcode.h:54
@ RESERVED14_CODE
14: Reserved for future use (RFC1035)
Definition rcode.h:57
@ NXDOMAIN_CODE
3: Name Error (RFC1035)
Definition rcode.h:46
@ REFUSED_CODE
5: Refused (RFC1035)
Definition rcode.h:48
@ YXDOMAIN_CODE
6: Name unexpectedly exists (RFC2136)
Definition rcode.h:49
@ NOTZONE_CODE
10: Name is not within the zone (RFC2136)
Definition rcode.h:53
@ NOTAUTH_CODE
9: Server isn't authoritative (RFC2136)
Definition rcode.h:52
@ NOERROR_CODE
0: No error (RFC1035)
Definition rcode.h:43
@ BADVERS_CODE
16: EDNS version not implemented (RFC2671)
Definition rcode.h:59
static const Rcode & NXRRSET()
A constant object for the NXRRSET Rcode (see Rcode::NXRRSET_CODE).
Definition rcode.h:275
std::string toText() const
Convert the Rcode to a string.
Definition rcode.cc:80
static const Rcode & NXDOMAIN()
A constant object for the NXDOMAIN Rcode (see Rcode::NXDOMAIN_CODE).
Definition rcode.h:245
static const Rcode & NOTIMP()
A constant object for the NOTIMP Rcode (see Rcode::NOTIMP_CODE).
Definition rcode.h:251
bool operator!=(const Rcode &other) const
Same as nequals().
Definition rcode.h:148
uint16_t getCode() const
Returns the Rcode code value.
Definition rcode.h:105
static const Rcode & BADVERS()
A constant object for the BADVERS Rcode (see Rcode::BADVERS_CODE).
Definition rcode.h:323
bool equals(const Rcode &other) const
Return true iff two Rcodes are equal.
Definition rcode.h:128
static const Rcode & YXRRSET()
A constant object for the YXRRSET Rcode (see Rcode::YXRRSET_CODE).
Definition rcode.h:269
static const Rcode & RESERVED12()
A constant object for a reserved (code 12) Rcode.
Definition rcode.h:299
static const Rcode & RESERVED15()
A constant object for a reserved (code 15) Rcode.
Definition rcode.h:317
bool nequals(const Rcode &other) const
Return true iff two Rcodes are not equal.
Definition rcode.h:143
static const Rcode & NOTAUTH()
A constant object for the NOTAUTH Rcode (see Rcode::NOTAUTH_CODE).
Definition rcode.h:281
static const Rcode & SERVFAIL()
A constant object for the SERVFAIL Rcode (see Rcode::SERVFAIL_CODE).
Definition rcode.h:239
uint8_t getExtendedCode() const
Returns the upper 8-bit of the Rcode code value.
Definition rcode.cc:75
static const Rcode & NOTZONE()
A constant object for the NOTZONE Rcode (see Rcode::NOTZONE_CODE).
Definition rcode.h:287
static const Rcode & REFUSED()
A constant object for the REFUSED Rcode (see Rcode::REFUSED_CODE).
Definition rcode.h:257
static const Rcode & YXDOMAIN()
A constant object for the YXDOMAIN Rcode (see Rcode::YXDOMAIN_CODE).
Definition rcode.h:263
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.