BPX1GHA (gethostbyaddr) example

The following code returns a pointer to a HOSTENT structure, which contains the alias names and the internet addresses of a host whose address is specified as input. For the callable service, see gethostbyaddr (BPX1GHA, BPX4GHA) Get the IP address and alias of a host name for the specified IP address. AMODE 64 callers use BPX4GHA (gethostbyaddr) example.

The HOSTENT structure has the following format:
  • h_name - The address of the host name returned by the service. The host name is a variable length field that is ended by x'00'. #$
  • h_aliases - The address of a list of addresses that point to the alias names returned by the service. The list is ended by the pointer x'00000000'. Each alias name is a variable length field that is ended by x'00'.
  • h_addrtype - The value 2, which signifies AF_INET.
  • h_length - The length of the host internet addresses pointed to by h_addr_list.
  • h-addr_list - The address of a list of addresses that point to the host internet addresses returned by this service. The list is ended by the pointer x'00000000'.
                                              
*        MVC   HOST_ADDR,=XL4'C90E0256'   IP Address of Host            
         MVC   HOST_ADDRLEN,=F'4'         Address length                
         SPACE ,                                                        
         CALL  BPX1GHA,              Get host by address               +
               (HOST_ADDR,           Input: IP address of queried HOST +
               HOST_ADDRLEN,         Input: Length of IP address       +
               HOSTENT_PTR,          Output: 0 or -> HOSTENT structure +
               =A(AF_INET),          Input: Domain - AF_INET           +
               RETVAL,               Return code                       +
               RETCODE,              Return code                       +
               RSNCODE),             Reason code                       +
               VL,MF=(E,PLIST)       ----------------------------------