Kea 2.5.5
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
40class Rcode {
41public:
43 enum CodeValue {
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&
221 static Rcode c(0);
222 return (c);
223}
224
225inline const Rcode&
227 static Rcode c(1);
228 return (c);
229}
230
231inline const Rcode&
233 static Rcode c(2);
234 return (c);
235}
236
237inline const Rcode&
239 static Rcode c(3);
240 return (c);
241}
242
243inline const Rcode&
245 static Rcode c(4);
246 return (c);
247}
248
249inline const Rcode&
251 static Rcode c(5);
252 return (c);
253}
254
255inline const Rcode&
257 static Rcode c(6);
258 return (c);
259}
260
261inline const Rcode&
263 static Rcode c(7);
264 return (c);
265}
266
267inline const Rcode&
269 static Rcode c(8);
270 return (c);
271}
272
273inline const Rcode&
275 static Rcode c(9);
276 return (c);
277}
278
279inline const Rcode&
281 static Rcode c(10);
282 return (c);
283}
284
285inline const Rcode&
287 static Rcode c(11);
288 return (c);
289}
290
291inline const Rcode&
293 static Rcode c(12);
294 return (c);
295}
296
297inline const Rcode&
299 static Rcode c(13);
300 return (c);
301}
302
303inline const Rcode&
305 static Rcode c(14);
306 return (c);
307}
308
309inline const Rcode&
311 static Rcode c(15);
312 return (c);
313}
314
315inline const Rcode&
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:
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:298
bool operator==(const Rcode &other) const
Same as equals().
Definition: rcode.h:131
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:220
static const Rcode & RESERVED11()
A constant object for a reserved (code 11) Rcode.
Definition: rcode.h:286
static const Rcode & FORMERR()
A constant object for the FORMERR Rcode (see Rcode::FORMERR_CODE).
Definition: rcode.h:226
static const Rcode & RESERVED14()
A constant object for a reserved (code 14) Rcode.
Definition: rcode.h:304
static const Rcode & NXRRSET()
A constant object for the NXRRSET Rcode (see Rcode::NXRRSET_CODE).
Definition: rcode.h:268
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:238
static const Rcode & NOTIMP()
A constant object for the NOTIMP Rcode (see Rcode::NOTIMP_CODE).
Definition: rcode.h:244
bool operator!=(const Rcode &other) const
Same as nequals().
Definition: rcode.h:143
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:316
bool equals(const Rcode &other) const
Return true iff two Rcodes are equal.
Definition: rcode.h:127
static const Rcode & YXRRSET()
A constant object for the YXRRSET Rcode (see Rcode::YXRRSET_CODE).
Definition: rcode.h:262
static const Rcode & RESERVED12()
A constant object for a reserved (code 12) Rcode.
Definition: rcode.h:292
static const Rcode & RESERVED15()
A constant object for a reserved (code 15) Rcode.
Definition: rcode.h:310
bool nequals(const Rcode &other) const
Return true iff two Rcodes are not equal.
Definition: rcode.h:139
static const Rcode & NOTAUTH()
A constant object for the NOTAUTH Rcode (see Rcode::NOTAUTH_CODE).
Definition: rcode.h:274
static const Rcode & SERVFAIL()
A constant object for the SERVFAIL Rcode (see Rcode::SERVFAIL_CODE).
Definition: rcode.h:232
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:280
static const Rcode & REFUSED()
A constant object for the REFUSED Rcode (see Rcode::REFUSED_CODE).
Definition: rcode.h:250
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:256
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.