]>
git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/qtype.cc
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 static_assert(sizeof(QType
) == 2, "QType is not 2 bytes in size, something is wrong!");
33 vector
<QType::namenum
> QType::names
;
34 // XXX FIXME we need to do something with initializer order here!
35 QType::init
QType::initializer
;
42 bool QType::isSupportedType() {
43 for(vector
<namenum
>::iterator pos
=names
.begin();pos
<names
.end();++pos
)
49 bool QType::isMetadataType() {
50 if (code
== QType::AXFR
||
51 code
== QType::MAILA
||
52 code
== QType::MAILB
||
53 code
== QType::TSIG
||
60 uint16_t QType::getCode() const
65 const string
QType::getName() const
67 vector
<namenum
>::iterator pos
;
68 for(pos
=names
.begin();pos
<names
.end();++pos
)
72 return "TYPE"+itoa(code
);
75 QType
&QType::operator=(uint16_t n
)
81 int QType::chartocode(const char *p
)
83 string P
= toUpper(p
);
84 vector
<namenum
>::iterator pos
;
86 for(pos
=names
.begin(); pos
< names
.end(); ++pos
)
94 if(boost::starts_with(P
, "TYPE"))
100 QType
&QType::operator=(const char *p
)
106 QType
&QType::operator=(const string
&s
)
108 code
=chartocode(s
.c_str());
113 QType::QType(uint16_t n
): QType()