|GETNAMEINFO(3XNET)||X/Open Networking Services Library Functions||GETNAMEINFO(3XNET)|
cc [ flag ... ] file ... -lxnet [ library ... ] #include <sys/socket.h> #include <netdb.h> int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen, char *restrict service, socklen_t servicelen, unsigned flags);
The sa argument points to a socket address structure to be translated. If the socket address structure contains an IPv4-mapped IPv6 address or an IPv4-compatible IPv6 address, the implementation extracts the embedded IPv4 address and lookup the node name for that IPv4 address.
If the node argument is non-NULL and the nodelen argument is non-zero, then the node argument points to a buffer able to contain up to nodelen characters that receives the node name as a null-terminated string. If the node argument is NULL or the nodelen argument is zero, the node name is not returned. If the node's name cannot be located, the numeric form of the node's address is returned instead of its name.
If the service argument is non-NULL and the servicelen argument is non-zero, then the service argument points to a buffer able to contain up to servicelen bytes that receives the service name as a null-terminated string. If the service argument is NULL or the servicelen argument is zero, the service name is not returned. If the service's name cannot be located, the numeric form of the service address (for example, its port number) is returned instead of its name.
The flags argument is a flag that changes the default actions of the function. By default the fully-qualified domain name (FQDN) for the host is returned, but:
Upon successful completion, getnameinfo() returns the node and service names, if requested, in the buffers provided. The returned names are always null-terminated strings.
Given the IPv4-mapped IPv6 address "::ffff:22.214.171.124", the implementation performs a lookup as if the socket address structure contains the IPv4 address "126.96.36.199".
|ATTRIBUTE TYPE||ATTRIBUTE VALUE|
The two NI_NUMERICxxx flags are required to support the -n flag that many commands provide.
The NI_DGRAM flag is required for the few AF_INET and AF_INET6 port numbers (for example, [512,514]) that represent different services for UDP and TCP.
|November 1, 2003||OmniOS|