RPC_SVC_CALLS(3) NetBSD Library Functions Manual RPC_SVC_CALLS(3) NNAAMMEE ssvvcc__ddgg__eennaabblleeccaacchhee, ssvvcc__eexxiitt, ssvvcc__ffddsseett, ssvvcc__ffrreeeeaarrggss, ssvvcc__ggeettaarrggss, ssvvcc__ggeettrreeqq__ccoommmmoonn, ssvvcc__ggeettrreeqq__ppoollll, ssvvcc__ggeettrreeqqsseett, ssvvcc__ggeettrrppccccaalllleerr, ssvvcc__ppoollllsseett, ssvvcc__rruunn, ssvvcc__sseennddrreeppllyy - library routines for RPC servers LLIIBBRRAARRYY Standard C Library (libc, -lc) SSYYNNOOPPSSIISS ##iinncclluuddee <> _i_n_t ssvvcc__ddgg__eennaabblleeccaacchhee(_S_V_C_X_P_R_T _*_x_p_r_t, _c_o_n_s_t _u_n_s_i_g_n_e_d _c_a_c_h_e___s_i_z_e); _v_o_i_d ssvvcc__eexxiitt(_v_o_i_d); _b_o_o_l___t ssvvcc__ffrreeeeaarrggss(_c_o_n_s_t _S_V_C_X_P_R_T _*_x_p_r_t, _c_o_n_s_t _x_d_r_p_r_o_c___t _i_n_p_r_o_c, _c_a_d_d_r___t _i_n); _b_o_o_l___t ssvvcc__ggeettaarrggss(_c_o_n_s_t _S_V_C_X_P_R_T _*_x_p_r_t, _c_o_n_s_t _x_d_r_p_r_o_c___t _i_n_p_r_o_c, _c_a_d_d_r___t _i_n); _v_o_i_d ssvvcc__ggeettrreeqq__ccoommmmoonn(_c_o_n_s_t _i_n_t _f_d); _v_o_i_d ssvvcc__ggeettrreeqq__ppoollll(_s_t_r_u_c_t _p_o_l_l_f_d _*_p_f_d_p, _c_o_n_s_t _i_n_t _p_o_l_l_r_e_t_v_a_l); _v_o_i_d ssvvcc__ggeettrreeqqsseett(_f_d___s_e_t _* _r_d_f_d_s); _s_t_r_u_c_t _n_e_t_b_u_f _* ssvvcc__ggeettrrppccccaalllleerr(_c_o_n_s_t _S_V_C_X_P_R_T _*_x_p_r_t); _s_t_r_u_c_t _s_o_c_k_c_r_e_d _* ____ssvvcc__ggeettccaalllleerrccrreeddss(_c_o_n_s_t _S_V_C_X_P_R_T _*_x_p_r_t); _s_t_r_u_c_t _p_o_l_l_f_d _s_v_c___p_o_l_l_s_e_t_[_F_D___S_E_T_S_I_Z_E_]_; _v_o_i_d ssvvcc__rruunn(_v_o_i_d); _b_o_o_l___t ssvvcc__sseennddrreeppllyy(_c_o_n_s_t _S_V_C_X_P_R_T _*_x_p_r_t, _c_o_n_s_t _x_d_r_p_r_o_c___t _o_u_t_p_r_o_c, _c_o_n_s_t _c_a_d_d_r___t _*_o_u_t); DDEESSCCRRIIPPTTIIOONN These routines are part of the RPC library which allows C language pro- grams to make procedure calls on other machines across the network. These routines are associated with the server side of the RPC mechanism. Some of them are called by the server side dispatch function, while oth- ers (such as ssvvcc__rruunn()) are called when the server is initiated. RROOUUTTIINNEESS See rpc(3) for the definition of the SVCXPRT data structure. ssvvcc__ddgg__eennaabblleeccaacchhee() This function allocates a duplicate request cache for the service endpoint _x_p_r_t, large enough to hold _c_a_c_h_e___s_i_z_e entries. Once enabled, there is no way to disable caching. This routine returns 0 if space necessary for a cache of the given size was successfully allocated, and 1 otherwise. ssvvcc__eexxiitt() This function when called by any of the RPC server procedure or otherwise, causes ssvvcc__rruunn() to return. As currently implemented, ssvvcc__eexxiitt() zeroes the svc_fdset global variable. If RPC server activ- ity is to be resumed, services must be reregis- tered with the RPC library either through one of the rrppcc__ssvvcc__ccrreeaattee() functions, or using xxpprrtt__rreeggiisstteerr(). ssvvcc__eexxiitt() has global scope and ends all RPC server activity. _f_d___s_e_t _s_v_c___f_d_s_e_t A global variable reflecting the RPC server's read file descriptor bit mask; it is suitable as a parameter to the select(2) system call. This is only of interest if service implementors do not call ssvvcc__rruunn(), but rather do their own asynchro- nous event processing. This variable is read- only (do not pass its address to select(2)!), yet it may change after calls to ssvvcc__ggeettrreeqqsseett() or any creation routines. ssvvcc__ffrreeeeaarrggss() A function macro that frees any data allocated by the RPC/XDR system when it decoded the arguments to a service procedure using ssvvcc__ggeettaarrggss(). This routine returns TRUE if the results were success- fully freed, and FALSE otherwise. ssvvcc__ggeettaarrggss() A function macro that decodes the arguments of an RPC request associated with the RPC service transport handle _x_p_r_t. The parameter _i_n is the address where the arguments will be placed; _i_n_p_r_o_c is the XDR routine used to decode the arguments. This routine returns TRUE if decoding succeeds, and FALSE otherwise. ssvvcc__ggeettrreeqq__ccoommmmoonn() This routine is called to handle a request on the given file descriptor. ssvvcc__ggeettrreeqq__ppoollll() This routine is only of interest if a service implementor does not call ssvvcc__rruunn(), but instead implements custom asynchronous event processing. It is called when poll(2) has determined that an RPC request has arrived on some RPC file descrip- tors; ppoollllrreettvvaall() is the return value from poll(2) and _p_f_d_p is the array of _p_o_l_l_f_d struc- tures on which the poll(2) was done. It is assumed to be an array large enough to contain the maximal number of descriptors allowed. ssvvcc__ggeettrreeqqsseett() This routine is only of interest if a service implementor does not call ssvvcc__rruunn(), but instead implements custom asynchronous event processing. It is called when poll(2) has deter- mined that an RPC request has arrived on some RPC file descriptors; _r_d_f_d_s is the resultant read file descriptor bit mask. The routine returns when all file descriptors associated with the value of _r_d_f_d_s have been serviced. ssvvcc__ggeettrrppccccaalllleerr() The approved way of getting the network address of the caller of a procedure associated with the RPC service transport handle _x_p_r_t. ____ssvvcc__ggeettccaalllleerrccrreeddss() _W_a_r_n_i_n_g_: _t_h_i_s _m_a_c_r_o _i_s _s_p_e_c_i_f_i_c _t_o NetBSD _a_n_d _t_h_u_s _n_o_t _p_o_r_t_a_b_l_e_. This macro returns a pointer to a sockcred structure, defined in <_s_y_s_/_s_o_c_k_e_t_._h>, identifying the calling client. This only works if the client is calling the server over an AF_LOCAL socket. _s_t_r_u_c_t _p_o_l_l_f_d _s_v_c___p_o_l_l_s_e_t_[_F_D___S_E_T_S_I_Z_E_]_; _s_v_c___p_o_l_l_s_e_t is an array of _p_o_l_l_f_d structures derived from _s_v_c___f_d_s_e_t_[_]. It is suitable as a parameter to the poll(2) system call. The derivation of _s_v_c___p_o_l_l_s_e_t from _s_v_c___f_d_s_e_t is made in the current implementation in ssvvcc__rruunn(). Ser- vice implementors who do not call ssvvcc__rruunn() and who wish to use this array must perform this derivation themselves. ssvvcc__rruunn() This routine never returns. It waits for RPC requests to arrive, and calls the appropriate service procedure using ssvvcc__ggeettrreeqq__ppoollll() when one arrives. This procedure is usually waiting for the poll(2) system call to return. ssvvcc__sseennddrreeppllyy() Called by an RPC service's dispatch routine to send the results of a remote procedure call. The parameter _x_p_r_t is the request's associated trans- port handle; _o_u_t_p_r_o_c is the XDR routine which is used to encode the results; and _o_u_t is the address of the results. This routine returns TRUE if it succeeds, FALSE otherwise. SSEEEE AALLSSOO poll(2), rpc(3), rpc_svc_create(3), rpc_svc_err(3), rpc_svc_reg(3) NetBSD 2.1 May 3, 1993 NetBSD 2.1