raw ip paket sendto error
JINMEI Tatuya / 神明達哉
jinmei at isl.rdc.toshiba.co.jp
Tue Apr 11 07:42:15 UTC 2006
>>>>> On Mon, 10 Apr 2006 11:40:46 +0200,
>>>>> Stefan <stefan at 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 at isl.rdc.toshiba.co.jp
More information about the freebsd-net
mailing list