Kea 2.5.6
rrtype.cc
Go to the documentation of this file.
1// Copyright (C) 2010-2015 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 <stdint.h>
10
11#include <string>
12#include <ostream>
13
15
16#include <util/buffer.h>
17#include <dns/messagerenderer.h>
18#include <dns/rrparamregistry.h>
19#include <dns/rrtype.h>
20
21using namespace std;
22using namespace isc::util;
24
25namespace isc {
26namespace dns {
27
28RRType::RRType(const std::string& type_str) {
29 uint16_t typecode;
30 if (!RRParamRegistry::getRegistry().textToTypeCode(type_str, typecode)) {
32 "Unrecognized RR type string: " + type_str);
33 }
34 typecode_ = typecode;
35}
36
38 if (buffer.getLength() - buffer.getPosition() < sizeof(uint16_t)) {
39 isc_throw(IncompleteRRType, "incomplete wire-format RR type");
40 }
41 typecode_ = buffer.readUint16();
42}
43
44const string
46 return (RRParamRegistry::getRegistry().codeToTypeText(typecode_));
47}
48
49void
51 buffer.writeUint16(typecode_);
52}
53
54void
56 renderer.writeUint16(typecode_);
57}
58
59ostream&
60operator<<(ostream& os, const RRType& rrtype) {
61 os << rrtype.toText();
62 return (os);
63}
64}
65}
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
void writeUint16(uint16_t data)
Write an unsigned 16-bit integer in host byte order into the internal buffer in network byte order.
A standard DNS module exception that is thrown if an RRType object is being constructed from a incomp...
Definition: rrtype.h:54
A standard DNS module exception that is thrown if an RRType object is being constructed from an unrec...
Definition: rrtype.h:44
static RRParamRegistry & getRegistry()
Return the singleton instance of RRParamRegistry.
The RRType class encapsulates DNS resource record types.
Definition: rrtype.h:106
RRType(uint16_t typecode)
Constructor from an integer type code.
Definition: rrtype.h:117
void toWire(AbstractMessageRenderer &renderer) const
Render the RRType in the wire format.
Definition: rrtype.cc:55
const std::string toText() const
Convert the RRType to a string.
Definition: rrtype.cc:45
The InputBuffer class is a buffer abstraction for manipulating read-only data.
Definition: buffer.h:81
size_t getPosition() const
Return the current read position.
Definition: buffer.h:102
size_t getLength() const
Return the length of the data stored in the buffer.
Definition: buffer.h:100
uint16_t readUint16()
Read an unsigned 16-bit integer in network byte order from the buffer, convert it to host byte order,...
Definition: buffer.h:142
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
void writeUint16(uint16_t data)
Write an unsigned 16-bit integer in host byte order into the buffer in network byte order.
Definition: buffer.h:490
#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:172
Definition: edns.h:19
Defines the logger used by the top-level component of kea-lfc.