Kea  1.9.9-git
opcode.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2015 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 1
15 
16 namespace isc {
17 namespace dns {
18 
32 class Opcode {
33 public:
35  enum CodeValue {
36  QUERY_CODE = 0,
52  };
53 
62 
63  explicit Opcode(const uint8_t code);
72 
78  CodeValue getCode() const { return (code_); }
79 
88  bool equals(const Opcode& other) const
89  { return (code_ == other.code_); }
90 
92  bool operator==(const Opcode& other) const { return (equals(other)); }
93 
100  bool nequals(const Opcode& other) const
101  { return (code_ != other.code_); }
102 
104  bool operator!=(const Opcode& other) const { return (nequals(other)); }
105 
116  std::string toText() const;
117 
119  static const Opcode& QUERY();
120 
122  static const Opcode& IQUERY();
123 
125  static const Opcode& STATUS();
126 
128  static const Opcode& RESERVED3();
129 
131  static const Opcode& NOTIFY();
132 
134  static const Opcode& UPDATE();
135 
137  static const Opcode& RESERVED6();
138 
140  static const Opcode& RESERVED7();
141 
143  static const Opcode& RESERVED8();
144 
146  static const Opcode& RESERVED9();
147 
149  static const Opcode& RESERVED10();
150 
152  static const Opcode& RESERVED11();
153 
155  static const Opcode& RESERVED12();
156 
158  static const Opcode& RESERVED13();
159 
161  static const Opcode& RESERVED14();
162 
164  static const Opcode& RESERVED15();
165 private:
166  CodeValue code_;
167 };
168 
169 inline const Opcode&
171  static Opcode c(0);
172  return (c);
173 }
174 
175 inline const Opcode&
177  static Opcode c(1);
178  return (c);
179 }
180 
181 inline const Opcode&
183  static Opcode c(2);
184  return (c);
185 }
186 
187 inline const Opcode&
189  static Opcode c(3);
190  return (c);
191 }
192 
193 inline const Opcode&
195  static Opcode c(4);
196  return (c);
197 }
198 
199 inline const Opcode&
201  static Opcode c(5);
202  return (c);
203 }
204 
205 inline const Opcode&
207  static Opcode c(6);
208  return (c);
209 }
210 
211 inline const Opcode&
213  static Opcode c(7);
214  return (c);
215 }
216 
217 inline const Opcode&
219  static Opcode c(8);
220  return (c);
221 }
222 
223 inline const Opcode&
225  static Opcode c(9);
226  return (c);
227 }
228 
229 inline const Opcode&
231  static Opcode c(10);
232  return (c);
233 }
234 
235 inline const Opcode&
237  static Opcode c(11);
238  return (c);
239 }
240 
241 inline const Opcode&
243  static Opcode c(12);
244  return (c);
245 }
246 
247 inline const Opcode&
249  static Opcode c(13);
250  return (c);
251 }
252 
253 inline const Opcode&
255  static Opcode c(14);
256  return (c);
257 }
258 
259 inline const Opcode&
261  static Opcode c(15);
262  return (c);
263 }
264 
275 std::ostream& operator<<(std::ostream& os, const Opcode& opcode);
276 }
277 }
278 #endif // OPCODE_H
279 
280 // Local Variables:
281 // mode: c++
282 // End:
8: Reserved for future use (RFC1035)
Definition: opcode.h:44
6: Reserved for future use (RFC1035)
Definition: opcode.h:42
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition: edns.cc:172
static const Opcode & RESERVED7()
A constant object for a reserved (code 7) Opcode.
Definition: opcode.h:212
CodeValue
Constants for standard OPCODE values.
Definition: opcode.h:35
9: Reserved for future use (RFC1035)
Definition: opcode.h:45
7: Reserved for future use (RFC1035)
Definition: opcode.h:43
static const Opcode & RESERVED6()
A constant object for a reserved (code 6) Opcode.
Definition: opcode.h:206
bool equals(const Opcode &other) const
Return true iff two Opcodes are equal.
Definition: opcode.h:88
std::string toText() const
Convert the Opcode to a string.
Definition: opcode.cc:53
5: Dynamic update (RFC2136)
Definition: opcode.h:41
bool operator==(const Opcode &other) const
Same as equals().
Definition: opcode.h:92
3: Reserved for future use (RFC1035)
Definition: opcode.h:39
static const Opcode & RESERVED15()
A constant object for a reserved (code 15) Opcode.
Definition: opcode.h:260
15: Reserved for future use (RFC1035)
Definition: opcode.h:51
2: Server status request (RFC1035)
Definition: opcode.h:38
static const Opcode & RESERVED11()
A constant object for a reserved (code 11) Opcode.
Definition: opcode.h:236
static const Opcode & RESERVED13()
A constant object for a reserved (code 13) Opcode.
Definition: opcode.h:248
static const Opcode & RESERVED8()
A constant object for a reserved (code 8) Opcode.
Definition: opcode.h:218
static const Opcode & QUERY()
A constant object for the QUERY Opcode.
Definition: opcode.h:170
static const Opcode & RESERVED12()
A constant object for a reserved (code 12) Opcode.
Definition: opcode.h:242
static const Opcode & UPDATE()
A constant object for the UPDATE Opcode.
Definition: opcode.h:200
static const Opcode & NOTIFY()
A constant object for the NOTIFY Opcode.
Definition: opcode.h:194
bool nequals(const Opcode &other) const
Return true iff two Opcodes are not equal.
Definition: opcode.h:100
static const Opcode & RESERVED9()
A constant object for a reserved (code 9) Opcode.
Definition: opcode.h:224
12: Reserved for future use (RFC1035)
Definition: opcode.h:48
11: Reserved for future use (RFC1035)
Definition: opcode.h:47
bool operator!=(const Opcode &other) const
Same as nequals().
Definition: opcode.h:104
static const Opcode & RESERVED10()
A constant object for a reserved (code 10) Opcode.
Definition: opcode.h:230
CodeValue getCode() const
Returns the Opcode code value.
Definition: opcode.h:78
13: Reserved for future use (RFC1035)
Definition: opcode.h:49
0: Standard query (RFC1035)
Definition: opcode.h:36
static const Opcode & IQUERY()
A constant object for the IQUERY Opcode.
Definition: opcode.h:176
Defines the logger used by the top-level component of kea-dhcp-ddns.
1: Inverse query (RFC1035)
Definition: opcode.h:37
static const Opcode & STATUS()
A constant object for the STATUS Opcode.
Definition: opcode.h:182
4: Notify (RFC1996)
Definition: opcode.h:40
10: Reserved for future use (RFC1035)
Definition: opcode.h:46
static const Opcode & RESERVED14()
A constant object for a reserved (code 14) Opcode.
Definition: opcode.h:254
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:188
Opcode(const uint8_t code)
Constructor from the code value.
Definition: opcode.cc:44
14: Reserved for future use (RFC1035)
Definition: opcode.h:50