74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2014 Lennart 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 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 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 Poetteringtypedef struct DnsResourceKey DnsResourceKey;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef struct DnsResourceRecord DnsResourceRecord;
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)
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mack/* mDNS RR flags */
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 */
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 digest identifiers, see
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering * https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml */
6f717d0817573a76c3e586eae02793d8b23a0581Lennart Poettering DNSSEC_DIGEST_GOST_R_34_11_94 = 3, /* RFC 5933 */
d15ad74251454d55b715958d8e6f50f45195904aLennart Poettering/* DNSSEC NSEC3 hash algorithms, see
d15ad74251454d55b715958d8e6f50f45195904aLennart Poettering * https://www.iana.org/assignments/dnssec-nsec3-parameters/dnssec-nsec3-parameters.xhtml */
f57e3cd5fa709ec0f52531eccba909ac0851927cLennart Poettering unsigned n_ref; /* (unsigned -1) for const keys, see below */
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering char *_name; /* don't access directy, use DNS_RESOURCE_KEY_NAME()! */
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 ._name = (char*) n, \
ee3d6aff9bd73c1b23e29d1fa1fa6f7a1ef0533bLennart Poettering usec_t expiry; /* RRSIG signature expiry */
97c67192eadaffe67b803ec5b991a92bb1137d0bLennart Poettering /* How many labels to strip to determine "signer" of the RRSIG (aka, the zone). -1 if not signed. */
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. */
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering /* https://tools.ietf.org/html/rfc1876 */
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen /* https://tools.ietf.org/html/rfc4255#section-3.1 */
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek /* http://tools.ietf.org/html/rfc4034#section-2.1 */
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek /* http://tools.ietf.org/html/rfc4034#section-3.1 */
9ead3519c54b6d1b79b35541873b5cf7c8b3a7d3Lennart Poettering /* https://tools.ietf.org/html/rfc4034#section-4.1 */
6af47493de0ef2b66d4c3fbcdd4a2e12fec4bfbaLennart Poettering /* https://tools.ietf.org/html/rfc4034#section-5.1 */
48d45d2b49d2adb870cd5f1bc7cb389b33655f1cZbigniew Jędrzejewski-Szmek /* https://tools.ietf.org/html/draft-ietf-dane-protocol-23 */
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringstatic inline const char* DNS_RESOURCE_KEY_NAME(const DnsResourceKey *key) {
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering return (char*) key + sizeof(DnsResourceKey);
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poetteringstatic inline const void* DNS_RESOURCE_RECORD_RDATA(DnsResourceRecord *rr) {
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 Poetteringstatic inline size_t DNS_RESOURCE_RECORD_RDATA_SIZE(DnsResourceRecord *rr) {
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering assert(rr->wire_format_rdata_offset <= rr->wire_format_size);
85aeaccc10b111e8d16d3879b7c30a219ee6e10aLennart Poettering return rr->wire_format_size - rr->wire_format_rdata_offset;
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);
7778dffff3d8bd7438fe19a248c16203668324c9Daniel Mackstatic inline bool dns_key_is_shared(const DnsResourceKey *key) {
f57e3cd5fa709ec0f52531eccba909ac0851927cLennart Poetteringbool dns_resource_key_reduce(DnsResourceKey **a, DnsResourceKey **b);
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);
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poetteringint dns_resource_record_to_wire_format(DnsResourceRecord *rr, bool canonical);
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);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart PoetteringDnsTxtItem *dns_txt_item_free_all(DnsTxtItem *i);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poetteringbool dns_txt_item_equal(DnsTxtItem *a, DnsTxtItem *b);
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidtextern const struct hash_ops dns_resource_key_hash_ops;
c9c72065419e6595131a6fe1e663e2184a843f7cLennart Poetteringextern const struct hash_ops dns_resource_record_hash_ops;
8e54f5d90a6b9dd1ff672fb97ea98de66c49e332Lennart Poetteringint dnssec_algorithm_to_string_alloc(int i, char **ret);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poetteringint dnssec_algorithm_from_string(const char *s) _pure_;
8e54f5d90a6b9dd1ff672fb97ea98de66c49e332Lennart Poetteringint dnssec_digest_to_string_alloc(int i, char **ret);