diff options
author | Yuri Pankov <yuri.pankov@nexenta.com> | 2018-07-22 14:29:51 +0300 |
---|---|---|
committer | Dan McDonald <danmcd@joyent.com> | 2018-07-30 15:28:50 -0400 |
commit | 8a7aa2a592747bd90d85645126d80688e024a0e2 (patch) | |
tree | 7a6c84d942a965d07c6eb294f47cae56848fa273 /usr/src/man/man3socket | |
parent | 7e3488dc6cdcb0c04e1ce167a1a3bfef83b5f2e0 (diff) | |
download | illumos-joyent-8a7aa2a592747bd90d85645126d80688e024a0e2.tar.gz |
9673 move internet address manipulation functions to libc
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/man/man3socket')
-rw-r--r-- | usr/src/man/man3socket/Makefile | 28 | ||||
-rw-r--r-- | usr/src/man/man3socket/getipnodebyname.3socket | 10 | ||||
-rw-r--r-- | usr/src/man/man3socket/inet.3socket | 330 | ||||
-rw-r--r-- | usr/src/man/man3socket/sockaddr.3socket | 4 |
4 files changed, 7 insertions, 365 deletions
diff --git a/usr/src/man/man3socket/Makefile b/usr/src/man/man3socket/Makefile index 5174020548..3422782a2a 100644 --- a/usr/src/man/man3socket/Makefile +++ b/usr/src/man/man3socket/Makefile @@ -11,15 +11,15 @@ # # Copyright 2011, Richard Lowe -# Copyright 2013 Nexenta Systems, Inc. All rights reserved. +# Copyright 2018 Nexenta Systems, Inc. # Copyright 2013, OmniTI Computer Consulting, Inc. # include $(SRC)/Makefile.master -MANSECT= 3socket +MANSECT= 3socket -MANFILES= accept.3socket \ +MANFILES= accept.3socket \ bind.3socket \ byteorder.3socket \ connect.3socket \ @@ -36,7 +36,6 @@ MANFILES= accept.3socket \ getsourcefilter.3socket \ icmp6_filter.3socket \ if_nametoindex.3socket \ - inet.3socket \ inet6_opt.3socket \ inet6_rth.3socket \ listen.3socket \ @@ -97,7 +96,6 @@ MANLINKS= accept4.3socket \ if_freenameindex.3socket \ if_indextoname.3socket \ if_nameindex.3socket \ - inet6.3socket \ inet6_opt_append.3socket \ inet6_opt_find.3socket \ inet6_opt_finish.3socket \ @@ -111,15 +109,6 @@ MANLINKS= accept4.3socket \ inet6_rth_reverse.3socket \ inet6_rth_segments.3socket \ inet6_rth_space.3socket \ - inet_addr.3socket \ - inet_aton.3socket \ - inet_lnaof.3socket \ - inet_makeaddr.3socket \ - inet_netof.3socket \ - inet_network.3socket \ - inet_ntoa.3socket \ - inet_ntop.3socket \ - inet_pton.3socket \ ntohl.3socket \ ntohll.3socket \ ntohs.3socket \ @@ -207,17 +196,6 @@ if_freenameindex.3socket := LINKSRC = if_nametoindex.3socket if_indextoname.3socket := LINKSRC = if_nametoindex.3socket if_nameindex.3socket := LINKSRC = if_nametoindex.3socket -inet6.3socket := LINKSRC = inet.3socket -inet_addr.3socket := LINKSRC = inet.3socket -inet_aton.3socket := LINKSRC = inet.3socket -inet_lnaof.3socket := LINKSRC = inet.3socket -inet_makeaddr.3socket := LINKSRC = inet.3socket -inet_netof.3socket := LINKSRC = inet.3socket -inet_network.3socket := LINKSRC = inet.3socket -inet_ntoa.3socket := LINKSRC = inet.3socket -inet_ntop.3socket := LINKSRC = inet.3socket -inet_pton.3socket := LINKSRC = inet.3socket - inet6_opt_append.3socket := LINKSRC = inet6_opt.3socket inet6_opt_find.3socket := LINKSRC = inet6_opt.3socket inet6_opt_finish.3socket := LINKSRC = inet6_opt.3socket diff --git a/usr/src/man/man3socket/getipnodebyname.3socket b/usr/src/man/man3socket/getipnodebyname.3socket index 9b68ea15ff..7eca1e3892 100644 --- a/usr/src/man/man3socket/getipnodebyname.3socket +++ b/usr/src/man/man3socket/getipnodebyname.3socket @@ -29,7 +29,6 @@ getipnodebyname, getipnodebyaddr, freehostent \- get IP node entry .fi .SH PARAMETERS -.sp .ne 2 .na \fB\fIaf\fR\fR @@ -93,7 +92,6 @@ Pointer to \fBhostent\fR structure .RE .SH DESCRIPTION -.sp .LP The \fBgetipnodebyname()\fR function searches the \fBipnodes\fR database from the beginning. The function finds the first \fBh_name\fR member that matches @@ -254,7 +252,7 @@ The special flags value, \fBAI_DEFAULT\fR, is defined as .LP The \fBgetipnodebyname()\fR function allows the \fIname\fR argument to be a node name or a literal address string: a dotted-decimal IPv4 address or an IPv6 -hex address. Applications do not have to call \fBinet_pton\fR(3SOCKET) to +hex address. Applications do not have to call \fBinet_pton\fR(3C) to handle literal address strings. .sp .LP @@ -310,7 +308,6 @@ terminated by a \fINULL\fR pointer. .RE .SH RETURN VALUES -.sp .LP Upon successful completion, \fBgetipnodebyname()\fR and \fBgetipnodebyaddr()\fR return a \fBhostent\fR structure. Otherwise they return \fINULL\fR. @@ -489,7 +486,6 @@ hostname. .in -2 .SH ATTRIBUTES -.sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -507,13 +503,11 @@ MT-Level Safe .TE .SH SEE ALSO -.sp .LP \fBgetaddrinfo\fR(3SOCKET), \fBgethostbyname\fR(3NSL), \fBhtonl\fR(3SOCKET), \fBinet\fR(3SOCKET), \fBnetdb.h\fR(3HEAD), \fBhosts\fR(4), \fBnsswitch.conf\fR(4), \fBattributes\fR(5) .SH NOTES -.sp .LP No enumeration functions are provided for IPv6. Existing enumeration functions such as \fBsethostent\fR(3NSL) do not work in combination with the @@ -544,6 +538,6 @@ addresses. The form for an address of type \fBAF_INET\fR is a \fBstruct in_addr\fR defined in <\fBnetinet/in.h\fR>. The form for an address of type \fBAF_INET6\fR is a \fBstruct in6_addr\fR, also defined in <\fBnetinet/in.h\fR>. The functions -described in \fBinet_ntop\fR(3SOCKET) and \fBinet_pton\fR(3SOCKET) that are +described in \fBinet_ntop\fR(3C) and \fBinet_pton\fR(3C) that are illustrated in the EXAMPLES section are helpful in constructing and manipulating addresses in either of these forms. diff --git a/usr/src/man/man3socket/inet.3socket b/usr/src/man/man3socket/inet.3socket deleted file mode 100644 index 818fb98fdd..0000000000 --- a/usr/src/man/man3socket/inet.3socket +++ /dev/null @@ -1,330 +0,0 @@ -'\" te -.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved -.\" Copyright 1989 AT&T -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH INET 3SOCKET "Nov 28, 2007" -.SH NAME -inet, inet6, inet_ntop, inet_pton, inet_aton, inet_addr, inet_network, -inet_makeaddr, inet_lnaof, inet_netof, inet_ntoa \- Internet address -manipulation -.SH SYNOPSIS -.LP -.nf -\fBcc\fR [ \fIflag\fR... ] \fIfile\fR... \fB-lsocket\fR \fB -lnsl \fR [ \fIlibrary\fR... ] -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> - -\fBconst char *\fR\fBinet_ntop\fR(\fBint\fR \fIaf\fR, \fBconst void *\fR\fIaddr\fR, \fBchar *\fR\fIcp\fR, - \fBsize_t\fR \fIsize\fR); -.fi - -.LP -.nf -\fBint\fR \fBinet_pton\fR(\fBint\fR \fIaf\fR, \fBconst char *\fR\fIcp\fR, \fBvoid *\fR\fIaddr\fR); -.fi - -.LP -.nf -\fBint\fR \fBinet_aton\fR(\fBconst char *\fR\fIcp\fR, \fBstruct in_addr *\fR\fIaddr\fR); -.fi - -.LP -.nf -\fBin_addr_t\fR \fBinet_addr\fR(\fBconst char *\fR\fIcp\fR); -.fi - -.LP -.nf -\fBin_addr_t\fR \fBinet_network\fR(\fBconst char *\fR\fIcp\fR); -.fi - -.LP -.nf -\fBstruct in_addr\fR \fBinet_makeaddr\fR(\fBconst int\fR \fInet\fR, \fBconst int\fR \fIlna\fR); -.fi - -.LP -.nf -\fBint\fR \fBinet_lnaof\fR(\fBconst struct in_addr\fR \fIin\fR); -.fi - -.LP -.nf -\fBint\fR \fBinet_netof\fR(\fBconst struct in_addr\fR \fIin\fR); -.fi - -.LP -.nf -\fBchar *\fR\fBinet_ntoa\fR(\fBconst struct in_addr\fR \fIin\fR); -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBinet_ntop()\fR and \fBinet_pton()\fR functions can manipulate both IPv4 -and IPv6 addresses. The \fBinet_aton()\fR, \fBinet_addr()\fR, -\fBinet_network()\fR, \fBinet_makeaddr()\fR, \fBinet_lnaof()\fR, -\fBinet_netof()\fR, and \fBinet_ntoa()\fR functions can only manipulate IPv4 -addresses. -.sp -.LP -The \fBinet_ntop()\fR function converts a numeric address into a string -suitable for presentation. The \fIaf\fR argument specifies the family of the -address which can be \fBAF_INET\fR or \fBAF_INET6\fR. The \fIaddr\fR argument -points to a buffer that holds an IPv4 address if the \fIaf\fR argument is -\fBAF_INET\fR. The \fIaddr\fR argument points to a buffer that holds an IPv6 -address if the \fIaf\fR argument is \fBAF_INET6\fR. The address must be in -network byte order. The \fIcp\fR argument points to a buffer where the function -stores the resulting string. The application must specify a non-\fINULL\fR -\fIcp\fR argument. The \fIsize\fR argument specifies the size of this buffer. -For IPv6 addresses, the buffer must be at least 46-octets. For IPv4 addresses, -the buffer must be at least 16-octets. To allow applications to easily declare -buffers of the proper size to store IPv4 and IPv6 addresses in string form, the -following two constants are defined in <\fBnetinet/in.h\fR>: -.sp -.in +2 -.nf -#define INET_ADDRSTRLEN 16 -#define INET6_ADDRSTRLEN 46 -.fi -.in -2 - -.sp -.LP -The \fBinet_pton()\fR function converts the standard text presentation form of -a function to the numeric binary form. The \fIaf\fR argument specifies the -family of the address. Currently, the \fBAF_INET\fR and \fBAF_INET6\fR address -families are supported. The \fIcp\fR argument points to the string being passed -in. The \fIaddr\fR argument points to a buffer where the function stores the -numeric address. The calling application must ensure that the buffer referred -to by \fIaddr\fR is large enough to hold the numeric address, at least 4 bytes -for \fBAF_INET\fR or 16 bytes for \fBAF_INET6\fR. -.sp -.LP -The \fBinet_aton()\fR, \fBinet_addr()\fR, and \fBinet_network()\fR functions -interpret character strings that represent numbers expressed in the IPv4 -standard '\fB\&.\fR' notation, returning numbers suitable for use as IPv4 -addresses and IPv4 network numbers, respectively. The \fBinet_makeaddr()\fR -function uses an IPv4 network number and a local network address to construct -an IPv4 address. The \fBinet_netof()\fR and \fBinet_lnaof()\fR functions break -apart IPv4 host addresses, then return the network number and local network -address, respectively. -.sp -.LP -The \fBinet_ntoa()\fR function returns a pointer to a string in the base 256 -notation \fBd.d.d.d\fR. See the following section on IPv4 addresses. -.sp -.LP -Internet addresses are returned in network order, bytes ordered from left to -right. Network numbers and local address parts are returned as machine format -integer values. -.SS "IPv6 Addresses" -.sp -.LP -There are three conventional forms for representing IPv6 addresses as strings: -.RS +4 -.TP -1. -The preferred form is \fBx:x:x:x:x:x:x:x\fR, where the 'x's are the -hexadecimal values of the eight 16-bit pieces of the address. For example: -.sp -.in +2 -.nf -1080:0:0:0:8:800:200C:417A -.fi -.in -2 - -It is not necessary to write the leading zeros in an individual field. There -must be at least one numeral in every field, except when the special syntax -described in the following is used. -.RE -.RS +4 -.TP -2. -It is common for addresses to contain long strings of zero bits in some -methods used to allocate certain IPv6 address styles. A special syntax is -available to compress the zeros. The use of "\fB::\fR" indicates multiple -groups of 16 bits of zeros. The \fB::\fR may only appear once in an address. -The \fB::\fR can also be used to compress the leading and trailing zeros in an -address. For example: -.sp -.in +2 -.nf -1080::8:800:200C:417A -.fi -.in -2 - -.RE -.RS +4 -.TP -3. -The alternative form \fBx:x:x:x:x:x:d.d.d.d\fR is sometimes more convenient -when dealing with a mixed environment of IPv4 and IPv6 nodes. The \fBx\fR's in -this form represent the hexadecimal values of the six high-order 16-bit pieces -of the address. The \fBd\fR's represent the decimal values of the four -low-order 8-bit pieces of the standard IPv4 address. For example: -.sp -.in +2 -.nf -::FFFF:129.144.52.38 -::129.144.52.38 -.fi -.in -2 - -The \fB::FFFF:d.d.d.d\fR and \fB::d.d.d.d\fR pieces are the general forms of an -IPv4-mapped IPv6 address and an IPv4-compatible IPv6 address. -.sp -The IPv4 portion must be in the \fBd.d.d.d\fR form. The following forms are -invalid: -.sp -.in +2 -.nf -::FFFF:d.d.d -::FFFF:d.d -::d.d.d -::d.d -.fi -.in -2 - -The \fB::FFFF:d\fR form is a valid but unconventional representation of the -IPv4-compatible IPv6 address \fB::255.255.0.d\fR. -.sp -The \fB::d\fR form corresponds to the general IPv6 address -\fB0:0:0:0:0:0:0:d\fR. -.RE -.SS "IPv4 Addresses" -.sp -.LP -Values specified using `\fB\&.\fR' notation take one of the following forms: -.sp -.in +2 -.nf -d.d.d.d -d.d.d -d.d -d -.fi -.in -2 - -.sp -.LP -When four parts are specified, each part is interpreted as a byte of data and -assigned from left to right to the four bytes of an IPv4 address. -.sp -.LP -When a three-part address is specified, the last part is interpreted as a -16-bit quantity and placed in the right most two bytes of the network address. -The three part address format is convenient for specifying Class B network -addresses such as \fB128.net.host\fR. -.sp -.LP -When a two-part address is supplied, the last part is interpreted as a 24-bit -quantity and placed in the right most three bytes of the network address. The -two part address format is convenient for specifying Class A network addresses -such as \fBnet.host\fR. -.sp -.LP -When only one part is given, the value is stored directly in the network -address without any byte rearrangement. -.sp -.LP -With the exception of \fBinet_pton()\fR, numbers supplied as \fIparts\fR -in '\fB\&.\fR' notation may be decimal, octal, or hexadecimal, as specified in C -language. For example, a leading \fB0x\fR or \fB0X\fR implies hexadecimal. A -leading \fB0\fR implies octal. Otherwise, the number is interpreted as decimal. -.sp -.LP -For IPv4 addresses, \fBinet_pton()\fR accepts only a string in standard IPv4 -dot notation: -.sp -.in +2 -.nf -d.d.d.d -.fi -.in -2 - -.sp -.LP -Each number has one to three digits with a decimal value between 0 and 255. -.sp -.LP -The \fBinet_addr()\fR function has been obsoleted by \fBinet_aton()\fR. -.SH RETURN VALUES -.sp -.LP -The \fBinet_aton()\fR function returns nonzero if the address is valid, \fB0\fR -if the address is invalid. -.sp -.LP -The \fBinet_ntop()\fR function returns a pointer to the buffer that contains a -string if the conversion succeeds. Otherwise, \fINULL\fR is returned. Upon -failure, \fIerrno\fR is set to \fBEAFNOSUPPORT\fR if the \fIaf\fR argument is -invalid or \fBENOSPC\fR if the size of the result buffer is inadequate. -.sp -.LP -The \fBinet_pton()\fR function returns \fB1\fR if the conversion succeeds, -\fB0\fR if the input is not a valid IPv4 dotted-decimal string or a valid IPv6 -address string. The function returns \fB-1\fR with \fIerrno\fR set to -\fBEAFNOSUPPORT\fR if the af argument is unknown. -.sp -.LP -The value \fBINADDR_NONE\fR, which is equivalent to \fB(in_addr_t)(-1)\fR, is -returned by \fBinet_addr()\fR and \fBinet_network()\fR for malformed requests. -.sp -.LP -The functions \fBinet_netof()\fR and \fBinet_lnaof()\fR break apart IPv4 host -addresses, returning the network number and local network address part, -respectively. -.sp -.LP -The function \fBinet_ntoa()\fR returns a pointer to a string in the base 256 -notation \fBd.d.d.d\fR, described in the section on IPv4 addresses. -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability See below. -_ -MT-Level Safe -.TE - -.sp -.LP -The \fBinet_ntop()\fR, \fBinet_pton()\fR, \fBinet_aton()\fR, \fBinet_addr()\fR, -and \fBinet_network()\fR functions are Committed. The \fBinet_lnaof()\fR, -\fBinet_makeaddr()\fR, \fBinet_netof()\fR, and \fBinet_network()\fR functions -are Committed (Obsolete). -.SH SEE ALSO -.sp -.LP -\fBgethostbyname\fR(3NSL), \fBgetipnodebyname\fR(3SOCKET), -\fBgetnetbyname\fR(3SOCKET), \fBinet.h\fR(3HEAD), \fBhosts\fR(4), -\fBnetworks\fR(4), \fBattributes\fR(5) -.SH NOTES -.sp -.LP -The return value from \fBinet_ntoa()\fR points to a buffer which is overwritten -on each call. This buffer is implemented as thread-specific data in -multithreaded applications. -.sp -.LP -IPv4-mapped addresses are not recommended. -.SH BUGS -.sp -.LP -The problem of host byte ordering versus network byte ordering is confusing. A -simple way to specify Class C network addresses in a manner similar to that for -Class B and Class A is needed. diff --git a/usr/src/man/man3socket/sockaddr.3socket b/usr/src/man/man3socket/sockaddr.3socket index 372721f461..740b80e4dd 100644 --- a/usr/src/man/man3socket/sockaddr.3socket +++ b/usr/src/man/man3socket/sockaddr.3socket @@ -206,7 +206,7 @@ The member is the four byte IPv4 address. It is also stored in network byte order. The common way to write out the address is to use the function -.Xr inet_pton 3SOCKET +.Xr inet_pton 3C which converts between a human readable IP address such as "10.1.2.3" and the corresponding representation. .Lp @@ -271,7 +271,7 @@ The member .Em sin6_addr describes the 16-byte IPv6 address. In addition to the function -.Xr inet_pton 3SOCKET , +.Xr inet_pton 3C , the header file .In netinet/in.h defines many macros for manipulating and testing IPv6 addresses. |