getnetent(3N) getnetent(3N)
NAME
getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent - get net-
work entry
SYNOPSIS
#include <netdb.h>
struct netent *getnetent(void);
struct netent *getnetbyname(const char *name);
struct netent *getnetbyaddr(inaddrt net, int type);
void setnetent(int stayopen);
void endnetent(void);
DESCRIPTION
getnetent(), getnetbyname(), and getnetbyaddr() each return a pointer
to an object with the following structure containing the broken-out
fields of a line in the network database, /etc/networks.
struct netent {
char *nname; /* official name of net */
char **naliases; /* alias list */
int naddrtype; /* net number type */
inaddrt nnet; /* net number */
};
The members of this structure are:
nname The official name of the network.
naliases A zero terminated list of alternate names for the net-
work.
naddrtype The type of the network number returned; currently only
AFINET.
nnet 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.
Page 1 Reliant UNIX 5.44 Printed 11/98
getnetent(3N) getnetent(3N)
getnetbyname() and getnetbyaddr() sequentially search from the begin-
ning of the file until a matching net name or net address and type is
found, or until EOF is encountered. Network numbers are supplied in
host order.
DIAGNOSTICS
A NULL pointer is returned on EOF or error.
NOTES
All information is contained in a static area so it must be copied if
it is to be saved.
Only Internet network numbers are currently understood.
FILES
/etc/networks
SEE ALSO
networks(4).
Page 2 Reliant UNIX 5.44 Printed 11/98