Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Apr 2006 16:42:13 +0900
From:      JINMEI Tatuya / =?ISO-2022-JP?B?GyRCP0BMQEMjOkgbKEI=?= <jinmei@isl.rdc.toshiba.co.jp>
To:        Stefan <stefan@sf-net.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: raw ip paket sendto error
Message-ID:  <y7vslokk17u.wl%jinmei@isl.rdc.toshiba.co.jp>
In-Reply-To: <F8D644AB-76D0-49B6-A665-6B459A13F85D@sf-net.com>
References:  <F8D644AB-76D0-49B6-A665-6B459A13F85D@sf-net.com>

next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> On Mon, 10 Apr 2006 11:40:46 +0200, 
>>>>> Stefan <stefan@sf-net.com> said:

> I'm trying to port my little application to the FreeBSD-system and  
> encountered some difficults I can't solve. The program is running  
> fine on SunOS, OpenBSD, Mac OS X and Debian GNU/Linux so I thought it  
> should run fine on FreeBSD too. Maybe I forget something and you can  
> help me out?

> The first problem I had was at the function getaddrinfo. If I don't  
> submit a hints struct I get an error like this:
>   "servname not supported for ai_socktype"

> This is the source part where the error occured:

> if((getaddrinfoError = getaddrinfo(src_addr, src_port, NULL, &src_ai))
>         != 0) {
>          fprintf(stderr, "Error getaddrinfo (src address): %s\n",
>                  gai_strerror(getaddrinfoError));
>          exit(EXIT_FAILURE);
>      }

> When I changed it to use a hint like this:

> struct addrinfo hints;
> hints.ai_family = PF_UNSPEC;
> hints.ai_socktype = SOCK_DGRAM;
> hints.ai_flags = 0;
> hints.ai_protocol = 0;
> hints.ai_addrlen = 0;
> hints.ai_canonname = NULL;
> hints.ai_addr = NULL;
> hints.ai_next = NULL;

> The function runs fine like I expected. Why does this happen on  
> FreeBSD systems?

I guess in this case getaddrinfo() tried to match the specified
"service" (port) with a raw socket (for which there is no notion of
"service"), and returned an error.

BTW, when I tried the same test on Solaris 10 and OpenBSD 3.6 (and
NetBSD 2.0.1 for that matter), I saw the same error.  So, it seems the
current trend is to require a specific hint, and FreeBSD is not that
special.

					JINMEI, Tatuya
					Communication Platform Lab.
					Corporate R&D Center, Toshiba Corp.
					jinmei@isl.rdc.toshiba.co.jp



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?y7vslokk17u.wl%jinmei>