summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorshin <shin@FreeBSD.org>2000-03-12 19:38:22 +0000
committershin <shin@FreeBSD.org>2000-03-12 19:38:22 +0000
commit602b08acfa43a3a2b7f9ca255f8d32ca7262c4f2 (patch)
treeffacdb2e55307bad2aac0a4cad6f3d1ebdf0aa46 /lib
parent12c8708cdb2fa8e7a2d5d5ffe85b4fbfd45f503c (diff)
downloadFreeBSD-src-602b08acfa43a3a2b7f9ca255f8d32ca7262c4f2.zip
FreeBSD-src-602b08acfa43a3a2b7f9ca255f8d32ca7262c4f2.tar.gz
Merge from NetBSD. Addition of inet_ntop() and inet_pton() description.
Specified by: Robert Muir <rmuir@looksharp.net> Obtained from: NetBSD
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/Makefile.inc5
-rw-r--r--lib/libc/net/inet.357
2 files changed, 60 insertions, 2 deletions
diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc
index 7080581..22c4010 100644
--- a/lib/libc/net/Makefile.inc
+++ b/lib/libc/net/Makefile.inc
@@ -55,8 +55,9 @@ MLINKS+=if_indextoname.3 if_nametoindex.3 if_indextoname.3 if_nameindex.3 \
if_indextoname.3 if_freenameindex.3
MLINKS+=inet.3 addr.3 inet.3 inet_addr.3 inet.3 inet_aton.3 \
inet.3 inet_lnaof.3 inet.3 inet_makeaddr.3 inet.3 inet_netof.3 \
- inet.3 inet_network.3 inet.3 inet_ntoa.3 inet.3 network.3 \
- inet.3 ntoa.3
+ inet.3 inet_network.3 inet.3 inet_ntoa.3 \
+ inet.3 inet_ntop.3 inet.3 inet_pton.3 \
+ inet.3 network.3 inet.3 ntoa.3
MLINKS+=inet6_option_space.3 inet6_option_alloc.3 \
inet6_option_space.3 inet6_option_append.3 \
inet6_option_space.3 inet6_option_find.3 \
diff --git a/lib/libc/net/inet.3 b/lib/libc/net/inet.3
index 629ab0f..f9941fc 100644
--- a/lib/libc/net/inet.3
+++ b/lib/libc/net/inet.3
@@ -40,6 +40,8 @@
.Nm inet_addr ,
.Nm inet_network ,
.Nm inet_ntoa ,
+.Nm inet_ntop ,
+.Nm inet_pton ,
.Nm inet_makeaddr ,
.Nm inet_lnaof ,
.Nm inet_netof
@@ -57,6 +59,10 @@
.Fn inet_network "const char *cp"
.Ft char *
.Fn inet_ntoa "struct in_addr in"
+.Ft const char *
+.Fn inet_ntop "int af" "const void *src" "char *dst" "size_t size"
+.Ft int
+.Fn inet_pton "int af" "const char *src" "void *dst"
.Ft struct in_addr
.Fn inet_makeaddr "unsigned long net" "unsigned long lna"
.Ft unsigned long
@@ -73,6 +79,23 @@ interpret character strings representing
numbers expressed in the Internet standard
.Ql \&.
notation.
+.Pp
+The
+.Fn inet_pton
+function converts a presentation format address (that is, printable form
+as held in a character string) to network format (usually a
+.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
+if some system error occurred (in which case
+.Va errno
+will have been set).
+This function is presently valid for
+.Dv AF_INET
+and
+.Dv AF_INET6 .
+.Pp
The
.Fn inet_aton
routine interprets the specified character string as an Internet address,
@@ -86,6 +109,21 @@ and
functions return numbers suitable for use
as Internet addresses and Internet network
numbers, respectively.
+.Pp
+The function
+.Fn inet_ntop
+converts an address from network format (usually a
+.Ft struct in_addr
+or some other binary form, in network byte order) to presentation format
+(suitable for external display purposes).
+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.
+This function is presently valid for
+.Dv AF_INET
+and
+.Dv AF_INET6 .
+.Pp
The routine
.Fn inet_ntoa
takes an Internet address and returns an
@@ -187,6 +225,25 @@ for malformed requests.
.Xr getnetent 3 ,
.Xr hosts 5 ,
.Xr networks 5
+.Rs
+.%R RFC
+.%N 2373
+.%D July 1998
+.%T "IP Version 6 Addressing Architecture"
+.Re
+.Sh STANDARDS
+The
+.Nm inet_ntop
+and
+.Nm inet_pton
+functions conform to
+.St -xns5.2d2.0 .
+Note that
+.Nm inet_pton
+does not accept 1-, 2-, or 3-part dotted addresses; all four parts
+must be specified.
+This is a narrower input set than that accepted by
+.Nm inet_aton .
.Sh HISTORY
These
functions appeared in
OpenPOWER on IntegriCloud