From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 31 16:50:30 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B793D16A41A for ; Thu, 31 Jan 2008 16:50:30 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id 1AF4E13C448 for ; Thu, 31 Jan 2008 16:50:29 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id 6E0A22091; Thu, 31 Jan 2008 17:50:21 +0100 (CET) X-Spam-Tests: AWL X-Spam-Learn: disabled X-Spam-Score: -0.2/3.0 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on tim.des.no Received: from ds4.des.no (des.no [80.203.243.180]) by smtp.des.no (Postfix) with ESMTP id DEABD2090; Thu, 31 Jan 2008 17:50:20 +0100 (CET) Received: by ds4.des.no (Postfix, from userid 1001) id C3654844A0; Thu, 31 Jan 2008 17:50:20 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: "Heiko Wundram \(Beenic\)" References: <200801310923.16029.wundram@beenic.net> <86zlumvwob.fsf@ds4.des.no> <200801311701.49792.wundram@beenic.net> Date: Thu, 31 Jan 2008 17:50:20 +0100 In-Reply-To: <200801311701.49792.wundram@beenic.net> (Heiko Wundram's message of "Thu\, 31 Jan 2008 17\:01\:49 +0100") Message-ID: <86myqmvt0z.fsf@ds4.des.no> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: OT: getting the protocol family of a file descriptor X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jan 2008 16:50:30 -0000 "Heiko Wundram (Beenic)" writes: > Currently, you're basically required to do a getsockname to a struct > sockaddr_storage and typecast that to the actual socket addres type > based on the ss_family member (to be able to pass it to one of the > *_ntop-functions, for example), but generally, I don't find this too > beautiful. But, maybe, that's just my (horribly broken) taste. ;-) Uh, I'm pretty sure there's a function in the getaddr* family that will give you a string representation of any struct sockaddr. Actually, I'm absolutely sure of it: getnameinfo() with NI_NUMERICHOST|NI_NUMERICSERV will format the numerical address for you instead of looking it up in DNS. But what I really don't understand is this: you say you just want the address family so you'll know how to format the address. If you have the address, you already know the family. So what's the issue, really? DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no