]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/dns-type.c
Merge pull request #764 from ssahani/vxlan1
[thirdparty/systemd.git] / src / resolve / dns-type.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2014 Zbigniew Jędrzejewski-Szmek
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include "dns-type.h"
23
24 typedef const struct {
25 uint16_t type;
26 const char *name;
27 } dns_type;
28
29 static const struct dns_type_name *
30 lookup_dns_type (register const char *str, register unsigned int len);
31
32 #include "dns_type-from-name.h"
33 #include "dns_type-to-name.h"
34
35 int dns_type_from_string(const char *s) {
36 const struct dns_type_name *sc;
37
38 assert(s);
39
40 sc = lookup_dns_type(s, strlen(s));
41 if (!sc)
42 return _DNS_TYPE_INVALID;
43
44 return sc->id;
45 }
46
47 /* XXX: find an authoritative list of all pseudo types? */
48 bool dns_type_is_pseudo(int n) {
49 return IN_SET(n, DNS_TYPE_ANY, DNS_TYPE_AXFR, DNS_TYPE_IXFR, DNS_TYPE_OPT);
50 }