inet_ntopのヘルプ・マニュアル
日本語 英語
inet_ntop --help
man inet_ntop
INET_NTOP(3) Linux Programmer’s Manual INET_NTOP(3)
名前
inet_ntop - IPv4/IPv6 アドレスをバイナリ形式からテキスト形式に変換する
書式
#include
const char *inet_ntop(int af, const void *src,
char *dst, socklen_t size);
説明
この関数は、 af アドレスファミリーのネットワークアドレス構造体 src を文
字列に変換する。変換結果の文字列は、 dst が指すバッファにコピーされる。
dst は NULL でないポインタでなければならない。呼び出し時に、このバッフ
ァで利用できるバイト数を引き数 size に指定する。
inet_ntop() は inet_ntoa(3) 関数を拡張して複数のアドレスファミリーを 扱
えるようにしたものである。今後は inet_ntoa(3) は使わず、 inet_ntop() を
使うようにすると良いだろう。現在サポートされているアドレスファミリー は
以下の通り:
AF_INET
この場合 src は (ネットワークバイトオーダーの) struct in_addr へ
のポインタとみなされ、この構造体の内容がドット区切りの 10 進数形
式 "ddd.ddd.ddd.ddd" の IPv4 ネットワークアドレスに変換される。
バッファ dst は少なくとも INET_ADDRSTRLEN バイトの長さを持たなけ
ればならない。
AF_INET6
こ の 場合 src は (ネットワークバイトオーダーの) struct in6_addr
へのポインタとみなされ、この構造体の内容が、 (このアドレスに対し
て もっとも適切な) IPv6 ネットワークアドレスの表示形式に変換され
る。バッファ dst は少なくとも INET6_ADDRSTRLEN バイトの長さを 持
たなければならない。
返り値
成功すると、 inet_ntop() は dst への (NULL でない) ポインタを返す。エラ
ーがあった場合は NULL を返し、 errno をエラーを示す値に適切に設定する。
エラー
EAFNOSUPPORT
af がサポートされているアドレスファミリーでなかった。
ENOSPC 変換されたアドレス文字列の長さが size で指定されたサイズを超過し
てしまう。
準拠
POSIX.1-2001. RFC 2553 では最後の引き数 size のプロトタイプ を size_t
型 と定義している。多くのシステムでは RFC 2553 にしたがっている。 glibc
2.0 と 2.1 では size_t だが、 glibc 2.2 以降では socklen_t となっている
。
バグ
AF_INET6 は IPv4 がマップされた IPv6 アドレスを IPv6 形式に変換してしま
う。
例
inet_pton(3) を参照。
関連項目
getnameinfo(3), inet(3), inet_pton(3)
Linux 2008-11-11 INET_NTOP(3)
INET_NTOP(3) Linux Programmer’s Manual INET_NTOP(3)
NAME
inet_ntop - convert IPv4 and IPv6 addresses from binary to text form
SYNOPSIS
#include
const char *inet_ntop(int af, const void *src,
char *dst, socklen_t size);
DESCRIPTION
This function converts the network address structure src in the af
address family into a character string. The resulting string is copied
to the buffer pointed to by dst, which must be a non-NULL pointer. The
caller specifies the number of bytes available in this buffer in the
argument size.
inet_ntop() extends the inet_ntoa(3) function to support multiple
address families, inet_ntoa(3) is now considered to be deprecated in
favor of inet_ntop(). The following address families are currently
supported:
AF_INET
src points to a struct in_addr (in network byte order) which is
converted to an IPv4 network address in the dotted-decimal for-
mat, "ddd.ddd.ddd.ddd". The buffer dst must be at least
INET_ADDRSTRLEN bytes long.
AF_INET6
src points to a struct in6_addr (in network byte order) which is
converted to a representation of this address in the most appro-
priate IPv6 network address format for this address. The buffer
dst must be at least INET6_ADDRSTRLEN bytes long.
RETURN VALUE
On success, inet_ntop() returns a non-null pointer to dst. NULL is
returned if there was an error, with errno set to indicate the error.
ERRORS
EAFNOSUPPORT
af was not a valid address family.
ENOSPC The converted address string would exceed the size given by
size.
CONFORMING TO
POSIX.1-2001. Note that RFC 2553 defines a prototype where the last
argument size is of type size_t. Many systems follow RFC 2553. Glibc
2.0 and 2.1 have size_t, but 2.2 and later have socklen_t.
BUGS
AF_INET6 converts IPv4-mapped IPv6 addresses into an IPv6 format.
EXAMPLE
See inet_pton(3).
SEE ALSO
getnameinfo(3), inet(3), inet_pton(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2008-11-11 INET_NTOP(3)