From: Willem Toorop Date: Sun, 11 Sep 2011 21:38:03 +0000 (+0000) Subject: 1. Doxygen for printing and to text converting functions with ldns_output_format... X-Git-Tag: release-1.6.11rc1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59fdb9fb11733fed0d56b3b137258da9db667fe3;p=thirdparty%2Fldns.git 1. Doxygen for printing and to text converting functions with ldns_output_format specification (and inclusion in ldns_symbols.def), and 2. Extra functions to accomodate the construction of a hashed to unhashed name map (rbtree). Also, the usage of such a map to annotate NSEC3 RRs with the unhashed versions of their owner and next owner names in the comment section of a textual representation. Finalizes RT#539 and Bugzilla#366. --- diff --git a/dnssec_sign.c b/dnssec_sign.c index fcb1aae5..403831f5 100644 --- a/dnssec_sign.c +++ b/dnssec_sign.c @@ -765,14 +765,18 @@ ldns_dnssec_zone_create_nsecs(ldns_dnssec_zone *zone, } #ifdef HAVE_SSL +/* in dnssec_zone.c */ +extern int ldns_dname_compare_v(const void *a, const void *b); + ldns_status -ldns_dnssec_zone_create_nsec3s(ldns_dnssec_zone *zone, - ldns_rr_list *new_rrs, - uint8_t algorithm, - uint8_t flags, - uint16_t iterations, - uint8_t salt_length, - uint8_t *salt) +ldns_dnssec_zone_create_nsec3s_mkmap(ldns_dnssec_zone *zone, + ldns_rr_list *new_rrs, + uint8_t algorithm, + uint8_t flags, + uint16_t iterations, + uint8_t salt_length, + uint8_t *salt, + ldns_rbtree_t **map) { ldns_rbnode_t *first_name_node; ldns_rbnode_t *current_name_node; @@ -782,6 +786,7 @@ ldns_dnssec_zone_create_nsec3s(ldns_dnssec_zone *zone, ldns_rr_list *nsec3_list; uint32_t nsec_ttl; ldns_dnssec_rrsets *soa; + ldns_rbnode_t *hashmap_node; if (!zone || !new_rrs || !zone->names) { return LDNS_STATUS_ERR; @@ -802,6 +807,12 @@ ldns_dnssec_zone_create_nsec3s(ldns_dnssec_zone *zone, nsec_ttl = LDNS_DEFAULT_TTL; } + if (map) { + if ((*map = ldns_rbtree_create(ldns_dname_compare_v)) + == NULL) { + map = NULL; + }; + } nsec3_list = ldns_rr_list_new(); first_name_node = ldns_dnssec_name_node_next_nonglue( @@ -829,6 +840,17 @@ ldns_dnssec_zone_create_nsec3s(ldns_dnssec_zone *zone, result = ldns_dnssec_name_add_rr(current_name, nsec_rr); ldns_rr_list_push_rr(new_rrs, nsec_rr); ldns_rr_list_push_rr(nsec3_list, nsec_rr); + if (map) { + hashmap_node = LDNS_MALLOC(ldns_rbnode_t); + if (hashmap_node && ldns_rr_owner(nsec_rr)) { + hashmap_node->key = ldns_dname_label( + ldns_rr_owner(nsec_rr), 0); + if (hashmap_node->key) { + hashmap_node->data = current_name->name; + ldns_rbtree_insert(*map, hashmap_node); + } + } + } current_name_node = ldns_dnssec_name_node_next_nonglue( ldns_rbtree_next(current_name_node)); } @@ -845,6 +867,20 @@ ldns_dnssec_zone_create_nsec3s(ldns_dnssec_zone *zone, ldns_rr_list_free(nsec3_list); return result; } + +ldns_status +ldns_dnssec_zone_create_nsec3s(ldns_dnssec_zone *zone, + ldns_rr_list *new_rrs, + uint8_t algorithm, + uint8_t flags, + uint16_t iterations, + uint8_t salt_length, + uint8_t *salt) +{ + return ldns_dnssec_zone_create_nsec3s_mkmap(zone, new_rrs, algorithm, + flags, iterations, salt_length, salt, NULL); + +} #endif /* HAVE_SSL */ ldns_dnssec_rrs * @@ -1182,22 +1218,24 @@ ldns_dnssec_zone_sign_nsec3(ldns_dnssec_zone *zone, uint8_t salt_length, uint8_t *salt) { - return ldns_dnssec_zone_sign_nsec3_flg(zone, new_rrs, key_list, - func, arg, algorithm, flags, iterations, salt_length, salt, 0); + return ldns_dnssec_zone_sign_nsec3_flg_mkmap(zone, new_rrs, key_list, + func, arg, algorithm, flags, iterations, salt_length, salt, 0, + NULL); } ldns_status -ldns_dnssec_zone_sign_nsec3_flg(ldns_dnssec_zone *zone, - ldns_rr_list *new_rrs, - ldns_key_list *key_list, - int (*func)(ldns_rr *, void *), - void *arg, - uint8_t algorithm, - uint8_t flags, - uint16_t iterations, - uint8_t salt_length, - uint8_t *salt, - int signflags) +ldns_dnssec_zone_sign_nsec3_flg_mkmap(ldns_dnssec_zone *zone, + ldns_rr_list *new_rrs, + ldns_key_list *key_list, + int (*func)(ldns_rr *, void *), + void *arg, + uint8_t algorithm, + uint8_t flags, + uint16_t iterations, + uint8_t salt_length, + uint8_t *salt, + int signflags, + ldns_rbtree_t **map) { ldns_rr *nsec3, *nsec3param; ldns_status result = LDNS_STATUS_OK; @@ -1245,13 +1283,14 @@ ldns_dnssec_zone_sign_nsec3_flg(ldns_dnssec_zone *zone, } ldns_rr_list_push_rr(new_rrs, nsec3param); } - result = ldns_dnssec_zone_create_nsec3s(zone, + result = ldns_dnssec_zone_create_nsec3s_mkmap(zone, new_rrs, algorithm, flags, iterations, salt_length, - salt); + salt, + map); if (result != LDNS_STATUS_OK) { return result; } @@ -1268,6 +1307,23 @@ ldns_dnssec_zone_sign_nsec3_flg(ldns_dnssec_zone *zone, return result; } +ldns_status +ldns_dnssec_zone_sign_nsec3_flg(ldns_dnssec_zone *zone, + ldns_rr_list *new_rrs, + ldns_key_list *key_list, + int (*func)(ldns_rr *, void *), + void *arg, + uint8_t algorithm, + uint8_t flags, + uint16_t iterations, + uint8_t salt_length, + uint8_t *salt, + int signflags) +{ + return ldns_dnssec_zone_sign_nsec3_flg_mkmap(zone, new_rrs, key_list, + func, arg, algorithm, flags, iterations, salt_length, salt, + signflags, NULL); +} ldns_zone * ldns_zone_sign(const ldns_zone *zone, ldns_key_list *key_list) diff --git a/examples/ldns-signzone.c b/examples/ldns-signzone.c index 36c26ca6..486a0239 100644 --- a/examples/ldns-signzone.c +++ b/examples/ldns-signzone.c @@ -50,6 +50,8 @@ usage(FILE *fp, const char *prog) { fprintf(fp, "\t\t-t [number] number of hash iterations\n"); fprintf(fp, "\t\t-s [string] salt\n"); fprintf(fp, "\t\t-p set the opt-out flag on all nsec3 rrs\n"); + fprintf(fp, "\t\t-u include the unhashed NSEC3 names as comments " + "in the zone\n"); fprintf(fp, "\n"); fprintf(fp, " keys must be specified by their base name (usually K++),\n"); fprintf(fp, " i.e. WITHOUT the .private extension.\n"); @@ -376,6 +378,10 @@ main(int argc, char *argv[]) char *prog = strdup(argv[0]); ldns_status result; + + ldns_output_format fmt = { ldns_output_format_default->flags, NULL }; + ldns_rbtree_t **hashmap = NULL; + inception = 0; expiration = 0; @@ -384,7 +390,7 @@ main(int argc, char *argv[]) OPENSSL_config(NULL); - while ((c = getopt(argc, argv, "a:de:f:i:k:lno:ps:t:vAE:K:")) != -1) { + while ((c = getopt(argc, argv, "a:de:f:i:k:lno:ps:t:uvAE:K:")) != -1) { switch (c) { case 'a': nsec3_algorithm = (uint8_t) atoi(optarg); @@ -588,6 +594,10 @@ main(int argc, char *argv[]) } nsec3_iterations = (uint16_t) nsec3_iterations_cmd; break; + case 'u': + fmt.flags |= LDNS_COMMENT_NSEC3_CHAIN; + hashmap = (ldns_rbtree_t **)&fmt.data; + break; default: usage(stderr, prog); exit(EXIT_SUCCESS); @@ -754,7 +764,7 @@ main(int argc, char *argv[]) added_rrs = ldns_rr_list_new(); if (use_nsec3) { - result = ldns_dnssec_zone_sign_nsec3_flg(signed_zone, + result = ldns_dnssec_zone_sign_nsec3_flg_mkmap(signed_zone, added_rrs, keys, ldns_dnssec_default_replace_signatures, @@ -764,7 +774,8 @@ main(int argc, char *argv[]) nsec3_iterations, nsec3_salt_length, nsec3_salt, - signflags); + signflags, + hashmap); } else { result = ldns_dnssec_zone_sign_flg(signed_zone, added_rrs, @@ -792,7 +803,8 @@ main(int argc, char *argv[]) fprintf(stderr, "Unable to open %s for writing: %s\n", outputfile_name, strerror(errno)); } else { - ldns_dnssec_zone_print(outputfile, signed_zone); + ldns_dnssec_zone_print_fmt( + outputfile, &fmt, signed_zone); fclose(outputfile); } } diff --git a/host2str.c b/host2str.c index bf1ddf56..a8f9f6ce 100644 --- a/host2str.c +++ b/host2str.c @@ -1155,6 +1155,30 @@ ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf) return res; } +ldns_rdf * +ldns_b32_ext2dname(const ldns_rdf *rdf) +{ + size_t size; + char *b32; + ldns_rdf *out; + if(ldns_rdf_size(rdf) == 0) + return NULL; + /* remove -1 for the b32-hash-len octet */ + size = ldns_b32_ntop_calculate_size(ldns_rdf_size(rdf) - 1); + /* add one for the end nul for the string */ + b32 = LDNS_XMALLOC(char, size + 2); + if (b32 && ldns_b32_ntop_extended_hex(ldns_rdf_data(rdf) + 1, + ldns_rdf_size(rdf) - 1, b32, size+1) > 0) { + b32[size] = '.'; + b32[size+1] = '\0'; + if (ldns_str2rdf_dname(&out, b32) == LDNS_STATUS_OK) { + LDNS_FREE(b32); + return out; + } + LDNS_FREE(b32); + } + return NULL; +} ldns_status ldns_rr2buffer_str_fmt(ldns_buffer *output, @@ -1275,8 +1299,53 @@ ldns_rr2buffer_str_fmt(ldns_buffer *output, case LDNS_RR_TYPE_NSEC3: if ((fmt->flags & LDNS_COMMENT_FLAGS) && ldns_nsec3_optout(rr)) { - ldns_buffer_printf(output, " ; flags: optout"); + ldns_buffer_printf(output, + " ; flags: optout"); + } else if (fmt->flags + & LDNS_COMMENT_NSEC3_CHAIN) { + ldns_buffer_printf(output, " ;"); } + if (fmt->flags & LDNS_COMMENT_NSEC3_CHAIN + && fmt->data != NULL) { + ldns_rbnode_t *node; + ldns_rdf *key = ldns_dname_label( + ldns_rr_owner(rr), 0); + if (key) { + node = ldns_rbtree_search( + (ldns_rbtree_t *) + fmt->data, + (void *) key); + if (node->data) { + ldns_buffer_printf( + output, + " from: "); + ldns_rdf2buffer_str( + output, + (ldns_rdf *) + node->data); + } + ldns_rdf_free(key); + } + key = ldns_b32_ext2dname( + ldns_nsec3_next_owner(rr)); + if (key) { + node = ldns_rbtree_search( + (ldns_rbtree_t *) + fmt->data, + (void *) key); + if (node->data) { + ldns_buffer_printf( + output, + " to: "); + ldns_rdf2buffer_str( + output, + (ldns_rdf *) + node->data); + } + ldns_rdf_free(key); + } + } + break; default: break; diff --git a/ldns/dnssec_sign.h b/ldns/dnssec_sign.h index 2a622020..e77cb695 100644 --- a/ldns/dnssec_sign.h +++ b/ldns/dnssec_sign.h @@ -269,6 +269,40 @@ ldns_status ldns_dnssec_zone_sign_nsec3_flg(ldns_dnssec_zone *zone, uint8_t *salt, int signflags); +/** + * signs the given zone with the given new zone, with NSEC3 + * + * \param[in] zone the zone to sign + * \param[in] key_list the list of keys to sign the zone with + * \param[in] new_rrs newly created resource records are added to this list, to free them later + * \param[in] func callback function that decides what to do with old signatures + * \param[in] arg optional argument for the callback function + * \param[in] algorithm the NSEC3 hashing algorithm to use + * \param[in] flags NSEC3 flags + * \param[in] iterations the number of NSEC3 hash iterations to use + * \param[in] salt_length the length (in octets) of the NSEC3 salt + * \param[in] salt the NSEC3 salt data + * \param[in] signflags option flags for signing process. 0 is the default. + * \param[out] map a referenced rbtree pointer variable. The newly created + * rbtree will contain mappings from hashed owner names to the + * unhashed name. + * \return LDNS_STATUS_OK on success, an error code otherwise + */ +ldns_status ldns_dnssec_zone_sign_nsec3_flg_mkmap(ldns_dnssec_zone *zone, + ldns_rr_list *new_rrs, + ldns_key_list *key_list, + int (*func)(ldns_rr *, void *), + void *arg, + uint8_t algorithm, + uint8_t flags, + uint16_t iterations, + uint8_t salt_length, + uint8_t *salt, + int signflags, + ldns_rbtree_t **map + ); + + /** * signs the given zone with the given keys * diff --git a/ldns/dnssec_verify.h b/ldns/dnssec_verify.h index 992b1e7c..cfed9e60 100644 --- a/ldns/dnssec_verify.h +++ b/ldns/dnssec_verify.h @@ -56,6 +56,14 @@ void ldns_dnssec_data_chain_deep_free(ldns_dnssec_data_chain *chain); * \param[in] *chain The dnssec_data_chain to print */ void ldns_dnssec_data_chain_print(FILE *out, const ldns_dnssec_data_chain *chain); + +/** + * Prints the dnssec_data_chain to the given file stream + * + * \param[in] *out The file stream to print to + * \param[in] *fmt The format of the textual representation + * \param[in] *chain The dnssec_data_chain to print + */ void ldns_dnssec_data_chain_print_fmt(FILE *out, const ldns_output_format *fmt, const ldns_dnssec_data_chain *chain); @@ -165,6 +173,20 @@ void ldns_dnssec_trust_tree_print(FILE *out, ldns_dnssec_trust_tree *tree, size_t tabs, bool extended); + +/** + * Prints the dnssec_trust_tree structure to the given file + * stream. + * + * If a link status is not LDNS_STATUS_OK; the status and + * relevant signatures are printed too + * + * \param[in] *out The file stream to print to + * \param[in] *fmt The format of the textual representation + * \param[in] tree The trust tree to print + * \param[in] tabs Prepend each line with tabs*2 spaces + * \param[in] extended If true, add little explanation lines to the output + */ void ldns_dnssec_trust_tree_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_trust_tree *tree, diff --git a/ldns/dnssec_zone.h b/ldns/dnssec_zone.h index 8fcaba61..e2dd4029 100644 --- a/ldns/dnssec_zone.h +++ b/ldns/dnssec_zone.h @@ -135,6 +135,14 @@ ldns_status ldns_dnssec_rrs_add_rr(ldns_dnssec_rrs *rrs, ldns_rr *rr); * \param[in] rrs the list of RRs to print */ void ldns_dnssec_rrs_print(FILE *out, ldns_dnssec_rrs *rrs); + +/** + * Prints the given rrs to the file descriptor + * + * \param[in] out the file descriptor to print to + * \param[in] fmt the format of the textual representation + * \param[in] rrs the list of RRs to print + */ void ldns_dnssec_rrs_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_rrs *rrs); @@ -198,6 +206,15 @@ ldns_status ldns_dnssec_rrsets_add_rr(ldns_dnssec_rrsets *rrsets, ldns_rr *rr); void ldns_dnssec_rrsets_print(FILE *out, ldns_dnssec_rrsets *rrsets, bool follow); + +/** + * Print the given list of rrsets to the fiven file descriptor + * + * \param[in] out the file descriptor to print to + * \param[in] fmt the format of the textual representation + * \param[in] rrsets the list of RRsets to print + * \param[in] follow if set to false, only print the first RRset + */ void ldns_dnssec_rrsets_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_rrsets *rrsets, @@ -324,6 +341,15 @@ ldns_dnssec_rrsets *ldns_dnssec_zone_find_rrset(ldns_dnssec_zone *zone, * \param[in] name the name structure to print the contents of */ void ldns_dnssec_name_print(FILE *out, ldns_dnssec_name *name); + +/** + * Prints the RRs in the dnssec name structure to the given + * file descriptor + * + * \param[in] out the file descriptor to print to + * \param[in] fmt the format of the textual representation + * \param[in] name the name structure to print the contents of + */ void ldns_dnssec_name_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_name *name); @@ -368,6 +394,15 @@ ldns_status ldns_dnssec_zone_add_rr(ldns_dnssec_zone *zone, * \param[in] print_soa if true, print SOA records, if false, skip them */ void ldns_dnssec_zone_names_print(FILE *out, ldns_rbtree_t *tree, bool print_soa); + +/** + * Prints the rbtree of ldns_dnssec_name structures to the file descriptor + * + * \param[in] out the file descriptor to print the names to + * \param[in] fmt the format of the textual representation + * \param[in] tree the tree of ldns_dnssec_name structures to print + * \param[in] print_soa if true, print SOA records, if false, skip them + */ void ldns_dnssec_zone_names_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_rbtree_t *tree, bool print_soa); @@ -378,6 +413,14 @@ void ldns_dnssec_zone_names_print_fmt(FILE *out, const ldns_output_format *fmt, * \param[in] zone the dnssec_zone to print */ void ldns_dnssec_zone_print(FILE *out, ldns_dnssec_zone *zone); + +/** + * Prints the complete zone to the given file descriptor + * + * \param[in] out the file descriptor to print to + * \param[in] fmt the format of the textual representation + * \param[in] zone the dnssec_zone to print + */ void ldns_dnssec_zone_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_zone *zone); diff --git a/ldns/host2str.h b/ldns/host2str.h index 07f7c7b5..3b4fb7d3 100644 --- a/ldns/host2str.h +++ b/ldns/host2str.h @@ -39,27 +39,66 @@ extern "C" { #define LDNS_APL_MASK 0x7f #define LDNS_APL_NEGATION 0x80 +/** + * Represent a NULL pointer (in stead of a pointer to a ldns_rr as "; (null)" + * as opposed to outputting nothing at all in such a case. + */ #define LDNS_COMMENT_NULLS 0x01 +/** Show key id with DNSKEY RR's as comment */ #define LDNS_COMMENT_KEY_ID 0x02 +/** Show if a DNSKEY is a ZSK or KSK as comment */ #define LDNS_COMMENT_KEY_TYPE 0x04 +/** Show DNSKEY key size as comment */ #define LDNS_COMMENT_KEY_SIZE 0x08 +/** Show key id, type and size as comment for DNSKEY RR's */ #define LDNS_COMMENT_KEY (LDNS_COMMENT_KEY_ID \ |LDNS_COMMENT_KEY_TYPE\ |LDNS_COMMENT_KEY_SIZE) +/** Provide bubblebabble representation for DS RR's as comment */ #define LDNS_COMMENT_BUBBLEBABBLE 0x10 +/** Show when a NSEC3 RR has the optout flag set as comment */ #define LDNS_COMMENT_FLAGS 0x20 +/** Show the unhashed owner and next owner names for NSEC3 RR's as comment */ #define LDNS_COMMENT_NSEC3_CHAIN 0x40 +/** + * Output format specifier + * + * Determines how Packets, Resource Records and Resource record data fiels are + * formatted when printing or converting to string. + * Currently it is only used to specify what aspects of a Resource Record are + * annotated in the comment section of the textual representation the record. + * This is speciefed with flags and potential exra data (such as for example + * a lookup map of hashes to real names for annotation NSEC3 records). + */ struct ldns_struct_output_format { + /** Specification of how RR's should be formatted in text */ int flags; + /** Potential extra data to be used with formatting RR's in text */ void *data; }; typedef struct ldns_struct_output_format ldns_output_format; -extern const ldns_output_format *ldns_output_format_nocomments; -extern const ldns_output_format *ldns_output_format_onlykeyids; /* default */ +/** + * Standard output format record that disables commenting in the textual + * representation of Resource Records completely. + */ +extern const ldns_output_format *ldns_output_format_nocomments; +/** + * Standard output format record that annotated only DNSKEY RR's with commenti + * text. + */ +extern const ldns_output_format *ldns_output_format_onlykeyids; +/** + * The default output format record. Same as ldns_output_format_onlykeyids. + */ extern const ldns_output_format *ldns_output_format_default; +/** + * Standard output format record that shows all DNSKEY related information in + * the comment text, plus the optout flag when set with NSEC3's, plus the + * bubblebabble representation of DS RR's. + */ extern const ldns_output_format *ldns_output_format_bubblebabble; /** @@ -373,6 +412,18 @@ ldns_status ldns_rdf2buffer_str_tsig(ldns_buffer *output, const ldns_rdf *rdf); */ ldns_status ldns_rdf2buffer_str(ldns_buffer *output, const ldns_rdf *rdf); +/** + * Converts the data in the resource record to presentation + * format (as char *) and appends it to the given buffer. + * The presentation format of DNSKEY record is annotated with comments giving + * the id, type and size of the key. + * + * \param[in] output pointer to the buffer to append the data to + * \param[in] rr the pointer to the rr field to convert + * \return status + */ +ldns_status ldns_rr2buffer_str(ldns_buffer *output, const ldns_rr *rr); + /** * Converts the data in the resource record to presentation * format (as char *) and appends it to the given buffer. @@ -380,10 +431,11 @@ ldns_status ldns_rdf2buffer_str(ldns_buffer *output, const ldns_rdf *rdf); * additional information on the record. * * \param[in] output pointer to the buffer to append the data to + * \param[in] fmt how to format the textual representation of the + * resource record. * \param[in] rr the pointer to the rr field to convert * \return status */ -ldns_status ldns_rr2buffer_str(ldns_buffer *output, const ldns_rr *rr); ldns_status ldns_rr2buffer_str_fmt(ldns_buffer *output, const ldns_output_format *fmt, const ldns_rr *rr); @@ -396,6 +448,16 @@ ldns_status ldns_rr2buffer_str_fmt(ldns_buffer *output, * \return status */ ldns_status ldns_pkt2buffer_str(ldns_buffer *output, const ldns_pkt *pkt); + +/** + * Converts the data in the DNS packet to presentation + * format (as char *) and appends it to the given buffer + * + * \param[in] output pointer to the buffer to append the data to + * \param[in] fmt how to format the textual representation of the packet + * \param[in] pkt the pointer to the packet to convert + * \return status + */ ldns_status ldns_pkt2buffer_str_fmt(ldns_buffer *output, const ldns_output_format *fmt, const ldns_pkt *pkt); @@ -469,6 +531,16 @@ char *ldns_rdf2str(const ldns_rdf *rdf); * \return null terminated char * data, or NULL on error */ char *ldns_rr2str(const ldns_rr *rr); + +/** + * Converts the data in the resource record to presentation format and + * returns that as a char *. + * Remember to free it. + * + * \param[in] fmt how to format the resource record + * \param[in] rr The rdata field to convert + * \return null terminated char * data, or NULL on error + */ char *ldns_rr2str_fmt(const ldns_output_format *fmt, const ldns_rr *rr); /** @@ -480,6 +552,16 @@ char *ldns_rr2str_fmt(const ldns_output_format *fmt, const ldns_rr *rr); * \return null terminated char * data, or NULL on error */ char *ldns_pkt2str(const ldns_pkt *pkt); + +/** + * Converts the data in the DNS packet to presentation format and + * returns that as a char *. + * Remember to free it. + * + * \param[in] fmt how to format the packet + * \param[in] pkt The rdata field to convert + * \return null terminated char * data, or NULL on error + */ char *ldns_pkt2str_fmt(const ldns_output_format *fmt, const ldns_pkt *pkt); /** @@ -501,6 +583,16 @@ char *ldns_key2str(const ldns_key *k); * \return null terminated char * data, or NULL on error */ char *ldns_rr_list2str(const ldns_rr_list *rr_list); + +/** + * Converts a list of resource records to presentation format + * and returns that as a char *. + * Remember to free it. + * + * \param[in] fmt how to format the list of resource records + * \param[in] rr_list the rr_list to convert to text + * \return null terminated char * data, or NULL on error + */ char *ldns_rr_list2str_fmt( const ldns_output_format *fmt, const ldns_rr_list *rr_list); @@ -532,6 +624,16 @@ void ldns_rdf_print(FILE *output, const ldns_rdf *rdf); * \return void */ void ldns_rr_print(FILE *output, const ldns_rr *rr); + +/** + * Prints the data in the resource record to the given file stream + * (in presentation format) + * + * \param[in] output the file stream to print to + * \param[in] fmt format of the textual representation + * \param[in] rr the resource record to print + * \return void + */ void ldns_rr_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_rr *rr); @@ -544,6 +646,16 @@ void ldns_rr_print_fmt(FILE *output, * \return void */ void ldns_pkt_print(FILE *output, const ldns_pkt *pkt); + +/** + * Prints the data in the DNS packet to the given file stream + * (in presentation format) + * + * \param[in] output the file stream to print to + * \param[in] fmt format of the textual representation + * \param[in] pkt the packet to print + * \return void + */ void ldns_pkt_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_pkt *pkt); @@ -555,6 +667,15 @@ void ldns_pkt_print_fmt(FILE *output, * \return ldns_status */ ldns_status ldns_rr_list2buffer_str(ldns_buffer *output, const ldns_rr_list *list); + +/** + * Converts a rr_list to presentation format and appends it to + * the output buffer + * \param[in] output the buffer to append output to + * \param[in] fmt format of the textual representation + * \param[in] list the ldns_rr_list to print + * \return ldns_status + */ ldns_status ldns_rr_list2buffer_str_fmt(ldns_buffer *output, const ldns_output_format *fmt, const ldns_rr_list *list); @@ -569,10 +690,17 @@ ldns_status ldns_pktheader2buffer_str(ldns_buffer *output, const ldns_pkt *pkt); /** * print a rr_list to output - * param[in] output the fd to print to - * param[in] list the rr_list to print + * \param[in] output the fd to print to + * \param[in] list the rr_list to print */ void ldns_rr_list_print(FILE *output, const ldns_rr_list *list); + +/** + * print a rr_list to output + * \param[in] output the fd to print to + * \param[in] fmt format of the textual representation + * \param[in] list the rr_list to print + */ void ldns_rr_list_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_rr_list *list); @@ -583,6 +711,14 @@ void ldns_rr_list_print_fmt(FILE *output, * \param[in] r the resolver to print */ void ldns_resolver_print(FILE *output, const ldns_resolver *r); + +/** + * Print a resolver (in sofar that is possible) state + * to output. + * \param[in] output the fd to print to + * \param[in] fmt format of the textual representation + * \param[in] r the resolver to print + */ void ldns_resolver_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_resolver *r); @@ -593,6 +729,14 @@ void ldns_resolver_print_fmt(FILE *output, * \param[in] z the zone to print */ void ldns_zone_print(FILE *output, const ldns_zone *z); + +/** + * Print a zone structure * to output. Note the SOA record + * is included in this output + * \param[in] output the fd to print to + * \param[in] fmt format of the textual representation + * \param[in] z the zone to print + */ void ldns_zone_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_zone *z); diff --git a/ldns_symbols.def b/ldns_symbols.def index ef844a92..6503bd05 100644 --- a/ldns_symbols.def +++ b/ldns_symbols.def @@ -155,6 +155,7 @@ ldns_dnssec_zone_sign ldns_dnssec_zone_sign_flg ldns_dnssec_zone_sign_nsec3 ldns_dnssec_zone_sign_nsec3_flg +ldns_dnssec_zone_sign_nsec3_flg_mkmap ldns_ecdsa2pkey_raw ldns_edns_flags ldns_error_str @@ -311,6 +312,7 @@ ldns_pkt_nscount ldns_pkt_opcode2buffer_str ldns_pkt_opcode2str ldns_pkt_print +ldns_pkt_print_fmt ldns_pkt_push_rr ldns_pkt_push_rr_list ldns_pkt_qdcount @@ -473,6 +475,7 @@ ldns_resolver_pop_nameserver ldns_resolver_port ldns_resolver_prepare_query_pkt ldns_resolver_print +ldns_resolver_print_fmt ldns_resolver_push_dnssec_anchor ldns_resolver_push_nameserver ldns_resolver_push_nameserver_rr @@ -577,6 +580,7 @@ ldns_rr_list_pop_rr ldns_rr_list_pop_rr_list ldns_rr_list_pop_rrset ldns_rr_list_print +ldns_rr_list_print_fmt ldns_rr_list_push_rr ldns_rr_list_push_rr_list ldns_rr_list_rr @@ -599,6 +603,7 @@ ldns_rr_ns_nsdname ldns_rr_owner ldns_rr_pop_rdf ldns_rr_print +ldns_rr_print_fmt ldns_rr_push_rdf ldns_rr_rdata2buffer_wire ldns_rr_rd_count @@ -739,6 +744,7 @@ ldns_zone_new ldns_zone_new_frm_fp ldns_zone_new_frm_fp_l ldns_zone_print +ldns_zone_print_fmt ldns_zone_push_rr ldns_zone_push_rr_list ldns_zone_rr_count