• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PowerDNS / pdns / 18679017918

21 Oct 2025 09:15AM UTC coverage: 69.743% (+2.0%) from 67.713%
18679017918

Pull #16307

github

web-flow
Merge ba88af487 into da98764c6
Pull Request #16307: rec: explicit disabling/enabling of tls-gnutls for full and least configs and packages

26192 of 45526 branches covered (57.53%)

Branch coverage included in aggregate %.

6 of 6 new or added lines in 1 file covered. (100.0%)

2282 existing lines in 57 files now uncovered.

86265 of 115719 relevant lines covered (74.55%)

4323875.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.87
/pdns/qtype.hh
1
/*
2
 * This file is part of PowerDNS or dnsdist.
3
 * Copyright -- PowerDNS.COM B.V. and its contributors
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of version 2 of the GNU General Public License as
7
 * published by the Free Software Foundation.
8
 *
9
 * In addition, for the avoidance of any doubt, permission is granted to
10
 * link this program with OpenSSL and to (re)distribute the binaries
11
 * produced as the result of such linking.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 */
22
#pragma once
23
#ifdef HAVE_CONFIG_H
24
#include "config.h"
25
#endif
26

27
#include "namespaces.hh"
28

29
/** The QType class is meant to deal easily with the different kind of resource types, like 'A', 'NS',
30
 *  'CNAME' etcetera. These types have both a name and a number. This class can seamlessly move between
31
 *   them. Use it like this:
32

33
\code
34
   QType t;
35
   t="CNAME";
36
   cout<<t.getCode()<<endl; // prints '5'
37
   t=6;
38
   cout<<t.toString()<<endl; // prints 'SOA'
39
\endcode
40

41
*/
42

43
class QType
44
{
45
public:
46
  QType(uint16_t qtype = 0) : code(qtype) {}
18,266,394✔
47
  QType &operator=(const char *);
48
  QType &operator=(const string &);
49

50
  operator uint16_t() const {
7,921,581✔
51
    return code;
7,921,581✔
52
  }
7,921,581✔
53

54
  const string toString() const;
55
  uint16_t getCode() const
56
  {
41,412,566✔
57
    return code;
41,412,566✔
58
  }
41,412,566✔
59

60
  /**
61
   * \brief Return whether we know the name of this type.
62
   *
63
   * This does not presume that we have an implemented a content representation for this type,
64
   * for that please see DNSRecordContent::isRegisteredType().
65
   */
66
  bool isSupportedType() const;
67
  /**
68
   * \brief Whether the type is either a QTYPE or Meta-Type as defined by rfc6895 section 3.1.
69
   *
70
   * Note that ANY is 255 and falls outside the range.
71
   */
72
  bool isMetadataType() const;
73

74
  static uint16_t chartocode(const char* p);
75

76
  enum typeenum : uint16_t {
77
    ENT = 0,
78
    A = 1,
79
    NS = 2,
80
    CNAME = 5,
81
    SOA = 6,
82
    MB = 7,
83
    MG = 8,
84
    MR = 9,
85
    PTR = 12,
86
    HINFO = 13,
87
    MINFO = 14,
88
    MX = 15,
89
    TXT = 16,
90
    RP = 17,
91
    AFSDB = 18,
92
    SIG = 24,
93
    KEY = 25,
94
    AAAA = 28,
95
    LOC = 29,
96
    SRV = 33,
97
    NAPTR = 35,
98
    KX = 36,
99
    CERT = 37,
100
    A6 = 38,
101
    DNAME = 39,
102
    OPT = 41,
103
    APL = 42,
104
    DS = 43,
105
    SSHFP = 44,
106
    IPSECKEY = 45,
107
    RRSIG = 46,
108
    NSEC = 47,
109
    DNSKEY = 48,
110
    DHCID = 49,
111
    NSEC3 = 50,
112
    NSEC3PARAM = 51,
113
    TLSA = 52,
114
    SMIMEA = 53,
115
    RKEY = 57,
116
    CDS = 59,
117
    CDNSKEY = 60,
118
    OPENPGPKEY = 61,
119
    CSYNC = 62,
120
    ZONEMD = 63,
121
    SVCB = 64,
122
    HTTPS = 65,
123
    HHIT = 67,
124
    BRID = 68,
125
    SPF = 99,
126
    NID = 104,
127
    L32 = 105,
128
    L64 = 106,
129
    LP = 107,
130
    EUI48 = 108,
131
    EUI64 = 109,
132
    TKEY = 249,
133
    TSIG = 250,
134
    IXFR = 251,
135
    AXFR = 252,
136
    MAILB = 253,
137
    MAILA = 254,
138
    ANY = 255,
139
    URI = 256,
140
    CAA = 257,
141
    DLV = 32769,
142
    ADDR = 65400,
143
#if !defined(RECURSOR)
144
    ALIAS = 65401,
145
    LUA = 65402
146
#endif
147
  };
148

149
  const static uint16_t rfc6895MetaLowerBound = 128;
150
  const static uint16_t rfc6895MetaUpperBound = 254; // Note 255: ANY is not included
151
  const static uint16_t rfc6895Reserved = 65535;
152

153
  const static map<const string, uint16_t> names;
154
  const static map<uint16_t, const string> numbers;
155

156
  // QTypes that MUST NOT be used with any other QType on the same name.
157
  const static std::set<uint16_t> exclusiveEntryTypes;
158

159
private:
160

161
  uint16_t code;
162
};
163

164
// Define hash function on QType. See https://en.cppreference.com/w/cpp/utility/hash
165
namespace std {
166
  template<> struct hash<QType> {
167
    std::size_t operator()(QType qtype) const noexcept {
1,119✔
168
      return std::hash<uint16_t>{}(qtype.getCode());
1,119✔
169
    }
1,119✔
170
  };
171
}
172

173
inline std::ostream& operator<<(std::ostream& stream, const QType& qtype)
UNCOV
174
{
×
UNCOV
175
  return stream << qtype.toString();
×
UNCOV
176
}
×
177

178
// Used by e.g. boost multi-index
UNCOV
179
inline size_t hash_value(const QType qtype) {
×
UNCOV
180
  return qtype.getCode();
×
UNCOV
181
}
×
182

183
struct QClass
184
{
185
  constexpr QClass(uint16_t code = 0) : qclass(code) {}
1✔
186
  explicit QClass(const std::string& code);
187

188
  constexpr operator uint16_t() const {
28,016,711✔
189
    return qclass;
28,016,711✔
190
  }
28,016,711✔
191
  constexpr uint16_t getCode() const
192
  {
193
    return qclass;
194
  }
195
  std::string toString() const;
196

197
  static const QClass IN;
198
  static const QClass CHAOS;
199
  static const QClass NONE;
200
  static const QClass ANY;
201

202
private:
203
  uint16_t qclass;
204
};
205

206
constexpr QClass QClass::IN(1);
207
constexpr QClass QClass::CHAOS(3);
208
constexpr QClass QClass::NONE(254);
209
constexpr QClass QClass::ANY(255);
210

211
inline std::ostream& operator<<(std::ostream& s, QClass qclass)
212
{
×
213
  return s << qclass.toString();
×
214
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc