{
if (!(g_nodLookupDomain.isRoot())) {
// Send a DNS A query to <domain>.g_nodLookupDomain
- static const QType qt(QType::A);
- static const uint16_t qc(QClass::IN);
DNSName qname;
try {
qname = dname + g_nodLookupDomain;
return;
}
vector<DNSRecord> dummy;
- directResolve(qname, qt, qc, dummy);
+ directResolve(qname, QType::A, QClass::IN, dummy);
}
}
again, possibly encountering the same CNAME(s), and we don't want to trigger the CNAME
loop detection. */
vector<DNSRecord> newRecords;
- int rcode = directResolve(qname, QType(QType::A), QClass::IN, newRecords);
+ int rcode = directResolve(qname, QType::A, QClass::IN, newRecords);
ret.reserve(ret.size() + newRecords.size());
for (auto& record : newRecords) {
rr.d_content = std::make_shared<CNAMERecordContent>(newquery);
ret.push_back(rr);
- int rcode = directResolve(DNSName(newquery), QType(QType::PTR), QClass::IN, ret);
+ int rcode = directResolve(DNSName(newquery), QType::PTR, QClass::IN, ret);
return rcode;
}
code = chartocode(s.c_str());
return *this;
}
+
+const std::string QClass::toString() const
+{
+ switch (qclass) {
+ case IN:
+ return "IN";
+ case CHAOS:
+ return "CHAOS";
+ case NONE:
+ return "NONE";
+ case ANY:
+ return "ANY";
+ default :
+ return "CLASS" + std::to_string(qclass);
+ }
+}
struct QClass
{
- enum QClassEnum { IN = 1, CHAOS = 3, NONE = 254, ANY = 255 };
+ enum QClassEnum : uint16_t { IN = 1, CHAOS = 3, NONE = 254, ANY = 255 };
+
+ QClass(uint16_t code = 0) : qclass(code) {}
+
+ operator uint16_t() const {
+ return qclass;
+ }
+ uint16_t getCode() const
+ {
+ return qclass;
+ }
+ const std::string toString() const;
+
+private:
+ uint16_t qclass;
};
<< endl;
}
-static const string nameForClass(uint16_t qclass, uint16_t qtype)
+static const string nameForClass(QClass qclass, uint16_t qtype)
{
if (qtype == QType::OPT)
return "IN";
- switch (qclass) {
- case QClass::IN:
- return "IN";
- case QClass::CHAOS:
- return "CHAOS";
- case QClass::NONE:
- return "NONE";
- case QClass::ANY:
- return "ANY";
- default:
- return string("CLASS") + std::to_string(qclass);
- }
+ return qclass.toString();
}
static std::unordered_set<uint16_t> s_expectedIDs;
bool dnssec, const boost::optional<Netmask> ednsnm,
bool recurse, uint16_t xpfcode, uint16_t xpfversion,
uint64_t xpfproto, char* xpfsrc, char* xpfdst,
- uint16_t qclass, uint16_t qid)
+ QClass qclass, uint16_t qid)
{
DNSPacketWriter pw(packet, DNSName(q), DNSRecordContent::TypeToNumber(t), qclass);
boost::optional<Netmask> ednsnm;
uint16_t xpfcode = 0, xpfversion = 0, xpfproto = 0;
char *xpfsrc = NULL, *xpfdst = NULL;
- uint16_t qclass = QClass::IN;
+ QClass qclass = QClass::IN;
string proxyheader;
string subjectName;
string caStore;
}
/** everything begins here - this is the entry point just after receiving a packet */
-int SyncRes::beginResolve(const DNSName &qname, const QType qtype, uint16_t qclass, vector<DNSRecord>&ret, unsigned int depth)
+int SyncRes::beginResolve(const DNSName &qname, const QType qtype, QClass qclass, vector<DNSRecord>&ret, unsigned int depth)
{
vState state = vState::Indeterminate;
s_queries++;
* - trustanchor.server CH TXT
* - negativetrustanchor.server CH TXT
*/
-bool SyncRes::doSpecialNamesResolve(const DNSName &qname, const QType qtype, const uint16_t qclass, vector<DNSRecord> &ret)
+bool SyncRes::doSpecialNamesResolve(const DNSName &qname, const QType qtype, const QClass qclass, vector<DNSRecord> &ret)
{
static const DNSName arpa("1.0.0.127.in-addr.arpa."), ip6_arpa("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa."),
localhost("localhost."), versionbind("version.bind."), idserver("id.server."), versionpdns("version.pdns."), trustanchorserver("trustanchor.server."),
}
// used by PowerDNSLua - note that this neglects to add the packet count & statistics back to pdns_ercursor.cc
-int directResolve(const DNSName& qname, const QType qtype, int qclass, vector<DNSRecord>& ret)
+int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, vector<DNSRecord>& ret)
{
struct timeval now;
gettimeofday(&now, 0);
explicit SyncRes(const struct timeval& now);
- int beginResolve(const DNSName &qname, QType qtype, uint16_t qclass, vector<DNSRecord>&ret, unsigned int depth = 0);
+ int beginResolve(const DNSName &qname, QType qtype, QClass qclass, vector<DNSRecord>&ret, unsigned int depth = 0);
void setId(int id)
{
RCode::rcodes_ updateCacheFromRecords(unsigned int depth, LWResult& lwr, const DNSName& qname, const QType qtype, const DNSName& auth, bool wasForwarded, const boost::optional<Netmask>, vState& state, bool& needWildcardProof, bool& gatherWildcardProof, unsigned int& wildcardLabelsCount, bool sendRDQuery, const ComboAddress& remoteIP);
bool processRecords(const std::string& prefix, const DNSName& qname, const QType qtype, const DNSName& auth, LWResult& lwr, const bool sendRDQuery, vector<DNSRecord>& ret, set<DNSName>& nsset, DNSName& newtarget, DNSName& newauth, bool& realreferral, bool& negindic, vState& state, const bool needWildcardProof, const bool gatherwildcardProof, const unsigned int wildcardLabelsCount, int& rcode, bool& negIndicHasSignatures, unsigned int depth);
- bool doSpecialNamesResolve(const DNSName &qname, QType qtype, const uint16_t qclass, vector<DNSRecord> &ret);
+ bool doSpecialNamesResolve(const DNSName &qname, QType qtype, const QClass qclass, vector<DNSRecord> &ret);
LWResult::Result asyncresolveWrapper(const ComboAddress& ip, bool ednsMANDATORY, const DNSName& domain, const DNSName& auth, int type, bool doTCP, bool sendRDQuery, struct timeval* now, boost::optional<Netmask>& srcmask, LWResult* res, bool* chained) const;
void broadcastFunction(const pipefunc_t& func);
void distributeAsyncFunction(const std::string& question, const pipefunc_t& func);
-int directResolve(const DNSName& qname, const QType qtype, int qclass, vector<DNSRecord>& ret);
+int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, vector<DNSRecord>& ret);
int followCNAMERecords(std::vector<DNSRecord>& ret, const QType qtype, int oldret);
int getFakeAAAARecords(const DNSName& qname, ComboAddress prefix, vector<DNSRecord>& ret);
int getFakePTRRecords(const DNSName& qname, vector<DNSRecord>& ret);