2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

[master] use dns_message_totext() in wire_data

This commit is contained in:
Evan Hunt
2015-08-10 20:51:22 -07:00
parent f93884fcb7
commit 2a49f6bbfe
4 changed files with 36 additions and 246 deletions

View File

@@ -15,8 +15,6 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: wire_test.c,v 1.67 2007/06/19 23:46:59 tbox Exp $ */
#include <config.h>
#include <stdlib.h>
@@ -28,10 +26,9 @@
#include <isc/string.h>
#include <isc/util.h>
#include <dns/message.h>
#include <dns/result.h>
#include "printmsg.h"
int parseflags = 0;
isc_mem_t *mctx;
isc_boolean_t printmemstats = ISC_FALSE;
@@ -40,6 +37,9 @@ isc_boolean_t dorender = ISC_FALSE;
static void
process_message(isc_buffer_t *source);
static isc_result_t
printmessage(dns_message_t *msg);
static inline void
CHECKRESULT(isc_result_t result, const char *msg) {
if (result != ISC_R_SUCCESS) {
@@ -74,6 +74,36 @@ usage(void) {
fprintf(stderr, "\t-t\tTCP mode - ignore the first 2 bytes\n");
}
static isc_result_t
printmessage(dns_message_t *msg) {
isc_buffer_t b;
char *buf = NULL;
int len = 1024;
isc_result_t result = ISC_R_SUCCESS;
do {
buf = isc_mem_get(mctx, len);
if (buf == NULL) {
result = ISC_R_NOMEMORY;
break;
}
isc_buffer_init(&b, buf, len);
result = dns_message_totext(msg, &dns_master_style_debug,
0, &b);
if (result == ISC_R_NOSPACE) {
isc_mem_put(mctx, buf, len);
len *= 2;
} else if (result == ISC_R_SUCCESS)
printf("%.*s\n", (int) isc_buffer_usedlength(&b), buf);
} while (result == ISC_R_NOSPACE);
if (buf != NULL)
isc_mem_put(mctx, buf, len);
return (result);
}
int
main(int argc, char *argv[]) {
char *rp, *wp;