This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: one more bug in getaddrinfo()


On Fri, 03 Sep 1999, Ulrich Drepper wrote:

> That's a very strange reasoning.  There is no wording in the internet
> draft specifying that all names must be returned.
Yes, but I thing that it should return all addresses and seems doing this
properly in 2.1.2:
[misiek@linstar M]$ host-all linstar.zsz2.starachowice.pl
Resolving ... linstar.zsz2.starachowice.pl
fqdn: linstar.zsz2.starachowice.pl      ip addr: 195.164.211.2
fqdn: linstar.zsz2.starachowice.pl      ip addr: 195.164.211.33
fqdn: linstar.ipv6.zsz2.starachowice.pl ip addr: 3ffe:902:12::10

But I found another bug in getaddrinfo() (tested on 2.1.2):
Testing: EAI_ADDRFAMILY
It should return:       Address family for hostname not supported (-9)
while returned:         Name or service not known (-2)

Testing: EAI_NODATA
It should return:       No address associated with hostname (-5)
while returned:         Name or service not known (-2)

Testing: EAI_FAMILY
EAI_FAMILY test passed !

Testing: EAI_SOCKTYPE
EAI_SOCKTYPE test failed !

Testing: EAI_SERVICE
EAI_SERVICE test failed !

on KAME this test almost all test passed (only EAI_ADDRFAMILY fails).

> -- 
> ---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
> Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
> Cygnus Solutions `--' drepper at cygnus.com   `------------------------

-- 
Arkadiusz Mi¶kiewicz        http://www.misiek.eu.org/
PLD/Linux [IPv6 enabled]       http://www.pld.org.pl/
/* $Id:$
 * getaddrinfo() tests - Arkadiusz Mi¶kiewicz <misiek@pld.org.pl> */

#include <stdio.h>
#include <sys/socket.h>
#include <netdb.h>

int main()
{

	int err;
	struct  addrinfo hints, *res0;

	printf("getaddrinfo() errors tests - Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>\n");
	printf("\nTesting: EAI_ADDRFAMILY\n");	
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_INET;
	hints.ai_socktype = SOCK_STREAM;
	/* ai_family = AF_INET but address is IPv6 */
	if ((err = getaddrinfo("3ffe:902:12::10", "0", &hints, &res0)) != 0) {
		if (err != EAI_ADDRFAMILY) {
			fprintf(stderr, "It should return:\t%s (%d)\n",
					gai_strerror(EAI_ADDRFAMILY), EAI_ADDRFAMILY);
			fprintf(stderr, "while returned:\t\t%s (%d)\n", gai_strerror(err), err);
		} else
			printf("EAI_ADDRFAMILY test passed !\n");
	} else {
		printf("EAI_ADDRFAMILY test failed !\n");
		freeaddrinfo(res0);
	}

	printf("\nTesting: EAI_NODATA\n");
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	/* zsz2.starachowice.pl is domain - only MX record available */
	if ((err = getaddrinfo("zsz2.starachowice.pl", "0", &hints, &res0)) != 0) {
		if (err != EAI_NODATA)
		{
			fprintf(stderr, "It should return:\t%s (%d)\n",
				gai_strerror(EAI_NODATA), EAI_NODATA);
			fprintf(stderr, "while returned:\t\t%s (%d)\n", gai_strerror(err), err);
		} else
			printf("EAI_NODATA test passed !\n");
	} else {
		printf("EAI_NODATA test failed !\n");
		freeaddrinfo(res0);
	}

	printf("\nTesting: EAI_FAMILY\n");
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = AF_IPX;
        hints.ai_socktype = SOCK_STREAM;
        /* ai_family is strange ;) unsupported family */
        if ((err = getaddrinfo(NULL, "100", &hints, &res0)) != 0) {
                if (err != EAI_FAMILY)
                {
                        fprintf(stderr, "It should return:\t%s (%d)\n",
                                gai_strerror(EAI_FAMILY), EAI_FAMILY);
                        fprintf(stderr, "while returned:\t\t%s (%d)\n", gai_strerror(err), err);
                } else
                        printf("EAI_FAMILY test passed !\n");
        } else {
		printf("EAI_FAMILY test failed !\n");
                freeaddrinfo(res0);
	}

	printf("\nTesting: EAI_SOCKTYPE\n");
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = AF_UNSPEC;
        hints.ai_socktype = 98765;
        /* ai_socktype have stupid value */
        if ((err = getaddrinfo(NULL, "100", &hints, &res0)) != 0) {
                if (err != EAI_SOCKTYPE)
                {
                        fprintf(stderr, "It should return:\t%s (%d)\n",
                                gai_strerror(EAI_SOCKTYPE), EAI_SOCKTYPE);
                        fprintf(stderr, "while returned:\t\t%s (%d)\n", gai_strerror(err), err);
                } else
                        printf("EAI_SOCKTYPE test passed !\n");
        } else {
		printf("EAI_SOCKTYPE test failed !\n");
                freeaddrinfo(res0);
	}

	printf("\nTesting: EAI_SERVICE\n");
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = AF_UNSPEC;
        hints.ai_socktype = SOCK_STREAM;
        /* SOCK_STREAM but UDP service (syslog) */
        if ((err = getaddrinfo(NULL, "514/udp", &hints, &res0)) != 0) {
                if (err != EAI_SERVICE)
                {
                        fprintf(stderr, "It should return:\t%s (%d)\n",
                                gai_strerror(EAI_SERVICE), EAI_SERVICE);
                        fprintf(stderr, "while returned:\t\t%s (%d)\n", gai_strerror(err), err);
                } else
                        printf("EAI_SERVICE test passed !\n");
        } else {
		printf("EAI_SERVICE test failed !\n");
                freeaddrinfo(res0);
	}

}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]