Kea 2.5.6
tsigerror.h
Go to the documentation of this file.
1// Copyright (C) 2011-2015 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 1
9
10#include <ostream>
11#include <string>
12
13#include <dns/rcode.h>
14
15namespace isc {
16namespace dns {
22class TSIGError {
23public:
32 enum CodeValue {
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 { return (code_); }
74
83 bool equals(const TSIGError& other) const
84 { return (code_ == other.code_); }
85
87 bool operator==(const TSIGError& other) const { return (equals(other)); }
88
96 bool nequals(const TSIGError& other) const
97 { return (code_ != other.code_); }
98
100 bool operator!=(const TSIGError& other) const { return (nequals(other)); }
101
116 std::string toText() const;
117
132 Rcode toRcode() const;
133
135 static const TSIGError& NOERROR();
136
138 static const TSIGError& FORMERR();
139
141 static const TSIGError& SERVFAIL();
142
144 static const TSIGError& NXDOMAIN();
145
147 static const TSIGError& NOTIMP();
148
150 static const TSIGError& REFUSED();
151
153 static const TSIGError& YXDOMAIN();
154
156 static const TSIGError& YXRRSET();
157
159 static const TSIGError& NXRRSET();
160
162 static const TSIGError& NOTAUTH();
163
165 static const TSIGError& NOTZONE();
166
168 static const TSIGError& RESERVED11();
169
171 static const TSIGError& RESERVED12();
172
174 static const TSIGError& RESERVED13();
175
177 static const TSIGError& RESERVED14();
178
180 static const TSIGError& RESERVED15();
181
184 static const TSIGError& BAD_SIG();
185
188 static const TSIGError& BAD_KEY();
189
192 static const TSIGError& BAD_TIME();
193
196 static const TSIGError& BAD_MODE();
197
200 static const TSIGError& BAD_NAME();
201
204 static const TSIGError& BAD_ALG();
205
208 static const TSIGError& BAD_TRUNC();
209
210private:
211 // This is internally used to specify the maximum possible RCODE value
212 // that can be convertible to TSIGErrors.
213 static const int MAX_RCODE_FOR_TSIGERROR = 15;
214
215 uint16_t code_;
216};
217
218inline const TSIGError&
220 static TSIGError e(Rcode::NOERROR());
221 return (e);
222}
223
224inline const TSIGError&
226 static TSIGError e(Rcode::FORMERR());
227 return (e);
228}
229
230inline const TSIGError&
232 static TSIGError e(Rcode::SERVFAIL());
233 return (e);
234}
235
236inline const TSIGError&
238 static TSIGError e(Rcode::NXDOMAIN());
239 return (e);
240}
241
242inline const TSIGError&
244 static TSIGError e(Rcode::NOTIMP());
245 return (e);
246}
247
248inline const TSIGError&
250 static TSIGError e(Rcode::REFUSED());
251 return (e);
252}
253
254inline const TSIGError&
256 static TSIGError e(Rcode::YXDOMAIN());
257 return (e);
258}
259
260inline const TSIGError&
262 static TSIGError e(Rcode::YXRRSET());
263 return (e);
264}
265
266inline const TSIGError&
268 static TSIGError e(Rcode::NXRRSET());
269 return (e);
270}
271
272inline const TSIGError&
274 static TSIGError e(Rcode::NOTAUTH());
275 return (e);
276}
277
278inline const TSIGError&
280 static TSIGError e(Rcode::NOTZONE());
281 return (e);
282}
283
284inline const TSIGError&
286 static TSIGError e(Rcode::RESERVED11());
287 return (e);
288}
289
290inline const TSIGError&
292 static TSIGError e(Rcode::RESERVED12());
293 return (e);
294}
295
296inline const TSIGError&
298 static TSIGError e(Rcode::RESERVED13());
299 return (e);
300}
301
302inline const TSIGError&
304 static TSIGError e(Rcode::RESERVED14());
305 return (e);
306}
307
308inline const TSIGError&
310 static TSIGError e(Rcode::RESERVED15());
311 return (e);
312}
313
314inline const TSIGError&
316 static TSIGError e(BAD_SIG_CODE);
317 return (e);
318}
319
320inline const TSIGError&
322 static TSIGError e(BAD_KEY_CODE);
323 return (e);
324}
325
326inline const TSIGError&
328 static TSIGError e(BAD_TIME_CODE);
329 return (e);
330}
331
332inline const TSIGError&
334 static TSIGError e(BAD_MODE_CODE);
335 return (e);
336}
337
338inline const TSIGError&
340 static TSIGError e(BAD_NAME_CODE);
341 return (e);
342}
343
344inline const TSIGError&
346 static TSIGError e(BAD_ALG_CODE);
347 return (e);
348}
349
350inline const TSIGError&
352 static TSIGError e(BAD_TRUNC_CODE);
353 return (e);
354}
355
366std::ostream& operator<<(std::ostream& os, const TSIGError& tsig_error);
367}
368}
369
370#endif // TSIGERROR_H
371
372// Local Variables:
373// mode: c++
374// 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
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
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
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
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
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
static const Rcode & YXDOMAIN()
A constant object for the YXDOMAIN Rcode (see Rcode::YXDOMAIN_CODE).
Definition: rcode.h:256
TSIG errors.
Definition: tsigerror.h:22
bool operator==(const TSIGError &other) const
Same as equals().
Definition: tsigerror.h:87
static const TSIGError & SERVFAIL()
A constant TSIG error object derived from Rcode::SERVFAIL()
Definition: tsigerror.h:231
bool nequals(const TSIGError &other) const
Return true iff two TSIGError objects are not equal.
Definition: tsigerror.h:96
static const TSIGError & RESERVED14()
A constant TSIG error object derived from Rcode::RESERVED14()
Definition: tsigerror.h:303
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:261
static const TSIGError & BAD_ALG()
A constant TSIG error object for the BADALG code (see TSIGError::BAD_ALG_CODE).
Definition: tsigerror.h:345
bool operator!=(const TSIGError &other) const
Same as nequals().
Definition: tsigerror.h:100
static const TSIGError & YXDOMAIN()
A constant TSIG error object derived from Rcode::YXDOMAIN()
Definition: tsigerror.h:255
static const TSIGError & NOTZONE()
A constant TSIG error object derived from Rcode::NOTZONE()
Definition: tsigerror.h:279
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:339
static const TSIGError & NXRRSET()
A constant TSIG error object derived from Rcode::NXRRSET()
Definition: tsigerror.h:267
static const TSIGError & NOTIMP()
A constant TSIG error object derived from Rcode::NOTIMP()
Definition: tsigerror.h:243
static const TSIGError & REFUSED()
A constant TSIG error object derived from Rcode::REFUSED()
Definition: tsigerror.h:249
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:285
static const TSIGError & RESERVED15()
A constant TSIG error object derived from Rcode::RESERVED15()
Definition: tsigerror.h:309
static const TSIGError & BAD_SIG()
A constant TSIG error object for the BADSIG code (see TSIGError::BAD_SIG_CODE).
Definition: tsigerror.h:315
static const TSIGError & BAD_MODE()
A constant TSIG error object for the BADMODE code (see TSIGError::BAD_MODE_CODE).
Definition: tsigerror.h:333
static const TSIGError & BAD_KEY()
A constant TSIG error object for the BADKEY code (see TSIGError::BAD_KEY_CODE).
Definition: tsigerror.h:321
static const TSIGError & BAD_TIME()
A constant TSIG error object for the BADTIME code (see TSIGError::BAD_TIME_CODE).
Definition: tsigerror.h:327
static const TSIGError & NXDOMAIN()
A constant TSIG error object derived from Rcode::NXDOMAIN()
Definition: tsigerror.h:237
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:297
static const TSIGError & NOTAUTH()
A constant TSIG error object derived from Rcode::NOTAUTH()
Definition: tsigerror.h:273
static const TSIGError & NOERROR()
A constant TSIG error object derived from Rcode::NOERROR()
Definition: tsigerror.h:219
static const TSIGError & BAD_TRUNC()
A constant TSIG error object for the BADTRUNC code (see TSIGError::BAD_TRUNC_CODE).
Definition: tsigerror.h:351
static const TSIGError & FORMERR()
A constant TSIG error object derived from Rcode::FORMERR()
Definition: tsigerror.h:225
static const TSIGError & RESERVED12()
A constant TSIG error object derived from Rcode::RESERVED12()
Definition: tsigerror.h:291
bool equals(const TSIGError &other) const
Return true iff two TSIGError objects are equal.
Definition: tsigerror.h:83
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:172
Defines the logger used by the top-level component of kea-lfc.