inet_network()--Translate Network Portion of Address to 32-bit IP Address


  BSD 4.3 Syntax
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <arpa/inet.h>

 unsigned long inet_network(char *address_string)

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: Yes



  UNIX® 98 Compatible Syntax
  #define _XOPEN_SOURCE 520
  #include <arpa/inet.h>

 in_addr_t inet_network(const char *address_string)

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: Yes



The inet_network() function is used to translate an Internet address from dotted decimal format to a 32-bit network IP address, in which the host part of the IP address is set to zeros.

There are two versions of the API, as shown above. The base IBM® i API uses BSD 4.3 structures and syntax. The other uses syntax and structures compatible with the UNIX 98 programming interface specifications. You can select the UNIX 98 compatible interface with the _XOPEN_SOURCE macro.


Parameters

address_string
(Input) The Internet address in dotted decimal format that is to be converted to a 32-bit network IP address.

Authorities

No authorization is required.


Return Value

inet_network() returns an integer. Possible values are:


Error Conditions

When inet_network() fails, errno can be set to one of the following:

[EFAULT]

Bad address.

The system detected an address which was not valid while attempting to access the address_string parameter.

[EINVAL]

Parameter not valid.

When you develop in C-based languages and an application is compiled with the _XOPEN_SOURCE macro defined to the value 520 or greater, the inet_network() API is mapped to qso_inet_network98().


Related Information



API introduced: V3R1

[ Back to top | UNIX-Type APIs | APIs by category ]