getnetbyname()--Get Network Information for Domain Name


  BSD 4.3 Syntax
  #include <netdb.h>

 struct netent *getnetbyname(char *network_name)

  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 *getnetbyname(const char *network_name)

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: No; see Usage Notes.


The getnetbyname() 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_name
(Input) The pointer to the character string that contains the name of the network for which information is to be retrieved.

Authorities

No authorization is required.


Return Value

getnetbyname() 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 getnetbyname() points to static storage that is overwritten on subsequent calls to the getnetbyname(), getnetbyaddr(), 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 name specified by the network_name parameter, and for the network names returned in the netent structure, the job CCSID must be something other than 65535.

  5. Do not use the getnetbyname() function in a multithreaded environment. See the multithread alternative getnetbyname_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 getnetbyname() API is mapped to qso_getnetbyname98().

Related Information



API introduced: V3R1

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