getnetent.3n (2010 09)

g
getnetent(3N) getnetent(3N)
NAME
getnetent(), getnetbyaddr(), getnetbyname(), setnetent(), endnetent() - get, set, or end network entry
SYNOPSIS
#include <sys/socket.h>
#include <netdb.h>
struct netent *getnetent(void);
struct netent *getnetbyname(const char *name);
struct netent *getnetbyaddr(unsigned int net, int type);
_XOPEN_SOURCE_EXTENDED only
struct netent *getnetbyaddr(in_addr_t net, int type);
int setnetent(int stayopen);
int endnetent(void);
_XOPEN_SOURCE_EXTENDED only
void setnetent(int stayopen);
void endnetent(void);
DESCRIPTION
getnetent(), getnetbyname(), and
getnetbyaddr() each return a pointer to a structure of
type netent containing the broken-out fields of a line in the network data base,
/etc/networks
.
The members of this structure are:
n_name The official name of the network.
n_aliases A null-terminated list of alternate names for the network.
n_addrtype The type of the network number returned; always AF_INET.
n_net The network number.
Functions behave as follows:
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 network
data base is not closed after each call to getnetent() (either directly or
indirectly through one of the other getnet* calls).
endnetent() Closes the file.
getnetbyname() Sequentially searches from the beginning of the file until a network name
(among either the ofcial names or the aliases) matching its parameter
name is found, or until EOF is encountered.
getnetbyaddr() Sequentially searches from the beginning of the file until a network number
matching its parameter net is found, or until EOF is encountered. The
parameter net must be in network order. The parameter type must be the
constant AF_INET. Network numbers are supplied in host order (see
byteorder (3N)).
If the system is running Network Information Service (NFS),
getnetbyname() and getnet-
byaddr() obtain their network information from the NIS server (see ypserv (1M) and ypfiles (4)).
In a multithreaded application,
getnetent(), getentbyaddr(), and
getentbyname() use
thread-specific storage that is re-used in each call. The return value,
struct netent, should be unique
for each thread and should be saved, if desired, before the thread makes the next getnet*() call.
For enumeration in multithreaded applications, the position within the enumeration is a process-wide
property shared by all threads.
setnetent() may be used in a multithreaded application, but resets
the enumeration position for all threads. If multiple threads interleave calls to getnetent(), the
threads will enumerate disjoint subsets of the network database.
Name Service Switch-Based Operation
The library routines
getnetbyname(), getnetbyaddr(), and getnetent() internally call the
name service switch to access the "networks" database lookup policy configured in the
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)