From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 12 23:30:39 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C7AE216A4CE for ; Thu, 12 Aug 2004 23:30:39 +0000 (GMT) Received: from rosebud.otenet.gr (rosebud.otenet.gr [195.170.0.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0707443D41 for ; Thu, 12 Aug 2004 23:30:39 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-b147.otenet.gr [212.205.244.155]) i7CNUHuM001392; Fri, 13 Aug 2004 02:30:29 +0300 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.1/8.13.1) with ESMTP id i7CNTAqv007553; Fri, 13 Aug 2004 02:29:10 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.13.1/8.13.1/Submit) id i7CNT2WU007548; Fri, 13 Aug 2004 02:29:02 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 13 Aug 2004 02:29:02 +0300 From: Giorgos Keramidas To: Nicolas B?rard Nault Message-ID: <20040812232902.GC7173@gothmog.gr> References: <4962.69.70.227.33.1092276363.squirrel@webmail.north-zone.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4962.69.70.227.33.1092276363.squirrel@webmail.north-zone.net> X-Mailman-Approved-At: Fri, 13 Aug 2004 11:54:49 +0000 cc: freebsd-hackers@freebsd.org Subject: Re: inet_ntop( ) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2004 23:30:39 -0000 On 2004-08-12 02:06, Nicolas B?rard Nault wrote: > > I wondered, why does inet_ntop() returns addresses in the format > x:x:x:x:x:x:x.x.x.x ? This can be very annoying if that's not what you > want. Is there another standard function, other than inet_ntop(), to do > the same work ? Can you show us a minimal program that exhibits this behavior? The function seems to work as expected here. The only case where the format you describe is used is with AF_INET6 addresses, which is not a bug AFAIK. For instance, the following program: #include #include #include #include #include #include #include #define BUFLEN 100 int main(void) { struct in_addr ia; char buf[BUFLEN]; ia.s_addr = htonl(0x7f000001); if (inet_ntop(AF_INET, &ia, buf, BUFLEN - 1) == NULL) err(1, "inet_ntop"); printf("inet: %s\n", buf); return EXIT_SUCCESS; } Prints the following output (note that the inet6 address output is probably an invalid address but still gets printed in the usual format): $ ./foo inet: 127.0.0.1 $ Are you sure you're calling inet_ntop() as you should? - Giorgos