📄 svc.h
字号:
res = (*svc_func)(xprt, msg); \
return(res); \
}
#else
static bool_t svcreply(xprt,msg) \
SVCXPRT *xprt;\
struct rpc_msg *msg; \
{ \
bool_t res,(*svc_func) (ANSIPROT2(SVCXPRT *, struct rpc_msg *)); \
rpc_mutex_lock(xports_mtx_id); \
svc_func = xprt->xp_ops->xp_reply; \
rpc_mutex_unlock(xports_mtx_id); \
res = (*svc_func)(xprt, msg); \
return(res); \
}
#endif /* __STDC__ */
#define SVC_REPLY(xprt, msg) \
svcreply((xprt),(msg))
#define svc_reply(xprt, msg) \
svcreply((xprt),(msg))
#if (defined __STDC) || defined (__cplusplus)
static bool_t svcfreeargs(SVCXPRT *xprt, xdrproc_t xargs, caddr_t argsp) \
{ \
bool_t res,(*svc_func) (ANSIPROT3(SVCXPRT *, xdrproc_t, caddr_t)); \
rpc_mutex_lock(xports_mtx_id); \
svc_func = xprt->xp_ops->xp_freeargs; \
rpc_mutex_unlock(xports_mtx_id); \
res = (*svc_func)(xprt,xargs,argsp); \
return(res); \
}
#else
static bool_t svcfreeargs(xprt,xargs,argsp) \
SVCXPRT *xprt;\
xdrproc_t xargs;\
caddr_t argsp;\
{ \
bool_t res,(*svc_func) (ANSIPROT3(SVCXPRT *, xdrproc_t, caddr_t)); \
rpc_mutex_lock(xports_mtx_id); \
svc_func = xprt->xp_ops->xp_freeargs; \
rpc_mutex_unlock(xports_mtx_id); \
res = (*svc_func)(xprt,xargs,argsp); \
return(res); \
}
#endif /* __STDC__ */
#define SVC_FREEARGS(xprt, xargs, argsp) \
svcfreeargs((xprt), (xargs), (argsp))
#define svc_freeargs(xprt, xargs, argsp) \
svcfreeargs((xprt), (xargs), (argsp))
#if (defined __STDC) || defined (__cplusplus)
static void svcdestroy(SVCXPRT *xprt) \
{ \
void (*svc_func) (ANSIPROT1(SVCXPRT *)); \
rpc_mutex_lock(xports_mtx_id); \
svc_func = xprt->xp_ops->xp_destroy; \
rpc_mutex_unlock(xports_mtx_id); \
(*svc_func)(xprt); \
}
#else
static void svcdestroy(xprt) \
SVCXPRT *xprt;\
{ \
void (*svc_func) (ANSIPROT1(SVCXPRT *)); \
rpc_mutex_lock(xports_mtx_id); \
svc_func = xprt->xp_ops->xp_destroy; \
rpc_mutex_unlock(xports_mtx_id); \
(*svc_func)(xprt); \
}
#endif /* __STDC__ */
#define SVC_DESTROY(xprt) \
svcdestroy(xprt)
#define svc_destroy(xprt) \
svcdestroy(xprt) \
/*
* Service request
*/
struct svc_req {
u_long rq_prog; /* service program number */
u_long rq_vers; /* service protocol version */
u_long rq_proc; /* the desired procedure */
struct opaque_auth rq_cred; /* raw creds from the wire */
caddr_t rq_clntcred; /* read only cooked cred */
SVCXPRT *rq_xprt; /* associated transport */
};
/*
* Service registration
*
* svc_register(xprt, prog, vers, dispatch, protocol)
* SVCXPRT *xprt;
* u_long prog;
* u_long vers;
* void (*dispatch)();
* int protocol; like TCP or UDP, zero means do not register
*/
extern bool_t svc_register (ANSIPROT5(SVCXPRT *xprt, u_long prog, u_long vers,
void (*dispatch)(struct svc_req *,
SVCXPRT *),
int protocol));
/*
* Service un-registration
*
* svc_unregister(prog, vers)
* u_long prog;
* u_long vers;
*/
extern void svc_unregister (ANSIPROT2(u_long prog, u_long vers));
/*
* Transport registration.
*
* xprt_register(xprt)
* SVCXPRT *xprt;
*/
extern void xprt_register (ANSIPROT1(SVCXPRT *));
/*
* Transport un-register
*
* xprt_unregister(xprt)
* SVCXPRT *xprt;
*/
extern void xprt_unregister (ANSIPROT1(SVCXPRT *));
/*
* When the service routine is called, it must first check to see if it
* knows about the procedure; if not, it should call svcerr_noproc
* and return. If so, it should deserialize its arguments via
* SVC_GETARGS (defined above). If the deserialization does not work,
* svcerr_decode should be called followed by a return. Successful
* decoding of the arguments should be followed the execution of the
* procedure's code and a call to svc_sendreply.
*
* Also, if the service refuses to execute the procedure due to too-
* weak authentication parameters, svcerr_weakauth should be called.
* Note: do not confuse access-control failure with weak authentication!
*
* NB: In pure implementations of rpc, the caller always waits for a reply
* msg. This message is sent when svc_sendreply is called.
* Therefore pure service implementations should always call
* svc_sendreply even if the function logically returns void; use
* xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows
* for the abuse of pure rpc via batched calling or pipelining. In the
* case of a batched call, svc_sendreply should NOT be called since
* this would send a return message, which is what batching tries to avoid.
* It is the service/protocol writer's responsibility to know which calls are
* batched and which are not. Warning: responding to batch calls may
* deadlock the caller and server processes!
*/
extern bool_t svc_sendreply (ANSIPROT3(SVCXPRT *xprt, xdrproc_t xdr_results,
caddr_t xdr_location));
extern void svcerr_decode (ANSIPROT1(SVCXPRT *));
extern void svcerr_weakauth (ANSIPROT1(SVCXPRT *));
extern void svcerr_noproc (ANSIPROT1(SVCXPRT *));
extern void svcerr_progvers (ANSIPROT3(SVCXPRT *xprt, u_long low_vers, u_long
high_vers));
extern void svcerr_auth (ANSIPROT2(SVCXPRT *xprt, enum auth_stat why));
extern void svcerr_noprog (ANSIPROT1(SVCXPRT *));
extern void svcerr_systemerr (ANSIPROT1(SVCXPRT *));
/*
* Lowest level dispatching -OR- who owns this process anyway.
* Somebody has to wait for incoming requests and then call the correct
* service routine. The routine svc_run does infinite waiting; i.e.,
* svc_run never returns.
* Since another (co-existant) package may wish to selectively wait for
* incoming calls or other events outside of the rpc architecture, the
* routine svc_getreq is provided. It must be passed readfds, the
* "in-place" results of a select system call (see select, section 2).
*/
/*
* Global keeper of rpc service descriptors in use
* dynamic; must be inspected before each call to select
*/
#ifdef FD_SETSIZE
extern fd_set svc_fdset;
/*#define svc_fdset XTWS->tws_svcet_fds*/
#define svc_fds svc_fdset.fds_bits[0] /* compatibility */
#else
/*#define svc_fds XTWS->tws_svc_fds*/
extern int svc_fds;
#endif /* def FD_SETSIZE */
/*
* a small program implemented by the svc_rpc implementation itself;
* also see clnt.h for protocol numbers.
*/
extern void rpctest_service (ANSIPROT1(void));
extern void svc_getreq (ANSIPROT1(int));
extern void svc_getreqset (ANSIPROT1(int *)); /* takes fdset instead of int */
extern void svc_run (ANSIPROT1(void)); /* never returns */
/*
* Socket to use on svcxxx_create call to get default socket
*/
#define RPC_ANYSOCK -1
/*
* These are the existing service side transport implementations
*/
/*
* Memory based rpc for testing and timing.
*/
extern SVCXPRT *svcraw_create (ANSIPROT1(void));
/*
* Udp based rpc.
*/
extern SVCXPRT *svcudp_create (ANSIPROT1(int));
extern SVCXPRT *svcudp_bufcreate (ANSIPROT3(int sock, u_int sendsz, u_int recvsz));
/*
* Tcp based rpc.
*/
extern SVCXPRT *svctcp_create (ANSIPROT3(int sock, u_int sendsize, u_int recvsize));
#ifdef __cplusplus
}
#endif
#endif /* !__SVC_HEADER__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -