From 9551c15505e283f9e5e43635c2920bfdfc584c30 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 2 Dec 2015 20:56:55 +0100 Subject: resolved: add code to map DNSSEC digest types to strings and back --- src/resolve/resolved-dns-packet.c | 6 ++++++ src/resolve/resolved-dns-packet.h | 10 ++++++++++ 2 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c index 7cebad22ff..06464324d2 100644 --- a/src/resolve/resolved-dns-packet.c +++ b/src/resolve/resolved-dns-packet.c @@ -1952,3 +1952,9 @@ static const char* const dnssec_algorithm_table[_DNSSEC_ALGORITHM_MAX_DEFINED] = [DNSSEC_ALGORITHM_PRIVATEOID] = "PRIVATEOID", }; DEFINE_STRING_TABLE_LOOKUP(dnssec_algorithm, int); + +static const char* const dnssec_digest_table[_DNSSEC_DIGEST_MAX_DEFINED] = { + [DNSSEC_DIGEST_SHA1] = "SHA1", + [DNSSEC_DIGEST_SHA256] = "SHA256", +}; +DEFINE_STRING_TABLE_LOOKUP(dnssec_digest, int); diff --git a/src/resolve/resolved-dns-packet.h b/src/resolve/resolved-dns-packet.h index 16a38e5361..b236333f61 100644 --- a/src/resolve/resolved-dns-packet.h +++ b/src/resolve/resolved-dns-packet.h @@ -247,6 +247,16 @@ enum { const char* dnssec_algorithm_to_string(int i) _const_; int dnssec_algorithm_from_string(const char *s) _pure_; +/* https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml */ +enum { + DNSSEC_DIGEST_SHA1 = 1, + DNSSEC_DIGEST_SHA256 = 2, + _DNSSEC_DIGEST_MAX_DEFINED +}; + +const char *dnssec_digest_to_string(int i) _const_; +int dnssec_digest_from_string(const char *s) _pure_; + static inline uint64_t SD_RESOLVED_FLAGS_MAKE(DnsProtocol protocol, int family) { /* Converts a protocol + family into a flags field as used in queries */ -- cgit v1.2.3-54-g00ecf