diff options
| author | guenther <> | 2014-04-19 11:18:01 +0000 |
|---|---|---|
| committer | guenther <> | 2014-04-19 11:18:01 +0000 |
| commit | d43e1f468c006866ad7261a6e699a0fe621ad9ba (patch) | |
| tree | 2d4d6567e4224e5b538d0c518319524895f5a922 /src/lib/libc/net/inet_ntop.3 | |
| parent | 97da5086f010911eda828f087392365d8bc6e1ff (diff) | |
| download | openbsd-d43e1f468c006866ad7261a6e699a0fe621ad9ba.tar.gz openbsd-d43e1f468c006866ad7261a6e699a0fe621ad9ba.tar.bz2 openbsd-d43e1f468c006866ad7261a6e699a0fe621ad9ba.zip | |
Split inet(3) into three pages by decade: 1980s -> inet_lnaof(3),
1990s -> inet_addr(3), 2000s and beyond -> inet_ntop(3).
ok tedu@ (who also noted the timeline) deraadt@ jmc@
Diffstat (limited to 'src/lib/libc/net/inet_ntop.3')
| -rw-r--r-- | src/lib/libc/net/inet_ntop.3 | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/src/lib/libc/net/inet_ntop.3 b/src/lib/libc/net/inet_ntop.3 new file mode 100644 index 0000000000..a5bd5076fe --- /dev/null +++ b/src/lib/libc/net/inet_ntop.3 | |||
| @@ -0,0 +1,204 @@ | |||
| 1 | .\" $OpenBSD: inet_ntop.3,v 1.1 2014/04/19 11:18:01 guenther Exp $ | ||
| 2 | .\" $NetBSD: inet.3,v 1.7 1997/06/18 02:25:24 lukem Exp $ | ||
| 3 | .\" | ||
| 4 | .\" Copyright (c) 1983, 1990, 1991, 1993 | ||
| 5 | .\" The Regents of the University of California. All rights reserved. | ||
| 6 | .\" | ||
| 7 | .\" Redistribution and use in source and binary forms, with or without | ||
| 8 | .\" modification, are permitted provided that the following conditions | ||
| 9 | .\" are met: | ||
| 10 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 11 | .\" notice, this list of conditions and the following disclaimer. | ||
| 12 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 14 | .\" documentation and/or other materials provided with the distribution. | ||
| 15 | .\" 3. Neither the name of the University nor the names of its contributors | ||
| 16 | .\" may be used to endorse or promote products derived from this software | ||
| 17 | .\" without specific prior written permission. | ||
| 18 | .\" | ||
| 19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 29 | .\" SUCH DAMAGE. | ||
| 30 | .\" | ||
| 31 | .\" @(#)inet.3 8.1 (Berkeley) 6/4/93 | ||
| 32 | .\" | ||
| 33 | .Dd $Mdocdate: April 19 2014 $ | ||
| 34 | .Dt INET_NTOP 3 | ||
| 35 | .Os | ||
| 36 | .Sh NAME | ||
| 37 | .Nm inet_ntop , | ||
| 38 | .Nm inet_pton | ||
| 39 | .Nd convert Internet addresses between presentation and network formats | ||
| 40 | .Sh SYNOPSIS | ||
| 41 | .In arpa/inet.h | ||
| 42 | .Ft const char * | ||
| 43 | .Fn inet_ntop "int af" "const void * restrict src" "char * restrict dst" "socklen_t size" | ||
| 44 | .Ft int | ||
| 45 | .Fn inet_pton "int af" "const char * restrict src" "void * restrict dst" | ||
| 46 | .Sh DESCRIPTION | ||
| 47 | The | ||
| 48 | .Fn inet_pton | ||
| 49 | function converts a presentation format address (that is, printable form | ||
| 50 | as held in a character string) to network format (usually a | ||
| 51 | .Li struct in_addr | ||
| 52 | or some other internal binary representation, in network byte order). | ||
| 53 | It returns 1 if the address was valid for the specified address family; | ||
| 54 | 0 if the address wasn't parseable in the specified address family; or \-1 | ||
| 55 | if some system error occurred (in which case | ||
| 56 | .Va errno | ||
| 57 | will have been set). | ||
| 58 | This function is presently valid for | ||
| 59 | .Dv AF_INET | ||
| 60 | and | ||
| 61 | .Dv AF_INET6 . | ||
| 62 | .Pp | ||
| 63 | The function | ||
| 64 | .Fn inet_ntop | ||
| 65 | converts an address from network format to presentation format. | ||
| 66 | It returns | ||
| 67 | .Dv NULL | ||
| 68 | if a system | ||
| 69 | error occurs (in which case, | ||
| 70 | .Va errno | ||
| 71 | will have been set), or it returns a pointer to the destination string. | ||
| 72 | .Pp | ||
| 73 | All Internet addresses are returned in network | ||
| 74 | order (bytes ordered from left to right). | ||
| 75 | .Sh INTERNET ADDRESSES (IP VERSION 4) | ||
| 76 | Values must be specified using the standard dot notation: | ||
| 77 | .Bd -literal -offset indent | ||
| 78 | a.b.c.d | ||
| 79 | .Ed | ||
| 80 | .Pp | ||
| 81 | All four parts must be decimal numbers between 0 and 255, inclusive. | ||
| 82 | .Sh INTERNET ADDRESSES (IP VERSION 6) | ||
| 83 | In order to support scoped IPv6 addresses, | ||
| 84 | .Xr getaddrinfo 3 | ||
| 85 | and | ||
| 86 | .Xr getnameinfo 3 | ||
| 87 | are recommended rather than the functions presented here. | ||
| 88 | .Pp | ||
| 89 | The presentation format of an IPv6 address is given in RFC 4291: | ||
| 90 | .Pp | ||
| 91 | There are three conventional forms for representing IPv6 addresses as | ||
| 92 | text strings: | ||
| 93 | .Bl -enum | ||
| 94 | .It | ||
| 95 | The preferred form is x:x:x:x:x:x:x:x, where the 'x's are the | ||
| 96 | hexadecimal values of the eight 16-bit pieces of the address. | ||
| 97 | Examples: | ||
| 98 | .Bd -literal -offset indent | ||
| 99 | FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 | ||
| 100 | 1080:0:0:0:8:800:200C:417A | ||
| 101 | .Ed | ||
| 102 | .Pp | ||
| 103 | Note that it is not necessary to write the leading zeros in an | ||
| 104 | individual field, but there must be at least one numeral in | ||
| 105 | every field (except for the case described in 2.). | ||
| 106 | .It | ||
| 107 | Due to the method of allocating certain styles of IPv6 | ||
| 108 | addresses, it will be common for addresses to contain long | ||
| 109 | strings of zero bits. | ||
| 110 | In order to make writing addresses | ||
| 111 | containing zero bits easier, a special syntax is available to | ||
| 112 | compress the zeros. | ||
| 113 | The use of | ||
| 114 | .Dq \&:\&: | ||
| 115 | indicates multiple groups | ||
| 116 | of 16 bits of zeros. | ||
| 117 | The | ||
| 118 | .Dq \&:\&: | ||
| 119 | can only appear once in an | ||
| 120 | address. | ||
| 121 | The | ||
| 122 | .Dq \&:\&: | ||
| 123 | can also be used to compress the leading and/or trailing zeros in an address. | ||
| 124 | .Pp | ||
| 125 | For example the following addresses: | ||
| 126 | .Bd -literal -offset indent | ||
| 127 | 1080:0:0:0:8:800:200C:417A a unicast address | ||
| 128 | FF01:0:0:0:0:0:0:43 a multicast address | ||
| 129 | 0:0:0:0:0:0:0:1 the loopback address | ||
| 130 | 0:0:0:0:0:0:0:0 the unspecified addresses | ||
| 131 | .Ed | ||
| 132 | .Pp | ||
| 133 | may be represented as: | ||
| 134 | .Bd -literal -offset indent | ||
| 135 | 1080::8:800:200C:417A a unicast address | ||
| 136 | FF01::43 a multicast address | ||
| 137 | ::1 the loopback address | ||
| 138 | :: the unspecified addresses | ||
| 139 | .Ed | ||
| 140 | .It | ||
| 141 | An alternative form that is sometimes more convenient when | ||
| 142 | dealing with a mixed environment of IPv4 and IPv6 nodes is | ||
| 143 | x:x:x:x:x:x:d.d.d.d, where the 'x's are the hexadecimal values | ||
| 144 | of the six high-order 16-bit pieces of the address, and the 'd's | ||
| 145 | are the decimal values of the four low-order 8-bit pieces of the | ||
| 146 | address (standard IPv4 representation). | ||
| 147 | Examples: | ||
| 148 | .Bd -literal -offset indent | ||
| 149 | 0:0:0:0:0:0:13.1.68.3 | ||
| 150 | 0:0:0:0:0:FFFF:129.144.52.38 | ||
| 151 | .Ed | ||
| 152 | .Pp | ||
| 153 | or in compressed form: | ||
| 154 | .Bd -literal -offset indent | ||
| 155 | ::13.1.68.3 | ||
| 156 | ::FFFF:129.144.52.38 | ||
| 157 | .Ed | ||
| 158 | .El | ||
| 159 | .Sh SEE ALSO | ||
| 160 | .Xr gethostbyname 3 , | ||
| 161 | .Xr inet_addr 3 , | ||
| 162 | .Xr inet_net 3 , | ||
| 163 | .Xr hosts 5 | ||
| 164 | .Sh STANDARDS | ||
| 165 | The | ||
| 166 | .Nm inet_ntop | ||
| 167 | and | ||
| 168 | .Nm inet_pton | ||
| 169 | functions conform to the IETF IPv6 BSD API and address formatting | ||
| 170 | specifications, as well as | ||
| 171 | .St -p1003.1-2008 . | ||
| 172 | .Sh HISTORY | ||
| 173 | The | ||
| 174 | .Nm inet_pton | ||
| 175 | and | ||
| 176 | .Nm inet_ntop | ||
| 177 | functions appeared in BIND 4.9.4. | ||
| 178 | .Sh CAVEATS | ||
| 179 | Note that | ||
| 180 | .Nm inet_pton | ||
| 181 | does not accept 1-, 2-, or 3-part dotted addresses; | ||
| 182 | all four parts must be specified and must be in decimal | ||
| 183 | (and not octal or hexadecimal). | ||
| 184 | This is a narrower input set than that accepted by | ||
| 185 | .Nm inet_aton . | ||
| 186 | .Pp | ||
| 187 | .Rs | ||
| 188 | .%A R. Gilligan | ||
| 189 | .%A S. Thomson | ||
| 190 | .%A J. Bound | ||
| 191 | .%A J. McCann | ||
| 192 | .%A W. Stevens | ||
| 193 | .%D February 2003 | ||
| 194 | .%R RFC 3493 | ||
| 195 | .%T Basic Socket Interface Extensions for IPv6 | ||
| 196 | .Re | ||
| 197 | .Pp | ||
| 198 | .Rs | ||
| 199 | .%A R. Hinden | ||
| 200 | .%A S. Deering | ||
| 201 | .%D February 2006 | ||
| 202 | .%R RFC 4291 | ||
| 203 | .%T IP Version 6 Addressing Architecture | ||
| 204 | .Re | ||
