.\" SUCH DAMAGE.
.\"
.\" $ANA: addr2ascii.3,v 1.1 1996/06/13 18:41:46 wollman Exp $
-.\" $FreeBSD: src/lib/libc/net/addr2ascii.3,v 1.13 2002/12/19 09:40:22 ru Exp $
+.\" $FreeBSD: src/lib/libc/net/addr2ascii.3,v 1.17 2004/10/09 17:13:58 maxim Exp $
.\"
.Dd June 13, 1996
.Dt ADDR2ASCII 3
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
-.In sys/types.h
-.In netinet/in.h
.In arpa/inet.h
.Ft "char *"
.Fn addr2ascii "int af" "const void *addrp" "int len" "char *buf"
and
.Fn ascii2addr
are used to convert network addresses between binary form and a
-printable form appropriate to the address family. Both functions take
+printable form appropriate to the address family.
+Both functions take
an
.Fa af
argument, specifying the address family to be used in the conversion
.Fn addr2ascii
function
is used to convert binary, network-format addresses into printable
-form. In addition to
+form.
+In addition to
.Fa af ,
-there are three other arguments. The
+there are three other arguments.
+The
.Fa addrp
argument is a pointer to the network address to be converted.
The
.Fa len
-argument is the length of the address. The
+argument is the length of the address.
+The
.Fa buf
argument is an optional pointer to a caller-allocated buffer to hold
the result; if a null pointer is passed,
The
.Fa ascii
argument is a pointer to the string which is to be converted into
-binary. The
+binary.
+The
.Fa result
argument is a pointer to an appropriate network address structure for
the specified family.
.It Dv AF_INET
.Li struct in_addr
(in
-.Aq Pa netinet/in.h )
+.In arpa/inet.h )
.It Dv AF_LINK
.Li struct sockaddr_dl
(in
-.Aq Pa net/if_dl.h )
+.In net/if_dl.h )
.\" .It Dv AF_INET6
.\" .Li struct in6_addr
.\" (in
-.\" .Aq Pa netinet6/in6.h )
+.\" .In netinet6/in6.h )
.El
+.Pp
+.Dv AF_INET and AF_LINK constants are defined in
+.In sys/socket.h
.Sh RETURN VALUES
The
.Fn addr2ascii
.Fn inet_aton
could be implemented thusly:
.Bd -literal -offset indent
-#include <sys/types.h>
#include <sys/socket.h>
-#include <netinet/in.h>
#include <arpa/inet.h>
char *
.Xr inet 4
.Sh HISTORY
An interface close to this one was originally suggested by Craig
-Partridge. This particular interface originally appeared in the
+Partridge.
+This particular interface originally appeared in the
.Tn INRIA
.Tn IPv6
implementation.
.An Garrett A. Wollman ,
MIT Laboratory for Computer Science.
.Sh BUGS
-The original implementations supported IPv6. This support should
-eventually be resurrected. The
+The original implementations supported IPv6.
+This support should
+eventually be resurrected.
+The
.Tn NRL
implementation also included support for the
.Dv AF_ISO
.Dv AF_NS
address families.
.Pp
-The genericity of this interface is somewhat questionable. A truly
+The genericity of this interface is somewhat questionable.
+A truly
generic interface would provide a means for determining the length of
the buffer to be used so that it could be dynamically allocated, and
would always require a
.Dq Li "struct sockaddr"
-to hold the binary address. Unfortunately, this is incompatible with existing
-practice. This limitation means that a routine for printing network
+to hold the binary address.
+Unfortunately, this is incompatible with existing
+practice.
+This limitation means that a routine for printing network
addresses from arbitrary address families must still have internal
knowledge of the maximum buffer length needed and the appropriate part
of the address to use as the binary address.