resolved-dns-rr.h revision a43a068a30f7a47aba39f8b48d5db0c4d39fd21d
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
#pragma once
/***
This file is part of systemd.
Copyright 2014 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "bitmap.h"
#include "dns-type.h"
#include "hashmap.h"
#include "in-addr-util.h"
#include "list.h"
typedef struct DnsResourceKey DnsResourceKey;
typedef struct DnsResourceRecord DnsResourceRecord;
typedef struct DnsTxtItem DnsTxtItem;
/* DNSKEY RR flags */
/* mDNS RR flags */
/* DNSSEC algorithm identifiers, see
* http://tools.ietf.org/html/rfc4034#appendix-A.1 and
enum {
DNSSEC_ALGORITHM_INDIRECT = 252,
};
/* DNSSEC digest identifiers, see
enum {
DNSSEC_DIGEST_SHA1 = 1,
};
/* DNSSEC NSEC3 hash algorithms, see
enum {
NSEC3_ALGORITHM_SHA1 = 1,
};
struct DnsResourceKey {
unsigned n_ref; /* (unsigned -1) for const keys, see below */
char *_name; /* don't access directy, use DNS_RESOURCE_KEY_NAME()! */
};
/* Creates a temporary resource key. This is only useful to quickly
* look up something, without allocating a full DnsResourceKey object
* for it. Note that it is not OK to take references to this kind of
* resource key object. */
#define DNS_RESOURCE_KEY_CONST(c, t, n) \
((DnsResourceKey) { \
.n_ref = (unsigned) -1, \
.class = c, \
.type = t, \
._name = (char*) n, \
})
struct DnsTxtItem {
};
struct DnsResourceRecord {
unsigned n_ref;
char *to_string;
/* How many labels to strip to determine "signer" of the RRSIG (aka, the zone). -1 if not signed. */
unsigned n_skip_labels_signer;
/* How many labels to strip to determine "synthesizing source" of this RR, i.e. the wildcard's immediate parent. -1 if not signed. */
unsigned n_skip_labels_source;
bool unparseable:1;
bool wire_format_canonical:1;
void *wire_format;
union {
struct {
void *data;
struct {
char *name;
} srv;
struct {
char *name;
struct {
char *cpu;
char *os;
} hinfo;
struct {
struct {
} a;
struct {
} aaaa;
struct {
char *mname;
char *rname;
} soa;
struct {
char *exchange;
} mx;
struct {
} loc;
/* https://tools.ietf.org/html/rfc4255#section-3.1 */
struct {
void *fingerprint;
} sshfp;
/* http://tools.ietf.org/html/rfc4034#section-2.1 */
struct {
void* key;
} dnskey;
/* http://tools.ietf.org/html/rfc4034#section-3.1 */
struct {
char *signer;
void *signature;
} rrsig;
/* https://tools.ietf.org/html/rfc4034#section-4.1 */
struct {
char *next_domain_name;
} nsec;
/* https://tools.ietf.org/html/rfc4034#section-5.1 */
struct {
void *digest;
} ds;
struct {
void *salt;
void *next_hashed_name;
} nsec3;
struct {
void *data;
} tlsa;
};
};
if (!key)
return NULL;
return (char*) key + sizeof(DnsResourceKey);
}
if (!rr)
return NULL;
if (!rr->wire_format)
return NULL;
}
if (!rr)
return 0;
if (!rr->wire_format)
return 0;
}
DnsResourceKey* dns_resource_key_new_redirect(const DnsResourceKey *key, const DnsResourceRecord *cname);
int dns_resource_key_match_rr(const DnsResourceKey *key, DnsResourceRecord *rr, const char *search_domain);
int dns_resource_key_match_cname_or_dname(const DnsResourceKey *key, const DnsResourceKey *cname, const char *search_domain);
}
int dns_resource_record_new_reverse(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *name);
int dns_resource_record_new_address(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *name);
extern const struct hash_ops dns_resource_key_hash_ops;
extern const struct hash_ops dns_resource_record_hash_ops;
int dnssec_algorithm_to_string_alloc(int i, char **ret);
int dnssec_algorithm_from_string(const char *s) _pure_;
int dnssec_digest_to_string_alloc(int i, char **ret);
int dnssec_digest_from_string(const char *s) _pure_;