GETNETENT(3N)
NAME
getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent − get network entry
USAGE
#include <netdb.h>
struct netent *getnetent()
struct netent *getnetbyname(name)
char *name;
struct netent *getnetbyaddr(net, addrtype)
long net;
int addrtype;
setnetent(stayopen)
int stayopen
endnetent()
DESCRIPTION
Getnetent, getnetbyname, and getnetbyaddr each return a pointer to an object with the following structure. The structure contains the separate fields of a line in the network database, /etc/networks.
structnetent {
char*n_name;/* official name of net */
char**n_aliases;/* alias list */
intn_addrtype;/* net number type*/
longn_net;/* net number */
};
The members of this structure are:
n_name The official name of the network.
n_aliases A zero terminated list of alternate names for the network.
n_addrtype The type of the network number returned; currently only AF_INET.
n_net The network number. Network numbers are returned in machine byte order.
Getnetent reads the next line of the file, opening the file if necessary.
Setnetent opens and rewinds the file. If the stayopen flag is non-zero, the net database will not be closed after each call to getnetent (either directly, or indirectly through one of the other “getnet” calls).
Endnetent closes the file.
Getnetbyname and getnetbyaddr search sequentially from the beginning of the file, until a matching net name or net address is found, or until EOF is encountered. Network numbers are supplied in host order.
NOTES
All information is kept in a static area, so it must be copied if you wish to save it. These functions only understand the Internet address format. If addrtype is supplied, it must be AF_INET.
DIAGNOSTICS
Null pointer (zero) returned on EOF or error.
FILES
/etc/networks