#include <netdb.h> struct netent *getnetent(void); struct netent *getnetbyname(const char *name); struct netent *getnetbyaddr(long net, int type); void setnetent(int stayopen); void endnetent(void);
The getnetbyname() function returns a netent structure for the line from /etc/networks that matches the network name.
The getnetbyaddr() function returns a netent structure for the line that matches the network number net of type type.
The setnetent() function opens and rewinds the /etc/networks file. If stayopen is true (1), then the file will not be closed between calls to getnetbyname() and getnetbyaddr().
The endservent() function closes /etc/networks.
The netent structure is defined in <netdb.h> as follows:
struct netent { char *n_name; /* official network name */ char **n_aliases; /* alias list */ int n_addrtype; /* net address type */ unsigned long int n_net; /* network number */ }
The members of the netent structure are: