getnetent(3N) 4 BSD 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, type)
long net, type;
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 data base,
/etc/networks.
struct netent {
char *n_name; /* official name of net */
char **n_aliases; /* alias list */
int n_addrtype; /* net number type */
long n_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.
CX/UX supports both a proprietary version and an 88open
Object Compatibility Standard Networking Supplement (OCSNS)
version of getnetbyname and getnetbyaddr. The OCSNS ver-
sions of these functions check for the existence of the
function /etc/bcs_cat and if it exists and has proper exe-
cute permission, will issue a popen(3S) call of the command
Page 1 CX/UX Networking
getnetent(3N) 4 BSD getnetent(3N)
/etc/bcs_cat networks. If the file does not exist, the
functions will access the /etc/networks file.
getnetent reads the next line of the /etc/networks file,
opening the file if necessary and returning a pointer to a
netent structure containing the file entry.
Setnetent opens and rewinds the /etc/networks file. If the
stayopen flag is non-zero, the net data base will not be
closed after each call to getnetent, getnetbyname, or get-
netbyaddr.
Endnetent closes the file /etc/networks and clears the stay-
open flag.
The functions getnetent, setnetent, and endnetent are
defined in the 88open OCSNS. Their functionality is the
same as described above.
Both versions of getnetbyname and getnetbyaddr sequentially
search 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. The type param-
eter for getnetbyaddr must be AF_INET. The 88open OCSNS
versions of the above files may be accessed through special
OCS options passed to cc(1) and/or ld(1).
FILES
/etc/networks
SEE ALSO
bcs_cat(1), networks(4C)
DIAGNOSTICS
Null pointer (0) returned on EOF or error.
BUGS
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. Expecting network numbers to fit
in no more than 32 bits is probably naive.
Page 2 CX/UX Networking