|
Description
In contrast to gethostbyaddr() and gethostbyname(), the functions getipnodebyaddr() and getipnodebyname() support IPv6 as well as IPv4.
The getipnodebyaddr() and getipnodebyname() functions return current information on all known hosts on the network by obtaining the required information (host name and host address) from a DNS server via the DNS Resolver integrated in SOCKETS(BS2000). If this is not successful, the information is taken from the BCAM processor table (see the "BCAM" manual).
For getipnodebyaddr(), addr is a pointer to the host address. This host address must be in binary format with the length len.
For getipnodebyname(), the host name (socket host name) must be specified for name. You can specify the name as a fully-qualified DNS name, i.e. including host name and domain part (e.g. hostx.fujitsu.com) as a partially-qualified DNS name (e.g. hostx.) or only as a host name (e.g. hostx). You can also specify an IPv4 address in decimal dotted notation or an IPv6 address in hexadecimal colon notation.
The af parameter in the call is used to specify the address family (AF_INET or AF_INET6). AF_UNSPEC can also be specified for getipnodebyname() if an IP address is specified as name in dotted or colon notation.
The flags parameter can be used to control the output of the desired address family. If flags has the value 0, an address appropriate to the address family specified in af is returned.
AI_V4MAPPED
The caller accepts IPv4-mapped addresses if no IPv6 address is available.
AI_ALL
Only if AI_V4MAPPED is also set: IPv6 addresses and IPv4-mapped addresses are returned if available. af must have the value AF_INET6.
AI_ADDRCONFIG
Depending on the value of af, only an IPv6 or IPv4 address is returned if the host on which the function is called has an interface address of the same type.
AI_DEFAULT
Equals (AI_ADDRCONFIG | AI_V4MAPPED).
If af = AF_INET6 is set and the host on which the function is called has an IPv6 address, an IPv6 address is returned for the specified host name.
If the host on which the function is called has only an IPv4 interface address, an IPv4-mapped address is returned.
The getipnodebyaddr() and getipnodebyname() functions return a pointer to an object of the type struct hostent. Memory for this object is requested dynamically and must be released by the caller with the freehostent() function.
The hostent structure is described in section "Converting host names into network addresses and vice versa".
Return value
Pointer to an object of the type struct hostent. If an error occurs, the null pointer is returned and the variable err is supplied with one of the following values:
HOST_NOT_FOUND
Host unknown.
NO_ADDRESS
No host address is available for the specified name.
NO_RECOVERY
An unrecoverable server error has occurred.
TRY_AGAIN
Access must be repeated.
-1:
Errors; errno is set to indicate the error.
Errors
EAFNOSUPPORT
The function is not supported on this system. See also "Dependencies on the BS2000 transport system BCAM" for more information.