From owner-freebsd-net@FreeBSD.ORG Tue Apr 11 07:42:15 2006 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7FE7616A401 for ; Tue, 11 Apr 2006 07:42:15 +0000 (UTC) (envelope-from jinmei@isl.rdc.toshiba.co.jp) Received: from shuttle.wide.toshiba.co.jp (shuttle.wide.toshiba.co.jp [202.249.10.124]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A8CA43D45 for ; Tue, 11 Apr 2006 07:42:15 +0000 (GMT) (envelope-from jinmei@isl.rdc.toshiba.co.jp) Received: from impact.jinmei.org (unknown [3ffe:501:100f:1010:6c5c:a64d:d15:fba5]) by shuttle.wide.toshiba.co.jp (Postfix) with ESMTP id 8A63015218; Tue, 11 Apr 2006 16:42:13 +0900 (JST) Date: Tue, 11 Apr 2006 16:42:13 +0900 Message-ID: From: JINMEI Tatuya / =?ISO-2022-JP?B?GyRCP0BMQEMjOkgbKEI=?= To: Stefan In-Reply-To: References: User-Agent: Wanderlust/2.14.0 (Africa) Emacs/21.3 Mule/5.0 (SAKAKI) Organization: Research & Development Center, Toshiba Corp., Kawasaki, Japan. MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: freebsd-net@freebsd.org Subject: Re: raw ip paket sendto error X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2006 07:42:15 -0000 >>>>> On Mon, 10 Apr 2006 11:40:46 +0200, >>>>> Stefan 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