resolved-dns-rr.h revision 85aeaccc10b111e8d16d3879b7c30a219ee6e10a
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
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>
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
b5efdb8af40ea759a1ea584c1bc44ecc81dd00ceLennart Poettering#include "bitmap.h"
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering#include "dns-type.h"
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering#include "hashmap.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "in-addr-util.h"
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include "list.h"
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef struct DnsResourceKey DnsResourceKey;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef struct DnsResourceRecord DnsResourceRecord;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef struct DnsTxtItem DnsTxtItem;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/* DNSKEY RR flags */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#define DNSKEY_FLAG_SEP (UINT16_C(1) << 0)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#define DNSKEY_FLAG_REVOKE (UINT16_C(1) << 7)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#define DNSKEY_FLAG_ZONE_KEY (UINT16_C(1) << 8)
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/* mDNS RR flags */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#define MDNS_RR_CACHE_FLUSH (UINT16_C(1) << 15)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/* DNSSEC algorithm identifiers, see
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * http://tools.ietf.org/html/rfc4034#appendix-A.1 and
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringenum {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_RSAMD5 = 1,
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering DNSSEC_ALGORITHM_DH,
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering DNSSEC_ALGORITHM_DSA,
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering DNSSEC_ALGORITHM_ECC,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_RSASHA1,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_DSA_NSEC3_SHA1,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_RSASHA1_NSEC3_SHA1,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_RSASHA256 = 8, /* RFC 5702 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_RSASHA512 = 10, /* RFC 5702 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_ECC_GOST = 12, /* RFC 5933 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_ECDSAP256SHA256 = 13, /* RFC 6605 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_ECDSAP384SHA384 = 14, /* RFC 6605 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_INDIRECT = 252,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_PRIVATEDNS,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_ALGORITHM_PRIVATEOID,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _DNSSEC_ALGORITHM_MAX_DEFINED
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering};
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/* DNSSEC digest identifiers, see
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringenum {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DNSSEC_DIGEST_SHA1 = 1,
00f0a16ab4576535021456f8955446d3ae8f0b5fLennart Poettering DNSSEC_DIGEST_SHA256 = 2, /* RFC 4509 */
a51c10485af349eb15faa4d1a63b9818bcf3e589Lennart Poettering DNSSEC_DIGEST_GOST_R_34_11_94 = 3, /* RFC 5933 */
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering DNSSEC_DIGEST_SHA384 = 4, /* RFC 6605 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _DNSSEC_DIGEST_MAX_DEFINED
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering};
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/* DNSSEC NSEC3 hash algorithms, see
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * https://www.iana.org/assignments/dnssec-nsec3-parameters/dnssec-nsec3-parameters.xhtml */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringenum {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering NSEC3_ALGORITHM_SHA1 = 1,
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering _NSEC3_ALGORITHM_MAX_DEFINED
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering};
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mackstruct DnsResourceKey {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering unsigned n_ref;
8a516214c4412e8a40544bd725a6d499a30cbbbfLennart Poettering uint16_t class, type;
8a516214c4412e8a40544bd725a6d499a30cbbbfLennart Poettering char *_name; /* don't access directy, use DNS_RESOURCE_KEY_NAME()! */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering};
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering/* Creates a temporary resource key. This is only useful to quickly
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering * look up something, without allocating a full DnsResourceKey object
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering * for it. Note that it is not OK to take references to this kind of
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering * resource key object. */
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering#define DNS_RESOURCE_KEY_CONST(c, t, n) \
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering ((DnsResourceKey) { \
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering .n_ref = (unsigned) -1, \
dfc1091b2f5f21f69e0aa6d3c4536b8990d4b100Lennart Poettering .class = c, \
dfc1091b2f5f21f69e0aa6d3c4536b8990d4b100Lennart Poettering .type = t, \
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering ._name = (char*) n, \
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering })
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poetteringstruct DnsTxtItem {
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering size_t length;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering LIST_FIELDS(DnsTxtItem, items);
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering uint8_t data[];
dfc1091b2f5f21f69e0aa6d3c4536b8990d4b100Lennart Poettering};
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poetteringstruct DnsResourceRecord {
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering unsigned n_ref;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering DnsResourceKey *key;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering char *to_string;
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt uint32_t ttl;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering usec_t expiry; /* RRSIG signature expiry */
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering bool unparseable:1;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering bool wire_format_canonical:1;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering void *wire_format;
dfc1091b2f5f21f69e0aa6d3c4536b8990d4b100Lennart Poettering size_t wire_format_size;
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering size_t wire_format_rdata_offset;
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering union {
db97a66aa69925f7403ba3c433e86320d136567dLennart Poettering struct {
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering void *data;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering size_t size;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering } generic, opt;
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering struct {
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering uint16_t priority;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering uint16_t weight;
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack uint16_t port;
dfc1091b2f5f21f69e0aa6d3c4536b8990d4b100Lennart Poettering char *name;
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering } srv;
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack struct {
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack char *name;
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack } ptr, ns, cname, dname;
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack struct {
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack char *cpu;
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack char *os;
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack } hinfo;
dfc1091b2f5f21f69e0aa6d3c4536b8990d4b100Lennart Poettering
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering struct {
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering DnsTxtItem *items;
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack } txt, spf;
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack struct {
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack struct in_addr in_addr;
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack } a;
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack
b4f1862df2e45aba90386887d685b8bf3c840e10Daniel Mack struct {
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering struct in6_addr in6_addr;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } aaaa;
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering struct {
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering char *mname;
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering char *rname;
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering uint32_t serial;
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering uint32_t refresh;
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering uint32_t retry;
1c4baffc1895809bae9ac36b670af90a4cb9cd7dTom Gundersen uint32_t expire;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering uint32_t minimum;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } soa;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering uint16_t priority;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *exchange;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } mx;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* https://tools.ietf.org/html/rfc1876 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
1c4baffc1895809bae9ac36b670af90a4cb9cd7dTom Gundersen uint8_t version;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering uint8_t size;
1c4baffc1895809bae9ac36b670af90a4cb9cd7dTom Gundersen uint8_t horiz_pre;
cc7844e78751916acb639443c119763cafe2c684Lennart Poettering uint8_t vert_pre;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering uint32_t latitude;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering uint32_t longitude;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering uint32_t altitude;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering } loc;
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering /* https://tools.ietf.org/html/rfc4255#section-3.1 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering uint8_t algorithm;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering uint8_t fptype;
6073b6f26ab9fc6bf335faa7073ec443eef093fdTom Gundersen void *fingerprint;
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen size_t fingerprint_size;
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen } sshfp;
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* http://tools.ietf.org/html/rfc4034#section-2.1 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering uint16_t flags;
d6731e4c7964ee2860d4f5abdb0b52acd7a66960Tom Gundersen uint8_t protocol;
1ade96e980d3c0855a04140f4728b3ffd429bbeaLennart Poettering uint8_t algorithm;
1ade96e980d3c0855a04140f4728b3ffd429bbeaLennart Poettering void* key;
1ade96e980d3c0855a04140f4728b3ffd429bbeaLennart Poettering size_t key_size;
1ade96e980d3c0855a04140f4728b3ffd429bbeaLennart Poettering } dnskey;
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* http://tools.ietf.org/html/rfc4034#section-3.1 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering uint16_t type_covered;
5cb36f41f01cf4b1f4395abfffd1b33116591e58Lennart Poettering uint8_t algorithm;
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen uint8_t labels;
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen uint32_t original_ttl;
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering uint32_t expiration;
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen uint32_t inception;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering uint16_t key_tag;
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen char *signer;
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen void *signature;
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen size_t signature_size;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } rrsig;
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* https://tools.ietf.org/html/rfc4034#section-4.1 */
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *next_domain_name;
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering Bitmap *types;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } nsec;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* https://tools.ietf.org/html/rfc4034#section-5.1 */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering uint16_t key_tag;
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering uint8_t algorithm;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering uint8_t digest_type;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering void *digest;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering size_t digest_size;
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering } ds;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering uint8_t algorithm;
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering uint8_t flags;
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering uint16_t iterations;
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering void *salt;
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering size_t salt_size;
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering void *next_hashed_name;
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering size_t next_hashed_name_size;
d6731e4c7964ee2860d4f5abdb0b52acd7a66960Tom Gundersen Bitmap *types;
1ade96e980d3c0855a04140f4728b3ffd429bbeaLennart Poettering } nsec3;
1ade96e980d3c0855a04140f4728b3ffd429bbeaLennart Poettering };
1ade96e980d3c0855a04140f4728b3ffd429bbeaLennart Poettering};
1ade96e980d3c0855a04140f4728b3ffd429bbeaLennart Poettering
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poetteringstatic inline const char* DNS_RESOURCE_KEY_NAME(const DnsResourceKey *key) {
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering if (!key)
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering return NULL;
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering if (key->_name)
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering return key->_name;
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering return (char*) key + sizeof(DnsResourceKey);
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering}
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poetteringstatic inline const void* DNS_RESOURCE_RECORD_RDATA(DnsResourceRecord *rr) {
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering if (!rr)
af49ca27ffd790d78dbbb465b978266dfd5c93daLennart Poettering return NULL;
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering if (!rr->wire_format)
19b50b5ba7ee8c1bfb330377309e4bab7a7531d8Lennart Poettering return NULL;
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering assert(rr->wire_format_rdata_offset <= rr->wire_format_size);
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering return (uint8_t*) rr->wire_format + rr->wire_format_rdata_offset;
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering}
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering
aaa297d4e5401fd4466632555432774863457f1dLennart Poetteringstatic inline size_t DNS_RESOURCE_RECORD_RDATA_SIZE(DnsResourceRecord *rr) {
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering if (!rr)
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering return 0;
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering if (!rr->wire_format)
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering return 0;
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering assert(rr->wire_format_rdata_offset <= rr->wire_format_size);
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering return rr->wire_format_size - rr->wire_format_rdata_offset;
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering}
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering
aaa297d4e5401fd4466632555432774863457f1dLennart PoetteringDnsResourceKey* dns_resource_key_new(uint16_t class, uint16_t type, const char *name);
aaa297d4e5401fd4466632555432774863457f1dLennart PoetteringDnsResourceKey* dns_resource_key_new_redirect(const DnsResourceKey *key, const DnsResourceRecord *cname);
aaa297d4e5401fd4466632555432774863457f1dLennart Poetteringint dns_resource_key_new_append_suffix(DnsResourceKey **ret, DnsResourceKey *key, char *name);
aaa297d4e5401fd4466632555432774863457f1dLennart PoetteringDnsResourceKey* dns_resource_key_new_consume(uint16_t class, uint16_t type, char *name);
aaa297d4e5401fd4466632555432774863457f1dLennart PoetteringDnsResourceKey* dns_resource_key_ref(DnsResourceKey *key);
aaa297d4e5401fd4466632555432774863457f1dLennart PoetteringDnsResourceKey* dns_resource_key_unref(DnsResourceKey *key);
aaa297d4e5401fd4466632555432774863457f1dLennart Poetteringbool dns_resource_key_is_address(const DnsResourceKey *key);
aaa297d4e5401fd4466632555432774863457f1dLennart Poetteringint dns_resource_key_equal(const DnsResourceKey *a, const DnsResourceKey *b);
aaa297d4e5401fd4466632555432774863457f1dLennart Poetteringint dns_resource_key_match_rr(const DnsResourceKey *key, DnsResourceRecord *rr, const char *search_domain);
aaa297d4e5401fd4466632555432774863457f1dLennart Poetteringint dns_resource_key_match_cname_or_dname(const DnsResourceKey *key, const DnsResourceKey *cname, const char *search_domain);
aaa297d4e5401fd4466632555432774863457f1dLennart Poetteringint dns_resource_key_match_soa(const DnsResourceKey *key, const DnsResourceKey *soa);
aaa297d4e5401fd4466632555432774863457f1dLennart Poetteringint dns_resource_key_to_string(const DnsResourceKey *key, char **ret);
ad6c04756115809d615dede330213d73edf732a8Lennart PoetteringDEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceKey*, dns_resource_key_unref);
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering
2e1bab34bdb1a5e849060afa8361b865ce39f87fLennart Poetteringstatic inline bool dns_key_is_shared(const DnsResourceKey *key) {
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering return IN_SET(key->type, DNS_TYPE_PTR);
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering}
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering
ad6c04756115809d615dede330213d73edf732a8Lennart PoetteringDnsResourceRecord* dns_resource_record_new(DnsResourceKey *key);
ad6c04756115809d615dede330213d73edf732a8Lennart PoetteringDnsResourceRecord* dns_resource_record_new_full(uint16_t class, uint16_t type, const char *name);
ad6c04756115809d615dede330213d73edf732a8Lennart PoetteringDnsResourceRecord* dns_resource_record_ref(DnsResourceRecord *rr);
ad6c04756115809d615dede330213d73edf732a8Lennart PoetteringDnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr);
ad6c04756115809d615dede330213d73edf732a8Lennart Poetteringint dns_resource_record_new_reverse(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *name);
ad6c04756115809d615dede330213d73edf732a8Lennart Poetteringint dns_resource_record_new_address(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *name);
ad6c04756115809d615dede330213d73edf732a8Lennart Poetteringint dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecord *b);
ad6c04756115809d615dede330213d73edf732a8Lennart Poetteringconst char* dns_resource_record_to_string(DnsResourceRecord *rr);
ad6c04756115809d615dede330213d73edf732a8Lennart PoetteringDEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceRecord*, dns_resource_record_unref);
2e1bab34bdb1a5e849060afa8361b865ce39f87fLennart Poettering
2e1bab34bdb1a5e849060afa8361b865ce39f87fLennart Poetteringint dns_resource_record_to_wire_format(DnsResourceRecord *rr, bool canonical);
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering
ad6c04756115809d615dede330213d73edf732a8Lennart PoetteringDnsTxtItem *dns_txt_item_free_all(DnsTxtItem *i);
ad6c04756115809d615dede330213d73edf732a8Lennart Poetteringbool dns_txt_item_equal(DnsTxtItem *a, DnsTxtItem *b);
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering
2e1bab34bdb1a5e849060afa8361b865ce39f87fLennart Poetteringextern const struct hash_ops dns_resource_key_hash_ops;
2e1bab34bdb1a5e849060afa8361b865ce39f87fLennart Poettering
2e1bab34bdb1a5e849060afa8361b865ce39f87fLennart Poetteringint dnssec_algorithm_to_string_alloc(int i, char **ret);
2e1bab34bdb1a5e849060afa8361b865ce39f87fLennart Poetteringint dnssec_algorithm_from_string(const char *s) _pure_;
2e1bab34bdb1a5e849060afa8361b865ce39f87fLennart Poettering
2e1bab34bdb1a5e849060afa8361b865ce39f87fLennart Poetteringint dnssec_digest_to_string_alloc(int i, char **ret);
2e1bab34bdb1a5e849060afa8361b865ce39f87fLennart Poetteringint dnssec_digest_from_string(const char *s) _pure_;
2e1bab34bdb1a5e849060afa8361b865ce39f87fLennart Poettering