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 /** 23 * \file 24 * 25 * Defines functions to convert dns data in presentation format or text files 26 * to internal structures. 27 */ 28 29 /** 30 * convert a byte into wireformat 31 * \param[in] rd the rdf where to put the data 32 * \param[in] bytestr the string to be converted 33 * \return ldns_status 34 */ 35 ldns_status ldns_str2rdf_int8(ldns_rdf **rd, const char *bytestr); 36 37 /** 38 * convert a string to a int16 in wireformat 39 * \param[in] rd the rdf where to put the data 40 * \param[in] shortstr the string to be converted 41 * \return ldns_status 42 */ 43 ldns_status ldns_str2rdf_int16(ldns_rdf **rd, const char *shortstr); 44 45 /** 46 * convert a strings into a 4 byte int in wireformat 47 * \param[in] rd the rdf where to put the data 48 * \param[in] longstr the string to be converted 49 * \return ldns_status 50 */ 51 ldns_status ldns_str2rdf_int32(ldns_rdf **rd, const char *longstr); 52 53 /** 54 * convert a time string to a time value in wireformat 55 * \param[in] rd the rdf where to put the data 56 * \param[in] time the string to be converted 57 * \return ldns_status 58 */ 59 ldns_status ldns_str2rdf_time(ldns_rdf **rd, const char *time); 60 61 /* convert string with NSEC3 salt to wireformat) 62 * \param[in] rd the rdf where to put the data 63 * \param[in] str the string to be converted 64 * return ldns_status 65 */ 66 ldns_status ldns_str2rdf_nsec3_salt(ldns_rdf **rd, const char *nsec3_salt); 67 68 /* convert a time period (think TTL's) to wireformat) 69 * \param[in] rd the rdf where to put the data 70 * \param[in] str the string to be converted 71 * return ldns_status 72 */ 73 ldns_status ldns_str2rdf_period(ldns_rdf **rd, const char *str); 74 75 /** 76 * convert str with an A record into wireformat 77 * \param[in] rd the rdf where to put the data 78 * \param[in] str the string to be converted 79 * \return ldns_status 80 */ 81 ldns_status ldns_str2rdf_a(ldns_rdf **rd, const char *str); 82 83 /** 84 * convert the str with an AAAA record into wireformat 85 * \param[in] rd the rdf where to put the data 86 * \param[in] str the string to be converted 87 * \return ldns_status 88 */ 89 ldns_status ldns_str2rdf_aaaa(ldns_rdf **rd, const char *str); 90 91 /** 92 * convert a string into wireformat (think txt record) 93 * \param[in] rd the rdf where to put the data 94 * \param[in] str the string to be converted (NULL terminated) 95 * \return ldns_status 96 */ 97 ldns_status ldns_str2rdf_str(ldns_rdf **rd, const char *str); 98 99 /** 100 * convert str with the apl record into wireformat 101 * \param[in] rd the rdf where to put the data 102 * \param[in] str the string to be converted 103 * \return ldns_status 104 */ 105 ldns_status ldns_str2rdf_apl(ldns_rdf **rd, const char *str); 106 107 /** 108 * convert the string with the b64 data into wireformat 109 * \param[in] rd the rdf where to put the data 110 * \param[in] str the string to be converted 111 * \return ldns_status 112 */ 113 ldns_status ldns_str2rdf_b64(ldns_rdf **rd, const char *str); 114 115 /** 116 * convert the string with the b32 ext hex data into wireformat 117 * \param[in] rd the rdf where to put the data 118 * \param[in] str the string to be converted 119 * \return ldns_status 120 */ 121 ldns_status ldns_str2rdf_b32_ext(ldns_rdf **rd, const char *str); 122 123 /** 124 * convert a hex value into wireformat 125 * \param[in] rd the rdf where to put the data 126 * \param[in] str the string to be converted 127 * \return ldns_status 128 */ 129 ldns_status ldns_str2rdf_hex(ldns_rdf **rd, const char *str); 130 131 /** 132 * convert string with nsec into wireformat 133 * \param[in] rd the rdf where to put the data 134 * \param[in] str the string to be converted 135 * \return ldns_status 136 */ 137 ldns_status ldns_str2rdf_nsec(ldns_rdf **rd, const char *str); 138 139 /** 140 * convert a rrtype into wireformat 141 * \param[in] rd the rdf where to put the data 142 * \param[in] str the string to be converted 143 * \return ldns_status 144 */ 145 ldns_status ldns_str2rdf_type(ldns_rdf **rd, const char *str); 146 147 /** 148 * convert string with a classname into wireformat 149 * \param[in] rd the rdf where to put the data 150 * \param[in] str the string to be converted 151 * \return ldns_status 152 */ 153 ldns_status ldns_str2rdf_class(ldns_rdf **rd, const char *str); 154 155 /** 156 * convert an certificate algorithm value into wireformat 157 * \param[in] rd the rdf where to put the data 158 * \param[in] str the string to be converted 159 * \return ldns_status 160 */ 161 ldns_status ldns_str2rdf_cert_alg(ldns_rdf **rd, const char *str); 162 163 /** 164 * convert and algorithm value into wireformat 165 * \param[in] rd the rdf where to put the data 166 * \param[in] str the string to be converted 167 * \return ldns_status 168 */ 169 ldns_status ldns_str2rdf_alg(ldns_rdf **rd, const char *str); 170 171 /** 172 * convert a string with a unknown RR into wireformat 173 * \param[in] rd the rdf where to put the data 174 * \param[in] str the string to be converted 175 * \return ldns_status 176 */ 177 ldns_status ldns_str2rdf_unknown(ldns_rdf **rd, const char *str); 178 179 /** 180 * convert string with a tsig? RR into wireformat 181 * \param[in] rd the rdf where to put the data 182 * \param[in] str the string to be converted 183 * \return ldns_status 184 */ 185 ldns_status ldns_str2rdf_tsig(ldns_rdf **rd, const char *str); 186 187 /** 188 * convert string with a protocol service into wireformat 189 * \param[in] rd the rdf where to put the data 190 * \param[in] str the string to be converted 191 * \return ldns_status 192 */ 193 ldns_status ldns_str2rdf_service(ldns_rdf **rd, const char *str); 194 195 /** 196 * convert a string with a LOC RR into wireformat 197 * \param[in] rd the rdf where to put the data 198 * \param[in] str the string to be converted 199 * \return ldns_status 200 */ 201 ldns_status ldns_str2rdf_loc(ldns_rdf **rd, const char *str); 202 203 /** 204 * convert string with a WKS RR into wireformat 205 * \param[in] rd the rdf where to put the data 206 * \param[in] str the string to be converted 207 * \return ldns_status 208 */ 209 ldns_status ldns_str2rdf_wks(ldns_rdf **rd, const char *str); 210 211 /** 212 * convert a str with a NSAP RR into wireformat 213 * \param[in] rd the rdf where to put the data 214 * \param[in] str the string to be converted 215 * \return ldns_status 216 */ 217 ldns_status ldns_str2rdf_nsap(ldns_rdf **rd, const char *str); 218 219 /** 220 * convert a str with a ATMA RR into wireformat 221 * \param[in] rd the rdf where to put the data 222 * \param[in] str the string to be converted 223 * \return ldns_status 224 */ 225 ldns_status ldns_str2rdf_atma(ldns_rdf **rd, const char *str); 226 227 /** 228 * convert a str with a IPSECKEY RR into wireformat 229 * \param[in] rd the rdf where to put the data 230 * \param[in] str the string to be converted 231 * \return ldns_status 232 */ 233 ldns_status ldns_str2rdf_ipseckey(ldns_rdf **rd, const char *str); 234 235 /** 236 * convert a dname string into wireformat 237 * \param[in] rd the rdf where to put the data 238 * \param[in] str the string to be converted 239 * \return ldns_status 240 */ 241 ldns_status ldns_str2rdf_dname(ldns_rdf **rd, const char *str); 242 243 #endif /* LDNS_2HOST_H */ 244