From: Zbigniew Jędrzejewski-Szmek Date: Mon, 2 Feb 2015 04:12:27 +0000 (-0500) Subject: resolve-host: allow specifying type as TYPEnn X-Git-Tag: v229~59^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=869b3b67e392f1ea6219570ccf6aa3bf224d0391;p=thirdparty%2Fsystemd.git resolve-host: allow specifying type as TYPEnn This mirrors the behaviour of host and makes the conversion to and from string symmetrical. --- diff --git a/src/resolve/dns-type.c b/src/resolve/dns-type.c index 46ab6944968..fc2f1826fd1 100644 --- a/src/resolve/dns-type.c +++ b/src/resolve/dns-type.c @@ -22,6 +22,7 @@ #include #include "dns-type.h" +#include "parse-util.h" #include "string-util.h" typedef const struct { @@ -41,10 +42,19 @@ int dns_type_from_string(const char *s) { assert(s); sc = lookup_dns_type(s, strlen(s)); - if (!sc) - return _DNS_TYPE_INVALID; + if (sc) + return sc->id; - return sc->id; + s = startswith_no_case(s, "TYPE"); + if (s) { + unsigned x; + + if (safe_atou(s, &x) >= 0 && + x <= UINT16_MAX) + return (int) x; + } + + return _DNS_TYPE_INVALID; } bool dns_type_is_pseudo(uint16_t type) { diff --git a/src/resolve/dns-type.h b/src/resolve/dns-type.h index 1d9a59dfc1f..d025544babd 100644 --- a/src/resolve/dns-type.h +++ b/src/resolve/dns-type.h @@ -139,6 +139,7 @@ int dns_type_to_af(uint16_t t); bool dns_class_is_pseudo(uint16_t class); bool dns_class_is_valid_rr(uint16_t class); +/* TYPE?? follows http://tools.ietf.org/html/rfc3597#section-5 */ const char *dns_type_to_string(int type); int dns_type_from_string(const char *s);