1266077Sdes/**
2266077Sdes * str2wire.h -  read txt presentation of RRs
3266077Sdes *
4266077Sdes * (c) NLnet Labs, 2005-2006
5266077Sdes *
6266077Sdes * See the file LICENSE for the license
7266077Sdes */
8266077Sdes
9266077Sdes/**
10266077Sdes * \file
11266077Sdes *
12266077Sdes * Parses text to wireformat.
13266077Sdes */
14266077Sdes
15266077Sdes#ifndef LDNS_STR2WIRE_H
16266077Sdes#define LDNS_STR2WIRE_H
17266077Sdes
18266077Sdes/* include rrdef for MAX_DOMAINLEN constant */
19287915Sdes#include <sldns/rrdef.h>
20266077Sdes
21266077Sdes#ifdef __cplusplus
22266077Sdesextern "C" {
23266077Sdes#endif
24266077Sdesstruct sldns_struct_lookup_table;
25266077Sdes
26266077Sdes/** buffer to read an RR, cannot be larger than 64K because of packet size */
27266077Sdes#define LDNS_RR_BUF_SIZE 65535 /* bytes */
28266077Sdes#define LDNS_DEFAULT_TTL	3600
29266077Sdes
30266077Sdes/*
31266077Sdes * To convert class and type to string see
32266077Sdes * sldns_get_rr_class_by_name(str)
33266077Sdes * sldns_get_rr_type_by_name(str)
34266077Sdes * from rrdef.h
35266077Sdes */
36266077Sdes
37266077Sdes/**
38266077Sdes * Convert text string into dname wireformat, mallocless, with user buffer.
39266077Sdes * @param str: the text string with the domain name.
40266077Sdes * @param buf: the result buffer, suggested size LDNS_MAX_DOMAINLEN+1
41266077Sdes * @param len: length of the buffer on input, length of the result on output.
42266077Sdes * @return 0 on success, otherwise an error.
43266077Sdes */
44266077Sdesint sldns_str2wire_dname_buf(const char* str, uint8_t* buf, size_t* len);
45266077Sdes
46266077Sdes/**
47266077Sdes * Same as sldns_str2wire_dname_buf, but concatenates origin if the domain
48266077Sdes * name is relative (does not end in '.').
49266077Sdes * @param str: the text string with the domain name.
50266077Sdes * @param buf: the result buffer, suggested size LDNS_MAX_DOMAINLEN+1
51266077Sdes * @param len: length of the buffer on input, length of the result on output.
52266077Sdes * @param origin: the origin to append or NULL (nothing is appended).
53266077Sdes * @param origin_len: length of origin.
54266077Sdes * @return 0 on success, otherwise an error.
55266077Sdes */
56266077Sdesint sldns_str2wire_dname_buf_origin(const char* str, uint8_t* buf, size_t* len,
57266077Sdes	uint8_t* origin, size_t origin_len);
58266077Sdes
59266077Sdes/**
60266077Sdes * Convert text string into dname wireformat
61266077Sdes * @param str: the text string with the domain name.
62266077Sdes * @param len: returned length of wireformat.
63266077Sdes * @return wireformat dname (malloced) or NULL on failure.
64266077Sdes */
65266077Sdesuint8_t* sldns_str2wire_dname(const char* str, size_t* len);
66266077Sdes
67266077Sdes/**
68266077Sdes * Convert text RR to wireformat, with user buffer.
69266077Sdes * @param str: the RR data in text presentation format.
70266077Sdes * @param rr: the buffer where the result is stored into.  This buffer has
71266077Sdes * 	the wire-dname(uncompressed), type, class, ttl, rdatalen, rdata.
72266077Sdes * 	These values are probably not aligned, and in network format.
73266077Sdes * 	Use the sldns_wirerr_get_xxx functions to access them safely.
74266077Sdes * 	buffer size LDNS_RR_BUF_SIZE is suggested.
75266077Sdes * @param len: on input the length of the buffer, on output the amount of
76266077Sdes * 	the buffer used for the rr.
77266077Sdes * @param dname_len: if non-NULL, filled with the dname length as result.
78266077Sdes * 	Because after the dname you find the type, class, ttl, rdatalen, rdata.
79266077Sdes * @param default_ttl: TTL used if no TTL available.
80266077Sdes * @param origin: used for origin dname (if not NULL)
81266077Sdes * @param origin_len: length of origin.
82266077Sdes * @param prev: used for prev_rr dname (if not NULL)
83266077Sdes * @param prev_len: length of prev.
84266077Sdes * @return 0 on success, an error on failure.
85266077Sdes */
86266077Sdesint sldns_str2wire_rr_buf(const char* str, uint8_t* rr, size_t* len,
87266077Sdes	size_t* dname_len, uint32_t default_ttl, uint8_t* origin,
88266077Sdes	size_t origin_len, uint8_t* prev, size_t prev_len);
89266077Sdes
90266077Sdes/**
91266077Sdes * Same as sldns_str2wire_rr_buf, but there is no rdata, it returns an RR
92266077Sdes * with zero rdata and no ttl.  It has name, type, class.
93266077Sdes * You can access those with the sldns_wirerr_get_type and class functions.
94266077Sdes * @param str: the RR data in text presentation format.
95266077Sdes * @param rr: the buffer where the result is stored into.
96266077Sdes * @param len: on input the length of the buffer, on output the amount of
97266077Sdes * 	the buffer used for the rr.
98266077Sdes * @param dname_len: if non-NULL, filled with the dname length as result.
99266077Sdes * 	Because after the dname you find the type, class, ttl, rdatalen, rdata.
100266077Sdes * @param origin: used for origin dname (if not NULL)
101266077Sdes * @param origin_len: length of origin.
102266077Sdes * @param prev: used for prev_rr dname (if not NULL)
103266077Sdes * @param prev_len: length of prev.
104266077Sdes * @return 0 on success, an error on failure.
105266077Sdes */
106266077Sdesint sldns_str2wire_rr_question_buf(const char* str, uint8_t* rr, size_t* len,
107266077Sdes	size_t* dname_len, uint8_t* origin, size_t origin_len, uint8_t* prev,
108266077Sdes	size_t prev_len);
109266077Sdes
110266077Sdes/**
111266077Sdes * Get the type of the RR.
112266077Sdes * @param rr: the RR in wire format.
113266077Sdes * @param len: rr length.
114266077Sdes * @param dname_len: dname length to skip.
115266077Sdes * @return type in host byteorder
116266077Sdes */
117266077Sdesuint16_t sldns_wirerr_get_type(uint8_t* rr, size_t len, size_t dname_len);
118266077Sdes
119266077Sdes/**
120266077Sdes * Get the class of the RR.
121266077Sdes * @param rr: the RR in wire format.
122266077Sdes * @param len: rr length.
123266077Sdes * @param dname_len: dname length to skip.
124266077Sdes * @return class in host byteorder
125266077Sdes */
126266077Sdesuint16_t sldns_wirerr_get_class(uint8_t* rr, size_t len, size_t dname_len);
127266077Sdes
128266077Sdes/**
129266077Sdes * Get the ttl of the RR.
130266077Sdes * @param rr: the RR in wire format.
131266077Sdes * @param len: rr length.
132266077Sdes * @param dname_len: dname length to skip.
133266077Sdes * @return ttl in host byteorder
134266077Sdes */
135266077Sdesuint32_t sldns_wirerr_get_ttl(uint8_t* rr, size_t len, size_t dname_len);
136266077Sdes
137266077Sdes/**
138266077Sdes * Get the rdata length of the RR.
139266077Sdes * @param rr: the RR in wire format.
140266077Sdes * @param len: rr length.
141266077Sdes * @param dname_len: dname length to skip.
142266077Sdes * @return rdata length in host byteorder
143266077Sdes * 	If the rdata length is larger than the rr-len allows, it is truncated.
144266077Sdes * 	So, that it is safe to read the data length returned
145266077Sdes * 	from this function from the rdata pointer of sldns_wirerr_get_rdata.
146266077Sdes */
147266077Sdesuint16_t sldns_wirerr_get_rdatalen(uint8_t* rr, size_t len, size_t dname_len);
148266077Sdes
149266077Sdes/**
150266077Sdes * Get the rdata pointer of the RR.
151266077Sdes * @param rr: the RR in wire format.
152266077Sdes * @param len: rr length.
153266077Sdes * @param dname_len: dname length to skip.
154266077Sdes * @return rdata pointer
155266077Sdes */
156266077Sdesuint8_t* sldns_wirerr_get_rdata(uint8_t* rr, size_t len, size_t dname_len);
157266077Sdes
158266077Sdes/**
159266077Sdes * Get the rdata pointer of the RR. prefixed with rdata length.
160266077Sdes * @param rr: the RR in wire format.
161266077Sdes * @param len: rr length.
162266077Sdes * @param dname_len: dname length to skip.
163266077Sdes * @return pointer to rdatalength, followed by the rdata.
164266077Sdes */
165266077Sdesuint8_t* sldns_wirerr_get_rdatawl(uint8_t* rr, size_t len, size_t dname_len);
166266077Sdes
167266077Sdes/**
168266077Sdes * Parse result codes
169266077Sdes */
170266077Sdes#define LDNS_WIREPARSE_MASK 0x0fff
171266077Sdes#define LDNS_WIREPARSE_SHIFT 12
172266077Sdes#define LDNS_WIREPARSE_ERROR(e) ((e)&LDNS_WIREPARSE_MASK)
173266077Sdes#define LDNS_WIREPARSE_OFFSET(e) (((e)&~LDNS_WIREPARSE_MASK)>>LDNS_WIREPARSE_SHIFT)
174266077Sdes/* use lookuptable to get error string, sldns_wireparse_errors */
175266077Sdes#define LDNS_WIREPARSE_ERR_OK 0
176266077Sdes#define LDNS_WIREPARSE_ERR_GENERAL 342
177266077Sdes#define LDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW 343
178266077Sdes#define LDNS_WIREPARSE_ERR_DOMAINNAME_UNDERFLOW 344
179266077Sdes#define LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL 345
180266077Sdes#define LDNS_WIREPARSE_ERR_LABEL_OVERFLOW 346
181266077Sdes#define LDNS_WIREPARSE_ERR_EMPTY_LABEL 347
182266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE 348
183266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX 349
184266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_TTL 350
185266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_TYPE 351
186266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_CLASS 352
187266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_RDATA 353
188266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_MISSING_VALUE 354
189266077Sdes#define LDNS_WIREPARSE_ERR_INVALID_STR 355
190266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_B64 356
191266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_B32_EXT 357
192266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_HEX 358
193266077Sdes#define LDNS_WIREPARSE_ERR_CERT_BAD_ALGORITHM 359
194266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_TIME 360
195266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_PERIOD 361
196266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_ILNP64 362
197266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_EUI48 363
198266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_EUI64 364
199266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_TAG 365
200266077Sdes#define LDNS_WIREPARSE_ERR_NOT_IMPL 366
201266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_INT 367
202266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_IP4 368
203266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_IP6 369
204266077Sdes#define LDNS_WIREPARSE_ERR_SYNTAX_INTEGER_OVERFLOW 370
205266077Sdes#define LDNS_WIREPARSE_ERR_INCLUDE 371
206266077Sdes#define LDNS_WIREPARSE_ERR_PARENTHESIS 372
207266077Sdes
208266077Sdes/**
209266077Sdes * Get reference to a constant string for the (parse) error.
210266077Sdes * @param e: error return value
211266077Sdes * @return string.
212266077Sdes */
213266077Sdesconst char* sldns_get_errorstr_parse(int e);
214266077Sdes
215266077Sdes/**
216266077Sdes * wire parse state for parsing files
217266077Sdes */
218266077Sdesstruct sldns_file_parse_state {
219266077Sdes	/** the origin domain name, if len!=0. uncompressed wireformat */
220266077Sdes	uint8_t origin[LDNS_MAX_DOMAINLEN+1];
221266077Sdes	/** length of origin domain name, in bytes. 0 if not set. */
222266077Sdes	size_t origin_len;
223266077Sdes	/** the previous domain name, if len!=0. uncompressed wireformat*/
224266077Sdes	uint8_t prev_rr[LDNS_MAX_DOMAINLEN+1];
225266077Sdes	/** length of the previous domain name, in bytes. 0 if not set. */
226266077Sdes	size_t prev_rr_len;
227266077Sdes	/** default TTL, this is used if the text does not specify a TTL,
228266077Sdes	 * host byteorder */
229266077Sdes	uint32_t default_ttl;
230266077Sdes	/** line number information */
231266077Sdes	int lineno;
232266077Sdes};
233266077Sdes
234266077Sdes/**
235266077Sdes * Read one RR from zonefile with buffer for the data.
236266077Sdes * @param in: file that is read from (one RR, multiple lines if it spans them).
237266077Sdes * @param rr: this is malloced by the user and the result is stored here,
238266077Sdes * 	if an RR is read.  If no RR is read this is signalled with the
239266077Sdes * 	return len set to 0 (for ORIGIN, TTL directives).
240266077Sdes * @param len: on input, the length of the rr buffer.  on output the rr len.
241266077Sdes * 	Buffer size of 64k should be enough.
242266077Sdes * @param dname_len: returns the length of the dname initial part of the rr.
243266077Sdes * @param parse_state: pass a pointer to user-allocated struct.
244266077Sdes * 	Contents are maintained by this function.
245266077Sdes * 	If you pass NULL then ORIGIN and TTL directives are not honored.
246266077Sdes * 	You can start out with a particular origin by pre-filling it.
247266077Sdes * 	otherwise, zero the structure before passing it.
248266077Sdes * 	lineno is incremented when a newline is passed by the parser,
249266077Sdes * 	you should initialize it at 1 at the start of the file.
250266077Sdes * @return 0 on success, error on failure.
251266077Sdes */
252266077Sdesint sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
253266077Sdes	struct sldns_file_parse_state* parse_state);
254266077Sdes
255266077Sdes/**
256266077Sdes * Convert one rdf in rdata to wireformat and parse from string.
257266077Sdes * @param str: the text to convert for this rdata element.
258266077Sdes * @param rd: rdata buffer for the wireformat.
259266077Sdes * @param len: length of rd buffer on input, used length on output.
260266077Sdes * @param rdftype: the type of the rdf.
261266077Sdes * @return 0 on success, error on failure.
262266077Sdes */
263266077Sdesint sldns_str2wire_rdf_buf(const char* str, uint8_t* rd, size_t* len,
264266077Sdes	sldns_rdf_type rdftype);
265266077Sdes
266266077Sdes/**
267266077Sdes * Convert rdf of type LDNS_RDF_TYPE_INT8 from string to wireformat.
268266077Sdes * @param str: the text to convert for this rdata element.
269266077Sdes * @param rd: rdata buffer for the wireformat.
270266077Sdes * @param len: length of rd buffer on input, used length on output.
271266077Sdes * @return 0 on success, error on failure.
272266077Sdes */
273266077Sdesint sldns_str2wire_int8_buf(const char* str, uint8_t* rd, size_t* len);
274266077Sdes
275266077Sdes/**
276266077Sdes * Convert rdf of type LDNS_RDF_TYPE_INT16 from string to wireformat.
277266077Sdes * @param str: the text to convert for this rdata element.
278266077Sdes * @param rd: rdata buffer for the wireformat.
279266077Sdes * @param len: length of rd buffer on input, used length on output.
280266077Sdes * @return 0 on success, error on failure.
281266077Sdes */
282266077Sdesint sldns_str2wire_int16_buf(const char* str, uint8_t* rd, size_t* len);
283266077Sdes
284266077Sdes/**
285266077Sdes * Convert rdf of type LDNS_RDF_TYPE_INT32 from string to wireformat.
286266077Sdes * @param str: the text to convert for this rdata element.
287266077Sdes * @param rd: rdata buffer for the wireformat.
288266077Sdes * @param len: length of rd buffer on input, used length on output.
289266077Sdes * @return 0 on success, error on failure.
290266077Sdes */
291266077Sdesint sldns_str2wire_int32_buf(const char* str, uint8_t* rd, size_t* len);
292266077Sdes
293266077Sdes/**
294266077Sdes * Convert rdf of type LDNS_RDF_TYPE_A from string to wireformat.
295266077Sdes * @param str: the text to convert for this rdata element.
296266077Sdes * @param rd: rdata buffer for the wireformat.
297266077Sdes * @param len: length of rd buffer on input, used length on output.
298266077Sdes * @return 0 on success, error on failure.
299266077Sdes */
300266077Sdesint sldns_str2wire_a_buf(const char* str, uint8_t* rd, size_t* len);
301266077Sdes
302266077Sdes/**
303266077Sdes * Convert rdf of type LDNS_RDF_TYPE_AAAA from string to wireformat.
304266077Sdes * @param str: the text to convert for this rdata element.
305266077Sdes * @param rd: rdata buffer for the wireformat.
306266077Sdes * @param len: length of rd buffer on input, used length on output.
307266077Sdes * @return 0 on success, error on failure.
308266077Sdes */
309266077Sdesint sldns_str2wire_aaaa_buf(const char* str, uint8_t* rd, size_t* len);
310266077Sdes
311266077Sdes/**
312266077Sdes * Convert rdf of type LDNS_RDF_TYPE_STR from string to wireformat.
313266077Sdes * @param str: the text to convert for this rdata element.
314266077Sdes * @param rd: rdata buffer for the wireformat.
315266077Sdes * @param len: length of rd buffer on input, used length on output.
316266077Sdes * @return 0 on success, error on failure.
317266077Sdes */
318266077Sdesint sldns_str2wire_str_buf(const char* str, uint8_t* rd, size_t* len);
319266077Sdes
320266077Sdes/**
321266077Sdes * Convert rdf of type LDNS_RDF_TYPE_APL from string to wireformat.
322266077Sdes * @param str: the text to convert for this rdata element.
323266077Sdes * @param rd: rdata buffer for the wireformat.
324266077Sdes * @param len: length of rd buffer on input, used length on output.
325266077Sdes * @return 0 on success, error on failure.
326266077Sdes */
327266077Sdesint sldns_str2wire_apl_buf(const char* str, uint8_t* rd, size_t* len);
328266077Sdes
329266077Sdes/**
330266077Sdes * Convert rdf of type LDNS_RDF_TYPE_B64 from string to wireformat.
331266077Sdes * @param str: the text to convert for this rdata element.
332266077Sdes * @param rd: rdata buffer for the wireformat.
333266077Sdes * @param len: length of rd buffer on input, used length on output.
334266077Sdes * @return 0 on success, error on failure.
335266077Sdes */
336266077Sdesint sldns_str2wire_b64_buf(const char* str, uint8_t* rd, size_t* len);
337266077Sdes
338266077Sdes/**
339266077Sdes * Convert rdf of type LDNS_RDF_TYPE_B32_EXT from string to wireformat.
340266077Sdes * And also LDNS_RDF_TYPE_NSEC3_NEXT_OWNER.
341266077Sdes * @param str: the text to convert for this rdata element.
342266077Sdes * @param rd: rdata buffer for the wireformat.
343266077Sdes * @param len: length of rd buffer on input, used length on output.
344266077Sdes * @return 0 on success, error on failure.
345266077Sdes */
346266077Sdesint sldns_str2wire_b32_ext_buf(const char* str, uint8_t* rd, size_t* len);
347266077Sdes
348266077Sdes/**
349266077Sdes * Convert rdf of type LDNS_RDF_TYPE_HEX from string to wireformat.
350266077Sdes * @param str: the text to convert for this rdata element.
351266077Sdes * @param rd: rdata buffer for the wireformat.
352266077Sdes * @param len: length of rd buffer on input, used length on output.
353266077Sdes * @return 0 on success, error on failure.
354266077Sdes */
355266077Sdesint sldns_str2wire_hex_buf(const char* str, uint8_t* rd, size_t* len);
356266077Sdes
357266077Sdes/**
358266077Sdes * Convert rdf of type LDNS_RDF_TYPE_NSEC from string to wireformat.
359266077Sdes * @param str: the text to convert for this rdata element.
360266077Sdes * @param rd: rdata buffer for the wireformat.
361266077Sdes * @param len: length of rd buffer on input, used length on output.
362266077Sdes * @return 0 on success, error on failure.
363266077Sdes */
364266077Sdesint sldns_str2wire_nsec_buf(const char* str, uint8_t* rd, size_t* len);
365266077Sdes
366266077Sdes/**
367266077Sdes * Convert rdf of type LDNS_RDF_TYPE_TYPE from string to wireformat.
368266077Sdes * @param str: the text to convert for this rdata element.
369266077Sdes * @param rd: rdata buffer for the wireformat.
370266077Sdes * @param len: length of rd buffer on input, used length on output.
371266077Sdes * @return 0 on success, error on failure.
372266077Sdes */
373266077Sdesint sldns_str2wire_type_buf(const char* str, uint8_t* rd, size_t* len);
374266077Sdes
375266077Sdes/**
376266077Sdes * Convert rdf of type LDNS_RDF_TYPE_CLASS from string to wireformat.
377266077Sdes * @param str: the text to convert for this rdata element.
378266077Sdes * @param rd: rdata buffer for the wireformat.
379266077Sdes * @param len: length of rd buffer on input, used length on output.
380266077Sdes * @return 0 on success, error on failure.
381266077Sdes */
382266077Sdesint sldns_str2wire_class_buf(const char* str, uint8_t* rd, size_t* len);
383266077Sdes
384266077Sdes/**
385266077Sdes * Convert rdf of type LDNS_RDF_TYPE_CERT_ALG from string to wireformat.
386266077Sdes * @param str: the text to convert for this rdata element.
387266077Sdes * @param rd: rdata buffer for the wireformat.
388266077Sdes * @param len: length of rd buffer on input, used length on output.
389266077Sdes * @return 0 on success, error on failure.
390266077Sdes */
391266077Sdesint sldns_str2wire_cert_alg_buf(const char* str, uint8_t* rd, size_t* len);
392266077Sdes
393266077Sdes/**
394266077Sdes * Convert rdf of type LDNS_RDF_TYPE_ALG from string to wireformat.
395266077Sdes * @param str: the text to convert for this rdata element.
396266077Sdes * @param rd: rdata buffer for the wireformat.
397266077Sdes * @param len: length of rd buffer on input, used length on output.
398266077Sdes * @return 0 on success, error on failure.
399266077Sdes */
400266077Sdesint sldns_str2wire_alg_buf(const char* str, uint8_t* rd, size_t* len);
401266077Sdes
402266077Sdes/**
403266077Sdes * Convert rdf of type LDNS_RDF_TYPE_TIME from string to wireformat.
404266077Sdes * @param str: the text to convert for this rdata element.
405266077Sdes * @param rd: rdata buffer for the wireformat.
406266077Sdes * @param len: length of rd buffer on input, used length on output.
407266077Sdes * @return 0 on success, error on failure.
408266077Sdes */
409266077Sdesint sldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len);
410266077Sdes
411266077Sdes/**
412266077Sdes * Convert rdf of type LDNS_RDF_TYPE_PERIOD from string to wireformat.
413266077Sdes * @param str: the text to convert for this rdata element.
414266077Sdes * @param rd: rdata buffer for the wireformat.
415266077Sdes * @param len: length of rd buffer on input, used length on output.
416266077Sdes * @return 0 on success, error on failure.
417266077Sdes */
418266077Sdesint sldns_str2wire_period_buf(const char* str, uint8_t* rd, size_t* len);
419266077Sdes
420266077Sdes/**
421266077Sdes * Convert rdf of type LDNS_RDF_TYPE_LOC from string to wireformat.
422266077Sdes * @param str: the text to convert for this rdata element.
423266077Sdes * @param rd: rdata buffer for the wireformat.
424266077Sdes * @param len: length of rd buffer on input, used length on output.
425266077Sdes * @return 0 on success, error on failure.
426266077Sdes */
427266077Sdesint sldns_str2wire_loc_buf(const char* str, uint8_t* rd, size_t* len);
428266077Sdes
429266077Sdes/**
430266077Sdes * Convert rdf of type LDNS_RDF_TYPE_WKS from string to wireformat.
431266077Sdes * @param str: the text to convert for this rdata element.
432266077Sdes * @param rd: rdata buffer for the wireformat.
433266077Sdes * @param len: length of rd buffer on input, used length on output.
434266077Sdes * @return 0 on success, error on failure.
435266077Sdes */
436266077Sdesint sldns_str2wire_wks_buf(const char* str, uint8_t* rd, size_t* len);
437266077Sdes
438266077Sdes/**
439266077Sdes * Convert rdf of type LDNS_RDF_TYPE_NSAP from string to wireformat.
440266077Sdes * @param str: the text to convert for this rdata element.
441266077Sdes * @param rd: rdata buffer for the wireformat.
442266077Sdes * @param len: length of rd buffer on input, used length on output.
443266077Sdes * @return 0 on success, error on failure.
444266077Sdes */
445266077Sdesint sldns_str2wire_nsap_buf(const char* str, uint8_t* rd, size_t* len);
446266077Sdes
447266077Sdes/**
448266077Sdes * Convert rdf of type LDNS_RDF_TYPE_ATMA from string to wireformat.
449266077Sdes * @param str: the text to convert for this rdata element.
450266077Sdes * @param rd: rdata buffer for the wireformat.
451266077Sdes * @param len: length of rd buffer on input, used length on output.
452266077Sdes * @return 0 on success, error on failure.
453266077Sdes */
454266077Sdesint sldns_str2wire_atma_buf(const char* str, uint8_t* rd, size_t* len);
455266077Sdes
456266077Sdes/**
457266077Sdes * Convert rdf of type LDNS_RDF_TYPE_IPSECKEY from string to wireformat.
458266077Sdes * @param str: the text to convert for this rdata element.
459266077Sdes * @param rd: rdata buffer for the wireformat.
460266077Sdes * @param len: length of rd buffer on input, used length on output.
461266077Sdes * @return 0 on success, error on failure.
462266077Sdes */
463266077Sdesint sldns_str2wire_ipseckey_buf(const char* str, uint8_t* rd, size_t* len);
464266077Sdes
465266077Sdes/**
466266077Sdes * Convert rdf of type LDNS_RDF_TYPE_NSEC3_SALT from string to wireformat.
467266077Sdes * @param str: the text to convert for this rdata element.
468266077Sdes * @param rd: rdata buffer for the wireformat.
469266077Sdes * @param len: length of rd buffer on input, used length on output.
470266077Sdes * @return 0 on success, error on failure.
471266077Sdes */
472266077Sdesint sldns_str2wire_nsec3_salt_buf(const char* str, uint8_t* rd, size_t* len);
473266077Sdes
474266077Sdes/**
475266077Sdes * Convert rdf of type LDNS_RDF_TYPE_ILNP64 from string to wireformat.
476266077Sdes * @param str: the text to convert for this rdata element.
477266077Sdes * @param rd: rdata buffer for the wireformat.
478266077Sdes * @param len: length of rd buffer on input, used length on output.
479266077Sdes * @return 0 on success, error on failure.
480266077Sdes */
481266077Sdesint sldns_str2wire_ilnp64_buf(const char* str, uint8_t* rd, size_t* len);
482266077Sdes
483266077Sdes/**
484266077Sdes * Convert rdf of type LDNS_RDF_TYPE_EUI48 from string to wireformat.
485266077Sdes * @param str: the text to convert for this rdata element.
486266077Sdes * @param rd: rdata buffer for the wireformat.
487266077Sdes * @param len: length of rd buffer on input, used length on output.
488266077Sdes * @return 0 on success, error on failure.
489266077Sdes */
490266077Sdesint sldns_str2wire_eui48_buf(const char* str, uint8_t* rd, size_t* len);
491266077Sdes
492266077Sdes/**
493266077Sdes * Convert rdf of type LDNS_RDF_TYPE_EUI64 from string to wireformat.
494266077Sdes * @param str: the text to convert for this rdata element.
495266077Sdes * @param rd: rdata buffer for the wireformat.
496266077Sdes * @param len: length of rd buffer on input, used length on output.
497266077Sdes * @return 0 on success, error on failure.
498266077Sdes */
499266077Sdesint sldns_str2wire_eui64_buf(const char* str, uint8_t* rd, size_t* len);
500266077Sdes
501266077Sdes/**
502266077Sdes * Convert rdf of type LDNS_RDF_TYPE_TAG from string to wireformat.
503266077Sdes * @param str: the text to convert for this rdata element.
504266077Sdes * @param rd: rdata buffer for the wireformat.
505266077Sdes * @param len: length of rd buffer on input, used length on output.
506266077Sdes * @return 0 on success, error on failure.
507266077Sdes */
508266077Sdesint sldns_str2wire_tag_buf(const char* str, uint8_t* rd, size_t* len);
509266077Sdes
510266077Sdes/**
511266077Sdes * Convert rdf of type LDNS_RDF_TYPE_LONG_STR from string to wireformat.
512266077Sdes * @param str: the text to convert for this rdata element.
513266077Sdes * @param rd: rdata buffer for the wireformat.
514266077Sdes * @param len: length of rd buffer on input, used length on output.
515266077Sdes * @return 0 on success, error on failure.
516266077Sdes */
517266077Sdesint sldns_str2wire_long_str_buf(const char* str, uint8_t* rd, size_t* len);
518266077Sdes
519266077Sdes/**
520266077Sdes * Convert rdf of type LDNS_RDF_TYPE_HIP from string to wireformat.
521266077Sdes * @param str: the text to convert for this rdata element.
522266077Sdes * @param rd: rdata buffer for the wireformat.
523266077Sdes * @param len: length of rd buffer on input, used length on output.
524266077Sdes * @return 0 on success, error on failure.
525266077Sdes */
526266077Sdesint sldns_str2wire_hip_buf(const char* str, uint8_t* rd, size_t* len);
527266077Sdes
528266077Sdes/**
529266077Sdes * Convert rdf of type LDNS_RDF_TYPE_INT16_DATA from string to wireformat.
530266077Sdes * @param str: the text to convert for this rdata element.
531266077Sdes * @param rd: rdata buffer for the wireformat.
532266077Sdes * @param len: length of rd buffer on input, used length on output.
533266077Sdes * @return 0 on success, error on failure.
534266077Sdes */
535266077Sdesint sldns_str2wire_int16_data_buf(const char* str, uint8_t* rd, size_t* len);
536266077Sdes
537266077Sdes#ifdef __cplusplus
538266077Sdes}
539266077Sdes#endif
540266077Sdes
541266077Sdes#endif /* LDNS_STR2WIRE_H */
542