GETNETENT(3) BSD Programmer's Manual GETNETENT(3) NNAAMMEE ggeettnneetteenntt, ggeettnneettbbyyaaddddrr, ggeettnneettbbyynnaammee, sseettnneetteenntt, eennddnneetteenntt - get network entry SSYYNNOOPPSSIISS ##iinncclluuddee <<nneettddbb..hh>> _s_t_r_u_c_t _n_e_t_e_n_t _* ggeettnneetteenntt(); _s_t_r_u_c_t _n_e_t_e_n_t _* ggeettnneettbbyynnaammee(_c_h_a_r _*_n_a_m_e); _s_t_r_u_c_t _n_e_t_e_n_t _* ggeettnneettbbyyaaddddrr(_l_o_n_g _n_e_t, _i_n_t _t_y_p_e); sseettnneetteenntt(_i_n_t _s_t_a_y_o_p_e_n); eennddnneetteenntt(); DDEESSCCRRIIPPTTIIOONN The ggeettnneetteenntt(), ggeettnneettbbyynnaammee(), and ggeettnneettbbyyaaddddrr() functions each return a pointer to an object with the following structure containing the bro- ken-out fields of a line in the network data base, _/_e_t_c_/_n_e_t_w_o_r_k_s. 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___n_a_m_e The official name of the network. _n___a_l_i_a_s_e_s A zero terminated list of alternate names for the network. _n___a_d_d_r_t_y_p_e The type of the network number returned; currently only AF_INET. _n___n_e_t The network number. Network numbers are returned in machine byte order. The ggeettnneetteenntt() function reads the next line of the file, opening the file if necessary. The sseettnneetteenntt() function opens and rewinds the file. If the _s_t_a_y_o_p_e_n flag is non-zero, the net data base will not be closed after each call to ggeettnneettbbyynnaammee() or ggeettnneettbbyyaaddddrr(). The eennddnneetteenntt() function closes the file. The ggeettnneettbbyynnaammee() function and ggeettnneettbbyyaaddddrr() 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. FFIILLEESS /etc/networks DDIIAAGGNNOOSSTTIICCSS Null pointer (0) returned on EOF or error. SSEEEE AALLSSOO networks(5) HHIISSTTOORRYY The ggeettnneetteenntt(), ggeettnneettbbyyaaddddrr(), ggeettnneettbbyynnaammee(), sseettnneetteenntt(), and eennddnneetteenntt() functions appeared in 4.2BSD. BBUUGGSS The data space used by these functions is static; if future use requires the data, it should be copied before any subsequent calls to these func- tions overwrite it. Only Internet network numbers are currently under- stood. Expecting network numbers to fit in no more than 32 bits is prob- ably naive. 4.2 Berkeley Distribution June 4, 1993 2