resolved: move DNS RR/key/answer/question/packet tools to shared/
We want to reuse these generic DNS concepts in resolved hook implementations, hence move them to shared code. (This also enables us to immediately remove som SVCB record handling duplicate definitions.) No real code changes, just some moving around of things.
This commit is contained in:
@@ -6,25 +6,6 @@
|
||||
#include "sd-forward.h"
|
||||
#include "socket-netlink.h"
|
||||
|
||||
/* https://www.iana.org/assignments/dns-svcb/dns-svcb.xhtml#dns-svcparamkeys */
|
||||
enum {
|
||||
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 */
|
||||
};
|
||||
|
||||
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]) {})
|
||||
|
||||
/* Represents a "designated resolver" */
|
||||
/* typedef struct sd_dns_resolver sd_dns_resolver; */
|
||||
typedef struct sd_dns_resolver {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "alloc-util.h"
|
||||
#include "dns-def.h"
|
||||
#include "dns-domain.h"
|
||||
#include "dns-packet.h"
|
||||
#include "dns-resolver-internal.h"
|
||||
#include "ether-addr-util.h"
|
||||
#include "hash-funcs.h"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "dns-packet.h"
|
||||
#include "dns-resolver-internal.h"
|
||||
#include "errno-util.h"
|
||||
#include "siphash24.h"
|
||||
@@ -154,29 +155,6 @@ void siphash24_compress_resolver(const sd_dns_resolver *res, struct siphash *sta
|
||||
siphash24_compress_typesafe(*addr, state);
|
||||
}
|
||||
|
||||
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]) {
|
||||
assert(buf);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int dns_resolver_transports_to_strv(sd_dns_alpn_flags transports, char ***ret) {
|
||||
_cleanup_strv_free_ char **ans = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user