getnetent_r()--Get Next Entry from Network Database
Syntax
#include <netdb.h> int getnetent_r(struct netent *netent_struct_addr, struct netent_data *netent_data_struct_addr)
Service Program Name: QSOSRV2
Default Public Authority: *USE
Threadsafe: Yes
The getnetent_r() function is used to retrieve network information from the network database file. When the getnetent_r() is first called, the file is opened, and the first entry is returned. Each subsequent call of getnetent_r() results in the next entry in the file being returned. To close the file, use endnetent_r().
Parameters
- struct netent *netent_struct_addr (input/output)
- Specifies the pointer to a netent structure where the results will be
placed. All results must be referenced through this structure.
- struct netent_data *netent_data_struct_addr (input/output)
- Specifies the pointer to the netent_data structure, which is used to pass and preserve results between function calls. The field net_control_blk in the netent_data structure must be initialized with hexadecimal zeros before its initial use. If compatibility with other platforms is required, then the entire netent_data structure must initialized with hexadecimal zeros before initial use.
Authorities
No authorization is required.
Return Value
The getnetent_r() function returns an integer. Possible values are:
- -1 (unsuccessful call)
- 0 (successful call)
The struct netent, denoted by netent_struct_addr and struct netent_datadenoted by netent_data_struct_addr are both defined in <netdb.h>. The structure struct netentis defined as:
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 list of pointers, each of which points to a character string that represents an alternative name for the network. n_addrtype contains the address type of the network (that is, AF_INET). n_net is the 32-bit network address (that is, an IP address in network byte order with host part set to zero).
Error Conditions
When the getnetent_r() function fails, errno can be set to:
- [EINVAL]
The netent_data structure was not properly initialized to hexadecimal zeros before initial use. For corrective action, see the description for structure netent_data.
Usage Notes
- System i® Navigator or the following CL commands can be
used to access the network database file:
- WRKNETTBLE (Work with Network Table Entries)
- ADDNETTBLE (Add Network Table Entry)
- RMVNETTBLE (Remove Network Table Entry)
- 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.
Related Information
- getnetbyaddr_r()--Get Network Information for IP
Address
- getnetbyname_r()--Get Network Information for Domain
Name
- setnetent_r()--Open Network Database
- endnetent_r()--Close Network Database
API introduced: V3R1