GETNETENT(3N) GETNETENT(3N) NAME getnetent, getnetent_r, fgetnetent, fgetnetent_r, getnetbyaddr, getnetbyaddr_r, getnetbyname, getnetbyname_r, setnetent, endnetent - get network entry SYNOPSIS #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); DESCRIPTION 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. 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. NOTE 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. DIAGNOSTICS All functions that return struct netent * will return a null (0) pointer in the case of EOF or failure. FILES /etc/networks /var/ns/cache/networks.byname.m /var/ns/cache/networks.byaddr.m SEE ALSO nsd(1M), networks(4) DIAGNOSTICS Null pointer (0) returned on EOF or error. BUGS Only Internet network numbers are currently understood. Expecting network numbers to fit in no more than 32 bits is probably naive. Page 3