diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-08-01 19:37:16 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-08-03 22:02:32 -0400 |
commit | 7263f72499e962b3fd54cdb7c79d49ca72121ede (patch) | |
tree | d74d2593c003166d21f38945c244b6d5a1180982 /src/resolve/resolved-dns-rr.c | |
parent | fd00a088216f6d6a6c502faf6b46c1e2ae7cbc54 (diff) |
resolve: add more record types and convert to gperf table
We are unlikely to evert support most of them, but we can at least
display the types properly.
The list is taken from the IANA list.
The table of number->name mappings is converted to a switch
statement. gcc does a nice job of optimizing lookup (when optimization
is enabled).
systemd-resolve-host -t is now case insensitive.
Diffstat (limited to 'src/resolve/resolved-dns-rr.c')
-rw-r--r-- | src/resolve/resolved-dns-rr.c | 52 |
1 files changed, 1 insertions, 51 deletions
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index 7d1cfe4aae..af22a8901d 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; -} |