From 274e6aaee17099a03ce6af19cd5bc5c5a47d7b8d Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Mon, 7 Feb 2011 19:36:54 +0000 Subject: [PATCH] Thanks to Jan-Piet Mens' "zone from hell", we can now serve unknown record types ('TYPE65534'). git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1993 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/dnsparser.hh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/pdns/dnsparser.hh b/pdns/dnsparser.hh index 6a94910c84..9cd9abd3b9 100644 --- a/pdns/dnsparser.hh +++ b/pdns/dnsparser.hh @@ -31,6 +31,7 @@ #include #include #include +#include #include "dns.hh" #include "dnswriter.hh" @@ -187,7 +188,7 @@ public: if(z) getZmakermap()[make_pair(cl,ty)]=z; - getNamemap()[make_pair(cl,ty)]=name; + getNamemap().left.insert(make_pair(make_pair(cl,ty), name)); } static void unregist(uint16_t cl, uint16_t ty) @@ -199,19 +200,23 @@ public: static uint16_t TypeToNumber(const string& name) { - for(namemap_t::const_iterator i=getNamemap().begin(); i!=getNamemap().end();++i) - if(pdns_iequals(i->second, name)) - return i->first.second; - + namemap_t::right_const_iterator iter = getNamemap().right.find(name); + if(iter != getNamemap().right.end()) + return iter->second.second; + + if(boost::starts_with(name, "TYPE")) + return atoi(name.c_str()+4); + throw runtime_error("Unknown DNS type '"+name+"'"); } static const string NumberToType(uint16_t num, uint16_t classnum=1) { - if(!getNamemap().count(make_pair(classnum,num))) - return "#" + lexical_cast(num); + namemap_t::left_const_iterator iter = getNamemap().left.find(make_pair(classnum, num)); + if(iter == getNamemap().left.end()) + return "TYPE" + lexical_cast(num); // throw runtime_error("Unknown DNS type with numerical id "+lexical_cast(num)); - return getNamemap()[make_pair(classnum,num)]; + return iter->second; } explicit DNSRecordContent(uint16_t type) : d_qtype(type) @@ -232,7 +237,7 @@ public: protected: typedef std::map, makerfunc_t* > typemap_t; typedef std::map, zmakerfunc_t* > zmakermap_t; - typedef std::map, string > namemap_t; + typedef boost::bimap, string > namemap_t; static typemap_t& getTypemap(); static namemap_t& getNamemap(); -- 2.47.3