Kea 2.7.5
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
40class Rcode {
41public:
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&
229 static Rcode c(0);
230 return (c);
231}
232
233inline const Rcode&
235 static Rcode c(1);
236 return (c);
237}
238
239inline const Rcode&
241 static Rcode c(2);
242 return (c);
243}
244
245inline const Rcode&
247 static Rcode c(3);
248 return (c);
249}
250
251inline const Rcode&
253 static Rcode c(4);
254 return (c);
255}
256
257inline const Rcode&
259 static Rcode c(5);
260 return (c);
261}
262
263inline const Rcode&
265 static Rcode c(6);
266 return (c);
267}
268
269inline const Rcode&
271 static Rcode c(7);
272 return (c);
273}
274
275inline const Rcode&
277 static Rcode c(8);
278 return (c);
279}
280
281inline const Rcode&
283 static Rcode c(9);
284 return (c);
285}
286
287inline const Rcode&
289 static Rcode c(10);
290 return (c);
291}
292
293inline const Rcode&
295 static Rcode c(11);
296 return (c);
297}
298
299inline const Rcode&
301 static Rcode c(12);
302 return (c);
303}
304
305inline const Rcode&
307 static Rcode c(13);
308 return (c);
309}
310
311inline const Rcode&
313 static Rcode c(14);
314 return (c);
315}
316
317inline const Rcode&
319 static Rcode c(15);
320 return (c);
321}
322
323inline const Rcode&
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
DNS Response Codes (RCODEs) class.
Definition rcode.h:40
static const Rcode & RESERVED13()
A constant object for a reserved (code 13) Rcode.
Definition rcode.h:306
bool operator==(const Rcode &other) const
Same as equals().
Definition rcode.h:134
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:228
static const Rcode & RESERVED11()
A constant object for a reserved (code 11) Rcode.
Definition rcode.h:294
static const Rcode & FORMERR()
A constant object for the FORMERR Rcode (see Rcode::FORMERR_CODE).
Definition rcode.h:234
static const Rcode & RESERVED14()
A constant object for a reserved (code 14) Rcode.
Definition rcode.h:312
static const Rcode & NXRRSET()
A constant object for the NXRRSET Rcode (see Rcode::NXRRSET_CODE).
Definition rcode.h:276
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:246
static const Rcode & NOTIMP()
A constant object for the NOTIMP Rcode (see Rcode::NOTIMP_CODE).
Definition rcode.h:252
bool operator!=(const Rcode &other) const
Same as nequals().
Definition rcode.h:149
uint16_t getCode() const
Returns the Rcode code value.
Definition rcode.h:106
static const Rcode & BADVERS()
A constant object for the BADVERS Rcode (see Rcode::BADVERS_CODE).
Definition rcode.h:324
bool equals(const Rcode &other) const
Return true iff two Rcodes are equal.
Definition rcode.h:129
static const Rcode & YXRRSET()
A constant object for the YXRRSET Rcode (see Rcode::YXRRSET_CODE).
Definition rcode.h:270
static const Rcode & RESERVED12()
A constant object for a reserved (code 12) Rcode.
Definition rcode.h:300
static const Rcode & RESERVED15()
A constant object for a reserved (code 15) Rcode.
Definition rcode.h:318
bool nequals(const Rcode &other) const
Return true iff two Rcodes are not equal.
Definition rcode.h:144
static const Rcode & NOTAUTH()
A constant object for the NOTAUTH Rcode (see Rcode::NOTAUTH_CODE).
Definition rcode.h:282
static const Rcode & SERVFAIL()
A constant object for the SERVFAIL Rcode (see Rcode::SERVFAIL_CODE).
Definition rcode.h:240
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:288
static const Rcode & REFUSED()
A constant object for the REFUSED Rcode (see Rcode::REFUSED_CODE).
Definition rcode.h:258
CodeValue
Constants for pre-defined RCODE values.
Definition rcode.h:43
@ YXRRSET_CODE
7: RRset unexpectedly exists (RFC2136)
Definition rcode.h:51
@ RESERVED15_CODE
15: Reserved for future use (RFC1035)
Definition rcode.h:59
@ NOTIMP_CODE
4: Not Implemented (RFC1035)
Definition rcode.h:48
@ NXRRSET_CODE
8: RRset should exist but not (RFC2136)
Definition rcode.h:52
@ RESERVED12_CODE
12: Reserved for future use (RFC1035)
Definition rcode.h:56
@ FORMERR_CODE
1: Format error (RFC1035)
Definition rcode.h:45
@ SERVFAIL_CODE
2: Server failure (RFC1035)
Definition rcode.h:46
@ RESERVED13_CODE
13: Reserved for future use (RFC1035)
Definition rcode.h:57
@ RESERVED11_CODE
11: Reserved for future use (RFC1035)
Definition rcode.h:55
@ RESERVED14_CODE
14: Reserved for future use (RFC1035)
Definition rcode.h:58
@ NXDOMAIN_CODE
3: Name Error (RFC1035)
Definition rcode.h:47
@ REFUSED_CODE
5: Refused (RFC1035)
Definition rcode.h:49
@ YXDOMAIN_CODE
6: Name unexpectedly exists (RFC2136)
Definition rcode.h:50
@ NOTZONE_CODE
10: Name is not within the zone (RFC2136)
Definition rcode.h:54
@ NOTAUTH_CODE
9: Server isn't authoritative (RFC2136)
Definition rcode.h:53
@ NOERROR_CODE
0: No error (RFC1035)
Definition rcode.h:44
@ BADVERS_CODE
16: EDNS version not implemented (RFC2671)
Definition rcode.h:60
static const Rcode & YXDOMAIN()
A constant object for the YXDOMAIN Rcode (see Rcode::YXDOMAIN_CODE).
Definition rcode.h:264
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.