]>
Commit | Line | Data |
---|---|---|
5b2abdfb A |
1 | .\" $NetBSD: inet_net.3,v 1.4 1999/03/22 19:44:52 garbled Exp $ |
2 | .\" | |
3 | .\" Copyright (c) 1997 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | |
5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Luke Mewburn. | |
8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
15 | .\" notice, this list of conditions and the following disclaimer in the | |
16 | .\" documentation and/or other materials provided with the distribution. | |
17 | .\" 3. All advertising materials mentioning features or use of this software | |
18 | .\" must display the following acknowledgement: | |
19 | .\" This product includes software developed by the NetBSD | |
20 | .\" Foundation, Inc. and its contributors. | |
21 | .\" 4. Neither the name of The NetBSD Foundation nor the names of its | |
22 | .\" contributors may be used to endorse or promote products derived | |
23 | .\" from this software without specific prior written permission. | |
24 | .\" | |
25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | .\" POSSIBILITY OF SUCH DAMAGE. | |
36 | .\" | |
37 | .\" $FreeBSD: src/lib/libc/net/inet_net.3,v 1.1 2001/08/31 10:54:44 ru Exp $ | |
38 | .\" | |
39 | .Dd June 18, 1997 | |
40 | .Dt INET_NET 3 | |
41 | .Os | |
42 | .Sh NAME | |
43 | .Nm inet_net_ntop , | |
44 | .Nm inet_net_pton | |
45 | .Nd Internet network number manipulation routines | |
46 | .Sh LIBRARY | |
47 | .Lb libc | |
48 | .Sh SYNOPSIS | |
49 | .In sys/types.h | |
50 | .In sys/socket.h | |
51 | .In netinet/in.h | |
52 | .In arpa/inet.h | |
53 | .Ft char * | |
54 | .Fn inet_net_ntop "int af" "const void *src" "int bits" "char *dst" "size_t size" | |
55 | .Ft int | |
56 | .Fn inet_net_pton "int af" "const char *src" "void *dst" "size_t size" | |
57 | .Sh DESCRIPTION | |
58 | The | |
59 | .Fn inet_net_ntop | |
60 | function converts an Internet network number from network format (usually a | |
61 | .Vt "struct in_addr" | |
62 | or some other binary form, in network byte order) to CIDR presentation format | |
63 | (suitable for external display purposes). | |
64 | .Fa bits | |
65 | is the number of bits in | |
66 | .Fa src | |
67 | that are the network number. | |
68 | It returns | |
69 | .Dv NULL | |
70 | if a system error occurs (in which case, | |
71 | .Va errno | |
72 | will have been set), or it returns a pointer to the destination string. | |
73 | .Pp | |
74 | The | |
75 | .Fn inet_net_pton | |
76 | function converts a presentation format Internet network number (that is, | |
77 | printable form as held in a character string) to network format (usually a | |
78 | .Vt "struct in_addr" | |
79 | or some other internal binary representation, in network byte order). | |
80 | It returns the number of bits (either computed based on the class, or | |
81 | specified with /CIDR), or \-1 if a failure occurred | |
82 | (in which case | |
83 | .Va errno | |
84 | will have been set. | |
85 | It will be set to | |
86 | .Er ENOENT | |
87 | if the Internet network number was not valid). | |
88 | .Pp | |
89 | The only value for | |
90 | .Fa af | |
91 | currently supported is | |
92 | .Dv AF_INET . | |
93 | .Fa size | |
94 | is the size of the result buffer | |
95 | .Fa dst . | |
96 | .Pp | |
97 | .Sh NETWORK NUMBERS (IP VERSION 4) | |
98 | Internet network numbers may be specified in one of the following forms: | |
99 | .Bd -literal -offset indent | |
100 | a.b.c.d/bits | |
101 | a.b.c.d | |
102 | a.b.c | |
103 | a.b | |
104 | a | |
105 | .Ed | |
106 | .Pp | |
107 | When four parts are specified, each is interpreted | |
108 | as a byte of data and assigned, from left to right, | |
109 | to the four bytes of an Internet network number. | |
110 | Note | |
111 | that when an Internet network number is viewed as a 32-bit | |
112 | integer quantity on a system that uses little-endian | |
113 | byte order (such as the | |
114 | .Tn Intel 386 , 486 , | |
115 | and | |
116 | .Tn Pentium | |
117 | processors) the bytes referred to above appear as | |
118 | .Dq Li d.c.b.a . | |
119 | That is, little-endian bytes are ordered from right to left. | |
120 | .Pp | |
121 | When a three part number is specified, the last | |
122 | part is interpreted as a 16-bit quantity and placed | |
123 | in the rightmost two bytes of the Internet network number. | |
124 | This makes the three part number format convenient | |
125 | for specifying Class B network numbers as | |
126 | .Dq Li 128.net.host . | |
127 | .Pp | |
128 | When a two part number is supplied, the last part | |
129 | is interpreted as a 24-bit quantity and placed in | |
130 | the rightmost three bytes of the Internet network number. | |
131 | This makes the two part number format convenient | |
132 | for specifying Class A network numbers as | |
133 | .Dq Li net.host . | |
134 | .Pp | |
135 | When only one part is given, the value is stored | |
136 | directly in the Internet network number without any byte | |
137 | rearrangement. | |
138 | .Pp | |
139 | All numbers supplied as | |
140 | .Dq parts | |
141 | in a | |
142 | .Ql \&. | |
143 | notation | |
144 | may be decimal, octal, or hexadecimal, as specified | |
145 | in the C language (i.e., a leading 0x or 0X implies | |
146 | hexadecimal; otherwise, a leading 0 implies octal; | |
147 | otherwise, the number is interpreted as decimal). | |
148 | .Sh SEE ALSO | |
149 | .Xr byteorder 3 , | |
150 | .Xr inet 3 , | |
151 | .Xr networks 5 | |
152 | .Sh HISTORY | |
153 | The | |
154 | .Fn inet_net_ntop | |
155 | and | |
156 | .Fn inet_net_pton | |
157 | functions appeared in BIND 4.9.4. |