diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-10-22 09:05:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-22 09:05:36 +0200 |
commit | 2d74427a7cfa2f4feb9e5aabf7a1a00b1718801b (patch) | |
tree | 0c3e5b8334a4e4301bf569cc26833890451f106f /src/resolve | |
parent | test: CET/EET are deprecated, use Europe/Berlin and Kyiv (diff) | |
parent | resolve: move sd-* api into libsystemd-network (diff) | |
download | systemd-2d74427a7cfa2f4feb9e5aabf7a1a00b1718801b.tar.xz systemd-2d74427a7cfa2f4feb9e5aabf7a1a00b1718801b.zip |
Merge pull request #30952 from rpigott/resolved-dnr
RFC9463: Discovery of Network-designated Resolvers
Diffstat (limited to 'src/resolve')
-rw-r--r-- | src/resolve/resolved-dns-packet.c | 42 | ||||
-rw-r--r-- | src/resolve/resolved-dns-packet.h | 36 |
2 files changed, 39 insertions, 39 deletions
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c index c32a1a9a67..f9991d86ab 100644 --- a/src/resolve/resolved-dns-packet.c +++ b/src/resolve/resolved-dns-packet.c @@ -2881,6 +2881,27 @@ size_t dns_packet_size_unfragmented(DnsPacket *p) { return LESS_BY(p->fragsize, udp_header_size(p->family)); } +static const char* const dns_svc_param_key_table[_DNS_SVC_PARAM_KEY_MAX_DEFINED] = { + [DNS_SVC_PARAM_KEY_MANDATORY] = "mandatory", + [DNS_SVC_PARAM_KEY_ALPN] = "alpn", + [DNS_SVC_PARAM_KEY_NO_DEFAULT_ALPN] = "no-default-alpn", + [DNS_SVC_PARAM_KEY_PORT] = "port", + [DNS_SVC_PARAM_KEY_IPV4HINT] = "ipv4hint", + [DNS_SVC_PARAM_KEY_ECH] = "ech", + [DNS_SVC_PARAM_KEY_IPV6HINT] = "ipv6hint", + [DNS_SVC_PARAM_KEY_DOHPATH] = "dohpath", + [DNS_SVC_PARAM_KEY_OHTTP] = "ohttp", +}; +DEFINE_STRING_TABLE_LOOKUP_TO_STRING(dns_svc_param_key, int); + +const char* format_dns_svc_param_key(uint16_t i, char buf[static DECIMAL_STR_MAX(uint16_t)+3]) { + const char *p = dns_svc_param_key_to_string(i); + if (p) + return p; + + return snprintf_ok(buf, DECIMAL_STR_MAX(uint16_t)+3, "key%i", i); +} + static const char* const dns_rcode_table[_DNS_RCODE_MAX_DEFINED] = { [DNS_RCODE_SUCCESS] = "SUCCESS", [DNS_RCODE_FORMERR] = "FORMERR", @@ -2955,27 +2976,6 @@ const char* format_dns_ede_rcode(int i, char buf[static DECIMAL_STR_MAX(int)]) { return snprintf_ok(buf, DECIMAL_STR_MAX(int), "%i", i); } -static const char* const dns_svc_param_key_table[_DNS_SVC_PARAM_KEY_MAX_DEFINED] = { - [DNS_SVC_PARAM_KEY_MANDATORY] = "mandatory", - [DNS_SVC_PARAM_KEY_ALPN] = "alpn", - [DNS_SVC_PARAM_KEY_NO_DEFAULT_ALPN] = "no-default-alpn", - [DNS_SVC_PARAM_KEY_PORT] = "port", - [DNS_SVC_PARAM_KEY_IPV4HINT] = "ipv4hint", - [DNS_SVC_PARAM_KEY_ECH] = "ech", - [DNS_SVC_PARAM_KEY_IPV6HINT] = "ipv6hint", - [DNS_SVC_PARAM_KEY_DOHPATH] = "dohpath", - [DNS_SVC_PARAM_KEY_OHTTP] = "ohttp", -}; -DEFINE_STRING_TABLE_LOOKUP_TO_STRING(dns_svc_param_key, int); - -const char* format_dns_svc_param_key(uint16_t i, char buf[static DECIMAL_STR_MAX(uint16_t)+3]) { - const char *p = dns_svc_param_key_to_string(i); - if (p) - return p; - - return snprintf_ok(buf, DECIMAL_STR_MAX(uint16_t)+3, "key%i", i); -} - static const char* const dns_protocol_table[_DNS_PROTOCOL_MAX] = { [DNS_PROTOCOL_DNS] = "dns", [DNS_PROTOCOL_MDNS] = "mdns", diff --git a/src/resolve/resolved-dns-packet.h b/src/resolve/resolved-dns-packet.h index 437c220b6a..6fe30bca73 100644 --- a/src/resolve/resolved-dns-packet.h +++ b/src/resolve/resolved-dns-packet.h @@ -363,33 +363,33 @@ const char* format_dns_ede_rcode(int i, char buf[static DECIMAL_STR_MAX(int)]); const char* dns_protocol_to_string(DnsProtocol p) _const_; DnsProtocol dns_protocol_from_string(const char *s) _pure_; +#define LLMNR_MULTICAST_IPV4_ADDRESS ((struct in_addr) { .s_addr = htobe32(224U << 24 | 252U) }) +#define LLMNR_MULTICAST_IPV6_ADDRESS ((struct in6_addr) { .s6_addr = { 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03 } }) + +#define MDNS_MULTICAST_IPV4_ADDRESS ((struct in_addr) { .s_addr = htobe32(224U << 24 | 251U) }) +#define MDNS_MULTICAST_IPV6_ADDRESS ((struct in6_addr) { .s6_addr = { 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb } }) + +extern const struct hash_ops dns_packet_hash_ops; + /* https://www.iana.org/assignments/dns-svcb/dns-svcb.xhtml#dns-svcparamkeys */ enum { - DNS_SVC_PARAM_KEY_MANDATORY = 0, /* RFC 9460 section 8 */ - DNS_SVC_PARAM_KEY_ALPN = 1, /* RFC 9460 section 7.1 */ - DNS_SVC_PARAM_KEY_NO_DEFAULT_ALPN = 2, /* RFC 9460 Section 7.1 */ - DNS_SVC_PARAM_KEY_PORT = 3, /* RFC 9460 section 7.2 */ - DNS_SVC_PARAM_KEY_IPV4HINT = 4, /* RFC 9460 section 7.3 */ - DNS_SVC_PARAM_KEY_ECH = 5, /* RFC 9460 */ - DNS_SVC_PARAM_KEY_IPV6HINT = 6, /* RFC 9460 section 7.3 */ - DNS_SVC_PARAM_KEY_DOHPATH = 7, /* RFC 9461 */ - DNS_SVC_PARAM_KEY_OHTTP = 8, + DNS_SVC_PARAM_KEY_MANDATORY = 0, /* RFC 9460 § 8 */ + DNS_SVC_PARAM_KEY_ALPN = 1, /* RFC 9460 § 7.1 */ + DNS_SVC_PARAM_KEY_NO_DEFAULT_ALPN = 2, /* RFC 9460 § 7.1 */ + DNS_SVC_PARAM_KEY_PORT = 3, /* RFC 9460 § 7.2 */ + DNS_SVC_PARAM_KEY_IPV4HINT = 4, /* RFC 9460 § 7.3 */ + DNS_SVC_PARAM_KEY_ECH = 5, /* RFC 9460 */ + DNS_SVC_PARAM_KEY_IPV6HINT = 6, /* RFC 9460 § 7.3 */ + DNS_SVC_PARAM_KEY_DOHPATH = 7, /* RFC 9461 */ + DNS_SVC_PARAM_KEY_OHTTP = 8, _DNS_SVC_PARAM_KEY_MAX_DEFINED, - DNS_SVC_PARAM_KEY_INVALID = 65535 /* RFC 9460 */ + DNS_SVC_PARAM_KEY_INVALID = 65535 /* RFC 9460 */ }; const char* dns_svc_param_key_to_string(int i) _const_; const char* format_dns_svc_param_key(uint16_t i, char buf[static DECIMAL_STR_MAX(uint16_t)+3]); #define FORMAT_DNS_SVC_PARAM_KEY(i) format_dns_svc_param_key(i, (char [DECIMAL_STR_MAX(uint16_t)+3]) {}) -#define LLMNR_MULTICAST_IPV4_ADDRESS ((struct in_addr) { .s_addr = htobe32(224U << 24 | 252U) }) -#define LLMNR_MULTICAST_IPV6_ADDRESS ((struct in6_addr) { .s6_addr = { 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03 } }) - -#define MDNS_MULTICAST_IPV4_ADDRESS ((struct in_addr) { .s_addr = htobe32(224U << 24 | 251U) }) -#define MDNS_MULTICAST_IPV6_ADDRESS ((struct in6_addr) { .s6_addr = { 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb } }) - -extern const struct hash_ops dns_packet_hash_ops; - static inline uint64_t SD_RESOLVED_FLAGS_MAKE( DnsProtocol protocol, int family, |