]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
finished CERT type from string. renamed some values and functions, removed old code
authorJelte Jansen <jeltejan@NLnetLabs.nl>
Tue, 23 Aug 2005 09:26:22 +0000 (09:26 +0000)
committerJelte Jansen <jeltejan@NLnetLabs.nl>
Tue, 23 Aug 2005 09:26:22 +0000 (09:26 +0000)
host2str.c
ldns/dns.h
ldns/host2str.h
ldns/rdata.h
ldns/str2host.h
rdata.c
rr.c
str2host.c
wire2host.c

index 2b4adc1f5e3d37187ff30569577eaf2765f8e633..63b21f27be6d3fe80c97c320e8d5fcca9388493a 100644 (file)
 
 /* lookup tables for standard DNS stuff  */
 
-/* Taken from RFC 2538, section 2.1.  */
-ldns_lookup_table ldns_certificate_types[] = {
-        { 0, "PKIX" },  /* X.509 as per PKIX */
-        { 1, "SPKI" },  /* SPKI cert */
-        { 2, "PGP" },   /* PGP cert */
-        { 253, "URI" }, /* URI private */
-        { 254, "OID" }, /* OID private */
-        { 0, NULL }
-};
-
 /* Taken from RFC 2535, section 7.  */
 ldns_lookup_table ldns_algorithms[] = {
         { LDNS_RSAMD5, "RSAMD5" },
@@ -46,6 +36,16 @@ ldns_lookup_table ldns_algorithms[] = {
         { 0, NULL }
 };
 
+/* Taken from RFC 2538  */
+ldns_lookup_table ldns_cert_algorithms[] = {
+        { LDNS_CERT_PKIX, "PKIX" },
+       { LDNS_CERT_SPKI, "SPKI" },
+       { LDNS_CERT_PGP, "PGP" },
+       { LDNS_CERT_URI, "URI" },
+       { LDNS_CERT_OID, "OID" },
+        { 0, NULL }
+};
+
 /* classes  */
 ldns_lookup_table ldns_rr_classes[] = {
         { LDNS_RR_CLASS_IN, "IN" },
@@ -268,27 +268,27 @@ ldns_rdf2buffer_str_class(ldns_buffer *output, ldns_rdf *rdf)
 }      
 
 ldns_status
-ldns_rdf2buffer_str_alg(ldns_buffer *output, ldns_rdf *rdf)
+ldns_rdf2buffer_str_cert_alg(ldns_buffer *output, ldns_rdf *rdf)
 {
         uint8_t data = ldns_rdf_data(rdf)[0];
        ldns_lookup_table *lt;
 
-       lt = ldns_lookup_by_id(ldns_algorithms, (int) data);
+       lt = ldns_lookup_by_id(ldns_cert_algorithms, (int) data);
        if (lt) {
                ldns_buffer_printf(output, "%s", lt->name);
        } else {
-               ldns_buffer_printf(output, "ALG%d", data);
+               ldns_buffer_printf(output, "%d", data);
        }
        return ldns_buffer_status(output);
 }      
 
 ldns_status
-ldns_rdf2buffer_str_cert(ldns_buffer *output, ldns_rdf *rdf)
+ldns_rdf2buffer_str_alg(ldns_buffer *output, ldns_rdf *rdf)
 {
-        uint16_t data = ldns_read_uint16(ldns_rdf_data(rdf));
+        uint8_t data = ldns_rdf_data(rdf)[0];
        ldns_lookup_table *lt;
 
-       lt = ldns_lookup_by_id(ldns_certificate_types, (int) data);
+       lt = ldns_lookup_by_id(ldns_algorithms, (int) data);
        if (lt) {
                ldns_buffer_printf(output, "%s", lt->name);
        } else {
@@ -735,8 +735,8 @@ ldns_rdf2buffer_str(ldns_buffer *buffer, ldns_rdf *rdf)
                case LDNS_RDF_TYPE_CLASS:
                        res = ldns_rdf2buffer_str_class(buffer, rdf);
                        break;
-               case LDNS_RDF_TYPE_CERT:
-                       res = ldns_rdf2buffer_str_cert(buffer, rdf);
+               case LDNS_RDF_TYPE_CERT_ALG:
+                       res = ldns_rdf2buffer_str_cert_alg(buffer, rdf);
                        break;
                case LDNS_RDF_TYPE_ALG:
                        res = ldns_rdf2buffer_str_alg(buffer, rdf);
index 5e35f3c37dd80766c01c6ce68646dfae49b7a46b..c257d3dcc547ab1f1005bda99ed37ccffeddec12 100644 (file)
@@ -51,6 +51,8 @@
 extern ldns_lookup_table ldns_certificate_types[];
 /* Taken from RFC 2535, section 7.  */
 extern ldns_lookup_table ldns_algorithms[];
+/* Taken from RFC 2538.  */
+extern ldns_lookup_table ldns_cert_algorithms[];
 /* rr types  */
 extern ldns_lookup_table ldns_rr_classes[];
 /* if these are used elsewhere */
index a38d7886d7b75b88d6a41b6e0400234981d58e0c..3168a6370a21760004a8fbb0644606377e9a9cd3 100644 (file)
@@ -93,7 +93,7 @@ ldns_status ldns_rdf2buffer_str_alg(ldns_buffer *output, ldns_rdf *rdf);
  * \param[in] *output The buffer to add the data to
  * \return LDNS_STATUS_OK on success, and error status on failure
  */
-ldns_status ldns_rdf2buffer_str_cert(ldns_buffer *output, ldns_rdf *rdf);
+ldns_status ldns_rdf2buffer_str_cert_alg(ldns_buffer *output, ldns_rdf *rdf);
 
 /** 
  * Converts an LDNS_RDF_TYPE_LOC rdata element to string format and adds it to the output buffer 
index 0f92ebee73a2f3521f5653081f538cad524b11ec..4a5048f149e42badc9c9bacd24f588665e876212 100644 (file)
@@ -52,8 +52,8 @@ enum ldns_enum_rdf_type
        LDNS_RDF_TYPE_TYPE, 
        /** a class */
        LDNS_RDF_TYPE_CLASS,
-       /** certificates */
-       LDNS_RDF_TYPE_CERT,
+       /** certificate algorithm */
+       LDNS_RDF_TYPE_CERT_ALG,
        /** a key algorithm */
        LDNS_RDF_TYPE_ALG,
        /** unknown types */
@@ -81,6 +81,21 @@ enum ldns_enum_rdf_type
 };
 typedef enum ldns_enum_rdf_type ldns_rdf_type;
 
+/**
+ * algorithms used in CERT rrs
+ */
+enum ldns_enum_cert_algorithm
+{
+       LDNS_CERT_PKIX          = 1,
+       LDNS_CERT_SPKI          = 2,
+       LDNS_CERT_PGP           = 3,
+       LDNS_CERT_URI           = 253,
+       LDNS_CERT_OID           = 254
+};
+typedef enum ldns_enum_cert_algorithm ldns_cert_algorithm;
+
+
+
 /**
  * Resource record data.
  *
index 004a083dc1c5304f262d4ee3c22f1f8bfb116d7f..dff31214d58f7c72402afad1da551f934c617a4a 100644 (file)
@@ -141,6 +141,14 @@ ldns_status ldns_str2rdf_class(ldns_rdf **rd, const char *str);
  */
 ldns_status ldns_str2rdf_cert(ldns_rdf **rd, const char *str);
 
+/**
+ * convert an certificate algorithm value 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_str2rdf_cert_alg(ldns_rdf **rd, const char *str);
+
 /**
  * convert and algorithm value into wireformat
  * \param[in] rd the rdf where to put the data
diff --git a/rdata.c b/rdata.c
index 7b70a206b4cc91767bdd94a2cc6183efa4ede3b8..c1906d4487d9d99d03eca4a84b8764c825062989 100644 (file)
--- a/rdata.c
+++ b/rdata.c
@@ -329,8 +329,8 @@ ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str)
        case LDNS_RDF_TYPE_CLASS:
                status = ldns_str2rdf_class(&rdf, str);
                break;
-       case LDNS_RDF_TYPE_CERT:
-               status = ldns_str2rdf_cert(&rdf, str);
+       case LDNS_RDF_TYPE_CERT_ALG:
+               status = ldns_str2rdf_cert_alg(&rdf, str);
                break;
        case LDNS_RDF_TYPE_ALG:
                status = ldns_str2rdf_alg(&rdf, str);
diff --git a/rr.c b/rr.c
index f852dfc097f758f158a5a183bbc0a25627bbab03..4565b2c1f15bfed596c14cec4c0aaac5341a1919 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -397,7 +397,15 @@ ldns_rr_new_frm_fp_l(FILE *fp, uint16_t ttl, ldns_rdf *origin, int *line_nr)
         }
 
        rr = ldns_rr_new_frm_str((const char*) line, ttl, origin);
-
+/*
+printf("line %d: %s\n", *line_nr, line);
+*/
+if (rr && ldns_rr_get_type(rr) == LDNS_RR_TYPE_CERT) {
+       printf("got CERT RR:\n");
+       ldns_rr_print(stdout, rr);
+       printf("from:\n%s\n", line);
+exit(1);
+}
        LDNS_FREE(line);
        return rr;
 }
@@ -1290,7 +1298,7 @@ static const ldns_rdf_type type_kx_wireformat[] = {
        LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
 };
 static const ldns_rdf_type type_cert_wireformat[] = {
-        LDNS_RDF_TYPE_CERT, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_B64
+        LDNS_RDF_TYPE_CERT_ALG, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_B64
 };
 static const ldns_rdf_type type_a6_wireformat[] = { LDNS_RDF_TYPE_DNAME };
 static const ldns_rdf_type type_dname_wireformat[] = { LDNS_RDF_TYPE_DNAME };
index 573b8aa48b7c6c50733a3823a72d4d061654d7b3..d39d50c5d6828fb51f114bd0ff78fa2482ece0e8 100644 (file)
@@ -460,14 +460,35 @@ ldns_str2rdf_class(ldns_rdf **rd, const char *str)
        return LDNS_STATUS_OK;
 }
 
