Kea: rcode.h Source File

| Kea 2.2.0

rcode.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2015 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 1
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 { return (code_); }
107
117 uint8_t getExtendedCode() const;
118
127 bool equals(const Rcode& other) const
128 { return (code_ == other.code_); }
129
131 bool operator==(const Rcode& other) const { return (equals(other)); }
132
139 bool nequals(const Rcode& other) const
140 { return (code_ != other.code_); }
141
143 bool operator!=(const Rcode& other) const { return (nequals(other)); }
144
158 std::string toText() const;
159
161 static const Rcode& NOERROR();
162
164 static const Rcode& FORMERR();
165
167 static const Rcode& SERVFAIL();
168
170 static const Rcode& NXDOMAIN();
171
173 static const Rcode& NOTIMP();
174
176 static const Rcode& REFUSED();
177
179 static const Rcode& YXDOMAIN();
180
182 static const Rcode& YXRRSET();
183
185 static const Rcode& NXRRSET();
186
188 static const Rcode& NOTAUTH();
189
191 static const Rcode& NOTZONE();
192
195 static const Rcode& RESERVED11();
196
199 static const Rcode& RESERVED12();
200
203 static const Rcode& RESERVED13();
204
207 static const Rcode& RESERVED14();
208
211 static const Rcode& RESERVED15();
212
214 static const Rcode& BADVERS();
215private:
216 uint16_t code_;
217};
218
219inline const Rcode&
220Rcode::NOERROR() {
221 static Rcode c(0);
222 return (c);
223}
224
225inline const Rcode&
226Rcode::FORMERR() {
227 static Rcode c(1);
228 return (c);
229}
230
231inline const Rcode&
232Rcode::SERVFAIL() {
233 static Rcode c(2);
234 return (c);
235}
236
237inline const Rcode&
238Rcode::NXDOMAIN() {
239 static Rcode c(3);
240 return (c);
241}
242
243inline const Rcode&
244Rcode::NOTIMP() {
245 static Rcode c(4);
246 return (c);
247}
248
249inline const Rcode&
250Rcode::REFUSED() {
251 static Rcode c(5);
252 return (c);
253}
254
255inline const Rcode&
256Rcode::YXDOMAIN() {
257 static Rcode c(6);
258 return (c);
259}
260
261inline const Rcode&
262Rcode::YXRRSET() {
263 static Rcode c(7);
264 return (c);
265}
266
267inline const Rcode&
268Rcode::NXRRSET() {
269 static Rcode c(8);
270 return (c);
271}
272
273inline const Rcode&
274Rcode::NOTAUTH() {
275 static Rcode c(9);
276 return (c);
277}
278
279inline const Rcode&
280Rcode::NOTZONE() {
281 static Rcode c(10);
282 return (c);
283}
284
285inline const Rcode&
286Rcode::RESERVED11() {
287 static Rcode c(11);
288 return (c);
289}
290
291inline const Rcode&
292Rcode::RESERVED12() {
293 static Rcode c(12);
294 return (c);
295}
296
297inline const Rcode&
298Rcode::RESERVED13() {
299 static Rcode c(13);
300 return (c);
301}
302
303inline const Rcode&
304Rcode::RESERVED14() {
305 static Rcode c(14);
306 return (c);
307}
308
309inline const Rcode&
310Rcode::RESERVED15() {
311 static Rcode c(15);
312 return (c);
313}
314
315inline const Rcode&
316Rcode::BADVERS() {
317 static Rcode c(16);
318 return (c);
319}
320
331std::ostream& operator<<(std::ostream& os, const Rcode& rcode);
332}
333}
334#endif // RCODE_H
335
336// Local Variables:
337// mode: c++
338// End:
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:298
isc::dns::Rcode::operator==
bool operator==(const Rcode &other) const
Same as equals().
Definition: rcode.h:131
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:220
isc::dns::Rcode::RESERVED11
static const Rcode & RESERVED11()
A constant object for a reserved (code 11) Rcode.
Definition: rcode.h:286
isc::dns::Rcode::FORMERR
static const Rcode & FORMERR()
A constant object for the FORMERR Rcode (see Rcode::FORMERR_CODE).
Definition: rcode.h:226
isc::dns::Rcode::RESERVED14
static const Rcode & RESERVED14()
A constant object for a reserved (code 14) Rcode.
Definition: rcode.h:304
isc::dns::Rcode::NXRRSET
static const Rcode & NXRRSET()
A constant object for the NXRRSET Rcode (see Rcode::NXRRSET_CODE).
Definition: rcode.h:268
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:238
isc::dns::Rcode::NOTIMP
static const Rcode & NOTIMP()
A constant object for the NOTIMP Rcode (see Rcode::NOTIMP_CODE).
Definition: rcode.h:244
isc::dns::Rcode::operator!=
bool operator!=(const Rcode &other) const
Same as nequals().
Definition: rcode.h:143
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:316
isc::dns::Rcode::equals
bool equals(const Rcode &other) const
Return true iff two Rcodes are equal.
Definition: rcode.h:127
isc::dns::Rcode::YXRRSET
static const Rcode & YXRRSET()
A constant object for the YXRRSET Rcode (see Rcode::YXRRSET_CODE).
Definition: rcode.h:262
isc::dns::Rcode::RESERVED12
static const Rcode & RESERVED12()
A constant object for a reserved (code 12) Rcode.
Definition: rcode.h:292
isc::dns::Rcode::RESERVED15
static const Rcode & RESERVED15()
A constant object for a reserved (code 15) Rcode.
Definition: rcode.h:310
isc::dns::Rcode::nequals
bool nequals(const Rcode &other) const
Return true iff two Rcodes are not equal.
Definition: rcode.h:139
isc::dns::Rcode::NOTAUTH
static const Rcode & NOTAUTH()
A constant object for the NOTAUTH Rcode (see Rcode::NOTAUTH_CODE).
Definition: rcode.h:274
isc::dns::Rcode::SERVFAIL
static const Rcode & SERVFAIL()
A constant object for the SERVFAIL Rcode (see Rcode::SERVFAIL_CODE).
Definition: rcode.h:232
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:280
isc::dns::Rcode::REFUSED
static const Rcode & REFUSED()
A constant object for the REFUSED Rcode (see Rcode::REFUSED_CODE).
Definition: rcode.h:250
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:256
isc::dns::operator<<
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition: edns.cc:172
isc
Defines the logger used by the top-level component of kea-lfc.
Definition: agent_parser.cc:143