From: Aki Tuomi Date: Thu, 20 Feb 2014 06:19:10 +0000 (+0200) Subject: Replace strrcode with RCode::to_s X-Git-Tag: rec-3.6.0-rc1~173^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ab9bec7c6b6afce625bca1fc4d2e3f0f20856d2;p=pdns Replace strrcode with RCode::to_s --- diff --git a/pdns/dns.cc b/pdns/dns.cc index 9fdfbe35b..8ddbab566 100644 --- a/pdns/dns.cc +++ b/pdns/dns.cc @@ -5,6 +5,38 @@ #include #include #include +#include + +std::vector RCode::rcodes_s = boost::assign::list_of + ("No Error") + ("Form Error") + ("Server Failure") + ("Non-Existent domain") + ("Not Implemented") + ("Query Refused") + ("Name Exists when it should not") + ("RR Set Exists when it should not") + ("RR Set that should exist does not") + ("Server Not Authoritative for zone") + ("Name not contained in zone") + ("unassigned") + ("unassigned") + ("unassigned") + ("unassigned") + ("unassigned") + ("Bad OPT Version") + ("TSIG Signature Failure") + ("Key not recognized") + ("Signature out of time window") + ("Bad TKEY Mode") + ("Duplicate key name") + ("Algorithm not supported"); + +std::string RCode::to_s(unsigned short rcode) { + if (rcode > 21) + return boost::lexical_cast(rcode); + return RCode::rcodes_s[rcode]; +} static void appendEscapedLabel(string& ret, const char* begin, unsigned char labellen) { @@ -187,10 +219,10 @@ string& attodot(string &str) return str; } -string strrcode(unsigned char rcode) +/*string strrcode(unsigned char rcode) { static const char* rcodes[]={"No Error", "FormErr", "SERVFAIL", "NXDOMAIN", "NotImp", "Refused", "", "", "", "Not Auth"}; if((rcode < sizeof(rcodes) / sizeof(*rcodes)) && *rcodes[rcode]) return rcodes[rcode]; return "Err#"+lexical_cast((int)rcode); -} +}*/ diff --git a/pdns/dns.hh b/pdns/dns.hh index f0099aa59..7f7146f20 100644 --- a/pdns/dns.hh +++ b/pdns/dns.hh @@ -61,6 +61,8 @@ class RCode { public: enum rcodes_ { NoError=0, FormErr=1, ServFail=2, NXDomain=3, NotImp=4, Refused=5, YXDomain=6, YXRRSet=7, NXRRSet=8, NotAuth=9, NotZone=10}; + static std::string to_s(unsigned short rcode); + static std::vector rcodes_s; }; class Opcode