Date: Fri, 13 Aug 2004 02:29:02 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Nicolas B?rard Nault <nicobn@quebecbsd.org> Cc: freebsd-hackers@freebsd.org Subject: Re: inet_ntop( ) Message-ID: <20040812232902.GC7173@gothmog.gr> In-Reply-To: <4962.69.70.227.33.1092276363.squirrel@webmail.north-zone.net> References: <4962.69.70.227.33.1092276363.squirrel@webmail.north-zone.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2004-08-12 02:06, Nicolas B?rard Nault <nicobn@quebecbsd.org> 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 <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <err.h> #include <stdio.h> #include <stdlib.h> #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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040812232902.GC7173>