74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#pragma once
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/***
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2014 Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering ***/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include <netinet/in.h>
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen#include "bitmap.h"
71d35b6b5563817dfbe757ab9e3b9f018b2db491Thomas Hindoe Paaboel Andersen#include "dns-type.h"
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering#include "hashmap.h"
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering#include "in-addr-util.h"
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering#include "list.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef struct DnsResourceKey DnsResourceKey;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef struct DnsResourceRecord DnsResourceRecord;
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poetteringtypedef struct DnsTxtItem DnsTxtItem;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering/* DNSKEY RR flags */
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering#define DNSKEY_FLAG_SEP (UINT16_C(1) << 0)
28b8191e2f391f043d380d47eb79ed9ff66f14bdLennart Poettering#define DNSKEY_FLAG_REVOKE (UINT16_C(1) << 7)
28b8191e2f391f043d380d47eb79ed9ff66f14bdLennart Poettering#define DNSKEY_FLAG_ZONE_KEY (UINT16_C(1) << 8)
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mack/* mDNS RR flags */
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mack#define MDNS_RR_CACHE_FLUSH (UINT16_C(1) << 15)
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mack
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering/* DNSSEC algorithm identifiers, see
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering * http://tools.ietf.org/html/rfc4034#appendix-A.1 and
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering * https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml */
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poetteringenum {
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering DNSSEC_ALGORITHM_RSAMD5 = 1,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering DNSSEC_ALGORITHM_DH,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering DNSSEC_ALGORITHM_DSA,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering DNSSEC_ALGORITHM_ECC,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering DNSSEC_ALGORITHM_RSASHA1,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering DNSSEC_ALGORITHM_DSA_NSEC3_SHA1,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering DNSSEC_ALGORITHM_RSASHA1_NSEC3_SHA1,
6f717d0817573a76c3e586eae02793d8b23a0581Lennart Poettering DNSSEC_ALGORITHM_RSASHA256 = 8, /* RFC 5702 */
6f717d0817573a76c3e586eae02793d8b23a0581Lennart Poettering DNSSEC_ALGORITHM_RSASHA512 = 10, /* RFC 5702 */
6f717d0817573a76c3e586eae02793d8b23a0581Lennart Poettering DNSSEC_ALGORITHM_ECC_GOST = 12, /* RFC 5933 */
e0240c64b76ba8f0c9219feb23a5783f23100216Lennart Poettering DNSSEC_ALGORITHM_ECDSAP256SHA256 = 13, /* RFC 6605 */
e0240c64b76ba8f0c9219feb23a5783f23100216Lennart Poettering DNSSEC_ALGORITHM_ECDSAP384SHA384 = 14, /* RFC 6605 */
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering DNSSEC_ALGORITHM_INDIRECT = 252,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering DNSSEC_ALGORITHM_PRIVATEDNS,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering DNSSEC_ALGORITHM_PRIVATEOID,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering _DNSSEC_ALGORITHM_MAX_DEFINED
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering};
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering/* DNSSEC digest identifiers, see
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering * https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml */
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poetteringenum {
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering DNSSEC_DIGEST_SHA1 = 1,
6f717d0817573a76c3e586eae02793d8b23a0581Lennart Poettering DNSSEC_DIGEST_SHA256 = 2, /* RFC 4509 */
6f717d0817573a76c3e586eae02793d8b23a0581Lennart Poettering DNSSEC_DIGEST_GOST_R_34_11_94 = 3, /* RFC 5933 */
6f717d0817573a76c3e586eae02793d8b23a0581Lennart Poettering DNSSEC_DIGEST_SHA384 = 4, /* RFC 6605 */
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering _DNSSEC_DIGEST_MAX_DEFINED
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering};
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
d15ad74251454d55b715958d8e6f50f45195904aLennart Poettering/* DNSSEC NSEC3 hash algorithms, see
d15ad74251454d55b715958d8e6f50f45195904aLennart Poettering * https://www.iana.org/assignments/dnssec-nsec3-parameters/dnssec-nsec3-parameters.xhtml */
d15ad74251454d55b715958d8e6f50f45195904aLennart Poetteringenum {
d15ad74251454d55b715958d8e6f50f45195904aLennart Poettering NSEC3_ALGORITHM_SHA1 = 1,
d15ad74251454d55b715958d8e6f50f45195904aLennart Poettering _NSEC3_ALGORITHM_MAX_DEFINED
d15ad74251454d55b715958d8e6f50f45195904aLennart Poettering};
d15ad74251454d55b715958d8e6f50f45195904aLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstruct DnsResourceKey {
f57e3cd5fa709ec0f52531eccba909ac0851927cLennart Poettering unsigned n_ref; /* (unsigned -1) for const keys, see below */
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering uint16_t class, type;
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering char *_name; /* don't access directy, use DNS_RESOURCE_KEY_NAME()! */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering};
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering/* Creates a temporary resource key. This is only useful to quickly
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering * look up something, without allocating a full DnsResourceKey object
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering * for it. Note that it is not OK to take references to this kind of
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering * resource key object. */
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering#define DNS_RESOURCE_KEY_CONST(c, t, n) \
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering ((DnsResourceKey) { \
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering .n_ref = (unsigned) -1, \
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering .class = c, \
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering .type = t, \
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering ._name = (char*) n, \
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering })
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poetteringstruct DnsTxtItem {
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering size_t length;
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering LIST_FIELDS(DnsTxtItem, items);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering uint8_t data[];
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering};
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstruct DnsResourceRecord {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering unsigned n_ref;
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering DnsResourceKey *key;
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering
7b50eb2efa122200e39646c19a29abab302f7d24Lennart Poettering char *to_string;
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering uint32_t ttl;
ee3d6aff9bd73c1b23e29d1fa1fa6f7a1ef0533bLennart Poettering usec_t expiry; /* RRSIG signature expiry */
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering /* How many labels to strip to determine "signer" of the RRSIG (aka, the zone). -1 if not signed. */
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering unsigned n_skip_labels_signer;
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering /* How many labels to strip to determine "synthesizing source" of this RR, i.e. the wildcard's immediate parent. -1 if not signed. */
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering unsigned n_skip_labels_source;
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering bool unparseable:1;
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering bool wire_format_canonical:1;
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering void *wire_format;
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering size_t wire_format_size;
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering size_t wire_format_rdata_offset;
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering union {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering void *data;
a43a068a30f7a47aba39f8b48d5db0c4d39fd21dZbigniew Jędrzejewski-Szmek size_t data_size;
d75acfb059ece4512278b8820a9103664996f1e5Lennart Poettering } generic, opt;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering struct {
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering uint16_t priority;
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering uint16_t weight;
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering uint16_t port;
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering char *name;
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering } srv;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *name;
8ac4e9e1e54397f6d1745c2a7a806132418c7da2Lennart Poettering } ptr, ns, cname, dname;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *cpu;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *os;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } hinfo;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
2e276efc7b0398a3086629a52970bdd4ab7252f9Zbigniew Jędrzejewski-Szmek struct {
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering DnsTxtItem *items;
c0eb11cfd016381fe02875a4ef29c1ade00c94e7Lennart Poettering } txt, spf;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct in_addr in_addr;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } a;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct in6_addr in6_addr;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } aaaa;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering struct {
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering char *mname;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering char *rname;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering uint32_t serial;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering uint32_t refresh;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering uint32_t retry;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering uint32_t expire;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering uint32_t minimum;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering } soa;
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek struct {
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek uint16_t priority;
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek char *exchange;
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek } mx;
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering /* https://tools.ietf.org/html/rfc1876 */
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek struct {
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek uint8_t version;
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek uint8_t size;
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek uint8_t horiz_pre;
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek uint8_t vert_pre;
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek uint32_t latitude;
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek uint32_t longitude;
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek uint32_t altitude;
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek } loc;
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen /* https://tools.ietf.org/html/rfc4255#section-3.1 */
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering struct {
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering uint8_t algorithm;
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering uint8_t fptype;
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen void *fingerprint;
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen size_t fingerprint_size;
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering } sshfp;
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek /* http://tools.ietf.org/html/rfc4034#section-2.1 */
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek struct {
f91dc2400dc33e9a0745ecaaef7489af116dca38Lennart Poettering uint16_t flags;
f91dc2400dc33e9a0745ecaaef7489af116dca38Lennart Poettering uint8_t protocol;
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek uint8_t algorithm;
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek void* key;
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek size_t key_size;
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek } dnskey;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek /* http://tools.ietf.org/html/rfc4034#section-3.1 */
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek struct {
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek uint16_t type_covered;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek uint8_t algorithm;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek uint8_t labels;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek uint32_t original_ttl;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek uint32_t expiration;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek uint32_t inception;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek uint16_t key_tag;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek char *signer;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek void *signature;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek size_t signature_size;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek } rrsig;
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen
9ead3519c54b6d1b79b35541873b5cf7c8b3a7d3Lennart Poettering /* https://tools.ietf.org/html/rfc4034#section-4.1 */
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen struct {
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen char *next_domain_name;
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen Bitmap *types;
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen } nsec;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering /* https://tools.ietf.org/html/rfc4034#section-5.1 */
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering struct {
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering uint16_t key_tag;
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering uint8_t algorithm;
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering uint8_t digest_type;
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering void *digest;
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering size_t digest_size;
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering } ds;
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen struct {
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen uint8_t algorithm;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen uint8_t flags;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen uint16_t iterations;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen void *salt;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen size_t salt_size;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen void *next_hashed_name;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen size_t next_hashed_name_size;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen Bitmap *types;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen } nsec3;
48d45d2b49d2adb870cd5f1bc7cb389b33655f1cZbigniew Jędrzejewski-Szmek
48d45d2b49d2adb870cd5f1bc7cb389b33655f1cZbigniew Jędrzejewski-Szmek /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23 */
48d45d2b49d2adb870cd5f1bc7cb389b33655f1cZbigniew Jędrzejewski-Szmek struct {
48d45d2b49d2adb870cd5f1bc7cb389b33655f1cZbigniew Jędrzejewski-Szmek uint8_t cert_usage;
48d45d2b49d2adb870cd5f1bc7cb389b33655f1cZbigniew Jędrzejewski-Szmek uint8_t selector;
48d45d2b49d2adb870cd5f1bc7cb389b33655f1cZbigniew Jędrzejewski-Szmek uint8_t matching_type;
48d45d2b49d2adb870cd5f1bc7cb389b33655f1cZbigniew Jędrzejewski-Szmek void *data;
48d45d2b49d2adb870cd5f1bc7cb389b33655f1cZbigniew Jędrzejewski-Szmek size_t data_size;
48d45d2b49d2adb870cd5f1bc7cb389b33655f1cZbigniew Jędrzejewski-Szmek } tlsa;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering };
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering};
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringstatic inline const char* DNS_RESOURCE_KEY_NAME(const DnsResourceKey *key) {
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering if (!key)
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering return NULL;
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering if (key->_name)
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering return key->_name;
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering return (char*) key + sizeof(DnsResourceKey);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering}
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poetteringstatic inline const void* DNS_RESOURCE_RECORD_RDATA(DnsResourceRecord *rr) {
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering if (!rr)
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering return NULL;
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering if (!rr->wire_format)
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering return NULL;
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering assert(rr->wire_format_rdata_offset <= rr->wire_format_size);
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering return (uint8_t*) rr->wire_format + rr->wire_format_rdata_offset;
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering}
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poetteringstatic inline size_t DNS_RESOURCE_RECORD_RDATA_SIZE(DnsResourceRecord *rr) {
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering if (!rr)
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering return 0;
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering if (!rr->wire_format)
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering return 0;
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering assert(rr->wire_format_rdata_offset <= rr->wire_format_size);
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering return rr->wire_format_size - rr->wire_format_rdata_offset;
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering}
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDnsResourceKey* dns_resource_key_new(uint16_t class, uint16_t type, const char *name);
36d9205d669bcdcb04fa730d1f3549a9fc9a9001Tom GundersenDnsResourceKey* dns_resource_key_new_redirect(const DnsResourceKey *key, const DnsResourceRecord *cname);
801ad6a6a9cd8fbd58b9f9c27f20dbb3c87d47ddLennart Poetteringint dns_resource_key_new_append_suffix(DnsResourceKey **ret, DnsResourceKey *key, char *name);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDnsResourceKey* dns_resource_key_new_consume(uint16_t class, uint16_t type, char *name);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDnsResourceKey* dns_resource_key_ref(DnsResourceKey *key);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDnsResourceKey* dns_resource_key_unref(DnsResourceKey *key);
28b9b7640603f88cb49f95609331fa5072715f15Lennart Poetteringbool dns_resource_key_is_address(const DnsResourceKey *key);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint dns_resource_key_equal(const DnsResourceKey *a, const DnsResourceKey *b);
105e151299dc1208855380be2b22d0db2d66ebc6Lennart Poetteringint dns_resource_key_match_rr(const DnsResourceKey *key, DnsResourceRecord *rr, const char *search_domain);
5d27351f8546530cf779847b0b04b0172c09f9d0Tom Gundersenint dns_resource_key_match_cname_or_dname(const DnsResourceKey *key, const DnsResourceKey *cname, const char *search_domain);
547973dea7abd6c124ff6c79fe2bbe322a7314aeLennart Poetteringint dns_resource_key_match_soa(const DnsResourceKey *key, const DnsResourceKey *soa);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poetteringint dns_resource_key_to_string(const DnsResourceKey *key, char **ret);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceKey*, dns_resource_key_unref);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
7778dffff3d8bd7438fe19a248c16203668324c9Daniel Mackstatic inline bool dns_key_is_shared(const DnsResourceKey *key) {
7778dffff3d8bd7438fe19a248c16203668324c9Daniel Mack return IN_SET(key->type, DNS_TYPE_PTR);
7778dffff3d8bd7438fe19a248c16203668324c9Daniel Mack}
7778dffff3d8bd7438fe19a248c16203668324c9Daniel Mack
f57e3cd5fa709ec0f52531eccba909ac0851927cLennart Poetteringbool dns_resource_key_reduce(DnsResourceKey **a, DnsResourceKey **b);
f57e3cd5fa709ec0f52531eccba909ac0851927cLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDnsResourceRecord* dns_resource_record_new(DnsResourceKey *key);
8bf52d3d17d364438191077d0750b8b80b5dc53aLennart PoetteringDnsResourceRecord* dns_resource_record_new_full(uint16_t class, uint16_t type, const char *name);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart PoetteringDnsResourceRecord* dns_resource_record_ref(DnsResourceRecord *rr);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart PoetteringDnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr);
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poetteringint dns_resource_record_new_reverse(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *name);
78c6a153c47f8d597c827bdcaf8c4e42ac87f738Lennart Poetteringint dns_resource_record_new_address(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *name);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poetteringint dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecord *b);
7b50eb2efa122200e39646c19a29abab302f7d24Lennart Poetteringconst char* dns_resource_record_to_string(DnsResourceRecord *rr);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringDEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceRecord*, dns_resource_record_unref);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poetteringint dns_resource_record_to_wire_format(DnsResourceRecord *rr, bool canonical);
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poetteringint dns_resource_record_signer(DnsResourceRecord *rr, const char **ret);
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poetteringint dns_resource_record_source(DnsResourceRecord *rr, const char **ret);
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poetteringint dns_resource_record_is_signer(DnsResourceRecord *rr, const char *zone);
ab481675f98d3d3f12e7e48ba6d2159123b9c7bfLennart Poetteringint dns_resource_record_is_synthetic(DnsResourceRecord *rr);
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering
2001c80560e3dae69e14fd994d3978c187af48b8Lennart PoetteringDnsTxtItem *dns_txt_item_free_all(DnsTxtItem *i);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poetteringbool dns_txt_item_equal(DnsTxtItem *a, DnsTxtItem *b);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidtextern const struct hash_ops dns_resource_key_hash_ops;
c9c72065419e6595131a6fe1e663e2184a843f7cLennart Poetteringextern const struct hash_ops dns_resource_record_hash_ops;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8e54f5d90a6b9dd1ff672fb97ea98de66c49e332Lennart Poetteringint dnssec_algorithm_to_string_alloc(int i, char **ret);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poetteringint dnssec_algorithm_from_string(const char *s) _pure_;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8e54f5d90a6b9dd1ff672fb97ea98de66c49e332Lennart Poetteringint dnssec_digest_to_string_alloc(int i, char **ret);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poetteringint dnssec_digest_from_string(const char *s) _pure_;