wire_test.c revision ddd035637d92035a0d9e2bc32a7e2c9cc8a99d3f
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include <config.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <isc/assertions.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/compress.h>
static inline void
{
if (result != DNS_R_SUCCESS) {
exit(1);
}
}
#ifdef NOISY
static void
printf("\n");
}
#endif
#ifndef NOMAIN
static int
fromhex(char c) {
if (c >= '0' && c <= '9')
return (c - '0');
else if (c >= 'a' && c <= 'f')
return (c - 'a' + 10);
else if (c >= 'A' && c <= 'F')
return (c - 'A' + 10);
printf("bad input format: %02x\n", c);
exit(3);
/* NOTREACHED */
}
#endif
static char *opcodetext[] = {
"QUERY",
"IQUERY",
"STATUS",
"RESERVED3",
"NOTIFY",
"UPDATE",
"RESERVED6",
"RESERVED7",
"RESERVED8",
"RESERVED9",
"RESERVED10",
"RESERVED11",
"RESERVED12",
"RESERVED13",
"RESERVED14",
"RESERVED15"
};
static char *rcodetext[] = {
"NOERROR",
"FORMERR",
"SERVFAIL",
"NXDOMAIN",
"NOTIMPL",
"REFUSED",
"YXDOMAIN",
"YXRRSET",
"NXRRSET",
"NOTAUTH",
"NOTZONE",
"RESERVED11",
"RESERVED12",
"RESERVED13",
"RESERVED14",
"RESERVED15"
};
static dns_result_t
{
isc_region_t r;
char t[1000];
if (sectionid == DNS_SECTION_QUESTION)
else
if (result == DNS_R_NOMORE)
return (DNS_R_SUCCESS);
else if (result != DNS_R_SUCCESS)
return (result);
for (;;) {
print_name = name;
&target);
if (result != DNS_R_SUCCESS)
return (result);
#ifdef USEINITALWS
if (first) {
print_name = &empty_name;
}
#endif
}
isc_buffer_used(&target, &r);
if (result == DNS_R_NOMORE)
break;
else if (result != DNS_R_SUCCESS)
return (result);
}
return (DNS_R_SUCCESS);
}
printf(";; ->>HEADER<<- opcode: %s, status: %s, id: %u\n",
printf(";; flags: ");
printf("qr");
}
}
}
}
}
printf("; QUERY: %u, ANSWER: %u, AUTHORITY: %u, ADDITIONAL: %u\n",
printf("; PSEUDOSECTIONS: OPT: %u, TSIG: %u\n",
if (result != DNS_R_SUCCESS)
return (result);
if (result != DNS_R_SUCCESS)
return (result);
if (result != DNS_R_SUCCESS)
return (result);
if (result != DNS_R_SUCCESS)
return (result);
if (result != DNS_R_SUCCESS)
return (result);
if (result != DNS_R_SUCCESS)
return (result);
return (result);
}
#ifndef NOMAIN
int
unsigned char *bp;
int n;
FILE *f;
unsigned char b[1000];
char s[1000];
if (argc > 1) {
if (f == NULL) {
printf("fopen failed\n");
exit(1);
}
} else
f = stdin;
bp = b;
rp = s;
wp = s;
len = 0;
while (*rp != '\0') {
len++;
}
rp++;
}
if (len == 0)
break;
if (len % 2 != 0) {
exit(1);
}
if (len > (sizeof b) * 2) {
printf("input too long\n");
exit(2);
}
rp = s;
for (i = 0; i < len; i += 2) {
n *= 16;
*bp++ = n;
}
}
if (need_close)
fclose(f);
/*
* XXXMLG
* Changing this here is a hack, and should not be done in reasonable
* application code, ever.
*/
memset(&b, 0, sizeof(b));
0, 0);
0, 0);
0, 0);
0, 0);
0, 0);
0, 0);
printf("\n");
return (0);
}
#endif /* !NOMAIN */