]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Make QClass constants type QClass instead of enum
authorOtto <otto.moerbeek@open-xchange.com>
Wed, 31 Mar 2021 08:39:35 +0000 (10:39 +0200)
committerOtto <otto.moerbeek@open-xchange.com>
Wed, 31 Mar 2021 08:39:35 +0000 (10:39 +0200)
pdns/dnsdistdist/dnsdist-secpoll.cc
pdns/qtype.hh

index 8737dec4798b52bd736a312bc8877134c04a1883..5742aba4a473b4962d1f359c5544d20e8d73d587 100644 (file)
@@ -170,7 +170,7 @@ static std::string getSecPollStatus(const std::string& queriedName, int timeout=
 
     if (receivedName != sentName || receivedType != QType::TXT || receivedClass != QClass::IN) {
       if (g_verbose) {
-        warnlog("Invalid answer, either the qname (%s / %s), qtype (%s / %s) or qclass (%d / %d) does not match, received from the secpoll stub resolver %s", receivedName, sentName, QType(receivedType).getName(), QType(QType::TXT).getName(), receivedClass, QClass::IN, dest.toString());
+        warnlog("Invalid answer, either the qname (%s / %s), qtype (%s / %s) or qclass (%s / %s) does not match, received from the secpoll stub resolver %s", receivedName, sentName, QType(receivedType).getName(), QType(QType::TXT).getName(), QClass(receivedClass).toString(), QClass::IN.toString(), dest.toString());
       }
       continue;
     }
index 02c5ef57f36bddf77751807965819a3e156d08d2..b0ca39d3a4e70b8294656d30597bfe339b0b857c 100644 (file)
@@ -146,19 +146,32 @@ inline size_t hash_value(const QType qtype) {
 
 struct QClass
 {
-  enum QClassEnum : uint16_t { IN = 1, CHAOS = 3, NONE = 254, ANY = 255 };
+  constexpr QClass(uint16_t code = 0) : qclass(code) {}
 
-  QClass(uint16_t code = 0) : qclass(code) {}
-
-  operator uint16_t() const {
+  constexpr operator uint16_t() const {
     return qclass;
   }
-  uint16_t getCode() const
+  constexpr uint16_t getCode() const
   {
     return qclass;
   }
   const std::string toString() const;
 
+  static const QClass IN;
+  static const QClass CHAOS;
+  static const QClass NONE;
+  static const QClass ANY;
+
 private:
   uint16_t qclass;
 };
+
+constexpr QClass QClass::IN(1);
+constexpr QClass QClass::CHAOS(3);
+constexpr QClass QClass::NONE(254);
+constexpr QClass QClass::ANY(255);
+
+inline std::ostream& operator<<(std::ostream& s, QClass qclass)
+{
+  return s << qclass.toString();
+}