/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* onc720 src/oncplus/usr/include/tirpc/rpc/svc.h 1.5.1.1 */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* COPYRIGHT International Business Machines Corp. 1996,2012 */ /* All Rights Reserved */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* */ /* IBM_PROLOG_END_TAG */ /* * Copyright (c) 1986 - 1996 by Sun Microsystems, Inc. * All rights reserved. */ /* * svc.h, Server-side remote procedure call interface. * */ #ifndef _RPC_SVC_H #define _RPC_SVC_H /* #pragma ident "@(#)svc.h 1.51 97/05/14 SMI" */ typedef struct pollfd pollfd_t; #include #include #include /* * This interface must manage two items concerning remote procedure calling: * * 1) An arbitrary number of transport connections upon which rpc requests * are received. They are created and registered by routines in svc_generic.c, * svc_vc.c and svc_dg.c; they in turn call xprt_register and * xprt_unregister. * * 2) An arbitrary number of locally registered services. Services are * described by the following four data: program number, version number, * "service dispatch" function, a transport handle, and a boolean that * indicates whether or not the exported program should be registered with a * local binder service; if true the program's number and version and the * address from the transport handle are registered with the binder. * These data are registered with rpcbind via svc_reg(). * * A service's dispatch function is called whenever an rpc request comes in * on a transport. The request's program and version numbers must match * those of the registered service. The dispatch function is passed two * parameters, struct svc_req * and SVCXPRT *, defined below. */ #ifdef __cplusplus extern "C" { #endif /* * Service control requests */ #define SVCGET_VERSQUIET 1 #define SVCSET_VERSQUIET 2 #define SVCGET_XID 4 #define SVCSET_CONNMAXREC 6 #define SVCGET_CONNMAXREC 7 enum xprt_stat { XPRT_DIED, XPRT_MOREREQS, XPRT_IDLE }; /* * 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 */ struct __svcxprt *rq_xprt; /* associated transport */ }; struct xp_ops { bool_t (*xp_recv)(struct __svcxprt *, struct rpc_msg *); /* receive incoming requests */ enum xprt_stat (*xp_stat)(struct __svcxprt *); /* get transport status */ bool_t (*xp_getargs)(struct __svcxprt *, xdrproc_t, caddr_t); /* get arguments */ bool_t (*xp_reply)(struct __svcxprt *, struct rpc_msg *); /* send reply */ bool_t (*xp_freeargs)(struct __svcxprt *, xdrproc_t, caddr_t); /* free mem allocated for args */ void (*xp_destroy)(struct __svcxprt *); /* destroy this struct */ bool_t (*xp_control)(struct __svcxprt *, const u_int, void *); /* catch-all control function */ }; /* * Server side transport handle * xprt->xp_req_lock governs the following fields in xprt: * xp_req_head, xp_req_tail, xp_asleep, and xp_drowsy. * xprt->xp_thread_lock governs the following fields in xprt: * xp_max_threads, xp_min_threads, xp_detached_threads, * xp_threads, and xp_dead_cv. * xprt->xp_lock governs the rest of the fields in xprt, except for the * clone-only fields, which are not locked. * * The xp_threads count is the number of attached threads. These threads * are able to handle new requests, and it is expected that they will not * block for a very long time handling a given request. The * xp_detached_threads count is the number of threads that have detached * themselves from the transport. These threads can block indefinitely * while handling a request. Once they complete the request, they exit. * If the number of attached threads goes to zero, the transport can be * closed. If the sum of attached and detached threads goes to zero, the * data structure for the transport can be freed. * * A kernel service provider may register a callback function "closeproc" * for a transport. When the last attached thread exits (xp_threads goes * to zero in svc_thread_exit) it calls the callback function, passing it * a reference to the transport. This call is made with xp_thread_lock * held, so any cleanup bookkeeping it does should be done quickly. */ typedef struct __svcxprt { int xp_fd; #define xp_sock xp_fd u_short xp_port; /* * associated port number. * Obsoleted, but still used to * specify whether rendezvouser * or normal connection */ struct xp_ops *xp_ops; int xp_addrlen; /* length of remote addr. Obsoleted */ char *xp_tp; /* transport provider device name */ char *xp_netid; /* network token */ struct netbuf xp_ltaddr; /* local transport address */ struct netbuf xp_rtaddr; /* remote transport address */ char xp_raddr[16]; /* remote address. Now obsoleted */ struct opaque_auth xp_verf; /* raw response verifier */ caddr_t xp_p1; /* private: for use by svc ops */ caddr_t xp_p2; /* private: for use by svc ops */ caddr_t xp_p3; /* private: for use by svc lib */ int xp_type; /* transport type */ } SVCXPRT; /* * Approved way of getting address of caller, * address mask, and netid of transport. */ #define svc_getrpccaller(x) (&(x)->xp_rtaddr) /* * Operations defined on an SVCXPRT handle * * SVCXPRT *xprt; * struct rpc_msg *msg; * xdrproc_t xargs; * caddr_t argsp; */ #define SVC_RECV(xprt, msg) \ (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) #define svc_recv(xprt, msg) \ (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) #define SVC_STAT(xprt) \ (*(xprt)->xp_ops->xp_stat)(xprt) #define svc_stat(xprt) \ (*(xprt)->xp_ops->xp_stat)(xprt) #define SVC_GETARGS(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) #define svc_getargs(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) #define SVC_REPLY(xprt, msg) \ (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) #define svc_reply(xprt, msg) \ (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) #define SVC_FREEARGS(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) #define svc_freeargs(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) #define SVC_GETRES(xprt, size) \ (*(xprt)->xp_ops->xp_getres)((xprt), (size)) #define svc_getres(xprt, size) \ (*(xprt)->xp_ops->xp_getres)((xprt), (size)) #define SVC_FREERES(xprt) \ (*(xprt)->xp_ops->xp_freeres)(xprt) #define svc_freeres(xprt) \ (*(xprt)->xp_ops->xp_freeres)(xprt) #define SVC_DESTROY(xprt) \ (*(xprt)->xp_ops->xp_destroy)(xprt) #define svc_destroy(xprt) \ (*(xprt)->xp_ops->xp_destroy)(xprt) #define SVC_CONTROL(xprt, rq, in) \ (*(xprt)->xp_ops->xp_control)((xprt), (rq), (in)) #define svc_control(xprt, rq, in) \ (*(xprt)->xp_ops->xp_control)((xprt), (rq), (in)) extern bool_t rpc_reg(const rpcprog_t, const rpcvers_t, const rpcproc_t, char *(*)(char *), const xdrproc_t, const xdrproc_t, const char *); /* * Service registration * * svc_reg(xprt, prog, vers, dispatch, nconf) * const SVCXPRT *xprt; * const rpcprog_t prog; * const rpcvers_t vers; * const void (*dispatch)(); * const struct netconfig *nconf; */ extern int svc_reg(const SVCXPRT *, const rpcprog_t, const rpcvers_t, void (*)(struct svc_req *, SVCXPRT *), const struct netconfig *); /* * Service un-registration * * svc_unreg(prog, vers) * const rpcprog_t prog; * const rpcvers_t vers; */ extern void svc_unreg(const rpcprog_t, const rpcvers_t); extern int svc_auth_reg(const int,enum auth_stat (*handler)(struct svc_req *, struct rpc_msg *)); /* * Transport registration. * * xprt_register(xprt) * const SVCXPRT *xprt; */ extern void xprt_register(const SVCXPRT *); /* * Transport un-register * * xprt_unregister(xprt) * const SVCXPRT *xprt; */ extern void xprt_unregister(const 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, connectionful 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(const SVCXPRT *, const xdrproc_t, const caddr_t); extern void svcerr_decode(const SVCXPRT *); extern void svcerr_weakauth(const SVCXPRT *); extern void svcerr_noproc(const SVCXPRT *); extern void svcerr_progvers(const SVCXPRT *, const rpcvers_t, const rpcvers_t); extern void svcerr_auth(const SVCXPRT *, const enum auth_stat); extern void svcerr_noprog(const SVCXPRT *); extern void svcerr_systemerr(const 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 call (see select, section XXX). */ /* * Global keeper of rpc service descriptors in use * dynamic; must be inspected before each call to select */ extern pollfd_t *svc_pollfd; extern int svc_max_pollfd; extern fd_set svc_fdset; #define svc_fds svc_fdset.fds_bits[0] /* compatibility */ /* * a small program implemented by the svc_rpc implementation itself; * also see clnt.h for protocol numbers. */ extern void svc_getreq(int); extern void svc_getreqset(fd_set *); /* takes fdset instead of int */ extern void svc_run(void); extern void svc_exit(void); /* * These are the existing service side transport implementations */ /* * Transport independent svc_create routine. */ extern int svc_create(void (*)(struct svc_req *, SVCXPRT *), const rpcprog_t, const rpcvers_t, const char *); extern int svc_create2(void (*)(struct svc_req *, SVCXPRT *), const rpcprog_t, const rpcvers_t, const char *); /* * void (*dispatch)(); -- dispatch routine * const u_long prognum; -- program number * const u_long versnum; -- version number * const char *nettype; -- network type */ /* * Generic server creation routine. It takes a netconfig structure * instead of a nettype. */ extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *), const rpcprog_t, const rpcvers_t, const struct netconfig *); /* * void (*dispatch)(); -- dispatch routine * const rpcprog_t prognum; -- program number * const rpcvers_t versnum; -- version number * const struct netconfig *nconf; -- netconfig structure */ /* * Generic TLI create routine */ extern SVCXPRT *svc_tli_create(const int,const struct netconfig *, const struct t_bind *r,const uint_t,const uint_t); /* * const int fd; -- connection end point * const struct netconfig *nconf; -- netconfig structure for network * const struct t_bind *bindaddr; -- local bind address * const uint_t sendsz; -- max sendsize * const uint_t recvsz; -- max recvsize */ /* * Connectionless and connectionful create routines */ extern SVCXPRT *svc_vc_create(const int , const uint_t , const uint_t); /* * const int fd; -- open connection end point * const uint_t sendsize; -- max send size * const uint_t recvsize; -- max recv size */ extern SVCXPRT *svc_dg_create(const int, const uint_t, const uint_t); /* * const int fd; -- open connection * const uint_t sendsize; -- max send size * const uint_t recvsize; -- max recv size */ /* * the routine takes any *open* TLI file * descriptor as its first input and is used for open connections. */ extern SVCXPRT *svc_fd_create(const int, const uint_t, const uint_t); /* * const int fd; -- open connection end point * const uint_t sendsize; -- max send size * const uint_t recvsize; -- max recv size */ /* * Memory based rpc (for speed check and testing) */ extern SVCXPRT *svc_raw_create(void); /* * Creation of service over doors transport. */ extern SVCXPRT *svc_door_create(void (*)(struct svc_req *, SVCXPRT *), const rpcprog_t, const rpcvers_t, const uint_t); /* * void (*dispatch)(); -- dispatch routine * const rpcprog_t prognum; -- program number * const rpcvers_t versnum; -- version number * const uint_t sendsize; -- send buffer size */ /* * svc_dg_enable_cache() enables the cache on dg transports. */ extern int svc_dg_enablecache(SVCXPRT *, const uint_t); #ifdef PORTMAP /* For backward compatibility */ #include #endif /* * For user level MT hot server functions */ /* * Different MT modes */ #define RPC_SVC_MT_NONE 0 /* default, single-threaded */ #define RPC_SVC_MT_AUTO 1 /* automatic MT mode */ #define RPC_SVC_MT_USER 2 /* user MT mode */ void svc_done(SVCXPRT *); /* * Obtaining local credentials. */ typedef struct __svc_local_cred_t { uid_t euid; /* effective uid */ gid_t egid; /* effective gid */ uid_t ruid; /* real uid */ gid_t rgid; /* real gid */ pid_t pid; /* caller's pid, or -1 if not available */ } svc_local_cred_t; bool_t svc_get_local_cred(SVCXPRT *, svc_local_cred_t *); /* * Private interfaces and structures for user level duplicate request caching. * The interfaces and data structures are not committed and subject to * change in future releases. Currently only intended for use by automountd. */ struct dupreq { u_long dr_xid; u_long dr_proc; u_long dr_vers; u_long dr_prog; struct netbuf dr_addr; struct netbuf dr_resp; int dr_status; time_t dr_time; u_long dr_hash; struct dupreq *dr_next; struct dupreq *dr_prev; struct dupreq *dr_chain; struct dupreq *dr_prevchain; }; /* * the fixedtime state is defined if we want to expand the routines to * handle and encompass fixed size caches. */ #define DUPCACHE_FIXEDTIME 0 /* * states of requests for duplicate request caching. These are the * same as defined for the kernel. */ #define DUP_NEW 0x00 /* new entry */ #define DUP_INPROGRESS 0x01 /* request already going */ #define DUP_DONE 0x02 /* request done */ #define DUP_DROP 0x03 /* request dropped */ #define DUP_ERROR 0x04 /* error in dup req cache */ extern bool_t __svc_dupcache_init(void *, int, char **); extern int __svc_dup(struct svc_req *, caddr_t *, u_int *, char *); extern int __svc_dupdone(struct svc_req *, caddr_t, u_int, int, char *); extern bool_t __svc_vc_dupcache_init(SVCXPRT *, void *, int); extern int __svc_vc_dup(struct svc_req *, caddr_t *, u_int *); extern int __svc_vc_dupdone(struct svc_req *, caddr_t, u_int, int); #ifdef _AIX /* * Used in KERNEL and user space. These statistics are recorded in the * nfs_krpc.ext kernel extension and reported via the cmd nfsstat or the * programming interface nfs_cntl() (see below). * * Server side rpc statistics * struct is to be used with * NFS_CNTL_GET_SVKRPC_STAT in which the return stats are placed * in var of this type, i.e. * t_rsstat rsstat; * nfs_cntl(NFS_CNTL_GET_SVKRPC_STAT,&rsstat,NFS_CNTL_SVKRPC_SIZE); */ typedef struct { int rscalls; int rsbadcalls; int rsnullrecv; int rsbadlen; int rsxdrcall; int rsdupchecks; int rsdupreqs; } t_rsstat ; #endif #ifdef __cplusplus } #endif #endif /* !_RPC_SVC_H */