OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / draft / man3 / inet.3
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
4 .\" and Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
5 .\"     <mtk.manpages@gmail.com>
6 .\"
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
10 .\"
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
15 .\"
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein.  The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
22 .\" professionally.
23 .\"
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
26 .\"
27 .\" References consulted:
28 .\"     Linux libc source code
29 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
30 .\"     386BSD man pages
31 .\"     libc.info (from glibc distribution)
32 .\" Modified Sat Jul 24 19:12:00 1993 by Rik Faith <faith@cs.unc.edu>
33 .\" Modified Sun Sep  3 20:29:36 1995 by Jim Van Zandt <jrv@vanzandt.mv.com>
34 .\" Changed network into host byte order (for inet_network),
35 .\"     Andreas Jaeger <aj@arthur.rhein-neckar.de>, 980130.
36 .\" 2008-06-19, mtk
37 .\"     Describe the various address forms supported by inet_aton().
38 .\"     Clarify discussion of inet_lnaof(), inet_netof(), and inet_makeaddr().
39 .\"     Add discussion of Classful Addressing, noting that it is obsolete.
40 .\"     Added an EXAMPLE program.
41 .\"
42 .\" Japanese Version Copyright (c) 1998 Ueyama Rui
43 .\"         all rights reserved.
44 .\" Translated 1998-05-23, Ueyama Rui <rui@linux.or.jp>
45 .\" Updated & Modefied 1999-02-26, Shouichi Saito
46 .\" Updated 1999-12-26, Kentaro Shirakata <argrath@ub32.org>
47 .\" Updated 2005-10-04, Kentaro Shirakata <argrath@ub32.org>
48 .\" Updated 2007-05-01, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.46
49 .\" Updated 2008-08-13, Akihiro MOTOKI, LDP v3.05
50 .\"
51 .\"WORD:        numbers-and-dots notation       ¿ôÃͤȥɥåȤˤè¤ëµ­Ë¡
52 .\"WORD:        dotted-decimal notation ¥É¥Ã¥È¶èÀÚ¤ê¤Î 10 ¿Ê¿ôµ­Ë¡
53 .\"WORD:        feature test macro      µ¡Ç½¸¡ºº¥Þ¥¯¥í
54 .\"
55 .TH INET 3  2008-06-19 "GNU" "Linux Programmer's Manual"
56 .\"O .SH NAME
57 .SH Ì¾Á°
58 .\"O inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof,
59 .\"O inet_netof \- Internet address manipulation routines
60 inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof,
61 inet_netof \- ¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥¢¥É¥ì¥¹Áàºî¥ë¡¼¥Á¥ó
62 .\"O .SH SYNOPSIS
63 .SH ½ñ¼°
64 .nf
65 .B #include <sys/socket.h>
66 .B #include <netinet/in.h>
67 .B #include <arpa/inet.h>
68 .sp
69 .BI "int inet_aton(const char *" cp ", struct in_addr *" inp );
70 .sp
71 .BI "in_addr_t inet_addr(const char *" cp );
72 .sp
73 .BI "in_addr_t inet_network(const char *" cp );
74 .sp
75 .BI "char *inet_ntoa(struct in_addr " in );
76 .sp
77 .BI "struct in_addr inet_makeaddr(int " net ", int " host );
78 .sp
79 .BI "in_addr_t inet_lnaof(struct in_addr " in );
80 .sp
81 .BI "in_addr_t inet_netof(struct in_addr " in );
82 .fi
83 .sp
84 .in -4n
85 .\"O Feature Test Macro Requirements for glibc (see
86 .\"O .BR feature_test_macros (7)):
87 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
88 .RB ( feature_test_macros (7)
89 »²¾È):
90 .in
91 .sp
92 .BR inet_aton (),
93 .BR inet_ntoa ():
94 _BSD_SOURCE || _SVID_SOURCE
95 .\"O .SH DESCRIPTION
96 .SH ÀâÌÀ
97 .\"O .BR inet_aton ()
98 .\"O converts the Internet host address \fIcp\fP from the
99 .\"O IPv4 numbers-and-dots notation into binary form (in network byte order)
100 .\"O and stores it in the structure that \fIinp\fP points to.
101 .\"O .BR inet_aton ()
102 .\"O returns nonzero if the address is valid, zero if not.
103 .\"O The address supplied in
104 .\"O .I cp
105 .\"O can have one of the following forms:
106 .BR inet_aton ()
107 ¤Ï¡¢¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥Û¥¹¥È¤Î¥¢¥É¥ì¥¹ \fIcp\fP ¤ò¡¢
108 IPv4 ¤Î¿ôÃͤȥɥåȤˤè¤ëɽµ­¤«¤é (¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Î) ¥Ð¥¤¥Ê¥êÃͤØ
109 ÊÑ´¹¤·¡¢ÊÑ´¹·ë²Ì¤ò \fIinp\fP ¤¬»Ø¤·¤Æ¤¤¤ë¹½Â¤ÂΤ˳ÊǼ¤¹¤ë¡£
110 ¥¢¥É¥ì¥¹¤¬Í­¸ú¤Ê¾ì¹ç 0 °Ê³°¤òÊÖ¤·¡¢¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ï 0 ¤òÊÖ¤¹¡£
111 .I cp
112 ¤ÇÅϤ¹¥¢¥É¥ì¥¹¤È¤·¤Æ¡¢°Ê²¼¤Î·Á¼°¤òÍѤ¤¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
113 .TP 10
114 .I a.b.c.d
115 .\"O Each of the four numeric parts specifies a byte of the address;
116 .\"O the bytes are assigned in left-to-right order to produce the binary address.
117 4 ¤Ä¤Î¿ô»ú¤Î¤½¤ì¤¾¤ì¤Ï¥¢¥É¥ì¥¹¤Î³Æ¥Ð¥¤¥È¤ò¼¨¤¹¡£
118 ¤³¤ì¤é¤Î¥Ð¥¤¥È¤Ïº¸¤«¤é±¦¤Î½ç½ø¤Ç¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤Ë³ä¤êÅö¤Æ¤é¤ì¤ë¡£
119 .TP
120 .I a.b.c
121 .\"O Parts
122 .\"O .I a
123 .\"O and
124 .\"O .I b
125 .\"O specify the first two bytes of the binary address.
126 .\"O Part
127 .\"O .I c
128 .\"O is interpreted as a 16-bit value that defines the rightmost two bytes
129 .\"O of the binary address.
130 .\"O This notation is suitable for specifying (outmoded) Class B
131 .\"O network addresses.
132 .I a
133 ¤È
134 .I b
135 ¤Ï¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤ÎºÇ½é¤Î 2 ¥Ð¥¤¥È¤ò¼¨¤¹¡£
136 .I c
137 ¤Ï 16 ¥Ó¥Ã¥ÈÃͤȲò¼á¤µ¤ì¡¢¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤Î±¦Â¦¤Î 2 ¥Ð¥¤¥È¤òɽ¤¹¡£
138 ¤³¤Îɽµ­¤Ï¡¢(²áµî¤Î¤â¤Î¤È¤Ê¤Ã¤¿) ¥¯¥é¥¹ B ¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤ò
139 »ØÄꤹ¤ë¤Î¤ËŬ¤·¤Æ¤¤¤ë¡£
140 .TP
141 .I a.b
142 .\"O Part
143 .\"O .I a
144 .\"O specifies the first byte of the binary address.
145 .\"O Part
146 .\"O .I b
147 .\"O is interpreted as a 24-bit value that defines the rightmost three bytes
148 .\"O of the binary address.
149 .\"O This notation is suitable for specifying (outmoded) Class C
150 .\"O network addresses.
151 .I a
152 ¤Ï¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤ÎºÇ½é¤Î¥Ð¥¤¥È¤ò¼¨¤¹¡£
153 .I b
154 ¤Ï 24 ¥Ó¥Ã¥ÈÃͤȲò¼á¤µ¤ì¡¢¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤Î±¦Â¦¤Î 3 ¥Ð¥¤¥È¤òɽ¤¹¡£
155 ¤³¤Îɽµ­¤Ï¡¢(²áµî¤Î¤â¤Î¤È¤Ê¤Ã¤¿) ¥¯¥é¥¹ C ¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤ò
156 »ØÄꤹ¤ë¤Î¤ËŬ¤·¤Æ¤¤¤ë¡£
157 .TP
158 .I a
159 .\"O The value
160 .\"O .I a
161 .\"O is interpreted as a 32-bit value that is stored directly
162 .\"O into the binary address without any byte rearrangement.
163 ÃÍ
164 .I a
165 ¤Ï 32 ¥Ó¥Ã¥ÈÃͤȲò¼á¤µ¤ì¡¢¥Ð¥¤¥È¤ÎºÆÇÛÃ֤ϹԤï¤ì¤º¡¢
166 ¤½¤Î¤Þ¤Þ¥Ð¥¤¥Ê¥ê¥¢¥É¥ì¥¹¤È¤·¤Æ³ÊǼ¤µ¤ì¤ë¡£
167 .PP
168 .\"O In all of the above forms,
169 .\"O components of the dotted address can be specified in decimal,
170 .\"O octal (with a leading
171 .\"O .IR 0 ),
172 .\"O or hexadecimal, with a leading
173 .\"O .IR 0X ).
174 .\"O Addresses in any of these forms are collectively termed
175 .\"O .IR "IPV4 numbers-and-dots notation" .
176 .\"O The form that uses exactly four decimal numbers is referred to as
177 .\"O .IR "IPv4 dotted-decimal notation"
178 .\"O (or sometimes:
179 .\"O .IR "IPv4 dotted-quad notation" ).
180 ¾åµ­¤ÎÁ´¤Æ¤Î·Á¼°¤Ç¡¢¥É¥Ã¥È¶èÀÚ¤ê¤Î¥¢¥É¥ì¥¹¤Î³ÆÍ×ÁǤϡ¢10 ¿Ê¿ô¡¢
181 8 ¿Ê¿ô (ÀèƬ¤Ë
182 .I 0
183 ¤òÉÕ¤±¤ë)¡¢
184 16 ¿Ê¿ô (ÀèƬ¤Ë
185 .I 0X
186 ¤òÉÕ¤±¤ë) ¤Ç»ØÄê¤Ç¤­¤ë¡£
187 ¤³¤ì¤é¤Î·Á¼°¤Î¥¢¥É¥ì¥¹¤ò¤Þ¤È¤á¤Æ
188 .I "IPv4 ¤Î¿ôÃͤȥɥåȤˤè¤ëɽµ­ (IPv4 numbers-and-dots notation)"
189 ¤È¸Æ¤Ö¡£
190 ¤Þ¤¿¡¢10 ¿Ê¿ô 4 ¤Ä¤À¤±¤ò»È¤Ã¤¿·Á¼°¤ò
191 .I "IPv4 ¤Î¥É¥Ã¥È¶èÀÚ¤ê¤Î 10 ¿Ê¿ôɽµ­ (IPv4 dotted-decimal notation)"
192 ¤È¸Æ¤Ö
193 .RI ( "IPv4 ¤Î¥É¥Ã¥È¶èÀÚ¤ê 4 Ê¬³äɽµ­ (IPv4 dotted-decimal notation)"
194 ¤È¸Æ¤Ö¤³¤È¤â¤¢¤ë)¡£
195 .PP
196 .\"O The
197 .\"O .BR inet_addr ()
198 .\"O function converts the Internet host address
199 .\"O \fIcp\fP from IPv4 numbers-and-dots notation into binary data in network
200 .\"O byte order.
201 .\"O If the input is invalid,
202 .\"O .B INADDR_NONE
203 .\"O (usually \-1) is returned.
204 .\"O Use of this function is problematic because \-1 is a valid address
205 .\"O (255.255.255.255).
206 .\"O Avoid its use in favor of
207 .\"O .BR inet_aton (),
208 .\"O .BR inet_pton (3),
209 .\"O or
210 .\"O .BR getaddrinfo (3)
211 .\"O which provide a cleaner way to indicate error return.
212 .BR inet_addr ()
213 ´Ø¿ô¤Ï¡¢¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥Û¥¹¥È¤Î¥¢¥É¥ì¥¹ \fIcp\fP ¤ò¡¢
214 IPv4 ¤Î¿ôÃͤȥɥåȤˤè¤ëɽµ­¤«¤é¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Ç¤Î
215 ¥Ð¥¤¥Ê¥êÃͤØÊÑ´¹¤·¤ÆÊÖ¤¹¡£
216 ÆþÎϤ¬ÉÔÀµ¤Ê¾ì¹ç¡¢
217 .B INADDR_NONE
218 (ÉáÄ̤Ϡ\-1) ¤òÊÖ¤¹¡£
219 \-1 ¤ÏÍ­¸ú¤Ê¥¢¥É¥ì¥¹ (255.255.255.255) ¤Ê¤Î¤Ç¡¢¤³¤Î´Ø¿ô¤ò»È¤¦¤È
220 ÌäÂê¤Ë¤Ê¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
221 ¤³¤Î´Ø¿ô¤ò»È¤¦¤Î¤ÏÈò¤±¡¢Âå¤ï¤ê¤Ë
222 .BR inet_aton (),
223 .BR inet_pton (3),
224 .BR getaddrinfo (3)
225 ¤ò»È¤¦¤Î¤¬¤è¤¤¡£
226 ¤³¤ì¤é¤Î´Ø¿ô¤ÎÊý¤¬¡¢¥¨¥é¡¼¤ÎÄÌÃΤ¬¤è¤ê¤­¤ì¤¤¤ÊÊýË¡¤Ç¹Ô¤ï¤ì¤ë¡£
227 .PP
228 .\"O The
229 .\"O .BR inet_network ()
230 .\"O function converts
231 .\"O .IR cp ,
232 .\"O a string in IPv4 numbers-and-dots notation,
233 .\"O into a number in host byte order suitable for use as an
234 .\"O Internet network address.
235 .\"O On success, the converted address is returned.
236 .\"O If the input is invalid, \-1 is returned.
237 .BR inet_network ()
238 ´Ø¿ô¤Ï¡¢
239 IPv4 ¤Î¿ôÃͤȥɥåȤˤè¤ëɽµ­¤Îʸ»úÎó \fIcp\fP ¤ò¡¢
240 ¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥¢¥É¥ì¥¹¤È¤·¤Æ¤Î»ÈÍѤËŬ¤·¤¿
241 ¥Û¥¹¥È¥Ð¥¤¥È¥ª¡¼¥À¤Î¿ôÃͤËÊÑ´¹¤¹¤ë¡£
242 À®¸ù¤¹¤ë¤È¡¢ÊÑ´¹¤µ¤ì¤¿¥¢¥É¥ì¥¹¤òÊÖ¤¹¡£
243 ÆþÎϤ¬ÉÔÀµ¤Ê¾ì¹ç¤Ï \-1 ¤òÊÖ¤¹¡£
244 .PP
245 .\"O The
246 .\"O .BR inet_ntoa ()
247 .\"O function converts the Internet host address
248 .\"O \fIin\fP, given in network byte order, to a string in IPv4
249 .\"O dotted-decimal notation.
250 .\"O The string is returned in a statically
251 .\"O allocated buffer, which subsequent calls will overwrite.
252 .BR inet_ntoa ()
253 ´Ø¿ô¤Ï¡¢¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤ÇÅϤµ¤ì¤¿¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥Û¥¹¥È¥¢¥É¥ì¥¹
254 \fIin\fP ¤ò¡¢ IPv4 ¤Î¥É¥Ã¥È¶èÀÚ¤ê¤Î 10 ¿Ê¿ôɽµ­¤Îʸ»úÎó¤ËÊÑ´¹¤¹¤ë¡£
255 ʸ»úÎó¤ÏÀÅŪ¤Ë³äÅö¤Æ¤é¤ì¤¿¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ÆÊÖ¤µ¤ì¤ë¤Î¤Ç¡¢
256 ¤³¤Î¸å¤Ç¤³¤Î´Ø¿ô¤òºÆÅٸƤӽФ¹¤Èʸ»úÎó¤Ï¾å½ñ¤­¤µ¤ì¤ë¡£
257 .PP
258 .\"O The
259 .\"O .BR inet_lnaof ()
260 .\"O function returns the local network address part
261 .\"O of the Internet address \fIin\fP.
262 .\"O The returned value is in host byte order.
263 .BR inet_lnaof ()
264 ´Ø¿ô¤Ï¡¢¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥¢¥É¥ì¥¹ \fIin\fP ¤Î¥í¡¼¥«¥ë¥Í¥Ã¥È¥ï¡¼¥¯Éôʬ¤òÊÖ¤¹¡£
265 ¤³¤ÎÊÖ¤êÃͤϥۥ¹¥È¥Ð¥¤¥È¥ª¡¼¥À¤Ç¤¢¤ë¡£
266 .PP
267 .\"O The
268 .\"O .BR inet_netof ()
269 .\"O function returns the network number part of
270 .\"O the Internet address \fIin\fP.
271 .\"O The returned value is in host byte order.
272 .BR inet_netof ()
273 ´Ø¿ô¤Ï¡¢¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥¢¥É¥ì¥¹ \fIin\fP ¤Î¥Í¥Ã¥È¥ï¡¼¥¯Éôʬ¤òÊÖ¤¹¡£
274 ¤³¤ÎÊÖ¤êÃͤϥۥ¹¥È¥Ð¥¤¥È¥ª¡¼¥À¤Ç¤¢¤ë¡£
275 .PP
276 .\"O The
277 .\"O .BR inet_makeaddr ()
278 .\"O function is the converse of
279 .\"O .BR inet_netof ()
280 .\"O and
281 .\"O .BR inet_lnaof ().
282 .\"O It returns an Internet host address in network byte order,
283 .\"O created by combining the network number \fInet\fP
284 .\"O with the local address \fIhost\fP, both in
285 .\"O host byte order.
286 .BR inet_makeaddr ()
287 ´Ø¿ô¤Ï
288 .BR inet_netof ()
289 ¤È
290 .BR inet_lnaof ()
291 ¤ÎµÕ¤Îµ¡Ç½¤ò»ý¤Ä¡£
292 ¥Í¥Ã¥È¥ï¡¼¥¯ÈÖ¹æ \fInet\fP ¤È¡¢¥í¡¼¥«¥ë¥¢¥É¥ì¥¹ \fIhost\fP ¤ò
293 ÁȤ߹ç¤ï¤»¤ÆÀ¸À®¤·¤¿¡¢¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥Û¥¹¥È¥¢¥É¥ì¥¹¤ò
294 ¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤ÇÊÖ¤¹¡£
295 \fIhost\fP, \fInet\fP ¤Ï¤È¤â¤Ë¥Û¥¹¥È¥Ð¥¤¥È¥ª¡¼¥À¤Ç¤¢¤ë¡£
296 .PP
297 .\"O The structure \fIin_addr\fP as used in
298 .\"O .BR inet_ntoa (),
299 .\"O .BR inet_makeaddr (),
300 .\"O .BR inet_lnaof ()
301 .\"O and
302 .\"O .BR inet_netof ()
303 .\"O is defined in
304 .\"O .I <fnetinet/in.h>
305 .\"O as:
306 .BR inet_ntoa (),
307 .BR inet_makeaddr (),
308 .BR inet_lnaof (),
309 .BR inet_netof ()
310 ¤Ç»ÈÍѤ¹¤ë¹½Â¤ÂΠ\fIin_addr\fP ¤Ï
311 .I <netinet/in.h>
312 ¤Ç¼¡¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
313 .sp
314 .in +4n
315 .nf
316 typedef uint32_t in_addr_t;
317
318 struct in_addr {
319     in_addr_t s_addr;
320 };
321 .fi
322 .in
323 .\"O .SH "CONFORMING TO"
324 .SH ½àµò
325 4.3BSD.
326 .\"O .BR inet_addr ()
327 .\"O and
328 .\"O .BR inet_ntoa ()
329 .\"O are specified in POSIX.1-2001.
330 .BR inet_addr (),
331 .BR inet_ntoa ()
332 ¤Ï POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
333 .\"O .BR inet_aton ()
334 .\"O is not specified in POSIX.1-2001, but is available on most systems.
335 .BR inet_aton ()
336 ¤Ï POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢¤Û¤È¤ó¤É¤Î¥·¥¹¥Æ¥à¤ÇÍøÍѲÄǽ¤Ç¤¢¤ë¡£
337 .\"O .SH NOTES
338 .SH Ãí°Õ
339 .\"O On the i386 the host byte order is Least Significant Byte
340 .\"O first (little endian), whereas the network byte order, as used on the
341 .\"O Internet, is Most Significant Byte first (big endian).
342 i386 ¤Ç¤Ï¥Û¥¹¥È¥Ð¥¤¥È¥ª¡¼¥À¤Ï Least Significant Byte (LSB) first
343 (¥ê¥È¥ë¥¨¥ó¥Ç¥£¥¢¥ó) ¤À¤¬¡¢
344 ¥¤¥ó¥¿¡¼¥Í¥Ã¥È¤Ç»È¤ï¤ì¤ë¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Ï
345 Most Significant Byte (MSB) first (¥Ó¥Ã¥°¥¨¥ó¥Ç¥£¥¢¥ó)
346 ¤Ç¤¢¤ëÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
347
348 .\"O .BR inet_lnaof (),
349 .\"O .BR inet_netof (),
350 .\"O and
351 .\"O .BR inet_makeaddr ()
352 .\"O are legacy functions that assume they are dealing with
353 .\"O .IR "classful network addresses" .
354 .\"O Classful networking divides IPv4 network addresses into host and network
355 .\"O components at byte boundaries, as follows:
356 .BR inet_lnaof (),
357 .BR inet_netof (),
358 .BR inet_makeaddr ()
359 ¤Ï²áµî¤Î̾»Ä¤Ç¤¢¤ê¡¢ÅϤµ¤ì¤¿¥¢¥É¥ì¥¹¤¬
360 .I "¥¯¥é¥¹¥Õ¥ë¡¦¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹ (classful network addresses)"
361 ¤Ç¤¢¤ë¤È²¾Äꤷ¤Æ½èÍý¤ò¹Ô¤¦¡£
362 ¥¯¥é¥¹¥Õ¥ë¡¦¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤Ç¤Ï¡¢°Ê²¼¤Ë¤¢¤ë¤è¤¦¤Ë¡¢
363 IPv4 ¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤ò¥Ð¥¤¥È¶­³¦¤Ç¥Í¥Ã¥È¥ï¡¼¥¯Éô¤È¥Û¥¹¥ÈÉô¤Ëʬ³ä¤¹¤ë¡£
364 .TP 10
365 Class A
366 .\"O This address type is indicated by the value 0 in the
367 .\"O most significant bit of the (network byte ordered) address.
368 .\"O The network address is contained in the most significant byte,
369 .\"O and the host address occupies the remaining three bytes.
370 (¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Î) ¥¢¥É¥ì¥¹¤ÎºÇ¾å°Ì¥Ó¥Ã¥È¤¬ 0 ¤Î¾ì¹ç¡¢
371 ¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ȥʤ롣¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ǥϡ¢
372 ºÇ¾å°Ì¥Ð¥¤¥È¤¬¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤òɽ¤·¡¢
373 »Ä¤ê¤Î 3 ¥Ð¥¤¥È¤¬¥Û¥¹¥È¥¢¥É¥ì¥¹¤òɽ¤¹¡£
374 .TP
375 Class B
376 .\"O This address type is indicated by the binary value 10 in the
377 .\"O most significant two bits of the address.
378 .\"O The network address is contained in the two most significant bytes,
379 .\"O and the host address occupies the remaining two bytes.
380 (¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Î) ¥¢¥É¥ì¥¹¤Î¾å°Ì¦ 2 ¥Ó¥Ã¥È¤¬¥Ð¥¤¥Ê¥êÃͤÇ
381 10 ¤Î¾ì¹ç¡¢¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ȥʤ롣¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ǥϡ¢
382 ¾å°Ì 2 ¥Ð¥¤¥È¤¬¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤òɽ¤·¡¢
383 »Ä¤ê¤Î 2 ¥Ð¥¤¥È¤¬¥Û¥¹¥È¥¢¥É¥ì¥¹¤òɽ¤¹¡£
384 .TP
385 Class C
386 .\"O This address type is indicated by the binary value 110 in the
387 .\"O most significant three bits of the address.
388 .\"O The network address is contained in the three most significant bytes,
389 .\"O and the host address occupies the remaining byte.
390 (¥Í¥Ã¥È¥ï¡¼¥¯¥Ð¥¤¥È¥ª¡¼¥À¤Î) ¥¢¥É¥ì¥¹¤Î¾å°Ì¦ 3 ¥Ó¥Ã¥È¤¬¥Ð¥¤¥Ê¥êÃͤÇ
391 110 ¤Î¾ì¹ç¡¢¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ȥʤ롣¤³¤Î¥¢¥É¥ì¥¹¼ïÊ̤Ǥϡ¢
392 ¾å°Ì 3 ¥Ð¥¤¥È¤¬¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤òɽ¤·¡¢
393 »Ä¤ê¤Î 1 ¥Ð¥¤¥È¤¬¥Û¥¹¥È¥¢¥É¥ì¥¹¤òɽ¤¹¡£
394 .PP
395 .\"O Classful network addresses are now obsolete,
396 .\"O having been superseded by Classless Inter-Domain Routing (CIDR),
397 .\"O which divides addresses into network and host components at
398 .\"O arbitrary bit (rather than byte) boundaries.
399 ¥¯¥é¥¹¥Õ¥ë¡¦¥Í¥Ã¥È¥ï¡¼¥¯¥¢¥É¥ì¥¹¤Ï¸½ºß¤Ç¤ÏÇѻߤµ¤ì¡¢
400 ¥¯¥é¥¹¥ì¥¹¡¦¥É¥á¥¤¥ó´Ö¥ë¡¼¥Á¥ó (CIDR) ¤Ë¼è¤Ã¤ÆÂå¤ï¤é¤ì¤¿¡£
401 CIDR ¤Ç¤Ï¡¢¥¢¥É¥ì¥¹¤òǤ°Õ¤Î¥Ó¥Ã¥È¶­³¦ (¥Ð¥¤¥È¶­³¦¤Ç¤Ï¤Ê¤¤) ¤Ç
402 ¥Í¥Ã¥È¥ï¡¼¥¯Éô¤È¥Û¥¹¥ÈÉô¤Ëʬ³ä¤¹¤ë¡£
403 .\"O .SH EXAMPLE
404 .SH Îã
405 .\"O An example of the use of
406 .\"O .BR inet_aton ()
407 .\"O and
408 .\"O .BR inet_ntoa ()
409 .\"O is shown below.
410 .\"O Here are some example runs:
411 °Ê²¼¤Ï
412 .BR inet_aton ()
413 ¤È
414 .BR inet_ntoa ()
415 ¤Î»ÈÍÑÎã¤Ç¤¢¤ë¡£¤³¤Î¤è¤¦¤Ë¼Â¹Ô¤¹¤ë¡£
416 .in +4n
417 .nf
418
419 .RB "$" " ./a.out 226.000.000.037" "      # Last byte is in octal"
420 226.0.0.31
421 .RB "$" " ./a.out 0x7f.1         " "      # First byte is in hex"
422 127.0.0.1
423 .fi
424 .in
425 .\"O .SS Program source
426 .SS ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹
427 \&
428 .nf
429 #define _BSD_SOURCE
430 #include <arpa/inet.h>
431 #include <stdio.h>
432 #include <stdlib.h>
433
434 int
435 main(int argc, char *argv[])
436 {
437     struct in_addr addr;
438
439     if (argc != 2) {
440         fprintf(stderr, "%s <dotted\-address>\\n", argv[0]);
441         exit(EXIT_FAILURE);
442     }
443
444     if (inet_aton(argv[1], &addr) == 0) {
445         perror("inet_aton");
446         exit(EXIT_FAILURE);
447     }
448
449     printf("%s\\n", inet_ntoa(addr));
450     exit(EXIT_SUCCESS);
451 }
452 .fi
453 .\"O .SH "SEE ALSO"
454 .SH ´ØÏ¢¹àÌÜ
455 .BR byteorder (3),
456 .BR getaddrinfo (3),
457 .BR gethostbyname (3),
458 .BR getnameinfo (3),
459 .BR getnetent (3),
460 .BR inet_ntop (3),
461 .BR inet_pton (3),
462 .BR hosts (5),
463 .BR networks (5)