]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
lint update. And more printing code added. It begins to resemble to go\'old resolver...
authorMiek Gieben <miekg@NLnetLabs.nl>
Thu, 1 Dec 2005 11:31:16 +0000 (11:31 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Thu, 1 Dec 2005 11:31:16 +0000 (11:31 +0000)
drill/screen.c
drill/securetrace.c
host2str.c

index 29ccec094e6bf6c2c0b59fbd1fe79f5d12ee82ad..6cba51b828bb6476b4ed3ad18407853c930d43b4 100644 (file)
 #include "drill.h"
 #include <ldns/dns.h>
 
+
+void
+resolver_print_nameservers(ldns_resolver *r) 
+{
+       uint8_t i;
+       ldns_rdf **n;
+       n = ldns_resolver_nameservers(r);
+
+        for (i = 0; i < ldns_resolver_nameserver_count(r); i++) {
+               printf(" | @"); ldns_rdf_print(stdout, n[i]);
+        }
+}
+
+/* 
+ * print the key in abbr. form
+ * owner_name TYPE ; { id = id (ksk), size = b}
+ */
+void
+print_dnskey(ldns_rr_list *key_list) 
+{
+       uint16_t key_size;
+       uint16_t key_id;
+       uint16_t ksk;
+       ldns_rr *dnskey;
+       size_t i;
+
+       for (i = 0; i < ldns_rr_list_rr_count(key_list); i++) {
+               dnskey = ldns_rr_list_rr(key_list, i);
+               
+               printf(" | ");
+               ldns_rdf_print(stdout, ldns_rr_owner(dnskey));
+               printf(" DNSKEY ");
+               key_size = ldns_rr_dnskey_key_size(dnskey);
+               key_id = ldns_calc_keytag(dnskey);
+               ksk = ldns_rdf2native_int16(ldns_rr_rdf(dnskey, 0));
+
+               switch (ksk) {
+                       case 257:
+                               printf("; { id = %d (ksk), size = %db }\n",
+                                               (int)key_id, (int)key_size);
+                               break;
+                       case 256:
+                               printf("; { id = %d (zsk), size = %db }\n",
+                                               (int)key_id, (int)key_size);
+                               break;
+                       default:
+                               printf("; { id = %d, size = %db }\n",
+                                               (int)key_id, (int)key_size);
+                               break;
+               }
+       }
+}
+
+void
+print_ds(ldns_rr_list *ds_list) 
+{
+       ldns_rr *ds;
+       uint16_t key_id;
+       size_t i;
+
+       for (i = 0; i < ldns_rr_list_rr_count(ds_list); i++) {
+               ds = ldns_rr_list_rr(ds_list, i);
+               
+               printf(" | ");
+               ldns_rdf_print(stdout, ldns_rr_owner(ds));
+               printf(" DS ");
+               key_id = ldns_rdf2native_int16(ldns_rr_rdf(ds, 0));
+
+               printf("; { id = %d }\n", (int)key_id);
+       }
+}
index 2d51e9cf0239493882fd22779bb05804116d7fc8..e5fa643c2214e0c2a6cb817003026eb601f31f39 100644 (file)
@@ -133,9 +133,6 @@ do_secure_trace2(ldns_resolver *res, ldns_rdf *name, ldns_rr_type t,
        ldns_rr_list *rrsig_cache = NULL;
        ldns_rr_list *ds_cache = NULL;
 
-       /* put RRset in here that are validated */
-       ldns_rr_list *validated_cache = NULL;
-
        ldns_rdf *chopped_dname[11]; /* alloc 10 subparts for a dname */
        ldns_rr_list *ds;
        int8_t i, dname_labels;
@@ -169,19 +166,24 @@ do_secure_trace2(ldns_resolver *res, ldns_rdf *name, ldns_rr_type t,
                        break;
                }
        }
-       printf("\nFirst dname with keys and sigs here */\n");
-       ldns_rdf_print(stdout, chopped_dname[i]);
        lab_cnt = i;
 
+       /* Print whay we have found until now */
+       printf(" ("); 
+               ldns_rdf_print(stdout, chopped_dname[i]);
+       puts(")\n |");
+       resolver_print_nameservers(res);
+       puts("");
+       print_dnskey(dnskey_cache);
+       puts("");
+                       
+
        /* chopped_dname[i] is the zone which is configured at the
         * nameserver pointed to by res. This is our starting point
         * for the secure trace. Hopefully the trusted keys we got
         * match the keys we see here
         */
 
-printf("\nkeys\n");
-       ldns_rr_list_print(stdout, dnskey_cache);
-printf("\nsigs\n");
        if (!rrsig_cache) {
                /* huh!? the sigs must be sent along with the keys... 
                 * probably are using some lame forwarder... exit as
@@ -207,20 +209,14 @@ printf("\nsigs\n");
                }
        }
 
-       printf("key cache \n");
-       ldns_rr_list_print(stdout, dnskey_cache);
-       printf("ds_cache \n");
-       ldns_rr_list_print(stdout, ds_cache);
-       printf("sig cache \n");
-       ldns_rr_list_print(stdout, rrsig_cache);
+       print_dnskey(dnskey_cache);
+       print_ds(ds_cache);
 
        validated_ds = check_ds_key_equiv_rr_list(dnskey_cache, ds_cache); 
        if (validated_ds) {
-               ldns_rr_list_print(stdout, validated_ds);
+               print_ds(validated_ds);
        }
 
-       printf("\n");
-
        return LDNS_STATUS_OK;
 }
 
index 080b01990208181e4ac77bfe9398ba325c626f12..788202e740591b38cd70e8bf33257ffd2b7f143a 100644 (file)
@@ -843,23 +843,23 @@ ldns_rr2buffer_str(ldns_buffer *output, ldns_rr *rr)
                        switch (ldns_rr_get_type(rr)) {
                                case LDNS_RR_TYPE_DNSKEY:
                                        if (ldns_rdf2native_int16(ldns_rr_rdf(rr, 0)) == 256) {
-                                               ldns_buffer_printf(output, " ; {id = %d (zsk), size = %db}", 
+                                               ldns_buffer_printf(output, " ;{id = %d (zsk), size = %db}", 
                                                                ldns_calc_keytag(rr),
                                                                ldns_rr_dnskey_key_size(rr)); 
                                                break;
                                        } 
                                        if (ldns_rdf2native_int16(ldns_rr_rdf(rr, 0)) == 257) {
-                                               ldns_buffer_printf(output, " ; {id = %d (ksk), size = %db}", 
+                                               ldns_buffer_printf(output, " ;{id = %d (ksk), size = %db}", 
                                                                ldns_calc_keytag(rr),
                                                                ldns_rr_dnskey_key_size(rr)); 
                                                break;
                                        } 
-                                       ldns_buffer_printf(output, " ; {id = %d, size = %db}", 
+                                       ldns_buffer_printf(output, " ;{id = %d, size = %db}", 
                                                        ldns_calc_keytag(rr),
                                                        ldns_rr_dnskey_key_size(rr)); 
                                        break;
                                case LDNS_RR_TYPE_RRSIG:
-                                       ldns_buffer_printf(output, " ; {id = %d}", 
+                                       ldns_buffer_printf(output, " ;{id = %d}", 
                                                        ldns_rdf2native_int16(ldns_rr_rdf(rr, 6)));
                                                        break;
                                default: