From: Ruben d'Arco Date: Mon, 3 Dec 2012 04:06:40 +0000 (+0100) Subject: Add useful comparison and methods to QType X-Git-Tag: rec-3.6.0-rc1~556^2~3^2~110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2b22865394796f0602dca02fc677d72a93e2e83;p=pdns Add useful comparison and methods to QType These methods are used for rfc2136 to determine some requirements. The comparison operaters simply make it easy to compare things in the code itself. Some QTypes have been added because that's how RFC2136 defines them. --- diff --git a/pdns/qtype.cc b/pdns/qtype.cc index 3b00d6ab3..52ee10176 100644 --- a/pdns/qtype.cc +++ b/pdns/qtype.cc @@ -35,11 +35,30 @@ QType::QType() { } +bool QType::isSupportedType() { + for(vector::iterator pos=names.begin();possecond==code) + return true; + return false; +} + +bool QType::isMetadataType() { + if (code == QType::AXFR || + code == QType::MAILA || + code == QType::MAILB || + code == QType::TSIG || + code == QType::IXFR) + return true; + + return false; +} + uint16_t QType::getCode() const { return code; } + const string QType::getName() const { vector::iterator pos; @@ -80,6 +99,21 @@ QType &QType::operator=(const char *p) return *this; } +bool QType::operator==(const QType &comp) const +{ + return(comp.code==code); +} + +bool QType::operator!=(const QType &comp) const +{ + return(comp.code!=code); +} + +bool QType::operator==(const uint16_t comp) const +{ + return(comp==code); +} + QType &QType::operator=(const string &s) { code=chartocode(s.c_str()); diff --git a/pdns/qtype.hh b/pdns/qtype.hh index a4d34267e..42729128d 100644 --- a/pdns/qtype.hh +++ b/pdns/qtype.hh @@ -69,15 +69,22 @@ public: ar & code; } + bool operator!=(const QType &) const; //!< not equal operator + bool operator==(const QType &) const; //!< equality operator + bool operator==(const uint16_t) const; //!< equality operator + const string getName() const; //!< Get a string representation of this type uint16_t getCode() const; //!< Get the integer representation of this type + bool isSupportedType(); + bool isMetadataType(); static int chartocode(const char *p); //!< convert a character string to a code // more solaris fun #undef DS - enum typeenum {A=1,NS=2,CNAME=5,SOA=6, MR=9, PTR=12,HINFO=13,MX=15,TXT=16,RP=17,AFSDB=18, SIG=24, KEY=25,AAAA=28,LOC=29,SRV=33,NAPTR=35, KX=36, - CERT=37, A6=38, OPT=41, DS=43, SSHFP=44, IPSECKEY=45, RRSIG=46, NSEC=47, DNSKEY=48, DHCID=49, NSEC3=50, NSEC3PARAM=51, - TLSA=52, SPF=99, EUI48=108, EUI64=109, TSIG=250, AXFR=252, IXFR=251, ANY=255, URL=256, MBOXFW=257, CURL=258, ADDR=259, DLV=32769} types; + enum typeenum {A=1,NS=2,CNAME=5,SOA=6, MR=9, PTR=12,HINFO=13,MX=15,TXT=16,RP=17,AFSDB=18, SIG=24, KEY=25,AAAA=28,LOC=29,SRV=33,NAPTR=35, KX=36, + CERT=37, A6=38, OPT=41, DS=43, SSHFP=44, IPSECKEY=45, RRSIG=46, NSEC=47, DNSKEY=48, DHCID=49, NSEC3=50, NSEC3PARAM=51, + TLSA=52, SPF=99, EUI48=108, EUI64=109, TSIG=250, AXFR=252, IXFR=251, ANY=255, URL=256, MBOXFW=257, CURL=258, ADDR=259, DLV=32769} types; + typedef pair namenum; static vector names;