.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" SUCH DAMAGE.
.\"
.\" From: @(#)inet.3 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/net/inet.3,v 1.29 2004/07/02 23:52:11 ru Exp $
+.\" $FreeBSD: src/lib/libc/net/inet.3,v 1.36 2007/06/14 07:13:28 delphij Exp $
.\"
-.Dd June 14, 2004
+.Dd June 14, 2007
.Dt INET 3
.Os
.Sh NAME
-.Nm inet_aton ,
.Nm inet_addr ,
+.Nm inet_aton ,
+.Nm inet_lnaof ,
+.Nm inet_makeaddr ,
+.Nm inet_netof ,
.Nm inet_network ,
.Nm inet_ntoa ,
.Nm inet_ntop ,
-.Nm inet_pton ,
-.Nm inet_makeaddr ,
-.Nm inet_lnaof ,
-.Nm inet_netof
+.Nm inet_pton
.Nd Internet address manipulation routines
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
-.In netinet/in.h
.In arpa/inet.h
+.Ft in_addr_t
+.Fo inet_addr
+.Fa "const char *cp"
+.Fc
.Ft int
-.Fn inet_aton "const char *cp" "struct in_addr *pin"
+.Fo inet_aton
+.Fa "const char *cp"
+.Fa "struct in_addr *pin"
+.Fc
.Ft in_addr_t
-.Fn inet_addr "const char *cp"
+.Fo inet_lnaof
+.Fa "struct in_addr in"
+.Fc
+.Ft struct in_addr
+.Fo inet_makeaddr
+.Fa "in_addr_t net"
+.Fa "in_addr_t lna"
+.Fc
+.Ft in_addr_t
+.Fo inet_netof
+.Fa "struct in_addr in"
+.Fc
.Ft in_addr_t
-.Fn inet_network "const char *cp"
+.Fo inet_network
+.Fa "const char *cp"
+.Fc
.Ft char *
-.Fn inet_ntoa "struct in_addr in"
+.Fo inet_ntoa
+.Fa "struct in_addr in"
+.Fc
.Ft const char *
.Fo inet_ntop
.Fa "int af"
.Fa "socklen_t size"
.Fc
.Ft int
-.Fn inet_pton "int af" "const char * restrict src" "void * restrict dst"
-.Ft struct in_addr
-.Fn inet_makeaddr "in_addr_t net" "in_addr_t lna"
-.Ft in_addr_t
-.Fn inet_lnaof "struct in_addr in"
-.Ft in_addr_t
-.Fn inet_netof "struct in_addr in"
+.Fo inet_pton
+.Fa "int af"
+.Fa "const char * restrict src"
+.Fa "void * restrict dst"
+.Fc
.Sh DESCRIPTION
The routines
.Fn inet_aton ,
.Ft struct in_addr
or some other internal binary representation, in network byte order).
It returns 1 if the address was valid for the specified address family, or
-0 if the address wasn't parseable in the specified address family, or -1
+0 if the address was not parseable in the specified address family, or -1
if some system error occurred (in which case
.Va errno
will have been set).
.Fa size
argument specifies the size, in bytes, of the buffer
.Fa *dst .
+.Dv INET_ADDRSTRLEN
+and
+.Dv INET6_ADDRSTRLEN
+define the maximum size required to convert an address of the respective
+type.
It returns NULL if a system error occurs (in which case,
.Va errno
will have been set), or it returns a pointer to the destination string.
in the C language (i.e., a leading 0x or 0X implies
hexadecimal; otherwise, a leading 0 implies octal;
otherwise, the number is interpreted as decimal).
-.Pp
-The
-.Fn inet_aton
-and
-.Fn inet_ntoa
-functions are semi-deprecated in favor of the
-.Xr addr2ascii 3
-family.
-However, since those functions are not yet widely implemented,
-portable programs cannot rely on their presence and will continue
-to use the
-.Xr inet 3
-functions for some time.
.Sh DIAGNOSTICS
The constant
.Dv INADDR_NONE
.Fn inet_ntop
call fails if:
.Bl -tag -width Er
-.It Bq Er ENOSPC
-.Fa size
-was not large enough to store the presentation form of the address.
.It Bq Er EAFNOSUPPORT
.Fa *src
was not an
or
.Dv AF_INET6
family address.
+.It Bq Er ENOSPC
+.Fa size
+was not large enough to store the presentation form of the address.
.El
+.Sh LEGACY SYNOPSIS
+.Fd #include <sys/types.h>
+.Fd #include <sys/socket.h>
+.Fd #include <netinet/in.h>
+.Fd #include <arpa/inet.h>
+.Pp
+These include files are necessary for all functions.
.Sh SEE ALSO
-.Xr addr2ascii 3 ,
.Xr byteorder 3 ,
+.Xr getaddrinfo 3 ,
.Xr gethostbyname 3 ,
+.Xr getnameinfo 3 ,
.Xr getnetent 3 ,
.Xr inet_net 3 ,
.Xr hosts 5 ,
.Fn inet_ntoa
resides in a static memory area.
.Pp
-Inet_addr should return a
+The
+.Fn inet_addr
+function should return a
.Fa struct in_addr .