X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fresolve%2Fresolved-dns-rr.c;h=af22a8901d6233ef69663bb57801da2ff1b8cc7e;hb=7263f72499e962b3fd54cdb7c79d49ca72121ede;hp=7d1cfe4aae2b8ef5f266603aa875f0fc4eebffa4;hpb=23432a1c249b9c513e438bffe9778a7ce2ee74fe;p=elogind.git diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index 7d1cfe4aa..af22a8901 100644 --- a/src/resolve/resolved-dns-rr.c +++ b/src/resolve/resolved-dns-rr.c @@ -25,6 +25,7 @@ #include "resolved-dns-domain.h" #include "resolved-dns-rr.h" +#include "dns-type.h" DnsResourceKey* dns_resource_key_new(uint16_t class, uint16_t type, const char *name) { DnsResourceKey *k; @@ -627,54 +628,3 @@ int dns_class_from_string(const char *s, uint16_t *class) { return 0; } - -static const struct { - uint16_t type; - const char *name; -} dns_types[] = { - { DNS_TYPE_A, "A" }, - { DNS_TYPE_NS, "NS" }, - { DNS_TYPE_CNAME, "CNAME" }, - { DNS_TYPE_SOA, "SOA" }, - { DNS_TYPE_PTR, "PTR" }, - { DNS_TYPE_HINFO, "HINFO" }, - { DNS_TYPE_MX, "MX" }, - { DNS_TYPE_TXT, "TXT" }, - { DNS_TYPE_AAAA, "AAAA" }, - { DNS_TYPE_LOC, "LOC" }, - { DNS_TYPE_SRV, "SRV" }, - { DNS_TYPE_SSHFP, "SSHFP" }, - { DNS_TYPE_SPF, "SPF" }, - { DNS_TYPE_DNAME, "DNAME" }, - { DNS_TYPE_ANY, "ANY" }, - { DNS_TYPE_OPT, "OPT" }, - { DNS_TYPE_TKEY, "TKEY" }, - { DNS_TYPE_TSIG, "TSIG" }, - { DNS_TYPE_IXFR, "IXFR" }, - { DNS_TYPE_AXFR, "AXFR" }, -}; - -const char *dns_type_to_string(uint16_t type) { - unsigned i; - - for (i = 0; i < ELEMENTSOF(dns_types); i++) - if (dns_types[i].type == type) - return dns_types[i].name; - - return NULL; -} - -int dns_type_from_string(const char *s, uint16_t *type) { - unsigned i; - - assert(s); - assert(type); - - for (i = 0; i < ELEMENTSOF(dns_types); i++) - if (strcaseeq(dns_types[i].name, s)) { - *type = dns_types[i].type; - return 0; - } - - return -EINVAL; -}