Kea 2.7.5
question.h
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#ifndef QUESTION_H
8#define QUESTION_H
9
10#include <iostream>
11#include <string>
12
13#include <boost/shared_ptr.hpp>
14
15#include <dns/name.h>
16#include <dns/rrclass.h>
17#include <dns/rrtype.h>
18
19namespace isc {
20namespace dns {
21class Question;
22
24typedef boost::shared_ptr<Question> QuestionPtr;
25
27typedef boost::shared_ptr<const Question> ConstQuestionPtr;
28
88class Question {
98
99public:
111
121 Question(const Name& name, const RRClass& rrclass, const RRType& rrtype) :
122 name_(name), rrtype_(rrtype), rrclass_(rrclass) {
123 }
125
129
130
136 const Name& getName() const {
137 return (name_);
138 }
139
146 const RRType& getType() const {
147 return (rrtype_);
148 }
149
156 const RRClass& getClass() const {
157 return (rrclass_);
158 }
160
164
165
182 std::string toText(bool newline = false) const;
183
216 uint32_t toWire(AbstractMessageRenderer& renderer) const;
217
226 uint32_t toWire(isc::util::OutputBuffer& buffer) const;
228
232
233
235 bool operator <(const Question& rhs) const {
236 return (rrclass_ < rhs.rrclass_ ||
237 (rrclass_ == rhs.rrclass_ &&
238 (rrtype_ < rhs.rrtype_ ||
239 (rrtype_ == rhs.rrtype_ && (name_ < rhs.name_)))));
240 }
241
247 bool operator==(const Question& rhs) const {
248 return ((rrclass_ == rhs.rrclass_) && (rrtype_ == rhs.rrtype_) &&
249 (name_ == rhs.name_));
250 }
251
258 bool operator!=(const Question& rhs) const {
259 return (!operator==(rhs));
260 }
262
263private:
264 Name name_;
265 RRType rrtype_;
266 RRClass rrclass_;
267};
268
283std::ostream& operator<<(std::ostream& os, const Question& question);
284} // end of namespace dns
285} // end of namespace isc
286#endif // QUESTION_H
The AbstractMessageRenderer class is an abstract base class that provides common interfaces for rende...
The Name class encapsulates DNS names.
Definition name.h:219
The Question class encapsulates the common search key of DNS lookup, consisting of owner name,...
Definition question.h:88
std::string toText(bool newline=false) const
Convert the Question to a string.
Definition question.cc:38
Question(const Name &name, const RRClass &rrclass, const RRType &rrtype)
Constructor from fixed parameters of the Question.
Definition question.h:121
uint32_t toWire(AbstractMessageRenderer &renderer) const
Render the Question in the wire format with name compression.
Definition question.cc:58
const Name & getName() const
Returns the owner name of the Question.
Definition question.h:136
bool operator<(const Question &rhs) const
A "less than" operator is needed for this class so it can function as an index to std::map.
Definition question.h:235
Question(isc::util::InputBuffer &buff)
Constructor from wire-format data.
Definition question.cc:25
const RRType & getType() const
Returns the RR Class of the Question.
Definition question.h:146
bool operator==(const Question &rhs) const
Equality operator.
Definition question.h:247
bool operator!=(const Question &rhs) const
Inequality operator.
Definition question.h:258
const RRClass & getClass() const
Returns the RR Type of the Question.
Definition question.h:156
The RRClass class encapsulates DNS resource record classes.
Definition rrclass.h:89
The RRType class encapsulates DNS resource record types.
Definition rrtype.h:96
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
boost::shared_ptr< Question > QuestionPtr
A pointer-like type pointing to an Question object.
Definition question.h:24
ostream & operator<<(std::ostream &os, const EDNS &edns)
Insert the EDNS as a string into stream.
Definition edns.cc:163
boost::shared_ptr< const Question > ConstQuestionPtr
A pointer-like type pointing to an (immutable) Question object.
Definition question.h:27
Defines the logger used by the top-level component of kea-lfc.