]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-dns-rr.h
resolve-host: make arg_type an int
[thirdparty/systemd.git] / src / resolve / resolved-dns-rr.h
CommitLineData
74b2466e
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3#pragma once
4
5/***
6 This file is part of systemd.
7
8 Copyright 2014 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24#include <inttypes.h>
25#include <netinet/in.h>
26
27#include "util.h"
322345fd 28#include "hashmap.h"
623a4c97 29#include "in-addr-util.h"
7263f724 30#include "dns-type.h"
74b2466e
LP
31
32typedef struct DnsResourceKey DnsResourceKey;
33typedef struct DnsResourceRecord DnsResourceRecord;
34
35/* DNS record classes, see RFC 1035 */
36enum {
37 DNS_CLASS_IN = 0x01,
322345fd 38 DNS_CLASS_ANY = 0xFF,
b93312f5
ZJS
39 _DNS_CLASS_MAX,
40 _DNS_CLASS_INVALID = -1
74b2466e
LP
41};
42
74b2466e 43struct DnsResourceKey {
faa133f3
LP
44 unsigned n_ref;
45 uint16_t class, type;
46 char *_name; /* don't access directy, use DNS_RESOURCE_KEY_NAME()! */
74b2466e
LP
47};
48
49struct DnsResourceRecord {
50 unsigned n_ref;
faa133f3 51 DnsResourceKey *key;
74b2466e 52 uint32_t ttl;
0dae31d4 53 bool unparseable;
74b2466e
LP
54 union {
55 struct {
56 void *data;
57 uint16_t size;
58 } generic;
59
9c92ce6d
LP
60 struct {
61 uint16_t priority;
62 uint16_t weight;
63 uint16_t port;
64 char *name;
65 } srv;
74b2466e
LP
66
67 struct {
68 char *name;
8ac4e9e1 69 } ptr, ns, cname, dname;
74b2466e
LP
70
71 struct {
72 char *cpu;
73 char *os;
74 } hinfo;
75
2e276efc
ZJS
76 struct {
77 char **strings;
c0eb11cf 78 } txt, spf;
74b2466e
LP
79
80 struct {
81 struct in_addr in_addr;
82 } a;
83
84 struct {
85 struct in6_addr in6_addr;
86 } aaaa;
7e8e0422
LP
87
88 struct {
89 char *mname;
90 char *rname;
91 uint32_t serial;
92 uint32_t refresh;
93 uint32_t retry;
94 uint32_t expire;
95 uint32_t minimum;
96 } soa;
946c7094
ZJS
97
98 struct {
99 uint16_t priority;
100 char *exchange;
101 } mx;
0dae31d4
ZJS
102
103 struct {
104 uint8_t version;
105 uint8_t size;
106 uint8_t horiz_pre;
107 uint8_t vert_pre;
108 uint32_t latitude;
109 uint32_t longitude;
110 uint32_t altitude;
111 } loc;
42cc2eeb
LP
112
113 struct {
114 uint8_t algorithm;
115 uint8_t fptype;
116 void *key;
117 size_t key_size;
118 } sshfp;
74b2466e
LP
119 };
120};
121
faa133f3
LP
122static inline const char* DNS_RESOURCE_KEY_NAME(const DnsResourceKey *key) {
123 if (_unlikely_(!key))
124 return NULL;
125
126 if (key->_name)
127 return key->_name;
128
129 return (char*) key + sizeof(DnsResourceKey);
130}
74b2466e 131
faa133f3
LP
132DnsResourceKey* dns_resource_key_new(uint16_t class, uint16_t type, const char *name);
133DnsResourceKey* dns_resource_key_new_consume(uint16_t class, uint16_t type, char *name);
134DnsResourceKey* dns_resource_key_ref(DnsResourceKey *key);
135DnsResourceKey* dns_resource_key_unref(DnsResourceKey *key);
136int dns_resource_key_equal(const DnsResourceKey *a, const DnsResourceKey *b);
137int dns_resource_key_match_rr(const DnsResourceKey *key, const DnsResourceRecord *rr);
138int dns_resource_key_match_cname(const DnsResourceKey *key, const DnsResourceRecord *rr);
322345fd
LP
139unsigned long dns_resource_key_hash_func(const void *i, const uint8_t hash_key[HASH_KEY_SIZE]);
140int dns_resource_key_compare_func(const void *a, const void *b);
2d4c5cbc 141int dns_resource_key_to_string(const DnsResourceKey *key, char **ret);
faa133f3 142DEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceKey*, dns_resource_key_unref);
322345fd 143
faa133f3 144DnsResourceRecord* dns_resource_record_new(DnsResourceKey *key);
8bf52d3d 145DnsResourceRecord* dns_resource_record_new_full(uint16_t class, uint16_t type, const char *name);
74b2466e
LP
146DnsResourceRecord* dns_resource_record_ref(DnsResourceRecord *rr);
147DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr);
623a4c97 148int dns_resource_record_new_reverse(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *name);
322345fd 149int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecord *b);
2d4c5cbc 150int dns_resource_record_to_string(const DnsResourceRecord *rr, char **ret);
faa133f3 151DEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceRecord*, dns_resource_record_unref);
322345fd 152
322345fd 153const char *dns_class_to_string(uint16_t type);
2d4c5cbc 154int dns_class_from_string(const char *name, uint16_t *class);