]>
Commit | Line | Data |
---|---|---|
4192ca66 | 1 | /* |
12471842 PL |
2 | * This file is part of PowerDNS or dnsdist. |
3 | * Copyright -- PowerDNS.COM B.V. and its contributors | |
4 | * | |
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. | |
8 | * | |
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. | |
12 | * | |
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. | |
17 | * | |
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. | |
21 | */ | |
e8c59f2d | 22 | #pragma once |
2b808f13 | 23 | #include <inttypes.h> |
4192ca66 BH |
24 | #include <string> |
25 | #include <stdexcept> | |
26 | ||
10f4eea8 | 27 | #include "namespaces.hh" |
4a51ff72 | 28 | #include "dnsname.hh" |
f4352636 | 29 | #include "iputils.hh" |
786ed0ff | 30 | #include "misc.hh" |
373914dc | 31 | #include "svc-records.hh" |
4192ca66 BH |
32 | |
33 | class RecordTextException : public runtime_error | |
34 | { | |
35 | public: | |
36 | RecordTextException(const string& str) : runtime_error(str) | |
37 | {} | |
38 | }; | |
39 | ||
40 | class RecordTextReader | |
41 | { | |
42 | public: | |
1290c1d2 | 43 | RecordTextReader(string str, DNSName zone=DNSName("")); |
786ed0ff | 44 | void xfrNodeOrLocatorID(NodeOrLocatorID& val); |
341930bb BH |
45 | void xfr64BitInt(uint64_t& val); |
46 | void xfr48BitInt(uint64_t& val); | |
cbf0e7f3 BH |
47 | void xfr32BitInt(uint32_t& val); |
48 | void xfr16BitInt(uint16_t& val); | |
8c1c9170 | 49 | void xfr8BitInt(uint8_t& val); |
cbf0e7f3 | 50 | |
20133c59 | 51 | void xfrType(uint16_t& val); |
cbf0e7f3 | 52 | void xfrIP(uint32_t& val); |
b9b28916 | 53 | void xfrIP6(std::string& val); |
f4352636 PD |
54 | void xfrCAWithoutPort(uint8_t version, ComboAddress &val); |
55 | void xfrCAPort(ComboAddress &val); | |
8bf26468 BH |
56 | void xfrTime(uint32_t& val); |
57 | ||
f21fc0aa | 58 | void xfrName(DNSName& val, bool compress=false, bool noDot=false); |
84e1142d | 59 | void xfrText(string& val, bool multi=false, bool lenField=true); |
948a927f | 60 | void xfrUnquotedText(string& val, bool lenField=true); |
e4090157 | 61 | void xfrHexBlob(string& val, bool keepReading=false); |
8b606f6e | 62 | void xfrBase32HexBlob(string& val); |
1c4d88c5 | 63 | |
2fe9d6f7 | 64 | void xfrBlobNoSpaces(string& val, int len=-1); |
06ffdc52 | 65 | void xfrBlob(string& val, int len=-1); |
4192ca66 | 66 | |
373914dc | 67 | void xfrSvcParamKeyVals(set<SvcParam>& val); |
b1a048a9 | 68 | void xfrRFC1035CharString(string &val); |
d1082642 | 69 | void xfrSVCBValueList(vector<string> &val); |
373914dc | 70 | |
ddb79bca AT |
71 | const string getRemaining() const { |
72 | return d_string.substr(d_pos); | |
73 | } | |
74 | ||
b1a048a9 | 75 | |
20133c59 | 76 | bool eof(); |
4192ca66 BH |
77 | private: |
78 | string d_string; | |
3716f081 | 79 | DNSName d_zone; |
4192ca66 BH |
80 | string::size_type d_pos; |
81 | string::size_type d_end; | |
82 | void skipSpaces(); | |
83 | }; | |
84 | ||
85 | class RecordTextWriter | |
86 | { | |
87 | public: | |
f21fc0aa | 88 | RecordTextWriter(string& str, bool noDot=false); |
786ed0ff | 89 | void xfrNodeOrLocatorID(const NodeOrLocatorID& val); |
341930bb | 90 | void xfr48BitInt(const uint64_t& val); |
cbf0e7f3 BH |
91 | void xfr32BitInt(const uint32_t& val); |
92 | void xfr16BitInt(const uint16_t& val); | |
8c1c9170 | 93 | void xfr8BitInt(const uint8_t& val); |
cbf0e7f3 | 94 | void xfrIP(const uint32_t& val); |
b9b28916 | 95 | void xfrIP6(const std::string& val); |
f4352636 PD |
96 | void xfrCAWithoutPort(uint8_t version, ComboAddress &val); |
97 | void xfrCAPort(ComboAddress &val); | |
8bf26468 | 98 | void xfrTime(const uint32_t& val); |
1c4d88c5 | 99 | void xfrBase32HexBlob(const string& val); |
20133c59 BH |
100 | |
101 | void xfrType(const uint16_t& val); | |
f21fc0aa | 102 | void xfrName(const DNSName& val, bool compress=false, bool noDot=false); |
84e1142d | 103 | void xfrText(const string& val, bool multi=false, bool lenField=true); |
948a927f | 104 | void xfrUnquotedText(const string& val, bool lenField=true); |
2fe9d6f7 | 105 | void xfrBlobNoSpaces(const string& val, int len=-1); |
06ffdc52 | 106 | void xfrBlob(const string& val, int len=-1); |
e4090157 | 107 | void xfrHexBlob(const string& val, bool keepReading=false); |
373914dc | 108 | void xfrSvcParamKeyVals(const set<SvcParam>& val); |
d476d7fb | 109 | bool eof() { return true; }; |
ddb79bca | 110 | |
a064bd5a PL |
111 | void xfrSVCBValueList(const vector<string> &val); |
112 | ||
ddb79bca AT |
113 | const string getRemaining() const { |
114 | return ""; | |
115 | } | |
4192ca66 BH |
116 | private: |
117 | string& d_string; | |
f21fc0aa | 118 | bool d_nodot; |
4192ca66 | 119 | }; |