wire_test.c revision e5a56e1fd502d0c7e2fbde1ae3ff2e45df3775c7
/*
* 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/compress.h>
static void
printf("\n");
}
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);
}
static isc_uint16_t
isc_region_t r;
isc_buffer_remaining(buffer, &r);
if (r.length < 2) {
printf("not enough input\n");
exit(5);
}
return (isc_buffer_getuint16(buffer));
}
static unsigned int
unsigned char t[255];
unsigned char c[255];
isc_region_t r;
unsigned int current;
if (result == DNS_R_SUCCESS) {
dns_name_toregion(&name, &r);
print_wirename(&r);
printf("%u labels, %u bytes.\n",
r.length);
if (result == DNS_R_SUCCESS) {
isc_buffer_used(&text, &r);
} else
} else
}
int
char s[1000];
char *cp;
unsigned char *bp;
unsigned char b[255];
isc_region_t r;
int n;
FILE *f;
if (argc > 1) {
if (f == NULL) {
printf("fopen failed\n");
exit(1);
}
} else
f = stdin;
bp = b;
len--;
s[len] = '\0';
}
if (len == 0)
break;
if (len % 2 != 0) {
exit(1);
}
if (len > 510) {
printf("input too long\n");
exit(2);
}
cp = s;
for (i = 0; i < len; i += 2) {
n *= 16;
*bp++ = n;
}
}
if (need_close)
fclose(f);
if (ui > 1) {
printf("qdcount > 1 not supported\n");
exit(6);
}
if (ui == 0) {
printf("qdcount 0\n");
exit(6);
}
while (tc > 0) {
tc--;
ui *= 65536;
isc_buffer_remaining(&source, &r);
printf("unexpected end of rdata\n");
exit(7);
}
printf("rdata length mismatch\n");
exit(11);
}
} else
printf("\n");
}
isc_buffer_remaining(&source, &r);
if (r.length != 0)
printf("extra data at end of packet.\n");
return (0);
}