]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - sys/rpc/krpc.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / sys / rpc / krpc.h
1 /*-
2  * Copyright (c) 2009, Sun Microsystems, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * - Redistributions of source code must retain the above copyright notice,
8  *   this list of conditions and the following disclaimer.
9  * - Redistributions in binary form must reproduce the above copyright notice,
10  *   this list of conditions and the following disclaimer in the documentation
11  *   and/or other materials provided with the distribution.
12  * - Neither the name of Sun Microsystems, Inc. nor the names of its
13  *   contributors may be used to endorse or promote products derived
14  *   from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR   
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30
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 void clnt_bck_svccall(void *, struct mbuf *, uint32_t);
41 enum clnt_stat clnt_bck_call(CLIENT *, struct rpc_callextra *, rpcproc_t,
42     struct mbuf *, struct mbuf **, struct timeval, SVCXPRT *);
43
44 /*
45  * A pending RPC request which awaits a reply. Requests which have
46  * received their reply will have cr_xid set to zero and cr_mrep to
47  * the mbuf chain of the reply.
48  */
49 struct ct_request {
50         TAILQ_ENTRY(ct_request) cr_link;
51         uint32_t                cr_xid;         /* XID of request */
52         struct mbuf             *cr_mrep;       /* reply received by upcall */
53         int                     cr_error;       /* any error from upcall */
54         char                    cr_verf[MAX_AUTH_BYTES]; /* reply verf */
55 };
56
57 TAILQ_HEAD(ct_request_list, ct_request);
58
59 struct rc_data {
60         struct mtx              rc_lock;
61         struct sockaddr_storage rc_addr; /* server address */
62         struct netconfig*       rc_nconf; /* network type */
63         rpcprog_t               rc_prog;  /* program number */
64         rpcvers_t               rc_vers;  /* version number */
65         size_t                  rc_sendsz;
66         size_t                  rc_recvsz;
67         struct timeval          rc_timeout;
68         struct timeval          rc_retry;
69         int                     rc_retries;
70         int                     rc_privport;
71         char                    *rc_waitchan;
72         int                     rc_intr;
73         int                     rc_connecting;
74         int                     rc_closed;
75         struct ucred            *rc_ucred;
76         CLIENT*                 rc_client; /* underlying RPC client */
77         struct rpc_err          rc_err;
78         void                    *rc_backchannel;
79 };
80
81 struct ct_data {
82         struct mtx      ct_lock;
83         int             ct_threads;     /* number of threads in clnt_vc_call */
84         bool_t          ct_closing;     /* TRUE if we are closing */
85         bool_t          ct_closed;      /* TRUE if we are closed */
86         struct socket   *ct_socket;     /* connection socket */
87         bool_t          ct_closeit;     /* close it on destroy */
88         struct timeval  ct_wait;        /* wait interval in milliseconds */
89         struct sockaddr_storage ct_addr; /* remote addr */
90         struct rpc_err  ct_error;
91         uint32_t        ct_xid;
92         char            ct_mcallc[MCALL_MSG_SIZE]; /* marshalled callmsg */
93         size_t          ct_mpos;        /* pos after marshal */
94         const char      *ct_waitchan;
95         int             ct_waitflag;
96         struct mbuf     *ct_record;     /* current reply record */
97         size_t          ct_record_resid; /* how much left of reply to read */
98         bool_t          ct_record_eor;   /* true if reading last fragment */
99         struct ct_request_list ct_pending;
100         int             ct_upcallrefs;  /* Ref cnt of upcalls in prog. */
101         SVCXPRT         *ct_backchannelxprt; /* xprt for backchannel */
102 };
103
104 struct cf_conn {  /* kept in xprt->xp_p1 for actual connection */
105         enum xprt_stat strm_stat;
106         struct mbuf *mpending;  /* unparsed data read from the socket */
107         struct mbuf *mreq;      /* current record being built from mpending */
108         uint32_t resid;         /* number of bytes needed for fragment */
109         bool_t eor;             /* reading last fragment of current record */
110 };
111
112 #endif  /* _KERNEL */
113
114 #endif  /* _RPC_KRPC_H_ */