#include <netdb.h>struct netent *getnetent(void);
struct netent *getnetbyname (const char *name);
struct netent *getnetbyaddr (in_addr_t net, int type);
void setnetent(int stayopen);
void endnetent(void);
struct netent { char *n_name; /* official name of net */ char **n_aliases; /* alias list */ int n_addrtype; /* net number type */ in_addr_t n_net; /* net number */ };
The members of this structure are:
n_name
n_aliases
n_addrtype
n_net
setnetent opens and rewinds the file. If the stayopen flag is non-zero, the network data base will not be closed after each call to getnetent (either directly, or indirectly through one of the other getnet* calls).
endnetent closes the file.
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 machine byte order. The only type currently supported is AF_INET.
A call to setnetent must be made before a while loop using getnetent in order to perform initialization. endnetent must be used after the loop. Both getnetbyname and getnetbyaddr make calls to setnetent and endnetent.
It is probably not possible to expect network numbers to fit in no more than 32 bits.
RFC 1101