From: Miek Gieben Date: Thu, 20 Jan 2005 13:15:44 +0000 (+0000) Subject: added skeleton function for str2host conversion routines. X-Git-Tag: release-0.50~553 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5db5371de9f9cbcd92040586f473799053f0646d;p=thirdparty%2Fldns.git added skeleton function for str2host conversion routines. --- diff --git a/ldns/str2host.h b/ldns/str2host.h index 3813aa08..c3f7d102 100644 --- a/ldns/str2host.h +++ b/ldns/str2host.h @@ -10,9 +10,9 @@ #include #include -ldns_status ldns_conv_int8(ldns_rdf **, const char *); -ldns_status ldns_conv_int16(ldns_rdf **, const char *); -ldns_status ldns_conv_int32(ldns_rdf **, const char *); -ldns_status ldns_conv_time(ldns_rdf **, const char *); +ldns_status ldns_conv_int8(ldns_rdf **, const uint8_t *); +ldns_status ldns_conv_int16(ldns_rdf **, const uint8_t *); +ldns_status ldns_conv_int32(ldns_rdf **, const uint8_t *); +ldns_status ldns_conv_time(ldns_rdf **, const uint8_t *); #endif diff --git a/libdns.vim b/libdns.vim index e56210e4..f8514887 100644 --- a/libdns.vim +++ b/libdns.vim @@ -13,6 +13,7 @@ syn keyword ldnsMacro DEP " ldns/rdata.h syn keyword ldnsType ldns_rdf +syn keyword ldnsType ldns_rdf_type syn keyword ldnsType ldns_hdr syn keyword ldnsType ldns_pkt syn keyword ldnsType ldns_status @@ -43,6 +44,8 @@ syn keyword ldnsConstant LDNS_RDF_TYPE_TIME syn keyword ldnsConstant LDNS_RDF_TYPE_TSIGTIME syn keyword ldnsConstant LDNS_RDF_TYPE_SERVICE syn keyword ldnsConstant LDNS_RDF_TYPE_LOC +syn keyword ldnsConstant LDNS_RDF_TYPE_WKS +syn keyword ldnsConstant LDNS_RDF_TYPE_NSAP " dns/error.h syn keyword ldnsMacro LDNS_STATUS_OK diff --git a/rdata.c b/rdata.c index 788e31c7..bc7393b7 100644 --- a/rdata.c +++ b/rdata.c @@ -85,6 +85,100 @@ ldns_rdf_free(ldns_rdf *rd) FREE(rd); } +/** + * Create a new rdf from a string + * \param[in] str string to use + * \param[in] t type to use + * \return ldns_rdf* + */ +ldns_rdf * +ldns_rdf_new_frm_str(const char *str, ldns_rdf_type t) +{ + ldns_rdf *rd; + ldns_status stat; + + switch(t) { + case LDNS_RDF_TYPE_NONE: + stat = ldns_conv_none(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_DNAME: + stat = ldns_conv_dname(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_INT8: + stat = ldns_conv_int8(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_INT16: + stat = ldns_conv_int16(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_INT32: + stat = ldns_conv_int32(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_A: + stat = ldns_conv_a(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_AAAA: + stat = ldns_conv_aaaa(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_STR: + stat = ldns_conv_str(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_APL: + stat = ldns_conv_apl(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_B64: + stat = ldns_conv_b64(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_HEX: + stat = ldns_conv_hex(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_NSEC: + stat = ldns_conv_nsec(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_TYPE: + stat = ldns_conv_type(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_CLASS: + stat = ldns_conv_class(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_CERT: + stat = ldns_conv_cert(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_ALG: + stat = ldns_conv_alg(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_UNKNOWN: + stat = ldns_conv_unknown(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_TIME: + stat = ldns_conv_time(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_TSIGTIME: + stat = ldns_conv_tsigtime(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_SERVICE: + stat = ldns_conv_service(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_LOC: + stat = ldns_conv_loc(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_WKS: + stat = ldns_conv_wks(&rd, (const uint8_t*) str); + break; + case LDNS_RDF_TYPE_NSAP: + stat = ldns_conv_nsap(&rd, (const uint8_t*) str); + break; + default: + /* default default ??? */ + break; + } + if (LDNS_STATUS_OK != stat) { + return NULL; + } else { + ldns_rdf_set_type(rd, t); + return rd; + } +} + /** * remove \\DDD, \\[space] and other escapes from the input * See RFC 1035, section 5.1 diff --git a/str2host.c b/str2host.c index b48cc786..4731cd6d 100644 --- a/str2host.c +++ b/str2host.c @@ -27,10 +27,13 @@ #endif /** - * convert a short str into wireformat + * convert a string to a int16 in wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status */ ldns_status -ldns_conv_int16(ldns_rdf **rd, const char *shortstr) +ldns_conv_int16(ldns_rdf **rd, const uint8_t *shortstr) { char *end = NULL; uint16_t *r; @@ -48,10 +51,13 @@ ldns_conv_int16(ldns_rdf **rd, const char *shortstr) } /** - * convert a time str value to wireformat + * convert a time string to a time value in wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status */ ldns_status -ldns_conv_time(ldns_rdf **rd, const char *time) +ldns_conv_time(ldns_rdf **rd, const uint8_t *time) { /* convert a time YYHM to wireformat */ uint16_t *r = NULL; @@ -73,10 +79,13 @@ ldns_conv_time(ldns_rdf **rd, const char *time) } /** - * convert a long (32 bits) + * convert a strings into a 4 byte int in wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status */ ldns_status -ldns_conv_int32(ldns_rdf **rd, const char *longstr) +ldns_conv_int32(ldns_rdf **rd, const uint8_t *longstr) { char *end; uint16_t *r = NULL; @@ -96,10 +105,13 @@ ldns_conv_int32(ldns_rdf **rd, const char *longstr) } /** - * convert a byte (8 bits) + * convert a byte into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status */ ldns_status -ldns_conv_int8(ldns_rdf **rd, const char *bytestr) +ldns_conv_int8(ldns_rdf **rd, const uint8_t *bytestr) { char *end; uint8_t *r = NULL; @@ -117,6 +129,236 @@ ldns_conv_int8(ldns_rdf **rd, const char *bytestr) } } +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_none(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_dname(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_a(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_aaaa(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_str(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_apl(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_b64(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_hex(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_nsec(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_type(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_class(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_cert(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_alg(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_unknown(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_tsigtime(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_service(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_loc(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_wks(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + +/** + * convert .... into wireformat + * \param[in] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status +ldns_conv_nsap(ldns_rdf **rd, const uint8_t* str) +{ + return LDNS_STATUS_OK; +} + + + #if 0 /**