Kea 2.7.5
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 {
22class TSIGError {
23public:
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&
228 static TSIGError e(Rcode::NOERROR());
229 return (e);
230}
231
232inline const TSIGError&
234 static TSIGError e(Rcode::FORMERR());
235 return (e);
236}
237
238inline const TSIGError&
240 static TSIGError e(Rcode::SERVFAIL());
241 return (e);
242}
243
244inline const TSIGError&
246 static TSIGError e(Rcode::NXDOMAIN());
247 return (e);
248}
249
250inline const TSIGError&
252 static TSIGError e(Rcode::NOTIMP());
253 return (e);
254}
255
256inline const TSIGError&
258 static TSIGError e(Rcode::REFUSED());
259 return (e);
260}
261
262inline const TSIGError&
264 static TSIGError e(Rcode::YXDOMAIN());
265 return (e);
266}
267
268inline const TSIGError&
270 static TSIGError e(Rcode::YXRRSET());
271 return (e);
272}
273
274inline const TSIGError&
276 static TSIGError e(Rcode::NXRRSET());
277 return (e);
278}
279
280inline const TSIGError&
282 static TSIGError e(Rcode::NOTAUTH());
283 return (e);
284}
285
286inline const TSIGError&
288 static TSIGError e(Rcode::NOTZONE());
289 return (e);
290}
291
292inline const TSIGError&
294 static TSIGError e(Rcode::RESERVED11());
295 return (e);
296}
297
298inline const TSIGError&
300 static TSIGError e(Rcode::RESERVED12());
301 return (e);
302}
303
304inline const TSIGError&
306 static TSIGError e(Rcode::RESERVED13());
307 return (e);
308}
309
310inline const TSIGError&
312 static TSIGError e(Rcode::RESERVED14());
313 return (e);
314}
315
316inline const TSIGError&
318 static TSIGError e(Rcode::RESERVED15());
319 return (e);
320}
321
322inline const TSIGError&
324 static TSIGError e(BAD_SIG_CODE);
325 return (e);
326}
327
328inline const TSIGError&
330 static TSIGError e(BAD_KEY_CODE);
331 return (e);
332}
333
334inline const TSIGError&
336 static TSIGError e(BAD_TIME_CODE);
337 return (e);
338}
339
340inline const TSIGError&
342 static TSIGError e(BAD_MODE_CODE);
343 return (e);
344}
345
346inline const TSIGError&
348 static TSIGError e(BAD_NAME_CODE);
349 return (e);
350}
351
352inline const TSIGError&
354 static TSIGError e(BAD_ALG_CODE);
355 return (e);
356}
357
358inline const TSIGError&
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
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
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
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
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
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
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
static const Rcode & YXDOMAIN()
A constant object for the YXDOMAIN Rcode (see Rcode::YXDOMAIN_CODE).
Definition rcode.h:264
TSIG errors.
Definition tsigerror.h:22
bool operator==(const TSIGError &other) const
Same as equals().
Definition tsigerror.h:90
static const TSIGError & SERVFAIL()
A constant TSIG error object derived from Rcode::SERVFAIL()
Definition tsigerror.h:239
bool nequals(const TSIGError &other) const
Return true iff two TSIGError objects are not equal.
Definition tsigerror.h:101
static const TSIGError & RESERVED14()
A constant TSIG error object derived from Rcode::RESERVED14()
Definition tsigerror.h:311
CodeValue
Constants for pre-defined TSIG error values.
Definition tsigerror.h:32
@ BAD_ALG_CODE
21: TKEY algorithm not supported
Definition tsigerror.h:38
@ BAD_NAME_CODE
20: Duplicate TKEY name
Definition tsigerror.h:37
@ BAD_KEY_CODE
17: TSIG key is not recognized
Definition tsigerror.h:34
@ BAD_TRUNC_CODE
22: Bad truncation
Definition tsigerror.h:39
@ BAD_TIME_CODE
18: Current time and time signed are too different
Definition tsigerror.h:35
@ BAD_SIG_CODE
16: TSIG verification failure
Definition tsigerror.h:33
@ BAD_MODE_CODE
19: Bad TKEY mode
Definition tsigerror.h:36
static const TSIGError & YXRRSET()
A constant TSIG error object derived from Rcode::YXRRSET()
Definition tsigerror.h:269
static const TSIGError & BAD_ALG()
A constant TSIG error object for the BADALG code (see TSIGError::BAD_ALG_CODE).
Definition tsigerror.h:353
bool operator!=(const TSIGError &other) const
Same as nequals().
Definition tsigerror.h:106
static const TSIGError & YXDOMAIN()
A constant TSIG error object derived from Rcode::YXDOMAIN()
Definition tsigerror.h:263
static const TSIGError & NOTZONE()
A constant TSIG error object derived from Rcode::NOTZONE()
Definition tsigerror.h:287
std::string toText() const
Convert the TSIGError to a string.
Definition tsigerror.cc:40
static const TSIGError & BAD_NAME()
A constant TSIG error object for the BADNAME code (see TSIGError::BAD_NAME_CODE).
Definition tsigerror.h:347
static const TSIGError & NXRRSET()
A constant TSIG error object derived from Rcode::NXRRSET()
Definition tsigerror.h:275
static const TSIGError & NOTIMP()
A constant TSIG error object derived from Rcode::NOTIMP()
Definition tsigerror.h:251
static const TSIGError & REFUSED()
A constant TSIG error object derived from Rcode::REFUSED()
Definition tsigerror.h:257
TSIGError(uint16_t error_code)
Constructor from the code value.
Definition tsigerror.h:52
static const TSIGError & RESERVED11()
A constant TSIG error object derived from Rcode::RESERVED11()
Definition tsigerror.h:293
static const TSIGError & RESERVED15()
A constant TSIG error object derived from Rcode::RESERVED15()
Definition tsigerror.h:317
static const TSIGError & BAD_SIG()
A constant TSIG error object for the BADSIG code (see TSIGError::BAD_SIG_CODE).
Definition tsigerror.h:323
static const TSIGError & BAD_MODE()
A constant TSIG error object for the BADMODE code (see TSIGError::BAD_MODE_CODE).
Definition tsigerror.h:341
static const TSIGError & BAD_KEY()
A constant TSIG error object for the BADKEY code (see TSIGError::BAD_KEY_CODE).
Definition tsigerror.h:329
static const TSIGError & BAD_TIME()
A constant TSIG error object for the BADTIME code (see TSIGError::BAD_TIME_CODE).
Definition tsigerror.h:335
static const TSIGError & NXDOMAIN()
A constant TSIG error object derived from Rcode::NXDOMAIN()
Definition tsigerror.h:245
uint16_t getCode() const
Returns the TSIGCode error code value.
Definition tsigerror.h:73
static const TSIGError & RESERVED13()
A constant TSIG error object derived from Rcode::RESERVED13()
Definition tsigerror.h:305
static const TSIGError & NOTAUTH()
A constant TSIG error object derived from Rcode::NOTAUTH()
Definition tsigerror.h:281
static const TSIGError & NOERROR()
A constant TSIG error object derived from Rcode::NOERROR()
Definition tsigerror.h:227
static const TSIGError & BAD_TRUNC()
A constant TSIG error object for the BADTRUNC code (see TSIGError::BAD_TRUNC_CODE).
Definition tsigerror.h:359
static const TSIGError & FORMERR()
A constant TSIG error object derived from Rcode::FORMERR()
Definition tsigerror.h:233
static const TSIGError & RESERVED12()
A constant TSIG error object derived from Rcode::RESERVED12()
Definition tsigerror.h:299
bool equals(const TSIGError &other) const
Return true iff two TSIGError objects are equal.
Definition tsigerror.h:85
Rcode toRcode() const
Convert the TSIGError to a Rcode.
Definition tsigerror.cc:51
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.