1 /** 2 * str2wire.h - read txt presentation of RRs 3 * 4 * (c) NLnet Labs, 2005-2006 5 * 6 * See the file LICENSE for the license 7 */ 8 9 /** 10 * \file 11 * 12 * Parses text to wireformat. 13 */ 14 15 #ifndef LDNS_STR2WIRE_H 16 #define LDNS_STR2WIRE_H 17 18 /* include rrdef for MAX_DOMAINLEN constant */ 19 #include <sldns/rrdef.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 struct sldns_struct_lookup_table; 25 26 #define LDNS_IP4ADDRLEN (32/8) 27 #define LDNS_IP6ADDRLEN (128/8) 28 29 /** buffer to read an RR, cannot be larger than 64K because of packet size */ 30 #define LDNS_RR_BUF_SIZE 65535 /* bytes */ 31 #define LDNS_DEFAULT_TTL 3600 32 33 /* SVCB keys currently defined in draft-ietf-dnsop-svcb-https */ 34 #define SVCB_KEY_MANDATORY 0 35 #define SVCB_KEY_ALPN 1 36 #define SVCB_KEY_NO_DEFAULT_ALPN 2 37 #define SVCB_KEY_PORT 3 38 #define SVCB_KEY_IPV4HINT 4 39 #define SVCB_KEY_ECH 5 40 #define SVCB_KEY_IPV6HINT 6 41 #define SVCPARAMKEY_COUNT 7 42 43 #define MAX_NUMBER_OF_SVCPARAMS 64 44 45 #define SVCB_MAX_COMMA_SEPARATED_VALUES 1000 46 47 /* 48 * To convert class and type to string see 49 * sldns_get_rr_class_by_name(str) 50 * sldns_get_rr_type_by_name(str) 51 * from rrdef.h 52 */ 53 54 /** 55 * Convert text string into dname wireformat, mallocless, with user buffer. 56 * @param str: the text string with the domain name. 57 * @param buf: the result buffer, suggested size LDNS_MAX_DOMAINLEN+1 58 * @param len: length of the buffer on input, length of the result on output. 59 * @return 0 on success, otherwise an error. 60 */ 61 int sldns_str2wire_dname_buf(const char* str, uint8_t* buf, size_t* len); 62 63 /** 64 * Same as sldns_str2wire_dname_buf, but concatenates origin if the domain 65 * name is relative (does not end in '.'). 66 * @param str: the text string with the domain name. 67 * @param buf: the result buffer, suggested size LDNS_MAX_DOMAINLEN+1 68 * @param len: length of the buffer on input, length of the result on output. 69 * @param origin: the origin to append or NULL (nothing is appended). 70 * @param origin_len: length of origin. 71 * @return 0 on success, otherwise an error. 72 */ 73 int sldns_str2wire_dname_buf_origin(const char* str, uint8_t* buf, size_t* len, 74 uint8_t* origin, size_t origin_len); 75 76 /** 77 * Convert text string into dname wireformat 78 * @param str: the text string with the domain name. 79 * @param len: returned length of wireformat. 80 * @return wireformat dname (malloced) or NULL on failure. 81 */ 82 uint8_t* sldns_str2wire_dname(const char* str, size_t* len); 83 84 /** 85 * Convert text RR to wireformat, with user buffer. 86 * @param str: the RR data in text presentation format. 87 * @param rr: the buffer where the result is stored into. This buffer has 88 * the wire-dname(uncompressed), type, class, ttl, rdatalen, rdata. 89 * These values are probably not aligned, and in network format. 90 * Use the sldns_wirerr_get_xxx functions to access them safely. 91 * buffer size LDNS_RR_BUF_SIZE is suggested. 92 * @param len: on input the length of the buffer, on output the amount of 93 * the buffer used for the rr. 94 * @param dname_len: if non-NULL, filled with the dname length as result. 95 * Because after the dname you find the type, class, ttl, rdatalen, rdata. 96 * @param default_ttl: TTL used if no TTL available. 97 * @param origin: used for origin dname (if not NULL) 98 * @param origin_len: length of origin. 99 * @param prev: used for prev_rr dname (if not NULL) 100 * @param prev_len: length of prev. 101 * @return 0 on success, an error on failure. 102 */ 103 int sldns_str2wire_rr_buf(const char* str, uint8_t* rr, size_t* len, 104 size_t* dname_len, uint32_t default_ttl, uint8_t* origin, 105 size_t origin_len, uint8_t* prev, size_t prev_len); 106 107 /** 108 * Same as sldns_str2wire_rr_buf, but there is no rdata, it returns an RR 109 * with zero rdata and no ttl. It has name, type, class. 110 * You can access those with the sldns_wirerr_get_type and class functions. 111 * @param str: the RR data in text presentation format. 112 * @param rr: the buffer where the result is stored into. 113 * @param len: on input the length of the buffer, on output the amount of 114 * the buffer used for the rr. 115 * @param dname_len: if non-NULL, filled with the dname length as result. 116 * Because after the dname you find the type, class, ttl, rdatalen, rdata. 117 * @param origin: used for origin dname (if not NULL) 118 * @param origin_len: length of origin. 119 * @param prev: used for prev_rr dname (if not NULL) 120 * @param prev_len: length of prev. 121 * @return 0 on success, an error on failure. 122 */ 123 int sldns_str2wire_rr_question_buf(const char* str, uint8_t* rr, size_t* len, 124 size_t* dname_len, uint8_t* origin, size_t origin_len, uint8_t* prev, 125 size_t prev_len); 126 127 /** 128 * Get the type of the RR. 129 * @param rr: the RR in wire format. 130 * @param len: rr length. 131 * @param dname_len: dname length to skip. 132 * @return type in host byteorder 133 */ 134 uint16_t sldns_wirerr_get_type(uint8_t* rr, size_t len, size_t dname_len); 135 136 /** 137 * Get the class of the RR. 138 * @param rr: the RR in wire format. 139 * @param len: rr length. 140 * @param dname_len: dname length to skip. 141 * @return class in host byteorder 142 */ 143 uint16_t sldns_wirerr_get_class(uint8_t* rr, size_t len, size_t dname_len); 144 145 /** 146 * Get the ttl of the RR. 147 * @param rr: the RR in wire format. 148 * @param len: rr length. 149 * @param dname_len: dname length to skip. 150 * @return ttl in host byteorder 151 */ 152 uint32_t sldns_wirerr_get_ttl(uint8_t* rr, size_t len, size_t dname_len); 153 154 /** 155 * Get the rdata length of the RR. 156 * @param rr: the RR in wire format. 157 * @param len: rr length. 158 * @param dname_len: dname length to skip. 159 * @return rdata length in host byteorder 160 * If the rdata length is larger than the rr-len allows, it is truncated. 161 * So, that it is safe to read the data length returned 162 * from this function from the rdata pointer of sldns_wirerr_get_rdata. 163 */ 164 uint16_t sldns_wirerr_get_rdatalen(uint8_t* rr, size_t len, size_t dname_len); 165 166 /** 167 * Get the rdata pointer of the RR. 168 * @param rr: the RR in wire format. 169 * @param len: rr length. 170 * @param dname_len: dname length to skip. 171 * @return rdata pointer 172 */ 173 uint8_t* sldns_wirerr_get_rdata(uint8_t* rr, size_t len, size_t dname_len); 174 175 /** 176 * Get the rdata pointer of the RR. prefixed with rdata length. 177 * @param rr: the RR in wire format. 178 * @param len: rr length. 179 * @param dname_len: dname length to skip. 180 * @return pointer to rdatalength, followed by the rdata. 181 */ 182 uint8_t* sldns_wirerr_get_rdatawl(uint8_t* rr, size_t len, size_t dname_len); 183 184 /** 185 * Parse result codes 186 */ 187 #define LDNS_WIREPARSE_MASK 0x0fff 188 #define LDNS_WIREPARSE_SHIFT 12 189 #define LDNS_WIREPARSE_ERROR(e) ((e)&LDNS_WIREPARSE_MASK) 190 #define LDNS_WIREPARSE_OFFSET(e) (((e)&~LDNS_WIREPARSE_MASK)>>LDNS_WIREPARSE_SHIFT) 191 /* use lookuptable to get error string, sldns_wireparse_errors */ 192 #define LDNS_WIREPARSE_ERR_OK 0 193 #define LDNS_WIREPARSE_ERR_GENERAL 342 194 #define LDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW 343 195 #define LDNS_WIREPARSE_ERR_DOMAINNAME_UNDERFLOW 344 196 #define LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL 345 197 #define LDNS_WIREPARSE_ERR_LABEL_OVERFLOW 346 198 #define LDNS_WIREPARSE_ERR_EMPTY_LABEL 347 199 #define LDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE 348 200 #define LDNS_WIREPARSE_ERR_SYNTAX 349 201 #define LDNS_WIREPARSE_ERR_SYNTAX_TTL 350 202 #define LDNS_WIREPARSE_ERR_SYNTAX_TYPE 351 203 #define LDNS_WIREPARSE_ERR_SYNTAX_CLASS 352 204 #define LDNS_WIREPARSE_ERR_SYNTAX_RDATA 353 205 #define LDNS_WIREPARSE_ERR_SYNTAX_MISSING_VALUE 354 206 #define LDNS_WIREPARSE_ERR_INVALID_STR 355 207 #define LDNS_WIREPARSE_ERR_SYNTAX_B64 356 208 #define LDNS_WIREPARSE_ERR_SYNTAX_B32_EXT 357 209 #define LDNS_WIREPARSE_ERR_SYNTAX_HEX 358 210 #define LDNS_WIREPARSE_ERR_CERT_BAD_ALGORITHM 359 211 #define LDNS_WIREPARSE_ERR_SYNTAX_TIME 360 212 #define LDNS_WIREPARSE_ERR_SYNTAX_PERIOD 361 213 #define LDNS_WIREPARSE_ERR_SYNTAX_ILNP64 362 214 #define LDNS_WIREPARSE_ERR_SYNTAX_EUI48 363 215 #define LDNS_WIREPARSE_ERR_SYNTAX_EUI64 364 216 #define LDNS_WIREPARSE_ERR_SYNTAX_TAG 365 217 #define LDNS_WIREPARSE_ERR_NOT_IMPL 366 218 #define LDNS_WIREPARSE_ERR_SYNTAX_INT 367 219 #define LDNS_WIREPARSE_ERR_SYNTAX_IP4 368 220 #define LDNS_WIREPARSE_ERR_SYNTAX_IP6 369 221 #define LDNS_WIREPARSE_ERR_SYNTAX_INTEGER_OVERFLOW 370 222 #define LDNS_WIREPARSE_ERR_INCLUDE 371 223 #define LDNS_WIREPARSE_ERR_PARENTHESIS 372 224 #define LDNS_WIREPARSE_ERR_SVCB_UNKNOWN_KEY 373 225 #define LDNS_WIREPARSE_ERR_SVCB_MISSING_PARAM 374 226 #define LDNS_WIREPARSE_ERR_SVCB_TOO_MANY_PARAMS 375 227 #define LDNS_WIREPARSE_ERR_SVCB_DUPLICATE_KEYS 376 228 #define LDNS_WIREPARSE_ERR_SVCB_MANDATORY_TOO_MANY_KEYS 377 229 #define LDNS_WIREPARSE_ERR_SVCB_MANDATORY_MISSING_PARAM 378 230 #define LDNS_WIREPARSE_ERR_SVCB_MANDATORY_DUPLICATE_KEY 379 231 #define LDNS_WIREPARSE_ERR_SVCB_MANDATORY_IN_MANDATORY 380 232 #define LDNS_WIREPARSE_ERR_SVCB_PORT_VALUE_SYNTAX 381 233 #define LDNS_WIREPARSE_ERR_SVCB_IPV4_TOO_MANY_ADDRESSES 382 234 #define LDNS_WIREPARSE_ERR_SVCB_IPV6_TOO_MANY_ADDRESSES 383 235 #define LDNS_WIREPARSE_ERR_SVCB_ALPN_KEY_TOO_LARGE 384 236 #define LDNS_WIREPARSE_ERR_SVCB_NO_DEFAULT_ALPN_VALUE 385 237 #define LDNS_WIREPARSE_ERR_SVCPARAM_BROKEN_RDATA 386 238 239 /** 240 * Get reference to a constant string for the (parse) error. 241 * @param e: error return value 242 * @return string. 243 */ 244 const char* sldns_get_errorstr_parse(int e); 245 246 /** 247 * wire parse state for parsing files 248 */ 249 struct sldns_file_parse_state { 250 /** the origin domain name, if len!=0. uncompressed wireformat */ 251 uint8_t origin[LDNS_MAX_DOMAINLEN+1]; 252 /** length of origin domain name, in bytes. 0 if not set. */ 253 size_t origin_len; 254 /** the previous domain name, if len!=0. uncompressed wireformat*/ 255 uint8_t prev_rr[LDNS_MAX_DOMAINLEN+1]; 256 /** length of the previous domain name, in bytes. 0 if not set. */ 257 size_t prev_rr_len; 258 /** default TTL, this is used if the text does not specify a TTL, 259 * host byteorder */ 260 uint32_t default_ttl; 261 /** line number information */ 262 int lineno; 263 }; 264 265 /** 266 * Read one RR from zonefile with buffer for the data. 267 * @param in: file that is read from (one RR, multiple lines if it spans them). 268 * @param rr: this is malloced by the user and the result is stored here, 269 * if an RR is read. If no RR is read this is signalled with the 270 * return len set to 0 (for ORIGIN, TTL directives). 271 * The read line is available in the rr_buf (zero terminated), for 272 * $DIRECTIVE style elements. 273 * @param len: on input, the length of the rr buffer. on output the rr len. 274 * Buffer size of 64k should be enough. 275 * @param dname_len: returns the length of the dname initial part of the rr. 276 * @param parse_state: pass a pointer to user-allocated struct. 277 * Contents are maintained by this function. 278 * If you pass NULL then ORIGIN and TTL directives are not honored. 279 * You can start out with a particular origin by pre-filling it. 280 * otherwise, zero the structure before passing it. 281 * lineno is incremented when a newline is passed by the parser, 282 * you should initialize it at 1 at the start of the file. 283 * @return 0 on success, error on failure. 284 */ 285 int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len, 286 struct sldns_file_parse_state* parse_state); 287 288 /** 289 * Convert one rdf in rdata to wireformat and parse from string. 290 * @param str: the text to convert for this rdata element. 291 * @param rd: rdata buffer for the wireformat. 292 * @param len: length of rd buffer on input, used length on output. 293 * @param rdftype: the type of the rdf. 294 * @return 0 on success, error on failure. 295 */ 296 int sldns_str2wire_rdf_buf(const char* str, uint8_t* rd, size_t* len, 297 sldns_rdf_type rdftype); 298 299 /** 300 * Convert rdf of type LDNS_RDF_TYPE_INT8 from string to wireformat. 301 * @param str: the text to convert for this rdata element. 302 * @param rd: rdata buffer for the wireformat. 303 * @param len: length of rd buffer on input, used length on output. 304 * @return 0 on success, error on failure. 305 */ 306 int sldns_str2wire_int8_buf(const char* str, uint8_t* rd, size_t* len); 307 308 /** 309 * Convert rdf of type LDNS_RDF_TYPE_INT16 from string to wireformat. 310 * @param str: the text to convert for this rdata element. 311 * @param rd: rdata buffer for the wireformat. 312 * @param len: length of rd buffer on input, used length on output. 313 * @return 0 on success, error on failure. 314 */ 315 int sldns_str2wire_int16_buf(const char* str, uint8_t* rd, size_t* len); 316 317 /** 318 * Convert rdf of type LDNS_RDF_TYPE_INT32 from string to wireformat. 319 * @param str: the text to convert for this rdata element. 320 * @param rd: rdata buffer for the wireformat. 321 * @param len: length of rd buffer on input, used length on output. 322 * @return 0 on success, error on failure. 323 */ 324 int sldns_str2wire_int32_buf(const char* str, uint8_t* rd, size_t* len); 325 326 /** 327 * Convert rdf of type LDNS_RDF_TYPE_A from string to wireformat. 328 * @param str: the text to convert for this rdata element. 329 * @param rd: rdata buffer for the wireformat. 330 * @param len: length of rd buffer on input, used length on output. 331 * @return 0 on success, error on failure. 332 */ 333 int sldns_str2wire_a_buf(const char* str, uint8_t* rd, size_t* len); 334 335 /** 336 * Convert rdf of type LDNS_RDF_TYPE_AAAA from string to wireformat. 337 * @param str: the text to convert for this rdata element. 338 * @param rd: rdata buffer for the wireformat. 339 * @param len: length of rd buffer on input, used length on output. 340 * @return 0 on success, error on failure. 341 */ 342 int sldns_str2wire_aaaa_buf(const char* str, uint8_t* rd, size_t* len); 343 344 /** 345 * Convert rdf of type LDNS_RDF_TYPE_STR from string to wireformat. 346 * @param str: the text to convert for this rdata element. 347 * @param rd: rdata buffer for the wireformat. 348 * @param len: length of rd buffer on input, used length on output. 349 * @return 0 on success, error on failure. 350 */ 351 int sldns_str2wire_str_buf(const char* str, uint8_t* rd, size_t* len); 352 353 /** 354 * Convert rdf of type LDNS_RDF_TYPE_APL from string to wireformat. 355 * @param str: the text to convert for this rdata element. 356 * @param rd: rdata buffer for the wireformat. 357 * @param len: length of rd buffer on input, used length on output. 358 * @return 0 on success, error on failure. 359 */ 360 int sldns_str2wire_apl_buf(const char* str, uint8_t* rd, size_t* len); 361 362 /** 363 * Convert rdf of type LDNS_RDF_TYPE_B64 from string to wireformat. 364 * @param str: the text to convert for this rdata element. 365 * @param rd: rdata buffer for the wireformat. 366 * @param len: length of rd buffer on input, used length on output. 367 * @return 0 on success, error on failure. 368 */ 369 int sldns_str2wire_b64_buf(const char* str, uint8_t* rd, size_t* len); 370 371 /** 372 * Convert rdf of type LDNS_RDF_TYPE_B32_EXT from string to wireformat. 373 * And also LDNS_RDF_TYPE_NSEC3_NEXT_OWNER. 374 * @param str: the text to convert for this rdata element. 375 * @param rd: rdata buffer for the wireformat. 376 * @param len: length of rd buffer on input, used length on output. 377 * @return 0 on success, error on failure. 378 */ 379 int sldns_str2wire_b32_ext_buf(const char* str, uint8_t* rd, size_t* len); 380 381 /** 382 * Convert rdf of type LDNS_RDF_TYPE_HEX from string to wireformat. 383 * @param str: the text to convert for this rdata element. 384 * @param rd: rdata buffer for the wireformat. 385 * @param len: length of rd buffer on input, used length on output. 386 * @return 0 on success, error on failure. 387 */ 388 int sldns_str2wire_hex_buf(const char* str, uint8_t* rd, size_t* len); 389 390 /** 391 * Convert rdf of type LDNS_RDF_TYPE_NSEC from string to wireformat. 392 * @param str: the text to convert for this rdata element. 393 * @param rd: rdata buffer for the wireformat. 394 * @param len: length of rd buffer on input, used length on output. 395 * @return 0 on success, error on failure. 396 */ 397 int sldns_str2wire_nsec_buf(const char* str, uint8_t* rd, size_t* len); 398 399 /** 400 * Convert rdf of type LDNS_RDF_TYPE_TYPE from string to wireformat. 401 * @param str: the text to convert for this rdata element. 402 * @param rd: rdata buffer for the wireformat. 403 * @param len: length of rd buffer on input, used length on output. 404 * @return 0 on success, error on failure. 405 */ 406 int sldns_str2wire_type_buf(const char* str, uint8_t* rd, size_t* len); 407 408 /** 409 * Convert rdf of type LDNS_RDF_TYPE_CLASS from string to wireformat. 410 * @param str: the text to convert for this rdata element. 411 * @param rd: rdata buffer for the wireformat. 412 * @param len: length of rd buffer on input, used length on output. 413 * @return 0 on success, error on failure. 414 */ 415 int sldns_str2wire_class_buf(const char* str, uint8_t* rd, size_t* len); 416 417 /** 418 * Convert rdf of type LDNS_RDF_TYPE_CERT_ALG from string to wireformat. 419 * @param str: the text to convert for this rdata element. 420 * @param rd: rdata buffer for the wireformat. 421 * @param len: length of rd buffer on input, used length on output. 422 * @return 0 on success, error on failure. 423 */ 424 int sldns_str2wire_cert_alg_buf(const char* str, uint8_t* rd, size_t* len); 425 426 /** 427 * Convert rdf of type LDNS_RDF_TYPE_ALG from string to wireformat. 428 * @param str: the text to convert for this rdata element. 429 * @param rd: rdata buffer for the wireformat. 430 * @param len: length of rd buffer on input, used length on output. 431 * @return 0 on success, error on failure. 432 */ 433 int sldns_str2wire_alg_buf(const char* str, uint8_t* rd, size_t* len); 434 435 /** 436 * Convert rdf of type LDNS_RDF_TYPE_TIME from string to wireformat. 437 * @param str: the text to convert for this rdata element. 438 * @param rd: rdata buffer for the wireformat. 439 * @param len: length of rd buffer on input, used length on output. 440 * @return 0 on success, error on failure. 441 */ 442 int sldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len); 443 444 /** 445 * Convert rdf of type LDNS_RDF_TYPE_PERIOD from string to wireformat. 446 * @param str: the text to convert for this rdata element. 447 * @param rd: rdata buffer for the wireformat. 448 * @param len: length of rd buffer on input, used length on output. 449 * @return 0 on success, error on failure. 450 */ 451 int sldns_str2wire_period_buf(const char* str, uint8_t* rd, size_t* len); 452 453 /** 454 * Convert rdf of type LDNS_RDF_TYPE_TSIGTIME from string to wireformat. 455 * @param str: the text to convert for this rdata element. 456 * @param rd: rdata buffer for the wireformat. 457 * @param len: length of rd buffer on input, used length on output. 458 * @return 0 on success, error on failure. 459 */ 460 int sldns_str2wire_tsigtime_buf(const char* str, uint8_t* rd, size_t* len); 461 462 /** 463 * Convert rdf of type LDNS_RDF_TYPE_TSIGERROR from string to wireformat. 464 * @param str: the text to convert for this rdata element. 465 * @param rd: rdata buffer for the wireformat. 466 * @param len: length of rd buffer on input, used length on output. 467 * @return 0 on success, error on failure. 468 */ 469 int sldns_str2wire_tsigerror_buf(const char* str, uint8_t* rd, size_t* len); 470 471 /** 472 * Convert rdf of type LDNS_RDF_TYPE_LOC from string to wireformat. 473 * @param str: the text to convert for this rdata element. 474 * @param rd: rdata buffer for the wireformat. 475 * @param len: length of rd buffer on input, used length on output. 476 * @return 0 on success, error on failure. 477 */ 478 int sldns_str2wire_loc_buf(const char* str, uint8_t* rd, size_t* len); 479 480 /** 481 * Convert rdf of type LDNS_RDF_TYPE_WKS from string to wireformat. 482 * @param str: the text to convert for this rdata element. 483 * @param rd: rdata buffer for the wireformat. 484 * @param len: length of rd buffer on input, used length on output. 485 * @return 0 on success, error on failure. 486 */ 487 int sldns_str2wire_wks_buf(const char* str, uint8_t* rd, size_t* len); 488 489 /** 490 * Convert rdf of type LDNS_RDF_TYPE_NSAP from string to wireformat. 491 * @param str: the text to convert for this rdata element. 492 * @param rd: rdata buffer for the wireformat. 493 * @param len: length of rd buffer on input, used length on output. 494 * @return 0 on success, error on failure. 495 */ 496 int sldns_str2wire_nsap_buf(const char* str, uint8_t* rd, size_t* len); 497 498 /** 499 * Convert rdf of type LDNS_RDF_TYPE_ATMA from string to wireformat. 500 * @param str: the text to convert for this rdata element. 501 * @param rd: rdata buffer for the wireformat. 502 * @param len: length of rd buffer on input, used length on output. 503 * @return 0 on success, error on failure. 504 */ 505 int sldns_str2wire_atma_buf(const char* str, uint8_t* rd, size_t* len); 506 507 /** 508 * Convert rdf of type LDNS_RDF_TYPE_IPSECKEY from string to wireformat. 509 * @param str: the text to convert for this rdata element. 510 * @param rd: rdata buffer for the wireformat. 511 * @param len: length of rd buffer on input, used length on output. 512 * @return 0 on success, error on failure. 513 */ 514 int sldns_str2wire_ipseckey_buf(const char* str, uint8_t* rd, size_t* len); 515 516 /** 517 * Convert rdf of type LDNS_RDF_TYPE_NSEC3_SALT from string to wireformat. 518 * @param str: the text to convert for this rdata element. 519 * @param rd: rdata buffer for the wireformat. 520 * @param len: length of rd buffer on input, used length on output. 521 * @return 0 on success, error on failure. 522 */ 523 int sldns_str2wire_nsec3_salt_buf(const char* str, uint8_t* rd, size_t* len); 524 525 /** 526 * Convert rdf of type LDNS_RDF_TYPE_ILNP64 from string to wireformat. 527 * @param str: the text to convert for this rdata element. 528 * @param rd: rdata buffer for the wireformat. 529 * @param len: length of rd buffer on input, used length on output. 530 * @return 0 on success, error on failure. 531 */ 532 int sldns_str2wire_ilnp64_buf(const char* str, uint8_t* rd, size_t* len); 533 534 /** 535 * Convert rdf of type LDNS_RDF_TYPE_EUI48 from string to wireformat. 536 * @param str: the text to convert for this rdata element. 537 * @param rd: rdata buffer for the wireformat. 538 * @param len: length of rd buffer on input, used length on output. 539 * @return 0 on success, error on failure. 540 */ 541 int sldns_str2wire_eui48_buf(const char* str, uint8_t* rd, size_t* len); 542 543 /** 544 * Convert rdf of type LDNS_RDF_TYPE_EUI64 from string to wireformat. 545 * @param str: the text to convert for this rdata element. 546 * @param rd: rdata buffer for the wireformat. 547 * @param len: length of rd buffer on input, used length on output. 548 * @return 0 on success, error on failure. 549 */ 550 int sldns_str2wire_eui64_buf(const char* str, uint8_t* rd, size_t* len); 551 552 /** 553 * Convert rdf of type LDNS_RDF_TYPE_TAG from string to wireformat. 554 * @param str: the text to convert for this rdata element. 555 * @param rd: rdata buffer for the wireformat. 556 * @param len: length of rd buffer on input, used length on output. 557 * @return 0 on success, error on failure. 558 */ 559 int sldns_str2wire_tag_buf(const char* str, uint8_t* rd, size_t* len); 560 561 /** 562 * Convert rdf of type LDNS_RDF_TYPE_LONG_STR from string to wireformat. 563 * @param str: the text to convert for this rdata element. 564 * @param rd: rdata buffer for the wireformat. 565 * @param len: length of rd buffer on input, used length on output. 566 * @return 0 on success, error on failure. 567 */ 568 int sldns_str2wire_long_str_buf(const char* str, uint8_t* rd, size_t* len); 569 570 /** 571 * Convert rdf of type LDNS_RDF_TYPE_HIP from string to wireformat. 572 * @param str: the text to convert for this rdata element. 573 * @param rd: rdata buffer for the wireformat. 574 * @param len: length of rd buffer on input, used length on output. 575 * @return 0 on success, error on failure. 576 */ 577 int sldns_str2wire_hip_buf(const char* str, uint8_t* rd, size_t* len); 578 579 /** 580 * Convert rdf of type LDNS_RDF_TYPE_INT16_DATA from string to wireformat. 581 * @param str: the text to convert for this rdata element. 582 * @param rd: rdata buffer for the wireformat. 583 * @param len: length of rd buffer on input, used length on output. 584 * @return 0 on success, error on failure. 585 */ 586 int sldns_str2wire_int16_data_buf(const char* str, uint8_t* rd, size_t* len); 587 588 /** 589 * Strip whitespace from the start and the end of line. 590 * @param line: modified with 0 to shorten it. 591 * @return new start with spaces skipped. 592 */ 593 char * sldns_strip_ws(char *line); 594 #ifdef __cplusplus 595 } 596 #endif 597 598 #endif /* LDNS_STR2WIRE_H */ 599