4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 * clnt.h - Client side remote procedure call interface.
27 * Stripped down sockets based client for boot.
33 #pragma ident "%Z%%M% %I% %E% SMI"
35 #include <sys/types.h>
36 #include <rpc/clnt_stat.h>
38 #include <netinet/in.h>
48 enum clnt_stat re_status
;
50 int RE_errno
; /* realated system error */
51 enum auth_stat RE_why
; /* why the auth error occurred */
53 #define re_errno ru.RE_errno
54 #define re_why ru.RE_why
60 * Created by individual implementations, see e.g. rpc_udp.c.
61 * Client is responsible for initializing auth, see e.g. auth_none.c.
63 typedef struct __client
{
64 AUTH
*cl_auth
; /* authenticator */
66 /* call remote procedure */
67 enum clnt_stat (*cl_call
)(struct __client
*, rpcproc_t
,
68 xdrproc_t
, caddr_t
, xdrproc_t
,
69 caddr_t
, struct timeval
);
71 void (*cl_abort
)(/* various */);
72 /* get specific error code */
73 void (*cl_geterr
)(struct __client
*,
76 bool_t (*cl_freeres
)(struct __client
*, xdrproc_t
,
78 /* destroy this structure */
79 void (*cl_destroy
)(struct __client
*);
80 /* the ioctl() of rpc */
81 bool_t (*cl_control
)(struct __client
*, int, char *);
83 caddr_t cl_private
; /* private stuff */
88 * client side rpc interface ops
90 * Parameter types are:
96 * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
103 * struct timeval timeout;
105 #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
106 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
113 #define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh))
120 #define CLNT_GETERR(rh, errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
124 * CLNT_FREERES(rh, xres, resp);
129 #define CLNT_FREERES(rh, xres, resp) ((*(rh)->cl_ops->cl_freeres)\
134 * CLNT_CONTROL(cl, request, info)
139 #define CLNT_CONTROL(cl, rq, in) ((*(cl)->cl_ops->cl_control)(cl, rq, in))
142 * control operations that apply to both udp and tcp transports
144 #define CLSET_TIMEOUT 1 /* set timeout (timeval) */
145 #define CLGET_TIMEOUT 2 /* get timeout (timeval) */
146 #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
147 #define CLGET_FD 6 /* get connections file descriptor */
148 #define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */
149 #define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */
151 * udp only control operations
153 #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
154 #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
161 #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
164 * By convention, procedure 0 takes null arguments and returns them
167 #define NULLPROC ((ulong_t)0)
170 * Below are the client handle creation routines for the various
171 * implementations of client side rpc. They can return NULL if a
172 * creation failure occurs.
178 * clntbudp_create(raddr, program, version, wait, sockp)
179 * struct sockaddr_in *raddr;
182 * struct timeval wait;
185 * Same as above, but you specify max packet sizes.
187 * clntbudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
188 * struct sockaddr_in *raddr;
191 * struct timeval wait;
196 extern CLIENT
*clntbudp_create(struct sockaddr_in
*raddr
, rpcprog_t program
,
197 rpcvers_t version
, struct timeval wait
,
199 extern CLIENT
*clntbudp_bufcreate(struct sockaddr_in
*raddr
, rpcprog_t program
,
200 rpcvers_t version
, struct timeval wait
,
201 int *sockp
, uint_t sendsz
, uint_t recvsz
);
206 * clntbtcp_create(raddr, program, version, wait, sockp, sendsz, recvsz)
207 * struct sockaddr_in *raddr;
210 * struct timeval wait;
216 extern CLIENT
*clntbtcp_create(struct sockaddr_in
*raddr
, rpcprog_t program
,
217 rpcvers_t version
, struct timeval wait
,
218 int *sockp
, uint_t sendsz
, uint_t recvsz
);
220 * If a creation fails, the following allows the user to figure out why.
222 struct rpc_createerr
{
223 enum clnt_stat cf_stat
;
224 struct rpc_err cf_error
; /* useful when cf_stat == RPC_PMAPFAILURE */
227 extern struct rpc_createerr rpc_createerr
;
229 #define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */
230 #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */
231 #define TCPMSGSIZE (32 * 1024) /* reasonably sized RPC/TCP msg */
236 #endif /* !_RPC_CLNT_H */