Kea: tsigerror.h Source File

| Kea 3.2.0-git

tsigerror.h
Go to the documentation of this file.
1// Copyright (C) 2011-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef TSIGERROR_H
8#define TSIGERROR_H
9
10#include <ostream>
11#include <string>
12
13#include <dns/rcode.h>
14
15namespace isc {
16namespace dns {
22 class TSIGError {
23public:
32 enum CodeValue {
33 BAD_SIG_CODE = 16,
34 BAD_KEY_CODE = 17,
35 BAD_TIME_CODE = 18,
36 BAD_MODE_CODE = 19,
37 BAD_NAME_CODE = 20,
38 BAD_ALG_CODE = 21,
39 BAD_TRUNC_CODE = 22
40 };
41
46
47
52 explicit TSIGError(uint16_t error_code) : code_(error_code) {}
53
65 explicit TSIGError(Rcode rcode);
67
73 uint16_t getCode() const {
74 return (code_);
75 }
76
85 bool equals(const TSIGError& other) const {
86 return (code_ == other.code_);
87 }
88
90 bool operator==(const TSIGError& other) const {
91 return (equals(other));
92 }
93
101 bool nequals(const TSIGError& other) const {
102 return (code_ != other.code_);
103 }
104
106 bool operator!=(const TSIGError& other) const {
107 return (nequals(other));
108 }
109
124 std::string toText() const;
125
140 Rcode toRcode() const;
141
143 static const TSIGError& NOERROR();
144
146 static const TSIGError& FORMERR();
147
149 static const TSIGError& SERVFAIL();
150
152 static const TSIGError& NXDOMAIN();
153
155 static const TSIGError& NOTIMP();
156
158 static const TSIGError& REFUSED();
159
161 static const TSIGError& YXDOMAIN();
162
164 static const TSIGError& YXRRSET();
165
167 static const TSIGError& NXRRSET();
168
170 static const TSIGError& NOTAUTH();
171
173 static const TSIGError& NOTZONE();
174
176 static const TSIGError& RESERVED11();
177
179 static const TSIGError& RESERVED12();
180
182 static const TSIGError& RESERVED13();
183
185 static const TSIGError& RESERVED14();
186
188 static const TSIGError& RESERVED15();
189
192 static const TSIGError& BAD_SIG();
193
196 static const TSIGError& BAD_KEY();
197
200 static const TSIGError& BAD_TIME();
201
204 static const TSIGError& BAD_MODE();
205
208 static const TSIGError& BAD_NAME();
209
212 static const TSIGError& BAD_ALG();
213
216 static const TSIGError& BAD_TRUNC();
217
218private:
219 // This is internally used to specify the maximum possible RCODE value
220 // that can be convertible to TSIGErrors.
221 static const int MAX_RCODE_FOR_TSIGERROR = 15;
222
223 uint16_t code_;
224};
225
226inline const TSIGError&
227TSIGError::NOERROR() {
228 static TSIGError e(Rcode::NOERROR());
229 return (e);
230}
231
232inline const TSIGError&
233TSIGError::FORMERR() {
234 static TSIGError e(Rcode::FORMERR());
235 return (e);
236}
237
238inline const TSIGError&
239TSIGError::SERVFAIL() {
240 static TSIGError e(Rcode::SERVFAIL());
241 return (e);
242}
243
244inline const TSIGError&
245TSIGError::NXDOMAIN() {
246 static TSIGError e(Rcode::NXDOMAIN());
247 return (e);
248}
249
250inline const TSIGError&
251TSIGError::NOTIMP() {
252 static TSIGError e(Rcode::NOTIMP());
253 return (e);
254}
255
256inline const TSIGError&
257TSIGError::REFUSED() {
258 static TSIGError e(Rcode::REFUSED());
259 return (e);
260}
261
262inline const TSIGError&
263TSIGError::YXDOMAIN() {
264 static TSIGError e(Rcode::YXDOMAIN());
265 return (e);
266}
267
268inline const TSIGError&
269TSIGError::YXRRSET() {
270 static TSIGError e(Rcode::YXRRSET());
271 return (e);
272}
273
274inline const TSIGError&
275TSIGError::NXRRSET() {
276 static TSIGError e(Rcode::NXRRSET());
277 return (e);
278}
279
280inline const TSIGError&
281TSIGError::NOTAUTH() {
282 static TSIGError e(Rcode::NOTAUTH());
283 return (e);
284}
285
286inline const TSIGError&
287TSIGError::NOTZONE() {
288 static TSIGError e(Rcode::NOTZONE());
289 return (e);
290}
291
292inline const TSIGError&
293TSIGError::RESERVED11() {
294 static TSIGError e(Rcode::RESERVED11());
295 return (e);
296}
297
298inline const TSIGError&
299TSIGError::RESERVED12() {
300 static TSIGError e(Rcode::RESERVED12());
301 return (e);
302}
303
304inline const TSIGError&
305TSIGError::RESERVED13() {
306 static TSIGError e(Rcode::RESERVED13());
307 return (e);
308}
309
310inline const TSIGError&
311TSIGError::RESERVED14() {
312 static TSIGError e(Rcode::RESERVED14());
313 return (e);
314}
315
316inline const TSIGError&
317TSIGError::RESERVED15() {
318 static TSIGError e(Rcode::RESERVED15());
319 return (e);
320}
321
322inline const TSIGError&
323TSIGError::BAD_SIG() {
324 static TSIGError e(BAD_SIG_CODE);
325 return (e);
326}
327
328inline const TSIGError&
329TSIGError::BAD_KEY() {
330 static TSIGError e(BAD_KEY_CODE);
331 return (e);
332}
333
334inline const TSIGError&
335TSIGError::BAD_TIME() {
336 static TSIGError e(BAD_TIME_CODE);
337 return (e);
338}
339
340inline const TSIGError&
341TSIGError::BAD_MODE() {
342 static TSIGError e(BAD_MODE_CODE);
343 return (e);
344}
345
346inline const TSIGError&
347TSIGError::BAD_NAME() {
348 static TSIGError e(BAD_NAME_CODE);
349 return (e);
350}
351
352inline const TSIGError&
353TSIGError::BAD_ALG() {
354 static TSIGError e(BAD_ALG_CODE);
355 return (e);
356}
357
358inline const TSIGError&
359TSIGError::BAD_TRUNC() {
360 static TSIGError e(BAD_TRUNC_CODE);
361 return (e);
362}
363
374std::ostream& operator<<(std::ostream& os, const TSIGError& tsig_error);
375}
376}
377
378#endif // TSIGERROR_H
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:306
isc::dns::Rcode::NOERROR
static const Rcode & NOERROR()
A constant object for the NOERROR Rcode (see Rcode::NOERROR_CODE).
Definition rcode.h:228
isc::dns::Rcode::RESERVED11
static const Rcode & RESERVED11()
A constant object for a reserved (code 11) Rcode.
Definition rcode.h:294
isc::dns::Rcode::FORMERR
static const Rcode & FORMERR()
A constant object for the FORMERR Rcode (see Rcode::FORMERR_CODE).
Definition rcode.h:234
isc::dns::Rcode::RESERVED14
static const Rcode & RESERVED14()
A constant object for a reserved (code 14) Rcode.
Definition rcode.h:312
isc::dns::Rcode::NXRRSET
static const Rcode & NXRRSET()
A constant object for the NXRRSET Rcode (see Rcode::NXRRSET_CODE).
Definition rcode.h:276
isc::dns::Rcode::NXDOMAIN
static const Rcode & NXDOMAIN()
A constant object for the NXDOMAIN Rcode (see Rcode::NXDOMAIN_CODE).
Definition rcode.h:246
isc::dns::Rcode::NOTIMP
static const Rcode & NOTIMP()
A constant object for the NOTIMP Rcode (see Rcode::NOTIMP_CODE).
Definition rcode.h:252
isc::dns::Rcode::YXRRSET
static const Rcode & YXRRSET()
A constant object for the YXRRSET Rcode (see Rcode::YXRRSET_CODE).
Definition rcode.h:270
isc::dns::Rcode::RESERVED12
static const Rcode & RESERVED12()
A constant object for a reserved (code 12) Rcode.
Definition rcode.h:300
isc::dns::Rcode::RESERVED15
static const Rcode & RESERVED15()
A constant object for a reserved (code 15) Rcode.
Definition rcode.h:318
isc::dns::Rcode::NOTAUTH
static const Rcode & NOTAUTH()
A constant object for the NOTAUTH Rcode (see Rcode::NOTAUTH_CODE).
Definition rcode.h:282
isc::dns::Rcode::SERVFAIL
static const Rcode & SERVFAIL()
A constant object for the SERVFAIL Rcode (see Rcode::SERVFAIL_CODE).
Definition rcode.h:240
isc::dns::Rcode::NOTZONE
static const Rcode & NOTZONE()
A constant object for the NOTZONE Rcode (see Rcode::NOTZONE_CODE).
Definition rcode.h:288
isc::dns::Rcode::REFUSED
static const Rcode & REFUSED()
A constant object for the REFUSED Rcode (see Rcode::REFUSED_CODE).
Definition rcode.h:258
isc::dns::Rcode::YXDOMAIN
static const Rcode & YXDOMAIN()
A constant object for the YXDOMAIN Rcode (see Rcode::YXDOMAIN_CODE).
Definition rcode.h:264
isc::dns::TSIGError
TSIG errors.
Definition tsigerror.h:22
isc::dns::TSIGError::operator==
bool operator==(const TSIGError &other) const
Same as equals().
Definition tsigerror.h:90
isc::dns::TSIGError::SERVFAIL
static const TSIGError & SERVFAIL()
A constant TSIG error object derived from Rcode::SERVFAIL().
Definition tsigerror.h:239
isc::dns::TSIGError::nequals
bool nequals(const TSIGError &other) const
Return true iff two TSIGError objects are not equal.
Definition tsigerror.h:101
isc::dns::TSIGError::RESERVED14
static const TSIGError & RESERVED14()
A constant TSIG error object derived from Rcode::RESERVED14().
Definition tsigerror.h:311
isc::dns::TSIGError::CodeValue
CodeValue
Constants for pre-defined TSIG error values.
Definition tsigerror.h:32
isc::dns::TSIGError::BAD_ALG_CODE
@ BAD_ALG_CODE
21: TKEY algorithm not supported
Definition tsigerror.h:38
isc::dns::TSIGError::BAD_NAME_CODE
@ BAD_NAME_CODE
20: Duplicate TKEY name
Definition tsigerror.h:37
isc::dns::TSIGError::BAD_KEY_CODE
@ BAD_KEY_CODE
17: TSIG key is not recognized
Definition tsigerror.h:34
isc::dns::TSIGError::BAD_TRUNC_CODE
@ BAD_TRUNC_CODE
22: Bad truncation
Definition tsigerror.h:39
isc::dns::TSIGError::BAD_TIME_CODE
@ BAD_TIME_CODE
18: Current time and time signed are too different
Definition tsigerror.h:35
isc::dns::TSIGError::BAD_SIG_CODE
@ BAD_SIG_CODE
16: TSIG verification failure
Definition tsigerror.h:33
isc::dns::TSIGError::BAD_MODE_CODE
@ BAD_MODE_CODE
19: Bad TKEY mode
Definition tsigerror.h:36
isc::dns::TSIGError::YXRRSET
static const TSIGError & YXRRSET()
A constant TSIG error object derived from Rcode::YXRRSET().
Definition tsigerror.h:269
isc::dns::TSIGError::BAD_ALG
static const TSIGError & BAD_ALG()
A constant TSIG error object for the BADALG code (see TSIGError::BAD_ALG_CODE).
Definition tsigerror.h:353
isc::dns::TSIGError::operator!=
bool operator!=(const TSIGError &other) const
Same as nequals().
Definition tsigerror.h:106
isc::dns::TSIGError::YXDOMAIN
static const TSIGError & YXDOMAIN()
A constant TSIG error object derived from Rcode::YXDOMAIN().
Definition tsigerror.h:263
isc::dns::TSIGError::NOTZONE
static const TSIGError & NOTZONE()
A constant TSIG error object derived from Rcode::NOTZONE().
Definition tsigerror.h:287
isc::dns::TSIGError::toText
std::string toText() const
Convert the TSIGError to a string.
Definition tsigerror.cc:40
isc::dns::TSIGError::BAD_NAME
static const TSIGError & BAD_NAME()
A constant TSIG error object for the BADNAME code (see TSIGError::BAD_NAME_CODE).
Definition tsigerror.h:347
isc::dns::TSIGError::NXRRSET
static const TSIGError & NXRRSET()
A constant TSIG error object derived from Rcode::NXRRSET().
Definition tsigerror.h:275
isc::dns::TSIGError::NOTIMP
static const TSIGError & NOTIMP()
A constant TSIG error object derived from Rcode::NOTIMP().
Definition tsigerror.h:251
isc::dns::TSIGError::REFUSED
static const TSIGError & REFUSED()
A constant TSIG error object derived from Rcode::REFUSED().
Definition tsigerror.h:257
isc::dns::TSIGError::TSIGError
TSIGError(uint16_t error_code)
Constructor from the code value.
Definition tsigerror.h:52
isc::dns::TSIGError::RESERVED11
static const TSIGError & RESERVED11()
A constant TSIG error object derived from Rcode::RESERVED11().
Definition tsigerror.h:293
isc::dns::TSIGError::RESERVED15
static const TSIGError & RESERVED15()
A constant TSIG error object derived from Rcode::RESERVED15().
Definition tsigerror.h:317
isc::dns::TSIGError::BAD_SIG
static const TSIGError & BAD_SIG()
A constant TSIG error object for the BADSIG code (see TSIGError::BAD_SIG_CODE).
Definition tsigerror.h:323
isc::dns::TSIGError::BAD_MODE
static const TSIGError & BAD_MODE()
A constant TSIG error object for the BADMODE code (see TSIGError::BAD_MODE_CODE).
Definition tsigerror.h:341
isc::dns::TSIGError::BAD_KEY
static const TSIGError & BAD_KEY()
A constant TSIG error object for the BADKEY code (see TSIGError::BAD_KEY_CODE).
Definition tsigerror.h:329
isc::dns::TSIGError::BAD_TIME
static const TSIGError & BAD_TIME()
A constant TSIG error object for the BADTIME code (see TSIGError::BAD_TIME_CODE).
Definition tsigerror.h:335
isc::dns::TSIGError::NXDOMAIN
static const TSIGError & NXDOMAIN()
A constant TSIG error object derived from Rcode::NXDOMAIN().
Definition tsigerror.h:245
isc::dns::TSIGError::getCode
uint16_t getCode() const
Returns the TSIGCode error code value.
Definition tsigerror.h:73
isc::dns::TSIGError::RESERVED13
static const TSIGError & RESERVED13()
A constant TSIG error object derived from Rcode::RESERVED13().
Definition tsigerror.h:305
isc::dns::TSIGError::NOTAUTH
static const TSIGError & NOTAUTH()
A constant TSIG error object derived from Rcode::NOTAUTH().
Definition tsigerror.h:281
isc::dns::TSIGError::NOERROR
static const TSIGError & NOERROR()
A constant TSIG error object derived from Rcode::NOERROR().
Definition tsigerror.h:227
isc::dns::TSIGError::BAD_TRUNC
static const TSIGError & BAD_TRUNC()
A constant TSIG error object for the BADTRUNC code (see TSIGError::BAD_TRUNC_CODE).
Definition tsigerror.h:359
isc::dns::TSIGError::FORMERR
static const TSIGError & FORMERR()
A constant TSIG error object derived from Rcode::FORMERR().
Definition tsigerror.h:233
isc::dns::TSIGError::RESERVED12
static const TSIGError & RESERVED12()
A constant TSIG error object derived from Rcode::RESERVED12().
Definition tsigerror.h:299
isc::dns::TSIGError::equals
bool equals(const TSIGError &other) const
Return true iff two TSIGError objects are equal.
Definition tsigerror.h:85
isc::dns::TSIGError::toRcode
Rcode toRcode() const
Convert the TSIGError to a Rcode.
Definition tsigerror.cc:51
isc::dns
Definition char_string.cc:26
isc::dns::operator<<
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition edns.cc:163
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
rcode.h