getnetbyaddr()--Get Network Information for IP Address


  BSD 4.3 Syntax
  #include <netdb.h>

 struct netent *getnetbyaddr(long network_address,
                             int address_type)

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: No; see Usage Notes.



  UNIX® 98 Compatible Syntax
  #define _XOPEN_SOURCE 520
  #include <netdb.h>

 struct netent *getnetbyaddr(uint32_t network_address,
                             int address_type)

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: No; see Usage Notes.

The getnetbyaddr() function is used to retrieve information about a network. The information is retrieved from the network database file.

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

network_address
(Input) The 32-bit network IP address for which information is to be retrieved.

address_type
(Input) An integer that indicates the type of network_address.

Authorities

No authorization is required.


Return Value

getnetbyaddr() returns a pointer. Possible values are:

The structure struct netent is defined in <netdb.h>.

      struct netent {
        char            *n_name;
        char            **n_aliases;
        int             n_addrtype;
        unsigned long   n_net;
      };

n_name points to the character string that contains the name of the network. n_aliases is a pointer to a NULL-terminated array of alternate names for the network. n_addrtype contains the address type of the network. n_net is the 32-bit network address (an IP address with host part set to zero).


Usage Notes

  1. System i® Navigator or the following CL commands can be used to access the network database file:


  2. The pointer returned by getnetbyaddr() points to static storage that is overwritten on subsequent calls to the getnetbyaddr(), getnetbyname(), or getnetent() functions.

  3. When the network information is obtained from the network database file, the file is opened and the network information is retrieved (if it exists) from the file. The file is then closed only if a setnetent() with a nonzero parameter value was not previously done.

  4. A coded character set identifier (CCSID) of 65535 for the job requests that no database translation be performed. For translation to occur for the network names returned in the netent structure, the job CCSID must be something other than 65535.

  5. Do not use the getnetbyaddr() function in a multithreaded environment. See the multithread alternative getnetbyaddr_r() function.

  6. 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 getnetbyaddr() API is mapped to qso_getnetbyaddr98().

Related Information



API introduced: V3R1

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