diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-01-01 08:52:52 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-01-19 07:04:19 +0900 |
commit | c11e5f43d20b7b6b809200e91de69ab47802b664 (patch) | |
tree | 5c46fecef5b97448c51e205f56873ab83149038e | |
parent | af182ae1dc35a48276e9fe0aaa9454377b4a667b (diff) | |
download | systemd-c11e5f43d20b7b6b809200e91de69ab47802b664.tar.gz |
util: move several DNS related definitions to src/basic/dns-def.h
DNS_HOSTNAME_MAX is used by sd-resolve, but it was defined in
src/shared/dns-domain.h. The library libsystemd should be independent
of source files under src/shared.
-rw-r--r-- | src/basic/dns-def.h | 17 | ||||
-rw-r--r-- | src/basic/meson.build | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-resolve/sd-resolve.c | 2 | ||||
-rw-r--r-- | src/shared/dns-domain.h | 16 |
4 files changed, 20 insertions, 16 deletions
diff --git a/src/basic/dns-def.h b/src/basic/dns-def.h new file mode 100644 index 0000000000..d70220bcc0 --- /dev/null +++ b/src/basic/dns-def.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +/* Length of a single label, with all escaping removed, excluding any trailing dot or NUL byte */ +#define DNS_LABEL_MAX 63 + +/* Worst case length of a single label, with all escaping applied and room for a trailing NUL byte. */ +#define DNS_LABEL_ESCAPED_MAX (DNS_LABEL_MAX*4+1) + +/* Maximum length of a full hostname, consisting of a series of unescaped labels, and no trailing dot or NUL byte */ +#define DNS_HOSTNAME_MAX 253 + +/* Maximum length of a full hostname, on the wire, including the final NUL byte */ +#define DNS_WIRE_FORMAT_HOSTNAME_MAX 255 + +/* Maximum number of labels per valid hostname */ +#define DNS_N_LABELS_MAX 127 diff --git a/src/basic/meson.build b/src/basic/meson.build index c7d6872fbf..9b3366c5e9 100644 --- a/src/basic/meson.build +++ b/src/basic/meson.build @@ -42,6 +42,7 @@ basic_sources = files(''' dirent-util.h dlfcn-util.c dlfcn-util.h + dns-def.h efivars.c efivars.h env-file.c diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c index 2cfa22d280..6dae398acb 100644 --- a/src/libsystemd/sd-resolve/sd-resolve.c +++ b/src/libsystemd/sd-resolve/sd-resolve.c @@ -15,7 +15,7 @@ #include "sd-resolve.h" #include "alloc-util.h" -#include "dns-domain.h" +#include "dns-def.h" #include "errno-util.h" #include "fd-util.h" #include "io-util.h" diff --git a/src/shared/dns-domain.h b/src/shared/dns-domain.h index 77f596294d..c25fcaacc2 100644 --- a/src/shared/dns-domain.h +++ b/src/shared/dns-domain.h @@ -6,24 +6,10 @@ #include <stddef.h> #include <stdint.h> +#include "dns-def.h" #include "hashmap.h" #include "in-addr-util.h" -/* Length of a single label, with all escaping removed, excluding any trailing dot or NUL byte */ -#define DNS_LABEL_MAX 63 - -/* Worst case length of a single label, with all escaping applied and room for a trailing NUL byte. */ -#define DNS_LABEL_ESCAPED_MAX (DNS_LABEL_MAX*4+1) - -/* Maximum length of a full hostname, consisting of a series of unescaped labels, and no trailing dot or NUL byte */ -#define DNS_HOSTNAME_MAX 253 - -/* Maximum length of a full hostname, on the wire, including the final NUL byte */ -#define DNS_WIRE_FORMAT_HOSTNAME_MAX 255 - -/* Maximum number of labels per valid hostname */ -#define DNS_N_LABELS_MAX 127 - typedef enum DNSLabelFlags { DNS_LABEL_LDH = 1 << 0, /* Follow the "LDH" rule — only letters, digits, and internal hyphens. */ DNS_LABEL_NO_ESCAPES = 1 << 1, /* Do not treat backslashes specially */ |