krpc.h revision 261046
1238901Sandrew/*-
2238901Sandrew * Copyright (c) 2009, Sun Microsystems, Inc.
3353358Sdim * All rights reserved.
4353358Sdim *
5353358Sdim * Redistribution and use in source and binary forms, with or without
6238901Sandrew * modification, are permitted provided that the following conditions are met:
7238901Sandrew * - Redistributions of source code must retain the above copyright notice,
8238901Sandrew *   this list of conditions and the following disclaimer.
9238901Sandrew * - Redistributions in binary form must reproduce the above copyright notice,
10238901Sandrew *   this list of conditions and the following disclaimer in the documentation
11238901Sandrew *   and/or other materials provided with the distribution.
12238901Sandrew * - Neither the name of Sun Microsystems, Inc. nor the names of its
13238901Sandrew *   contributors may be used to endorse or promote products derived
14238901Sandrew *   from this software without specific prior written permission.
15238901Sandrew *
16238901Sandrew * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17238901Sandrew * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18238901Sandrew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19238901Sandrew * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20274201Sdim * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21274201Sdim * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22276789Sdim * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23245614Sandrew * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24251034Sed * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25238901Sandrew * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26238901Sandrew * POSSIBILITY OF SUCH DAMAGE.
27238901Sandrew *
28238901Sandrew * $FreeBSD: stable/10/sys/rpc/krpc.h 261046 2014-01-22 23:45:27Z mav $
29238901Sandrew */
30238901Sandrew
31#ifndef _RPC_KRPC_H_
32#define	_RPC_KRPC_H_
33
34#ifdef _KERNEL
35/*
36 * Definitions now shared between client and server RPC for backchannels.
37 */
38#define MCALL_MSG_SIZE 24
39
40/*
41 * A pending RPC request which awaits a reply. Requests which have
42 * received their reply will have cr_xid set to zero and cr_mrep to
43 * the mbuf chain of the reply.
44 */
45struct ct_request {
46	TAILQ_ENTRY(ct_request) cr_link;
47	uint32_t		cr_xid;		/* XID of request */
48	struct mbuf		*cr_mrep;	/* reply received by upcall */
49	int			cr_error;	/* any error from upcall */
50	char			cr_verf[MAX_AUTH_BYTES]; /* reply verf */
51};
52
53TAILQ_HEAD(ct_request_list, ct_request);
54
55struct rc_data {
56	struct mtx		rc_lock;
57	struct sockaddr_storage	rc_addr; /* server address */
58	struct netconfig*	rc_nconf; /* network type */
59	rpcprog_t		rc_prog;  /* program number */
60	rpcvers_t		rc_vers;  /* version number */
61	size_t			rc_sendsz;
62	size_t			rc_recvsz;
63	struct timeval		rc_timeout;
64	struct timeval		rc_retry;
65	int			rc_retries;
66	int			rc_privport;
67	char			*rc_waitchan;
68	int			rc_intr;
69	int			rc_connecting;
70	int			rc_closed;
71	struct ucred		*rc_ucred;
72	CLIENT*			rc_client; /* underlying RPC client */
73	struct rpc_err		rc_err;
74	void			*rc_backchannel;
75};
76
77struct ct_data {
78	struct mtx	ct_lock;
79	int		ct_threads;	/* number of threads in clnt_vc_call */
80	bool_t		ct_closing;	/* TRUE if we are closing */
81	bool_t		ct_closed;	/* TRUE if we are closed */
82	struct socket	*ct_socket;	/* connection socket */
83	bool_t		ct_closeit;	/* close it on destroy */
84	struct timeval	ct_wait;	/* wait interval in milliseconds */
85	struct sockaddr_storage	ct_addr; /* remote addr */
86	struct rpc_err	ct_error;
87	uint32_t	ct_xid;
88	char		ct_mcallc[MCALL_MSG_SIZE]; /* marshalled callmsg */
89	size_t		ct_mpos;	/* pos after marshal */
90	const char	*ct_waitchan;
91	int		ct_waitflag;
92	struct mbuf	*ct_record;	/* current reply record */
93	size_t		ct_record_resid; /* how much left of reply to read */
94	bool_t		ct_record_eor;	 /* true if reading last fragment */
95	struct ct_request_list ct_pending;
96	int		ct_upcallrefs;	/* Ref cnt of upcalls in prog. */
97	SVCXPRT		*ct_backchannelxprt; /* xprt for backchannel */
98};
99
100struct cf_conn {  /* kept in xprt->xp_p1 for actual connection */
101	enum xprt_stat strm_stat;
102	struct mbuf *mpending;	/* unparsed data read from the socket */
103	struct mbuf *mreq;	/* current record being built from mpending */
104	uint32_t resid;		/* number of bytes needed for fragment */
105	bool_t eor;		/* reading last fragment of current record */
106};
107
108#endif	/* _KERNEL */
109
110#endif	/* _RPC_KRPC_H_ */
111