Kea 3.3.3
opcode.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2026 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 <cstdint>
10#include <ostream>
11
12#ifndef OPCODE_H
13#define OPCODE_H
14
15namespace isc {
16namespace dns {
17
31class Opcode {
32public:
52
61
62
69 explicit Opcode(const uint8_t code);
71
78 return (code_);
79 }
80
89 bool equals(const Opcode& other) const {
90 return (code_ == other.code_);
91 }
92
94 bool operator==(const Opcode& other) const {
95 return (equals(other));
96 }
97
104 bool nequals(const Opcode& other) const {
105 return (code_ != other.code_);
106 }
107
109 bool operator!=(const Opcode& other) const {
110 return (nequals(other));
111 }
112
123 std::string toText() const;
124
126 static const Opcode& QUERY();
127
129 static const Opcode& IQUERY();
130
132 static const Opcode& STATUS();
133
135 static const Opcode& RESERVED3();
136
138 static const Opcode& NOTIFY();
139
141 static const Opcode& UPDATE();
142
144 static const Opcode& RESERVED6();
145
147 static const Opcode& RESERVED7();
148
150 static const Opcode& RESERVED8();
151
153 static const Opcode& RESERVED9();
154
156 static const Opcode& RESERVED10();
157
159 static const Opcode& RESERVED11();
160
162 static const Opcode& RESERVED12();
163
165 static const Opcode& RESERVED13();
166
168 static const Opcode& RESERVED14();
169
171 static const Opcode& RESERVED15();
172private:
173 CodeValue code_;
174};
175
176inline const Opcode&
178 static Opcode c(0);
179 return (c);
180}
181
182inline const Opcode&
184 static Opcode c(1);
185 return (c);
186}
187
188inline const Opcode&
190 static Opcode c(2);
191 return (c);
192}
193
194inline const Opcode&
196 static Opcode c(3);
197 return (c);
198}
199
200inline const Opcode&
202 static Opcode c(4);
203 return (c);
204}
205
206inline const Opcode&
208 static Opcode c(5);
209 return (c);
210}
211
212inline const Opcode&
214 static Opcode c(6);
215 return (c);
216}
217
218inline const Opcode&
220 static Opcode c(7);
221 return (c);
222}
223
224inline const Opcode&
226 static Opcode c(8);
227 return (c);
228}
229
230inline const Opcode&
232 static Opcode c(9);
233 return (c);
234}
235
236inline const Opcode&
238 static Opcode c(10);
239 return (c);
240}
241
242inline const Opcode&
244 static Opcode c(11);
245 return (c);
246}
247
248inline const Opcode&
250 static Opcode c(12);
251 return (c);
252}
253
254inline const Opcode&
256 static Opcode c(13);
257 return (c);
258}
259
260inline const Opcode&
262 static Opcode c(14);
263 return (c);
264}
265
266inline const Opcode&
268 static Opcode c(15);
269 return (c);
270}
271
282std::ostream& operator<<(std::ostream& os, const Opcode& opcode);
283}
284}
285#endif // OPCODE_H
The Opcode class objects represent standard OPCODEs of the header section of DNS messages as defined ...
Definition opcode.h:31
static const Opcode & RESERVED3()
A constant object for a reserved (code 3) Opcode.
Definition opcode.h:195
static const Opcode & RESERVED6()
A constant object for a reserved (code 6) Opcode.
Definition opcode.h:213
static const Opcode & RESERVED8()
A constant object for a reserved (code 8) Opcode.
Definition opcode.h:225
std::string toText() const
Convert the Opcode to a string.
Definition opcode.cc:53
static const Opcode & RESERVED12()
A constant object for a reserved (code 12) Opcode.
Definition opcode.h:249
static const Opcode & RESERVED11()
A constant object for a reserved (code 11) Opcode.
Definition opcode.h:243
static const Opcode & RESERVED13()
A constant object for a reserved (code 13) Opcode.
Definition opcode.h:255
static const Opcode & RESERVED14()
A constant object for a reserved (code 14) Opcode.
Definition opcode.h:261
static const Opcode & STATUS()
A constant object for the STATUS Opcode.
Definition opcode.h:189
static const Opcode & RESERVED15()
A constant object for a reserved (code 15) Opcode.
Definition opcode.h:267
static const Opcode & NOTIFY()
A constant object for the NOTIFY Opcode.
Definition opcode.h:201
static const Opcode & UPDATE()
A constant object for the UPDATE Opcode.
Definition opcode.h:207
bool nequals(const Opcode &other) const
Return true iff two Opcodes are not equal.
Definition opcode.h:104
Opcode(const uint8_t code)
Constructor from the code value.
Definition opcode.cc:44
bool operator==(const Opcode &other) const
Same as equals().
Definition opcode.h:94
CodeValue getCode() const
Returns the Opcode code value.
Definition opcode.h:77
static const Opcode & RESERVED9()
A constant object for a reserved (code 9) Opcode.
Definition opcode.h:231
static const Opcode & QUERY()
A constant object for the QUERY Opcode.
Definition opcode.h:177
bool equals(const Opcode &other) const
Return true iff two Opcodes are equal.
Definition opcode.h:89
static const Opcode & RESERVED7()
A constant object for a reserved (code 7) Opcode.
Definition opcode.h:219
static const Opcode & RESERVED10()
A constant object for a reserved (code 10) Opcode.
Definition opcode.h:237
bool operator!=(const Opcode &other) const
Same as nequals().
Definition opcode.h:109
static const Opcode & IQUERY()
A constant object for the IQUERY Opcode.
Definition opcode.h:183
CodeValue
Constants for standard OPCODE values.
Definition opcode.h:34
@ RESERVED13_CODE
13: Reserved for future use (RFC1035)
Definition opcode.h:48
@ RESERVED15_CODE
15: Reserved for future use (RFC1035)
Definition opcode.h:50
@ RESERVED12_CODE
12: Reserved for future use (RFC1035)
Definition opcode.h:47
@ RESERVED10_CODE
10: Reserved for future use (RFC1035)
Definition opcode.h:45
@ RESERVED11_CODE
11: Reserved for future use (RFC1035)
Definition opcode.h:46
@ UPDATE_CODE
5: Dynamic update (RFC2136)
Definition opcode.h:40
@ NOTIFY_CODE
4: Notify (RFC1996)
Definition opcode.h:39
@ RESERVED7_CODE
7: Reserved for future use (RFC1035)
Definition opcode.h:42
@ STATUS_CODE
2: Server status request (RFC1035)
Definition opcode.h:37
@ IQUERY_CODE
1: Inverse query (RFC1035)
Definition opcode.h:36
@ QUERY_CODE
0: Standard query (RFC1035)
Definition opcode.h:35
@ RESERVED14_CODE
14: Reserved for future use (RFC1035)
Definition opcode.h:49
@ RESERVED3_CODE
3: Reserved for future use (RFC1035)
Definition opcode.h:38
@ RESERVED6_CODE
6: Reserved for future use (RFC1035)
Definition opcode.h:41
@ RESERVED8_CODE
8: Reserved for future use (RFC1035)
Definition opcode.h:43
@ RESERVED9_CODE
9: Reserved for future use (RFC1035)
Definition opcode.h:44
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.