GETNETENT(3N) COMMAND REFERENCE GETNETENT(3N)
NAME
getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent
- get network entry
SYNOPSIS
#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
The network calls 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 data base, /etc/networks.
struct netent {
char *n_name; /* official name of net */
char **n_aliases; /* alias list */
int n_addrtype; /* net address type */
int n_net; /* network # */
};
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 host byte order.
The call getnetent reads the next line of the file, opening
the file /etc/networks if necessary; the file remains open
upon completion.
Printed 3/13/89 1
GETNETENT(3N) COMMAND REFERENCE GETNETENT(3N)
If the Yellow Pages aren't running, both getnetbyname and
getnetbyaddr open the /etc/networks file, if necessary, then
sequentially search from the beginning of the file until a
matching net name or net address and address family are
found, or until end-of-file is encountered. The file is
closed upon completion. Network numbers are supplied in
host byte order.
The setnetent call opens and rewinds the file; if the
stayopen flag is nonzero, the net data base will not close
by subsequent calls to endnetent (either directly or
indirectly through one of the other getnet calls); endnetent
closes the file.
FILES
/etc/networks
/etc/yp/domainname/hosts.byname
/etc/yp/domainname/hosts.byaddr
The domainname is the name of your host (domain).
DIAGNOSTICS
Null pointer (0) returned on end-of-file or error.
CAVEATS
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.
SEE ALSO
networks(5n), ypserv(8).
Printed 3/13/89 2
%%index%%
na:384,136;
sy:520,2168;
de:2688,1719;4863,1279;
fi:6142,352;
di:6494,179;
ca:6673,240;
se:6913,164;
%%index%%000000000134