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
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 *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.
Printed 10/17/86 1
GETNETENT(3N) COMMAND REFERENCE GETNETENT(3N)
Getnetent reads the next line of the file, opening the file
if necessary. The file remains open upon completion.
Getnetbyname and getnetbyaddr open the file, if necessary,
then sequentially search from the beginning of the file
until a matching net name or net address and address family
is found, or until EOF is encountered. The file is closed
upon completion. Network numbers are supplied in host byte
order.
Setnetent opens and rewinds the file. If the stayopen flag
is nonzero, the net database will not be closed by
subsequent calls to endnetent (either directly, or
indirectly through one of the other getnet calls).
Endnetent closes the file.
FILES
/etc/networks
DIAGNOSTICS
Null pointer (0) returned on EOF 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).
Printed 10/17/86 2
%%index%%
na:72,120;
sy:192,1408;
de:1600,1237;2981,1201;
fi:4182,79;
di:4261,127;
ca:4388,214;
se:4602,111;
%%index%%000000000132