Kea 2.7.0
rrtype.cc
Go to the documentation of this file.
1// Copyright (C) 2010-2024 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
10#include <dns/messagerenderer.h>
11#include <dns/rrparamregistry.h>
12#include <dns/rrtype.h>
13#include <util/buffer.h>
14
15#include <stdint.h>
16#include <string>
17#include <ostream>
18
19using namespace isc::util;
21
22using namespace std;
23
24namespace isc {
25namespace dns {
26
27RRType::RRType(const std::string& type_str) {
28 uint16_t typecode;
29 if (!RRParamRegistry::getRegistry().textToTypeCode(type_str, typecode)) {
31 "Unrecognized RR type string: " + type_str);
32 }
33 typecode_ = typecode;
34}
35
37 if (buffer.getLength() - buffer.getPosition() < sizeof(uint16_t)) {
38 isc_throw(IncompleteRRType, "incomplete wire-format RR type");
39 }
40 typecode_ = buffer.readUint16();
41}
42
43const string
45 return (RRParamRegistry::getRegistry().codeToTypeText(typecode_));
46}
47
48void
50 buffer.writeUint16(typecode_);
51}
52
53void
55 renderer.writeUint16(typecode_);
56}
57
58ostream&
59operator<<(ostream& os, const RRType& rrtype) {
60 os << rrtype.toText();
61 return (os);
62}
63}
64}
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
A standard DNS module exception that is thrown if an RRType object is being constructed from a incomp...
Definition rrtype.h:44
A standard DNS module exception that is thrown if an RRType object is being constructed from an unrec...
Definition rrtype.h:34
static RRParamRegistry & getRegistry()
Return the singleton instance of RRParamRegistry.
The RRType class encapsulates DNS resource record types.
Definition rrtype.h:96
RRType(uint16_t typecode)
Constructor from an integer type code.
Definition rrtype.h:107
void toWire(AbstractMessageRenderer &renderer) const
Render the RRType in the wire format.
Definition rrtype.cc:54
const std::string toText() const
Convert the RRType to a string.
Definition rrtype.cc:44
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition buffer.h:81
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition buffer.h:343
#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.