getnetbyaddr_r()--Get Network Information for IP Address
Syntax
#include <netdb.h>
int getnetbyaddr_r(long network_address,
int address_type,
struct netent *netent_struct_addr,
struct netent_data
*netent_data_struct_addr)
Service Program Name: QSOSRV2
Default Public Authority: *USE
Threadsafe: Yes
A program uses the getnetbyaddr_r() function to retrieve
information about a network. The information is retrieved from the network
database file.
Parameters
- long network_address (input)
- Specifies the 32-bit network IP address for which information is to be
retrieved.
- int address_type (input)
- Specifies an integer that indicates the type of
network_address.
- 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 be initialized with hexadecimal zeros before initial
use.
Authorities
No authorization is required.
Return Value
The getnetbyaddr_r() function returns a 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 getnetbyaddr_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
- The iSeries 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)
- 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_r() call with a
non-zero parameter value was not previously done.
- 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
API introduced: V3R1