]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
added skeleton function for str2host conversion routines.
authorMiek Gieben <miekg@NLnetLabs.nl>
Thu, 20 Jan 2005 13:15:44 +0000 (13:15 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Thu, 20 Jan 2005 13:15:44 +0000 (13:15 +0000)
ldns/str2host.h
libdns.vim
rdata.c
str2host.c

index 3813aa081afbfd929dd0ac55197a70c03416036f..c3f7d102e5d5bc1c83bceb1b4c82a3b7b86fcaa6 100644 (file)
@@ -10,9 +10,9 @@
 #include <ldns/buffer.h>
 #include <ctype.h>
 
-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
index e56210e41f7e9d2edefbe99ead8b507fd8efbcad..f85148877f20d1d89b044d72753040b179faff6d 100644 (file)
@@ -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 788e31c7aa815615f9a364a3faeb598df1c7d4e4..bc7393b7871f3e967057ea6e48787802b6e5470c 100644 (file)
--- 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
index b48cc7863b5f515cbbab6977959aaa311f0ae6ae..4731cd6dd42cae3d6d8f307071e13c600136476a 100644 (file)
 #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
 
 /**