/*
* Copyright (C) 2004, 2007, 2008, 2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2002 Internet Software Consortium.
*
* 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 ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC 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.
*/
/* $Id: lwtest.c,v 1.32 2008/04/02 02:37:42 marka Exp $ */
#include <config.h>
#include <assert.h>
#include <stdlib.h>
/*
* XXX getnameinfo errors, which don't appear to be standard.
*/
static int fails = 0;
static void
if (val != 0) {
exit(1);
}
}
static unsigned char TESTSTRING[] =
"This is a test. This is only a test. !!!";
static void
test_noop(void) {
/*
* Now, parse it into a new structure.
*/
lwres_buffer_first(&b);
nooprequest2 = NULL;
nooprequest.datalength) == 0);
b.length = 0;
/*
* Now, parse it into a new structure.
*/
lwres_buffer_first(&b);
noopresponse.datalength) == 0);
b.length = 0;
}
static void
{
unsigned int len;
&res);
fails++;
return;
}
if (ret == LWRES_R_SUCCESS) {
if (af == LWRES_ADDRTYPE_V4) {
len = 4;
} else {
len = 16;
}
fails++;
return;
}
break;
}
else
printf("I:gabn(%s) returned %s, expected %s\n",
fails++;
return;
}
}
}
static void
const char *name)
{
unsigned int len;
if (af == LWRES_ADDRTYPE_V4) {
len = 4;
} else {
len = 16;
}
fails++;
return;
}
printf("I:gnba(%s) returned %s, expected %s\n",
fails++;
return;
}
}
static void
int ret;
return;
else if (h_errno != HOST_NOT_FOUND) {
printf("I:gethostbyname(%s) failed: %s\n",
fails++;
return;
} else {
printf("I:gethostbyname(%s) returned not found\n",
name);
fails++;
return;
}
} else {
printf("I:gethostbyname(%s) returned %s, "
fails++;
return;
}
}
}
static void
return;
else if (h_errno != HOST_NOT_FOUND) {
printf("I:gethostbyname(%s) failed: %s\n",
fails++;
return;
} else {
printf("I:gethostbyname(%s) returned not found\n",
name);
fails++;
return;
}
} else {
len = 4;
else
len = 16;
printf("I:gethostbyname(%s) returned wrong family\n",
name);
fails++;
return;
}
{
printf("I:gethostbyname(%s) returned %s, "
fails++;
return;
}
}
}
static void
{
int error_num;
int flags = 0;
if (v4map)
flags |= AI_V4MAPPED;
if (all)
return;
else if (error_num != HOST_NOT_FOUND) {
printf("I:getipnodebyname(%s) failed: %d\n",
fails++;
return;
} else {
printf("I:getipnodebyname(%s) returned not found\n",
name);
fails++;
return;
}
} else {
len = 4;
else
len = 16;
printf("I:getipnodebyname(%s) returned wrong family\n",
name);
fails++;
return;
}
{
printf("I:getipnodebyname(%s) returned %s, "
fails++;
return;
}
}
}
static void
len = 4;
else
len = 16;
return;
else if (h_errno != HOST_NOT_FOUND) {
printf("I:gethostbyaddr(%s) failed: %s\n",
fails++;
return;
} else {
printf("I:gethostbyaddr(%s) returned not found\n",
address);
fails++;
return;
}
} else {
printf("I:gethostbyname(%s) returned %s, "
fails++;
return;
}
}
}
static void
int error_num;
len = 4;
else
len = 16;
return;
else if (error_num != HOST_NOT_FOUND) {
printf("I:getipnodebyaddr(%s) failed: %d\n",
fails++;
return;
} else {
printf("I:getipnodebyaddr(%s) returned not found\n",
address);
fails++;
return;
}
} else {
printf("I:getipnodebyaddr(%s) returned %s, "
fails++;
return;
}
}
}
static void
const char *address)
{
unsigned int len;
int ret;
} else {
if (v4ok)
else
}
if (ret != 0) {
return;
else if (ret != EAI_NODATA) {
printf("I:getaddrinfo(%s,%d,%d) failed: %s\n",
fails++;
return;
} else {
printf("I:getaddrinfo(%s,%d,%d) returned not found\n",
fails++;
return;
}
} else {
len = sizeof(struct sockaddr_in);
else
len = sizeof(struct sockaddr_in6);
printf("I:getaddrinfo(%s) returned wrong family\n",
name);
fails++;
return;
}
printf("I:getaddrinfo(%s) returned %lub, "
"expected %ub\n", name,
fails++;
return;
printf("I:getaddrinfo(%s) returned %s, "
fails++;
return;
}
} else {
{
printf("I:getaddrinfo(%s) returned %s, "
fails++;
return;
}
}
}
}
static void
int ret;
int salen;
#ifdef LWRES_PLATFORM_HAVESALEN
#endif
} else {
#ifdef LWRES_PLATFORM_HAVESALEN
#endif
}
if (ret != 0) {
return;
else if (ret != ENI_NOHOSTNAME) {
printf("I:getnameinfo(%s) failed: %d\n",
fails++;
return;
} else {
printf("I:getnameinfo(%s) returned not found\n",
address);
fails++;
return;
}
} else {
printf("I:getnameinfo(%s) returned %s, "
fails++;
return;
printf("I:getnameinfo(%s) returned %s, expected %s\n",
fails++;
return;
}
}
}
static void
int should_pass)
{
int ret;
fails++;
return;
} else if (ret == 0 && should_pass == 0) {
printf("I:getrrsetbyname(%s, %d) unexpectedly succeeded\n",
fails++;
return;
} else if (ret != 0)
return;
printf("I:getrrsetbyname(%s, %d): got %d rr, expected %d\n",
fails++;
}
printf("I:getrrsetbyname(%s, %d): got %d sig, expected %d\n",
fails++;
}
return;
}
int
main(void) {
lwres_udp_port = 9210;
test_noop();
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
"ipv4.example");
NULL);
test_gnba("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
test_gnba("0123:4567:89ab:cdef:0123:4567:89ab:cde0",
test_gnba("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
test_gnba("1123:4567:89ab:cdef:0123:4567:89ab:cde0",
test_gethostbyname2("b.example1.",
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
AF_INET6);
test_getipnodebyname("b.example1.",
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
AF_INET6, 0, 0);
test_getipnodebyname("a.example1.",
test_getipnodebyname("a.example1.",
test_getipnodebyname("b.example1.",
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
test_gethostbyaddr("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
AF_INET6, "ip6.int.example");
test_gethostbyaddr("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
AF_INET6, "ip6.arpa.example");
test_getipnodebyaddr("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
AF_INET6, "ip6.int.example");
test_getipnodebyaddr("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
AF_INET6, "ip6.arpa.example");
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff");
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff");
test_getnameinfo("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
AF_INET6, "ip6.int.example");
test_getnameinfo("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
AF_INET6, "ip6.arpa.example");
test_getnameinfo("1122:3344:5566:7788:99aa:bbcc:ddee:ff00",
AF_INET6, "dname.example1");
if (fails == 0)
printf("I:ok\n");
return (fails);
}