From: Miek Gieben Date: Thu, 1 Dec 2005 11:31:16 +0000 (+0000) Subject: lint update. And more printing code added. It begins to resemble to go\'old resolver... X-Git-Tag: release-1.1.0~572 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3be45a4fd434274d7ffd8e8d8f5856a5b8af4db2;p=thirdparty%2Fldns.git lint update. And more printing code added. It begins to resemble to go\'old resolver.pl code --- diff --git a/drill/screen.c b/drill/screen.c index 29ccec09..6cba51b8 100644 --- a/drill/screen.c +++ b/drill/screen.c @@ -11,3 +11,74 @@ #include "drill.h" #include + +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); + } +} diff --git a/drill/securetrace.c b/drill/securetrace.c index 2d51e9cf..e5fa643c 100644 --- a/drill/securetrace.c +++ b/drill/securetrace.c @@ -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; } diff --git a/host2str.c b/host2str.c index 080b0199..788202e7 100644 --- a/host2str.c +++ b/host2str.c @@ -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: