OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / LDP_man-pages / release / man3 / inet_ntop.3
1 .\" Copyright 2000 Sam Varshavchik <mrsam@courier-mta.com>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References: RFC 2553
24 .\"
25 .\" Japanese Version Copyright (c) 2001 NAKANO Takeo all rights reserved.
26 .\" Translated 2001-01-14, NAKANO Takeo <nakano@apm.seikei.ac.jp>
27 .\" Updated 2005-02-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
28 .\" Updated 2008-08-08, Akihiro MOTOKI, LDP v3.05
29 .\"
30 .TH INET_NTOP 3 2008-11-11 "Linux" "Linux Programmer's Manual"
31 .SH 名前
32 inet_ntop \- IPv4/IPv6 アドレスをバイナリ形式からテキスト形式に変換する
33 .SH 書式
34 .nf
35 .B #include <arpa/inet.h>
36 .sp
37 .BI "const char *inet_ntop(int " "af" ", const void *" "src" ,
38 .BI "                      char *" "dst" ", socklen_t " "size" );
39 .fi
40 .SH 説明
41 この関数は、
42 .I af
43 アドレスファミリーのネットワークアドレス構造体
44 .I src
45 を文字列に変換する。
46 変換結果の文字列は、
47 .I dst
48 が指すバッファにコピーされる。
49 .I dst
50 は NULL でないポインタでなければならない。
51 呼び出し時に、このバッファで利用できるバイト数を
52 引き数
53 .I size
54 に指定する。
55 .PP
56 .BR inet_ntop ()
57
58 .BR inet_ntoa (3)
59 関数を拡張して複数のアドレスファミリーを扱えるようにしたものである。
60 今後は
61 .BR inet_ntoa (3)
62 は使わず、
63 .BR inet_ntop ()
64 を使うようにすると良いだろう。
65 現在サポートされているアドレスファミリーは以下の通り:
66 .TP
67 .B AF_INET
68 この場合
69 .I src
70 は (ネットワークバイトオーダーの)
71 .I "struct in_addr"
72 へのポインタとみなされ、この構造体の内容が
73 ドット区切りの 10 進数形式 "\fIddd.ddd.ddd.ddd\fP" の
74 IPv4 ネットワークアドレスに変換される。
75 バッファ
76 .I dst
77 は少なくとも
78 .B INET_ADDRSTRLEN
79 バイトの長さを持たなければならない。
80 .TP
81 .B AF_INET6
82 この場合
83 .I src
84 は (ネットワークバイトオーダーの)
85 .I "struct in6_addr"
86 へのポインタとみなされ、この構造体の内容が、
87 (このアドレスに対してもっとも適切な)
88 IPv6 ネットワークアドレスの表示形式に変換される。
89 バッファ
90 .I dst
91 は少なくとも
92 .B INET6_ADDRSTRLEN
93 バイトの長さを持たなければならない。
94 .SH 返り値
95 成功すると、
96 .BR inet_ntop ()
97
98 .I dst
99 への (NULL でない) ポインタを返す。
100 エラーがあった場合は NULL を返し、
101 .I errno
102 をエラーを示す値に適切に設定する。
103 .SH エラー
104 .TP
105 .B EAFNOSUPPORT
106 .I af
107 がサポートされているアドレスファミリーでなかった。
108 .TP
109 .B ENOSPC
110 変換されたアドレス文字列の長さが
111 .I size
112 で指定されたサイズを超過してしまう。
113 .SH 準拠
114 POSIX.1-2001.
115 RFC\ 2553 では最後の引き数
116 .I size
117 のプロトタイプを
118 .I size_t
119 型と定義している。多くのシステムでは RFC\ 2553 にしたがっている。
120 glibc 2.0 と 2.1 では
121 .I size_t
122 だが、
123 glibc 2.2 以降では
124 .I socklen_t
125 となっている。
126 .\" 2.1.3: size_t, 2.1.91: socklen_t
127 .SH バグ
128 .B AF_INET6
129 は IPv4 がマップされた IPv6 アドレスを
130 IPv6 形式に変換してしまう。
131 .SH 例
132 .BR inet_pton (3)
133 を参照。
134 .SH 関連項目
135 .BR getnameinfo (3),
136 .BR inet (3),
137 .BR inet_pton (3)