Kea  1.9.9-git
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 
16 namespace isc {
17 namespace dns {
18 
40 class Rcode {
41 public:
43  enum CodeValue {
54  NOTZONE_CODE = 10,
61  };
62 
71 
72  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();
215 private:
216  uint16_t code_;
217 };
218 
219 inline const Rcode&
221  static Rcode c(0);
222  return (c);
223 }
224 
225 inline const Rcode&
227  static Rcode c(1);
228  return (c);
229 }
230 
231 inline const Rcode&
233  static Rcode c(2);
234  return (c);
235 }
236 
237 inline const Rcode&
239  static Rcode c(3);
240  return (c);
241 }
242 
243 inline const Rcode&
245  static Rcode c(4);
246  return (c);
247 }
248 
249 inline const Rcode&
251  static Rcode c(5);
252  return (c);
253 }
254 
255 inline const Rcode&
257  static Rcode c(6);
258  return (c);
259 }
260 
261 inline const Rcode&
263  static Rcode c(7);
264  return (c);
265 }
266 
267 inline const Rcode&
269  static Rcode c(8);
270  return (c);
271 }
272 
273 inline const Rcode&
275  static Rcode c(9);
276  return (c);
277 }
278 
279 inline const Rcode&
281  static Rcode c(10);
282  return (c);
283 }
284 
285 inline const Rcode&
287  static Rcode c(11);
288  return (c);
289 }
290 
291 inline const Rcode&
293  static Rcode c(12);
294  return (c);
295 }
296 
297 inline const Rcode&
299  static Rcode c(13);
300  return (c);
301 }
302 
303 inline const Rcode&
305  static Rcode c(14);
306  return (c);
307 }
308 
309 inline const Rcode&
311  static Rcode c(15);
312  return (c);
313 }
314 
315 inline const Rcode&
317  static Rcode c(16);
318  return (c);
319 }
320 
331 std::ostream& operator<<(std::ostream& os, const Rcode& rcode);
332 }
333 }
334 #endif // RCODE_H
335 
336 // Local Variables:
337 // mode: c++
338 // End:
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition: edns.cc:172
1: Format error (RFC1035)
Definition: rcode.h:45
std::string toText() const
Convert the Rcode to a string.
Definition: rcode.cc:80
static const Rcode & RESERVED12()
A constant object for a reserved (code 12) Rcode.
Definition: rcode.h:292
16: EDNS version not implemented (RFC2671)
Definition: rcode.h:60
static const Rcode & RESERVED15()
A constant object for a reserved (code 15) Rcode.
Definition: rcode.h:310
static const Rcode & NOERROR()
A constant object for the NOERROR Rcode (see Rcode::NOERROR_CODE).
Definition: rcode.h:220
bool operator!=(const Rcode &other) const
Same as nequals().
Definition: rcode.h:143
static const Rcode & BADVERS()
A constant object for the BADVERS Rcode (see Rcode::BADVERS_CODE).
Definition: rcode.h:316
static const Rcode & YXRRSET()
A constant object for the YXRRSET Rcode (see Rcode::YXRRSET_CODE).
Definition: rcode.h:262
15: Reserved for future use (RFC1035)
Definition: rcode.h:59
3: Name Error (RFC1035)
Definition: rcode.h:47
static const Rcode & YXDOMAIN()
A constant object for the YXDOMAIN Rcode (see Rcode::YXDOMAIN_CODE).
Definition: rcode.h:256
10: Name is not within the zone (RFC2136)
Definition: rcode.h:54
DNS Response Codes (RCODEs) class.
Definition: rcode.h:40
0: No error (RFC1035)
Definition: rcode.h:44
bool operator==(const Rcode &other) const
Same as equals().
Definition: rcode.h:131
9: Server isn't authoritative (RFC2136)
Definition: rcode.h:53
static const Rcode & NOTIMP()
A constant object for the NOTIMP Rcode (see Rcode::NOTIMP_CODE).
Definition: rcode.h:244
CodeValue
Constants for pre-defined RCODE values.
Definition: rcode.h:43
uint8_t getExtendedCode() const
Returns the upper 8-bit of the Rcode code value.
Definition: rcode.cc:75
Rcode(const uint16_t code)
Constructor from the code value.
Definition: rcode.cc:58
static const Rcode & RESERVED13()
A constant object for a reserved (code 13) Rcode.
Definition: rcode.h:298
4: Not Implemented (RFC1035)
Definition: rcode.h:48
8: RRset should exist but not (RFC2136)
Definition: rcode.h:52
bool equals(const Rcode &other) const
Return true iff two Rcodes are equal.
Definition: rcode.h:127
static const Rcode & NXDOMAIN()
A constant object for the NXDOMAIN Rcode (see Rcode::NXDOMAIN_CODE).
Definition: rcode.h:238
Defines the logger used by the top-level component of kea-dhcp-ddns.
12: Reserved for future use (RFC1035)
Definition: rcode.h:56
7: RRset unexpectedly exists (RFC2136)
Definition: rcode.h:51
2: Server failure (RFC1035)
Definition: rcode.h:46
bool nequals(const Rcode &other) const
Return true iff two Rcodes are not equal.
Definition: rcode.h:139
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
6: Name unexpectedly exists (RFC2136)
Definition: rcode.h:50
static const Rcode & NOTZONE()
A constant object for the NOTZONE Rcode (see Rcode::NOTZONE_CODE).
Definition: rcode.h:280
static const Rcode & NOTAUTH()
A constant object for the NOTAUTH Rcode (see Rcode::NOTAUTH_CODE).
Definition: rcode.h:274
11: Reserved for future use (RFC1035)
Definition: rcode.h:55
static const Rcode & REFUSED()
A constant object for the REFUSED Rcode (see Rcode::REFUSED_CODE).
Definition: rcode.h:250
5: Refused (RFC1035)
Definition: rcode.h:49
14: Reserved for future use (RFC1035)
Definition: rcode.h:58
static const Rcode & RESERVED14()
A constant object for a reserved (code 14) Rcode.
Definition: rcode.h:304
uint16_t getCode() const
Returns the Rcode code value.
Definition: rcode.h:106
13: Reserved for future use (RFC1035)
Definition: rcode.h:57
static const Rcode & NXRRSET()
A constant object for the NXRRSET Rcode (see Rcode::NXRRSET_CODE).
Definition: rcode.h:268
static const Rcode & SERVFAIL()
A constant object for the SERVFAIL Rcode (see Rcode::SERVFAIL_CODE).
Definition: rcode.h:232