]>
Commit | Line | Data |
---|---|---|
7263f724 ZJS |
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 | ||
de292aa1 | 35 | int dns_type_from_string(const char *s) { |
7263f724 ZJS |
36 | const struct dns_type_name *sc; |
37 | ||
38 | assert(s); | |
7263f724 ZJS |
39 | |
40 | sc = lookup_dns_type(s, strlen(s)); | |
41 | if (!sc) | |
de292aa1 | 42 | return _DNS_TYPE_INVALID; |
7263f724 | 43 | |
de292aa1 | 44 | return sc->id; |
7263f724 | 45 | } |
8e6edc49 | 46 | |
94e5ba37 | 47 | /* XXX: find an authoritative list of all pseudo types? */ |
8e6edc49 TG |
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 | } |