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