xref: /freebsd/sys/rpc/krpc.h (revision 595e514d0df2bac5b813d35f83e32875dbf16a83)
1 /*-
2  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3  * unrestricted use provided that this legend is included on all tape
4  * media and as a part of the software program in whole or part.  Users
5  * may copy or modify Sun RPC without charge, but are not authorized
6  * to license or distribute it to anyone else except as part of a product or
7  * program developed by the user.
8  *
9  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12  *
13  * Sun RPC is provided with no support and without any obligation on the
14  * part of Sun Microsystems, Inc. to assist in its use, correction,
15  * modification or enhancement.
16  *
17  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19  * OR ANY PART THEREOF.
20  *
21  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22  * or profits or other special, indirect and consequential damages, even if
23  * Sun has been advised of the possibility of such damages.
24  *
25  * Sun Microsystems, Inc.
26  * 2550 Garcia Avenue
27  * Mountain View, California  94043
28  *
29  * $FreeBSD$
30  */
31 
32 #ifndef _RPC_KRPC_H_
33 #define	_RPC_KRPC_H_
34 
35 #ifdef _KERNEL
36 /*
37  * Definitions now shared between client and server RPC for backchannels.
38  */
39 #define MCALL_MSG_SIZE 24
40 
41 /*
42  * A pending RPC request which awaits a reply. Requests which have
43  * received their reply will have cr_xid set to zero and cr_mrep to
44  * the mbuf chain of the reply.
45  */
46 struct ct_request {
47 	TAILQ_ENTRY(ct_request) cr_link;
48 	uint32_t		cr_xid;		/* XID of request */
49 	struct mbuf		*cr_mrep;	/* reply received by upcall */
50 	int			cr_error;	/* any error from upcall */
51 	char			cr_verf[MAX_AUTH_BYTES]; /* reply verf */
52 };
53 
54 TAILQ_HEAD(ct_request_list, ct_request);
55 
56 struct rc_data {
57 	struct mtx		rc_lock;
58 	struct sockaddr_storage	rc_addr; /* server address */
59 	struct netconfig*	rc_nconf; /* network type */
60 	rpcprog_t		rc_prog;  /* program number */
61 	rpcvers_t		rc_vers;  /* version number */
62 	size_t			rc_sendsz;
63 	size_t			rc_recvsz;
64 	struct timeval		rc_timeout;
65 	struct timeval		rc_retry;
66 	int			rc_retries;
67 	int			rc_privport;
68 	char			*rc_waitchan;
69 	int			rc_intr;
70 	int			rc_connecting;
71 	int			rc_closed;
72 	struct ucred		*rc_ucred;
73 	CLIENT*			rc_client; /* underlying RPC client */
74 	struct rpc_err		rc_err;
75 	void			*rc_backchannel;
76 };
77 
78 struct ct_data {
79 	struct mtx	ct_lock;
80 	int		ct_threads;	/* number of threads in clnt_vc_call */
81 	bool_t		ct_closing;	/* TRUE if we are closing */
82 	bool_t		ct_closed;	/* TRUE if we are closed */
83 	struct socket	*ct_socket;	/* connection socket */
84 	bool_t		ct_closeit;	/* close it on destroy */
85 	struct timeval	ct_wait;	/* wait interval in milliseconds */
86 	struct sockaddr_storage	ct_addr; /* remote addr */
87 	struct rpc_err	ct_error;
88 	uint32_t	ct_xid;
89 	char		ct_mcallc[MCALL_MSG_SIZE]; /* marshalled callmsg */
90 	size_t		ct_mpos;	/* pos after marshal */
91 	const char	*ct_waitchan;
92 	int		ct_waitflag;
93 	struct mbuf	*ct_record;	/* current reply record */
94 	size_t		ct_record_resid; /* how much left of reply to read */
95 	bool_t		ct_record_eor;	 /* true if reading last fragment */
96 	struct ct_request_list ct_pending;
97 	int		ct_upcallrefs;	/* Ref cnt of upcalls in prog. */
98 	SVCXPRT		*ct_backchannelxprt; /* xprt for backchannel */
99 };
100 
101 struct cf_conn {  /* kept in xprt->xp_p1 for actual connection */
102 	enum xprt_stat strm_stat;
103 	struct mbuf *mpending;	/* unparsed data read from the socket */
104 	struct mbuf *mreq;	/* current record being built from mpending */
105 	uint32_t resid;		/* number of bytes needed for fragment */
106 	bool_t eor;		/* reading last fragment of current record */
107 };
108 
109 #endif	/* _KERNEL */
110 
111 #endif	/* _RPC_KRPC_H_ */
112