|
Description
The getnetbyname(), getnetbyaddr() and getnetent() functions return information about the names and addresses of the reachable networks. The information about local network names is not available in BCAM. Assignment is by means of the file /etc/inet/networks as usual in UNIX systems. The file contents are coded in EBCDIC.
The getnetbyname(), getnetbyaddr() and getnetent() functions return a pointer to an object with the netent structure described below.
The netent structure corresponds to the fields of a line in the network database and is declared as follows:
struct netent { char *n_name; /* Official name of the network */ char **n_aliases; /* Alias list */ int n_addrtype; /* Address type */ in_addr_t n_net; /* Network address */ };
Components of the netent structure:
n_name
Official name of the network.
n_aliases
A list of alternative (alias) names for the host, terminated with null.
n_addrtype
Type of the returned address (always AF_INET).
n_net
Address of the network, which is returned in host byte order.
getnetent() reads the next line of the file. If necessary, getnetent() opens the file first.
setnetent() opens the file and resets it to the start. If the stayopen flag is not equal to zero, the database is not closed after any getnetent() call (neither directly nor indirectly via one of the other getnet...() calls).
endnetent() closes the file.
getnetbyname() and getnetbyaddr() search sequentially through the file from the start until
a matching name is found or
the matching network address is found or
the end of the file reached.
Return value
The null pointer is returned if the search reaches the end of the file.
Note
All information is in a static area and therefore has to be copied if it is to be saved.
Only IPv4 is supported.
File
/etc/inet/networks