From: Kees Monshouwer Date: Tue, 12 Nov 2013 20:25:49 +0000 (+0100) Subject: use QClassEnum for qclass values X-Git-Tag: rec-3.6.0-rc1~344^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=703761ccad133fbbff854fe4bdcb4de715030198;p=pdns use QClassEnum for qclass values --- diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index 96e4457c8..66e4f5b62 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -484,9 +484,9 @@ void reportBasicTypes() SOARecordContent::report(); SRVRecordContent::report(); PTRRecordContent::report(); - DNSRecordContent::regist(3, ns_t_txt, &TXTRecordContent::make, &TXTRecordContent::make, "TXT"); + DNSRecordContent::regist(QClass::CHAOS, ns_t_txt, &TXTRecordContent::make, &TXTRecordContent::make, "TXT"); TXTRecordContent::report(); - DNSRecordContent::regist(1, QType::ANY, 0, 0, "ANY"); + DNSRecordContent::regist(QClass::IN, QType::ANY, 0, 0, "ANY"); } void reportOtherTypes() @@ -509,7 +509,7 @@ void reportOtherTypes() NSEC3PARAMRecordContent::report(); TLSARecordContent::report(); DLVRecordContent::report(); - DNSRecordContent::regist(0xff, QType::TSIG, &TSIGRecordContent::make, &TSIGRecordContent::make, "TSIG"); + DNSRecordContent::regist(QClass::ANY, QType::TSIG, &TSIGRecordContent::make, &TSIGRecordContent::make, "TSIG"); //TSIGRecordContent::report(); OPTRecordContent::report(); EUI48RecordContent::report(); diff --git a/pdns/dnswriter.hh b/pdns/dnswriter.hh index a3c36c232..17976bef0 100644 --- a/pdns/dnswriter.hh +++ b/pdns/dnswriter.hh @@ -21,7 +21,7 @@ Calling convention: vector content; - DNSPacketWriter dpw(content, const string& qname, uint16_t qtype, uint16_t qclass=1); // sets the question + DNSPacketWriter dpw(content, const string& qname, uint16_t qtype, uint16_t qclass=QClass:IN); // sets the question dpw.startrecord("this.is.an.ip.address.", ns_t_a); // does nothing, except store qname and qtype dpw.xfr32BitInt(0x01020304); // adds 4 bytes (0x01020304) to the record buffer dpw.startrecord("this.is.an.ip.address.", ns_t_a); // aha! writes out dnsrecord header containing qname and qtype and length 4, plus the recordbuffer, which gets emptied @@ -41,11 +41,11 @@ public: enum Place {ANSWER=1, AUTHORITY=2, ADDITIONAL=3}; //! Start a DNS Packet in the vector passed, with question qname, qtype and qclass - DNSPacketWriter(vector& content, const string& qname, uint16_t qtype, uint16_t qclass=1, uint8_t opcode=0); + DNSPacketWriter(vector& content, const string& qname, uint16_t qtype, uint16_t qclass=QClass::IN, uint8_t opcode=0); /** Start a new DNS record within this packet for namq, qtype, ttl, class and in the requested place. Note that packets can only be written in natural order - ANSWER, AUTHORITY, ADDITIONAL */ - void startRecord(const string& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=1, Place place=ANSWER, bool compress=true); + void startRecord(const string& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=QClass::IN, Place place=ANSWER, bool compress=true); /** Shorthand way to add an Opt-record, for example for EDNS0 purposes */ typedef vector > optvect_t; diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 32e0c0c46..3437f4081 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -1208,7 +1208,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse) return r; } - if(p->qclass==255) // any class query + if(p->qclass==QClass::ANY) // any class query r->setA(false); else if(p->qclass != QClass::IN) // we only know about IN, so we don't find anything goto sendit; diff --git a/pdns/pdnssec.cc b/pdns/pdnssec.cc index 48c33c894..f0ac20547 100644 --- a/pdns/pdnssec.cc +++ b/pdns/pdnssec.cc @@ -627,7 +627,7 @@ void testSpeed(DNSSECKeeper& dk, const string& zone, const string& remote, int c rr.qtype=QType::A; rr.ttl=3600; rr.auth=1; - rr.qclass = 1; + rr.qclass = QClass::IN; rr.d_place=DNSResourceRecord::ANSWER; rr.priority=0; diff --git a/pdns/syncres.cc b/pdns/syncres.cc index ec62704ef..1b94a83d8 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -94,7 +94,7 @@ int SyncRes::beginResolve(const string &qname, const QType &qtype, uint16_t qcla DNSResourceRecord rr; rr.qname=qname; rr.qtype=qtype; - rr.qclass=1; + rr.qclass=QClass::IN; rr.ttl=86400; if(qtype.getCode()==QType::PTR) rr.content="localhost."; @@ -104,7 +104,7 @@ int SyncRes::beginResolve(const string &qname, const QType &qtype, uint16_t qcla return 0; } - if(qclass==3 && qtype.getCode()==QType::TXT && + if(qclass==QClass::CHAOS && qtype.getCode()==QType::TXT && (pdns_iequals(qname, "version.bind.") || pdns_iequals(qname, "id.server.") || pdns_iequals(qname, "version.pdns.") ) ) { ret.clear(); @@ -121,9 +121,9 @@ int SyncRes::beginResolve(const string &qname, const QType &qtype, uint16_t qcla return 0; } - if(qclass==0xff) - qclass=1; - else if(qclass!=1) + if(qclass==QClass::ANY) + qclass=QClass::IN; + else if(qclass!=QClass::IN) return -1; set beenthere;