1244008Srmacklem/*- 2261046Smav * Copyright (c) 2009, Sun Microsystems, Inc. 3261046Smav * All rights reserved. 4244008Srmacklem * 5261046Smav * Redistribution and use in source and binary forms, with or without 6261046Smav * modification, are permitted provided that the following conditions are met: 7261046Smav * - Redistributions of source code must retain the above copyright notice, 8261046Smav * this list of conditions and the following disclaimer. 9261046Smav * - Redistributions in binary form must reproduce the above copyright notice, 10261046Smav * this list of conditions and the following disclaimer in the documentation 11261046Smav * and/or other materials provided with the distribution. 12261046Smav * - Neither the name of Sun Microsystems, Inc. nor the names of its 13261046Smav * contributors may be used to endorse or promote products derived 14261046Smav * from this software without specific prior written permission. 15261046Smav * 16261046Smav * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17261046Smav * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18261046Smav * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19261046Smav * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20261046Smav * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21261046Smav * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22261046Smav * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23261046Smav * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24261046Smav * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25261046Smav * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26261046Smav * POSSIBILITY OF SUCH DAMAGE. 27261046Smav * 28244008Srmacklem * $FreeBSD$ 29244008Srmacklem */ 30244008Srmacklem 31244008Srmacklem#ifndef _RPC_KRPC_H_ 32244008Srmacklem#define _RPC_KRPC_H_ 33244008Srmacklem 34244008Srmacklem#ifdef _KERNEL 35244008Srmacklem/* 36244008Srmacklem * Definitions now shared between client and server RPC for backchannels. 37244008Srmacklem */ 38244008Srmacklem#define MCALL_MSG_SIZE 24 39244008Srmacklem 40269398Srmacklemvoid clnt_bck_svccall(void *, struct mbuf *, uint32_t); 41269398Srmacklemenum clnt_stat clnt_bck_call(CLIENT *, struct rpc_callextra *, rpcproc_t, 42269398Srmacklem struct mbuf *, struct mbuf **, struct timeval, SVCXPRT *); 43269398Srmacklem 44244008Srmacklem/* 45244008Srmacklem * A pending RPC request which awaits a reply. Requests which have 46244008Srmacklem * received their reply will have cr_xid set to zero and cr_mrep to 47244008Srmacklem * the mbuf chain of the reply. 48244008Srmacklem */ 49244008Srmacklemstruct ct_request { 50244008Srmacklem TAILQ_ENTRY(ct_request) cr_link; 51244008Srmacklem uint32_t cr_xid; /* XID of request */ 52244008Srmacklem struct mbuf *cr_mrep; /* reply received by upcall */ 53244008Srmacklem int cr_error; /* any error from upcall */ 54244008Srmacklem char cr_verf[MAX_AUTH_BYTES]; /* reply verf */ 55244008Srmacklem}; 56244008Srmacklem 57244008SrmacklemTAILQ_HEAD(ct_request_list, ct_request); 58244008Srmacklem 59244008Srmacklemstruct rc_data { 60244008Srmacklem struct mtx rc_lock; 61244008Srmacklem struct sockaddr_storage rc_addr; /* server address */ 62244008Srmacklem struct netconfig* rc_nconf; /* network type */ 63244008Srmacklem rpcprog_t rc_prog; /* program number */ 64244008Srmacklem rpcvers_t rc_vers; /* version number */ 65244008Srmacklem size_t rc_sendsz; 66244008Srmacklem size_t rc_recvsz; 67244008Srmacklem struct timeval rc_timeout; 68244008Srmacklem struct timeval rc_retry; 69244008Srmacklem int rc_retries; 70244008Srmacklem int rc_privport; 71244008Srmacklem char *rc_waitchan; 72244008Srmacklem int rc_intr; 73244008Srmacklem int rc_connecting; 74244008Srmacklem int rc_closed; 75244008Srmacklem struct ucred *rc_ucred; 76244008Srmacklem CLIENT* rc_client; /* underlying RPC client */ 77244008Srmacklem struct rpc_err rc_err; 78244008Srmacklem void *rc_backchannel; 79244008Srmacklem}; 80244008Srmacklem 81244008Srmacklemstruct ct_data { 82244008Srmacklem struct mtx ct_lock; 83244008Srmacklem int ct_threads; /* number of threads in clnt_vc_call */ 84244008Srmacklem bool_t ct_closing; /* TRUE if we are closing */ 85244008Srmacklem bool_t ct_closed; /* TRUE if we are closed */ 86244008Srmacklem struct socket *ct_socket; /* connection socket */ 87244008Srmacklem bool_t ct_closeit; /* close it on destroy */ 88244008Srmacklem struct timeval ct_wait; /* wait interval in milliseconds */ 89244008Srmacklem struct sockaddr_storage ct_addr; /* remote addr */ 90244008Srmacklem struct rpc_err ct_error; 91244008Srmacklem uint32_t ct_xid; 92244008Srmacklem char ct_mcallc[MCALL_MSG_SIZE]; /* marshalled callmsg */ 93244008Srmacklem size_t ct_mpos; /* pos after marshal */ 94244008Srmacklem const char *ct_waitchan; 95244008Srmacklem int ct_waitflag; 96244008Srmacklem struct mbuf *ct_record; /* current reply record */ 97244008Srmacklem size_t ct_record_resid; /* how much left of reply to read */ 98244008Srmacklem bool_t ct_record_eor; /* true if reading last fragment */ 99244008Srmacklem struct ct_request_list ct_pending; 100244008Srmacklem int ct_upcallrefs; /* Ref cnt of upcalls in prog. */ 101244008Srmacklem SVCXPRT *ct_backchannelxprt; /* xprt for backchannel */ 102244008Srmacklem}; 103244008Srmacklem 104244008Srmacklemstruct cf_conn { /* kept in xprt->xp_p1 for actual connection */ 105244008Srmacklem enum xprt_stat strm_stat; 106244008Srmacklem struct mbuf *mpending; /* unparsed data read from the socket */ 107244008Srmacklem struct mbuf *mreq; /* current record being built from mpending */ 108244008Srmacklem uint32_t resid; /* number of bytes needed for fragment */ 109244008Srmacklem bool_t eor; /* reading last fragment of current record */ 110244008Srmacklem}; 111244008Srmacklem 112244008Srmacklem#endif /* _KERNEL */ 113244008Srmacklem 114244008Srmacklem#endif /* _RPC_KRPC_H_ */ 115