Skip to content

Commit d07b43a

Browse files
committed
resolved: move dns_type_to_af() to dns-type.c
1 parent edbcc1f commit d07b43a

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/resolve/dns-type.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
along with systemd; If not, see <http://www.gnu.org/licenses/>.
2020
***/
2121

22+
#include <sys/socket.h>
23+
2224
#include "dns-type.h"
2325
#include "string-util.h"
2426

@@ -183,6 +185,23 @@ bool dns_type_is_obsolete(uint16_t type) {
183185
DNS_TYPE_NULL);
184186
}
185187

188+
int dns_type_to_af(uint16_t t) {
189+
switch (t) {
190+
191+
case DNS_TYPE_A:
192+
return AF_INET;
193+
194+
case DNS_TYPE_AAAA:
195+
return AF_INET6;
196+
197+
case DNS_TYPE_ANY:
198+
return AF_UNSPEC;
199+
200+
default:
201+
return -EINVAL;
202+
}
203+
}
204+
186205
const char *dns_class_to_string(uint16_t class) {
187206

188207
switch (class) {

src/resolve/dns-type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ bool dns_type_is_dnssec(uint16_t type);
133133
bool dns_type_is_obsolete(uint16_t type);
134134
bool dns_type_may_wildcard(uint16_t type);
135135
bool dns_type_apex_only(uint16_t type);
136+
int dns_type_to_af(uint16_t t);
136137

137138
bool dns_class_is_pseudo(uint16_t class);
138139
bool dns_class_is_valid_rr(uint16_t class);

src/resolve/resolved-dns-query.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -595,23 +595,6 @@ static DnsProtocol SYNTHESIZE_PROTOCOL(uint64_t flags) {
595595
return DNS_PROTOCOL_DNS;
596596
}
597597

598-
static int dns_type_to_af(uint16_t t) {
599-
switch (t) {
600-
601-
case DNS_TYPE_A:
602-
return AF_INET;
603-
604-
case DNS_TYPE_AAAA:
605-
return AF_INET6;
606-
607-
case DNS_TYPE_ANY:
608-
return AF_UNSPEC;
609-
610-
default:
611-
return -EINVAL;
612-
}
613-
}
614-
615598
static int synthesize_localhost_rr(DnsQuery *q, const DnsResourceKey *key, DnsAnswer **answer) {
616599
int r;
617600

0 commit comments

Comments
 (0)