Kea 2.7.6
opcode.cc
Go to the documentation of this file.
1// Copyright (C) 2010-2016 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#include <config.h>
8
9#include <string>
10#include <ostream>
11
13
14#include <dns/opcode.h>
15
16using namespace std;
17
18namespace isc {
19namespace dns {
20namespace {
21const char *opcodetext[] = {
22 "QUERY",
23 "IQUERY",
24 "STATUS",
25 "RESERVED3",
26 "NOTIFY",
27 "UPDATE",
28 "RESERVED6",
29 "RESERVED7",
30 "RESERVED8",
31 "RESERVED9",
32 "RESERVED10",
33 "RESERVED11",
34 "RESERVED12",
35 "RESERVED13",
36 "RESERVED14",
37 "RESERVED15"
38};
39
40// OPCODEs are 4-bit values. So 15 is the highest code.
41const uint8_t MAX_OPCODE = 15;
42}
43
44Opcode::Opcode(const uint8_t code) : code_(static_cast<CodeValue>(code)) {
45 if (code > MAX_OPCODE) {
47 "DNS Opcode is too large to construct: "
48 << static_cast<unsigned>(code));
49 }
50}
51
52string
54 return (opcodetext[code_]);
55}
56
57ostream&
58operator<<(std::ostream& os, const Opcode& opcode) {
59 return (os << opcode.toText());
60}
61}
62}
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
The Opcode class objects represent standard OPCODEs of the header section of DNS messages as defined ...
Definition opcode.h:32
std::string toText() const
Convert the Opcode to a string.
Definition opcode.cc:53
Opcode(const uint8_t code)
Constructor from the code value.
Definition opcode.cc:44
CodeValue
Constants for standard OPCODE values.
Definition opcode.h:35
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
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.
uint16_t code_