1 /** 2 * str2host.h - conversion from str to the host fmt 3 * 4 * a Net::DNS like library for C 5 * 6 * (c) NLnet Labs, 2005-2006 7 * 8 * See the file LICENSE for the license 9 */ 10 11 #ifndef LDNS_2HOST_H 12 #define LDNS_2HOST_H 13 14 #include <ldns/common.h> 15 #include <ldns/error.h> 16 #include <ldns/rr.h> 17 #include <ldns/rdata.h> 18 #include <ldns/packet.h> 19 #include <ldns/buffer.h> 20 #include <ctype.h> 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /** 27 * \file 28 * 29 * Defines functions to convert dns data in presentation format or text files 30 * to internal structures. 31 */ 32 33 /** 34 * convert a byte into wireformat 35 * \param[in] rd the rdf where to put the data 36 * \param[in] bytestr the string to be converted 37 * \return ldns_status 38 */ 39 ldns_status ldns_str2rdf_int8(ldns_rdf **rd, const char *bytestr); 40 41 /** 42 * convert a string to a int16 in wireformat 43 * \param[in] rd the rdf where to put the data 44 * \param[in] shortstr the string to be converted 45 * \return ldns_status 46 */ 47 ldns_status ldns_str2rdf_int16(ldns_rdf **rd, const char *shortstr); 48 49 /** 50 * convert a strings into a 4 byte int in wireformat 51 * \param[in] rd the rdf where to put the data 52 * \param[in] longstr the string to be converted 53 * \return ldns_status 54 */ 55 ldns_status ldns_str2rdf_int32(ldns_rdf **rd, const char *longstr); 56 57 /** 58 * convert a time string to a time value in wireformat 59 * \param[in] rd the rdf where to put the data 60 * \param[in] time the string to be converted 61 * \return ldns_status 62 */ 63 ldns_status ldns_str2rdf_time(ldns_rdf **rd, const char *time); 64 65 /* convert string with NSEC3 salt to wireformat) 66 * \param[in] rd the rdf where to put the data 67 * \param[in] str the string to be converted 68 * return ldns_status 69 */ 70 ldns_status ldns_str2rdf_nsec3_salt(ldns_rdf **rd, const char *nsec3_salt); 71 72 /* convert a time period (think TTL's) to wireformat) 73 * \param[in] rd the rdf where to put the data 74 * \param[in] str the string to be converted 75 * return ldns_status 76 */ 77 ldns_status ldns_str2rdf_period(ldns_rdf **rd, const char *str); 78 79 /** 80 * convert str with an A record into wireformat 81 * \param[in] rd the rdf where to put the data 82 * \param[in] str the string to be converted 83 * \return ldns_status 84 */ 85 ldns_status ldns_str2rdf_a(ldns_rdf **rd, const char *str); 86 87 /** 88 * convert the str with an AAAA record into wireformat 89 * \param[in] rd the rdf where to put the data 90 * \param[in] str the string to be converted 91 * \return ldns_status 92 */ 93 ldns_status ldns_str2rdf_aaaa(ldns_rdf **rd, const char *str); 94 95 /** 96 * convert a string into wireformat (think txt record) 97 * \param[in] rd the rdf where to put the data 98 * \param[in] str the string to be converted (NULL terminated) 99 * \return ldns_status 100 */ 101 ldns_status ldns_str2rdf_str(ldns_rdf **rd, const char *str); 102 103 /** 104 * convert str with the apl record into wireformat 105 * \param[in] rd the rdf where to put the data 106 * \param[in] str the string to be converted 107 * \return ldns_status 108 */ 109 ldns_status ldns_str2rdf_apl(ldns_rdf **rd, const char *str); 110 111 /** 112 * convert the string with the b64 data into wireformat 113 * \param[in] rd the rdf where to put the data 114 * \param[in] str the string to be converted 115 * \return ldns_status 116 */ 117 ldns_status ldns_str2rdf_b64(ldns_rdf **rd, const char *str); 118 119 /** 120 * convert the string with the b32 ext hex data into wireformat 121 * \param[in] rd the rdf where to put the data 122 * \param[in] str the string to be converted 123 * \return ldns_status 124 */ 125 ldns_status ldns_str2rdf_b32_ext(ldns_rdf **rd, const char *str); 126 127 /** 128 * convert a hex value into wireformat 129 * \param[in] rd the rdf where to put the data 130 * \param[in] str the string to be converted 131 * \return ldns_status 132 */ 133 ldns_status ldns_str2rdf_hex(ldns_rdf **rd, const char *str); 134 135 /** 136 * convert string with nsec into wireformat 137 * \param[in] rd the rdf where to put the data 138 * \param[in] str the string to be converted 139 * \return ldns_status 140 */ 141 ldns_status ldns_str2rdf_nsec(ldns_rdf **rd, const char *str); 142 143 /** 144 * convert a rrtype into wireformat 145 * \param[in] rd the rdf where to put the data 146 * \param[in] str the string to be converted 147 * \return ldns_status 148 */ 149 ldns_status ldns_str2rdf_type(ldns_rdf **rd, const char *str); 150 151 /** 152 * convert string with a classname into wireformat 153 * \param[in] rd the rdf where to put the data 154 * \param[in] str the string to be converted 155 * \return ldns_status 156 */ 157 ldns_status ldns_str2rdf_class(ldns_rdf **rd, const char *str); 158 159 /** 160 * convert an certificate algorithm value into wireformat 161 * \param[in] rd the rdf where to put the data 162 * \param[in] str the string to be converted 163 * \return ldns_status 164 */ 165 ldns_status ldns_str2rdf_cert_alg(ldns_rdf **rd, const char *str); 166 167 /** 168 * convert an algorithm value into wireformat 169 * \param[in] rd the rdf where to put the data 170 * \param[in] str the string to be converted 171 * \return ldns_status 172 */ 173 ldns_status ldns_str2rdf_alg(ldns_rdf **rd, const char *str); 174 175 /** 176 * convert a tlsa certificate usage value into wireformat 177 * \param[in] rd the rdf where to put the data 178 * \param[in] str the string to be converted 179 * \return ldns_status 180 */ 181 ldns_status ldns_str2rdf_certificate_usage(ldns_rdf **rd, const char *str); 182 183 /** 184 * convert a tlsa selector value into wireformat 185 * \param[in] rd the rdf where to put the data 186 * \param[in] str the string to be converted 187 * \return ldns_status 188 */ 189 ldns_status ldns_str2rdf_selector(ldns_rdf **rd, const char *str); 190 191 /** 192 * convert a tlsa matching type value into wireformat 193 * \param[in] rd the rdf where to put the data 194 * \param[in] str the string to be converted 195 * \return ldns_status 196 */ 197 ldns_status ldns_str2rdf_matching_type(ldns_rdf **rd, const char *str); 198 199 /** 200 * convert a string with a unknown RR into wireformat 201 * \param[in] rd the rdf where to put the data 202 * \param[in] str the string to be converted 203 * \return ldns_status 204 */ 205 ldns_status ldns_str2rdf_unknown(ldns_rdf **rd, const char *str); 206 207 /** 208 * convert string with a protocol service into wireformat 209 * \param[in] rd the rdf where to put the data 210 * \param[in] str the string to be converted 211 * \return ldns_status 212 */ 213 ldns_status ldns_str2rdf_service(ldns_rdf **rd, const char *str); 214 215 /** 216 * convert a string with a LOC RR into wireformat 217 * \param[in] rd the rdf where to put the data 218 * \param[in] str the string to be converted 219 * \return ldns_status 220 */ 221 ldns_status ldns_str2rdf_loc(ldns_rdf **rd, const char *str); 222 223 /** 224 * convert string with a WKS RR into wireformat 225 * \param[in] rd the rdf where to put the data 226 * \param[in] str the string to be converted 227 * \return ldns_status 228 */ 229 ldns_status ldns_str2rdf_wks(ldns_rdf **rd, const char *str); 230 231 /** 232 * convert a str with a NSAP RR into wireformat 233 * \param[in] rd the rdf where to put the data 234 * \param[in] str the string to be converted 235 * \return ldns_status 236 */ 237 ldns_status ldns_str2rdf_nsap(ldns_rdf **rd, const char *str); 238 239 /** 240 * convert a str with a ATMA RR into wireformat 241 * \param[in] rd the rdf where to put the data 242 * \param[in] str the string to be converted 243 * \return ldns_status 244 */ 245 ldns_status ldns_str2rdf_atma(ldns_rdf **rd, const char *str); 246 247 /** 248 * convert a str with a IPSECKEY RR into wireformat 249 * \param[in] rd the rdf where to put the data 250 * \param[in] str the string to be converted 251 * \return ldns_status 252 */ 253 ldns_status ldns_str2rdf_ipseckey(ldns_rdf **rd, const char *str); 254 255 /** 256 * convert a dname string into wireformat 257 * \param[in] rd the rdf where to put the data 258 * \param[in] str the string to be converted 259 * \return ldns_status 260 */ 261 ldns_status ldns_str2rdf_dname(ldns_rdf **rd, const char *str); 262 263 /** 264 * convert 4 * 16bit hex separated by colons into wireformat 265 * \param[in] rd the rdf where to put the data 266 * \param[in] str the string to be converted 267 * \return ldns_status 268 */ 269 ldns_status ldns_str2rdf_ilnp64(ldns_rdf **rd, const char *str); 270 271 /** 272 * convert 6 hex bytes separated by dashes into wireformat 273 * \param[in] rd the rdf where to put the data 274 * \param[in] str the string to be converted 275 * \return ldns_status 276 */ 277 ldns_status ldns_str2rdf_eui48(ldns_rdf **rd, const char *str); 278 279 /** 280 * convert 8 hex bytes separated by dashes into wireformat 281 * \param[in] rd the rdf where to put the data 282 * \param[in] str the string to be converted 283 * \return ldns_status 284 */ 285 ldns_status ldns_str2rdf_eui64(ldns_rdf **rd, const char *str); 286 287 /** 288 * Convert a non-zero sequence of US-ASCII letters and numbers into wireformat 289 * \param[in] rd the rdf where to put the data 290 * \param[in] str the string to be converted 291 * \return ldns_status 292 */ 293 ldns_status ldns_str2rdf_tag(ldns_rdf **rd, const char *str); 294 295 /** 296 * Convert a <character-string> encoding of the value field as specified 297 * [RFC1035], Section 5.1., encoded as one bug chunk of data. 298 * \param[in] rd the rdf where to put the data 299 * \param[in] str the string to be converted 300 * \return ldns_status 301 */ 302 ldns_status ldns_str2rdf_long_str(ldns_rdf **rd, const char *str); 303 304 /** 305 * Convert a "<algorithm> <hit> <pk>" encoding of the value field as specified 306 * in Section 6. of [RFC5205], encoded as wireformat as specified in Section 5. 307 * of [RFC5205]. 308 * \param[in] rd the rdf where to put the data 309 * \param[in] str the string to be converted 310 * \return ldns_status 311 */ 312 ldns_status ldns_str2rdf_hip(ldns_rdf **rd, const char *str); 313 314 /** 315 * Concert a"<precedence> <D-bit> <type> <relay>" encoding 316 * of the value field as specified in Section 4.3.1 of 317 * [draft-ietf-mboned-driad-amt-discovery], encoded as wireformat as specified in 318 * ection 4.2 of [draft-ietf-mboned-driad-amt-discovery] 319 * \param[in] rd the rdf where to put the data 320 * \param[in] str the string to be converted 321 * \return ldns_status 322 */ 323 ldns_status ldns_str2rdf_amtrelay(ldns_rdf **rd, const char *str); 324 325 #ifdef __cplusplus 326 } 327 #endif 328 329 #endif /* LDNS_2HOST_H */ 330