]> granicus.if.org Git - pdns/commitdiff
Replace strrcode with RCode::to_s
authorAki Tuomi <cmouse@desteem.org>
Thu, 20 Feb 2014 06:19:10 +0000 (08:19 +0200)
committerAki Tuomi <cmouse@desteem.org>
Thu, 20 Feb 2014 06:19:10 +0000 (08:19 +0200)
pdns/dns.cc
pdns/dns.hh

index 9fdfbe35b2140c22ef6c3c5d298cbdd15fc77327..8ddbab5660b22fa290c6cca69ffe162fcda50a56 100644 (file)
@@ -5,6 +5,38 @@
 #include <iostream>
 #include <boost/algorithm/string.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/assign/list_of.hpp>
+
+std::vector<std::string> 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<std::string>(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<string>((int)rcode);
-}
+}*/
index f0099aa592db9f0f68f0d97f4d62e52c68be0724..7f7146f202dbeb247f0bee7e3dbd47ac2c8ca9b2 100644 (file)
@@ -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<std::string> rcodes_s;
 };
 
 class Opcode