+/* An certificate alg field can either be specified as a 8 bits number
+ * or by its symbolic name. Handle both
+ */
 ldns_status
-ldns_str2rdf_cert(ldns_rdf **rd, const char *str)
+ldns_str2rdf_cert_alg(ldns_rdf **rd, const char *str)
 {
-       rd = rd;
-       str = str;
-       return LDNS_STATUS_NOT_IMPL;
-}
+       ldns_lookup_table *lt;
+       ldns_status st;
+
+       lt = ldns_lookup_by_name(ldns_cert_algorithms, str);
+       st = LDNS_STATUS_OK;
 
+printf("YOYOYO\n");
+       if (lt) {
+printf("LT: %s\n", str);
+               /* it was given as a integer */
+               *rd = ldns_rdf_new_frm_data(
+                       LDNS_RDF_TYPE_INT8, sizeof(uint8_t), &lt->id);
+               if (!*rd) {
+                       st = LDNS_STATUS_ERR;
+               }
+       } else {
+printf("NO LT: %s\n", str);
+               /* try as-is (a number) */
+               st = ldns_str2rdf_int8(rd, str);
+       }
+       return st;
+}
+               
 /* An alg field can either be specified as a 8 bits number
  * or by its symbolic name. Handle both
  */
index ce3df4c1ecf1d9c84a1e3a0df1b0ea38da52da84..dde2267a29ea14a487c3680073ffaabf18d2aeeb 100644 (file)
@@ -197,7 +197,7 @@ ldns_wire2rdf(ldns_rr *rr, const uint8_t *wire,
                        break;
                case LDNS_RDF_TYPE_TYPE:
                case LDNS_RDF_TYPE_INT16:
-               case LDNS_RDF_TYPE_CERT:
+               case LDNS_RDF_TYPE_CERT_ALG:
                        cur_rdf_length = 2;
                        break;
                case LDNS_RDF_TYPE_TIME: