diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-08-26 15:58:51 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-08-26 15:58:51 +0100 |
commit | 1eb80a4b7275d815f062dd2b200be6ea27ad271a (patch) | |
tree | 82aa08bdbafe8d4c6f481923918aba3059b9f334 | |
parent | a8ea1e714821d106e7b17deea4ae6852dac77bdc (diff) | |
download | rspamd-1eb80a4b7275d815f062dd2b200be6ea27ad271a.tar.gz rspamd-1eb80a4b7275d815f062dd2b200be6ea27ad271a.zip |
[Minor] Add another helper for rdns
-rw-r--r-- | contrib/librdns/rdns.h | 7 | ||||
-rw-r--r-- | contrib/librdns/util.c | 45 |
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) { |