GETNETENT(3N) GETNETENT(3N)
getnetent, getnetent_r, fgetnetent, fgetnetent_r, getnetbyaddr,
getnetbyaddr_r, getnetbyname, getnetbyname_r, setnetent, endnetent - get
network entry
#include <netdb.h>
struct netent *getnetent(void);
struct netent *getnetent_r(struct netent *nent, char *buffer, int bufsize);
struct netent *fgetnetent(FILE *);
struct netent *fgetnetent_r(FILE *, struct netent *nent, char *buffer, int bufsize);
struct netent *getnetbyname(const char *name);
struct netent *getnetbyname_r(const char *name, struct netent *nent, char *buffer, int bufsize);
struct netent *getnetbyaddr(long net, int type);
struct netent *getnetbyaddr_r(long net, int type, struct netent *nent, char *buffer, int bufsize);
void setnetent(int stayopen);
void endnetent(void);
Getnetent, fgetnetent, getnetbyname, getnetbyaddr and each of their
reentrant counterparts each return a pointer to an object with the
following structure containing the broken-out fields of a line in the
network data base file, /etc/networks, or some other back-end networks
database.
struct netent {
char *n_name; /* official name of net */
char **n_aliases; /* alias list */
int n_addrtype; /* net number type */
unsigned 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.
Page 1
GETNETENT(3N) GETNETENT(3N)
n_net 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 data base will not be closed after each call to getnetbyname or
getnetbyaddr.
Endnetent closes the file.
Getnetbyname and getnetbyaddr sequentially search from the beginning 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.
The routines fgetnetent and fgetnetent_r will return the next line in the
supplied file parsed into a struct netent structure. The file must be in
the same format as the /etc/networks file.
The routines getnetent, fgetnetent, getnetbyaddr, and getnetbyname all
return pointers into static space which is modified on each call.
Reentrant versions of each routine getnetent_r, fgetnetent_r,
getnetbyaddr_r and getnetbyname_r. These routines parse the result into
supplied space. They each take a pointer to a netent structure, a
pointer to some buffer, and a length for the buffer.
The routines documented in this file only parse files of the format given
in networks(4). These can be static files on the system such as the
/etc/networks file, or files supplied dynamically by the nsd(1M) daemon
from some other backend database such as NIS.
The Mips ABI specifies nothing but local files so applications which wish
to use anything else must compile with libc prior to libnsl in the
library list.
When nsd is running changes in the local networks file may not be noticed
by getnetent() until the enumeration cache file has timed out.
All functions that return struct netent * will return a null (0) pointer
in the case of EOF or failure.
/etc/networks /var/ns/cache/networks.byname.m
/var/ns/cache/networks.byaddr.m
nsd(1M), networks(4)
Page 2
GETNETENT(3N) GETNETENT(3N)
Null pointer (0) returned on EOF or error.
Only Internet network numbers are currently understood.
Expecting network numbers to fit in no more than 32 bits is probably
naive.
PPPPaaaaggggeeee 3333 [ Back ]
|