aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/librdns
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/librdns')
-rw-r--r--contrib/librdns/rdns.h7
-rw-r--r--contrib/librdns/util.c45
2 files changed, 52 insertions, 0 deletions
diff --git a/contrib/librdns/rdns.h b/contrib/librdns/rdns.h
index ff8eadcc6..7e5843183 100644
--- a/contrib/librdns/rdns.h
+++ b/contrib/librdns/rdns.h
@@ -360,6 +360,13 @@ const char *rdns_strtype (enum rdns_request_type type);
enum rdns_request_type rdns_type_fromstr (const char *str);
/**
+ * Parse string and return error code
+ * @param str
+ * @return
+ */
+enum dns_rcode rdns_rcode_fromstr (const char *str);
+
+/**
* Increase refcount for a request
* @param req
* @return
diff --git a/contrib/librdns/util.c b/contrib/librdns/util.c
index 1eb5410c3..0f701f1bd 100644
--- a/contrib/librdns/util.c
+++ b/contrib/librdns/util.c
@@ -289,6 +289,51 @@ rdns_type_fromstr (const char *str)
return -1;
}
+enum dns_rcode
+rdns_rcode_fromstr (const char *str)
+{
+ if (str) {
+ if (strcmp (str, "noerror") == 0) {
+ return RDNS_RC_NOERROR;
+ }
+ else if (strcmp (str, "formerr") == 0) {
+ return RDNS_RC_FORMERR;
+ }
+ else if (strcmp (str, "servfail") == 0) {
+ return RDNS_RC_SERVFAIL;
+ }
+ else if (strcmp (str, "notimp") == 0) {
+ return RDNS_RC_NOTIMP;
+ }
+ else if (strcmp (str, "yxdomain") == 0) {
+ return RDNS_RC_YXDOMAIN;
+ }
+ else if (strcmp (str, "yxrrset") == 0) {
+ return RDNS_RC_YXRRSET;
+ }
+ else if (strcmp (str, "nxrrset") == 0) {
+ return RDNS_RC_NXRRSET;
+ }
+ else if (strcmp (str, "notauth") == 0) {
+ return RDNS_RC_NOTAUTH;
+ }
+ else if (strcmp (str, "notzone") == 0) {
+ return RDNS_RC_NOTZONE;
+ }
+ else if (strcmp (str, "timeout") == 0) {
+ return RDNS_RC_TIMEOUT;
+ }
+ else if (strcmp (str, "neterr") == 0) {
+ return RDNS_RC_NETERR;
+ }
+ else if (strcmp (str, "norec") == 0) {
+ return RDNS_RC_NOREC;
+ }
+ }
+
+ return -1;
+}
+
uint16_t
rdns_permutor_generate_id (void)
{