[fd6a994] | 1 | /* $NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $ */ |
---|
| 2 | |
---|
[4721cf1] | 3 | /* |
---|
[fd6a994] | 4 | * The contents of this file are subject to the Sun Standards |
---|
| 5 | * License Version 1.0 the (the "License";) You may not use |
---|
| 6 | * this file except in compliance with the License. You may |
---|
| 7 | * obtain a copy of the License at lib/libc/rpc/LICENSE |
---|
| 8 | * |
---|
| 9 | * Software distributed under the License is distributed on |
---|
| 10 | * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either |
---|
| 11 | * express or implied. See the License for the specific |
---|
| 12 | * language governing rights and limitations under the License. |
---|
| 13 | * |
---|
| 14 | * The Original Code is Copyright 1998 by Sun Microsystems, Inc |
---|
| 15 | * |
---|
| 16 | * The Initial Developer of the Original Code is: Sun |
---|
| 17 | * Microsystems, Inc. |
---|
| 18 | * |
---|
| 19 | * All Rights Reserved. |
---|
| 20 | * |
---|
[4721cf1] | 21 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for |
---|
| 22 | * unrestricted use provided that this legend is included on all tape |
---|
| 23 | * media and as a part of the software program in whole or part. Users |
---|
| 24 | * may copy or modify Sun RPC without charge, but are not authorized |
---|
| 25 | * to license or distribute it to anyone else except as part of a product or |
---|
| 26 | * program developed by the user. |
---|
[df49c60] | 27 | * |
---|
[4721cf1] | 28 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE |
---|
[df49c60] | 29 | * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
---|
[4721cf1] | 30 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. |
---|
[df49c60] | 31 | * |
---|
[4721cf1] | 32 | * Sun RPC is provided with no support and without any obligation on the |
---|
| 33 | * part of Sun Microsystems, Inc. to assist in its use, correction, |
---|
| 34 | * modification or enhancement. |
---|
[df49c60] | 35 | * |
---|
[4721cf1] | 36 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE |
---|
| 37 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC |
---|
| 38 | * OR ANY PART THEREOF. |
---|
[df49c60] | 39 | * |
---|
[4721cf1] | 40 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue |
---|
| 41 | * or profits or other special, indirect and consequential damages, even if |
---|
| 42 | * Sun has been advised of the possibility of such damages. |
---|
[df49c60] | 43 | * |
---|
[4721cf1] | 44 | * Sun Microsystems, Inc. |
---|
| 45 | * 2550 Garcia Avenue |
---|
| 46 | * Mountain View, California 94043 |
---|
[df49c60] | 47 | * |
---|
[c11cb9a5] | 48 | * from: @(#)clnt.h 1.31 94/04/29 SMI |
---|
[df49c60] | 49 | * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC |
---|
[c11cb9a5] | 50 | * $FreeBSD: src/include/rpc/clnt.h,v 1.21 2003/01/24 01:47:55 fjoe Exp $ |
---|
[4721cf1] | 51 | */ |
---|
| 52 | |
---|
| 53 | /* |
---|
| 54 | * clnt.h - Client side remote procedure call interface. |
---|
| 55 | * |
---|
[c11cb9a5] | 56 | * Copyright (c) 1986-1991,1994-1999 by Sun Microsystems, Inc. |
---|
| 57 | * All rights reserved. |
---|
[4721cf1] | 58 | */ |
---|
| 59 | |
---|
[c11cb9a5] | 60 | /* |
---|
| 61 | * $Id$ |
---|
| 62 | */ |
---|
| 63 | |
---|
[df49c60] | 64 | #ifndef _RPC_CLNT_H_ |
---|
| 65 | #define _RPC_CLNT_H_ |
---|
[c11cb9a5] | 66 | #include <rpc/clnt_stat.h> |
---|
[ee613aa] | 67 | #include <sys/cdefs.h> |
---|
[df49c60] | 68 | #include <sys/un.h> |
---|
[4721cf1] | 69 | |
---|
| 70 | /* |
---|
| 71 | * Error info. |
---|
| 72 | */ |
---|
| 73 | struct rpc_err { |
---|
| 74 | enum clnt_stat re_status; |
---|
| 75 | union { |
---|
[df49c60] | 76 | int RE_errno; /* related system error */ |
---|
[4721cf1] | 77 | enum auth_stat RE_why; /* why the auth error occurred */ |
---|
| 78 | struct { |
---|
[fd6a994] | 79 | rpcvers_t low; /* lowest version supported */ |
---|
| 80 | rpcvers_t high; /* highest version supported */ |
---|
[4721cf1] | 81 | } RE_vers; |
---|
| 82 | struct { /* maybe meaningful if RPC_FAILED */ |
---|
[df49c60] | 83 | int32_t s1; |
---|
| 84 | int32_t s2; |
---|
[4721cf1] | 85 | } RE_lb; /* life boot & debugging only */ |
---|
| 86 | } ru; |
---|
| 87 | #define re_errno ru.RE_errno |
---|
| 88 | #define re_why ru.RE_why |
---|
| 89 | #define re_vers ru.RE_vers |
---|
| 90 | #define re_lb ru.RE_lb |
---|
| 91 | }; |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | /* |
---|
| 95 | * Client rpc handle. |
---|
[50e3b3f] | 96 | * Created by individual implementations |
---|
[4721cf1] | 97 | * Client is responsible for initializing auth, see e.g. auth_none.c. |
---|
| 98 | */ |
---|
[df49c60] | 99 | typedef struct __rpc_client { |
---|
[4721cf1] | 100 | AUTH *cl_auth; /* authenticator */ |
---|
| 101 | struct clnt_ops { |
---|
[df49c60] | 102 | /* call remote procedure */ |
---|
[fd6a994] | 103 | enum clnt_stat (*cl_call)(struct __rpc_client *, |
---|
[1f5986b] | 104 | rpcproc_t, xdrproc_t, void *, xdrproc_t, |
---|
| 105 | void *, struct timeval); |
---|
[df49c60] | 106 | /* abort a call */ |
---|
[0eeca97] | 107 | void (*cl_abort)(void); |
---|
[df49c60] | 108 | /* get specific error code */ |
---|
[fd6a994] | 109 | void (*cl_geterr)(struct __rpc_client *, |
---|
| 110 | struct rpc_err *); |
---|
[df49c60] | 111 | /* frees results */ |
---|
[fd6a994] | 112 | bool_t (*cl_freeres)(struct __rpc_client *, |
---|
[1f5986b] | 113 | xdrproc_t, void *); |
---|
[df49c60] | 114 | /* destroy this structure */ |
---|
[fd6a994] | 115 | void (*cl_destroy)(struct __rpc_client *); |
---|
[df49c60] | 116 | /* the ioctl() of rpc */ |
---|
[0eeca97] | 117 | bool_t (*cl_control)(struct __rpc_client *, int, |
---|
| 118 | char *); |
---|
[4721cf1] | 119 | } *cl_ops; |
---|
[9dcab59] | 120 | void *cl_private; /* private stuff */ |
---|
[4721cf1] | 121 | } CLIENT; |
---|
| 122 | |
---|
[c11cb9a5] | 123 | #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ |
---|
[4721cf1] | 124 | |
---|
| 125 | /* |
---|
| 126 | * client side rpc interface ops |
---|
| 127 | * |
---|
| 128 | * Parameter types are: |
---|
| 129 | * |
---|
| 130 | */ |
---|
| 131 | |
---|
| 132 | /* |
---|
| 133 | * enum clnt_stat |
---|
| 134 | * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) |
---|
| 135 | * CLIENT *rh; |
---|
[1f5986b] | 136 | * rpcproc_t proc; |
---|
[4721cf1] | 137 | * xdrproc_t xargs; |
---|
[1f5986b] | 138 | * void *argsp; |
---|
[4721cf1] | 139 | * xdrproc_t xres; |
---|
[1f5986b] | 140 | * void *resp; |
---|
[4721cf1] | 141 | * struct timeval timeout; |
---|
| 142 | */ |
---|
| 143 | #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ |
---|
[1f5986b] | 144 | ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ |
---|
| 145 | argsp, xres, resp, secs)) |
---|
[4721cf1] | 146 | #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ |
---|
[1f5986b] | 147 | ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ |
---|
| 148 | argsp, xres, resp, secs)) |
---|
[4721cf1] | 149 | |
---|
| 150 | /* |
---|
| 151 | * void |
---|
| 152 | * CLNT_ABORT(rh); |
---|
| 153 | * CLIENT *rh; |
---|
| 154 | */ |
---|
| 155 | #define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) |
---|
| 156 | #define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) |
---|
| 157 | |
---|
| 158 | /* |
---|
| 159 | * struct rpc_err |
---|
| 160 | * CLNT_GETERR(rh); |
---|
| 161 | * CLIENT *rh; |
---|
| 162 | */ |
---|
| 163 | #define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) |
---|
| 164 | #define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) |
---|
| 165 | |
---|
| 166 | |
---|
| 167 | /* |
---|
| 168 | * bool_t |
---|
| 169 | * CLNT_FREERES(rh, xres, resp); |
---|
| 170 | * CLIENT *rh; |
---|
| 171 | * xdrproc_t xres; |
---|
[1f5986b] | 172 | * void *resp; |
---|
[4721cf1] | 173 | */ |
---|
[1f5986b] | 174 | #define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) |
---|
| 175 | #define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) |
---|
[4721cf1] | 176 | |
---|
| 177 | /* |
---|
| 178 | * bool_t |
---|
| 179 | * CLNT_CONTROL(cl, request, info) |
---|
| 180 | * CLIENT *cl; |
---|
| 181 | * u_int request; |
---|
| 182 | * char *info; |
---|
| 183 | */ |
---|
| 184 | #define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) |
---|
| 185 | #define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) |
---|
| 186 | |
---|
| 187 | /* |
---|
[df49c60] | 188 | * control operations that apply to udp, tcp and unix transports |
---|
| 189 | * |
---|
| 190 | * Note: options marked XXX are no-ops in this implementation of RPC. |
---|
| 191 | * The are present in TI-RPC but can't be implemented here since they |
---|
| 192 | * depend on the presence of STREAMS/TLI, which we don't have. |
---|
| 193 | * |
---|
[4721cf1] | 194 | */ |
---|
| 195 | #define CLSET_TIMEOUT 1 /* set timeout (timeval) */ |
---|
| 196 | #define CLGET_TIMEOUT 2 /* get timeout (timeval) */ |
---|
| 197 | #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ |
---|
[df49c60] | 198 | #define CLGET_FD 6 /* get connections file descriptor */ |
---|
[50e3b3f] | 199 | #define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */ |
---|
[df49c60] | 200 | #define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ |
---|
| 201 | #define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ |
---|
| 202 | #define CLGET_XID 10 /* Get xid */ |
---|
| 203 | #define CLSET_XID 11 /* Set xid */ |
---|
| 204 | #define CLGET_VERS 12 /* Get version number */ |
---|
| 205 | #define CLSET_VERS 13 /* Set version number */ |
---|
| 206 | #define CLGET_PROG 14 /* Get program number */ |
---|
| 207 | #define CLSET_PROG 15 /* Set program number */ |
---|
| 208 | #define CLSET_SVC_ADDR 16 /* get server's address (netbuf) XXX */ |
---|
| 209 | #define CLSET_PUSH_TIMOD 17 /* push timod if not already present XXX */ |
---|
| 210 | #define CLSET_POP_TIMOD 18 /* pop timod XXX */ |
---|
| 211 | |
---|
[4721cf1] | 212 | /* |
---|
[fd6a994] | 213 | * Connectionless only control operations |
---|
[4721cf1] | 214 | */ |
---|
| 215 | #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ |
---|
| 216 | #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ |
---|
| 217 | |
---|
[df49c60] | 218 | /* |
---|
| 219 | * Operations which GSSAPI needs. (Bletch.) |
---|
| 220 | */ |
---|
| 221 | #define CLGET_LOCAL_ADDR 19 /* get local addr (sockaddr) */ |
---|
| 222 | |
---|
| 223 | |
---|
[4721cf1] | 224 | /* |
---|
| 225 | * void |
---|
| 226 | * CLNT_DESTROY(rh); |
---|
| 227 | * CLIENT *rh; |
---|
| 228 | */ |
---|
| 229 | #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) |
---|
| 230 | #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) |
---|
| 231 | |
---|
| 232 | |
---|
| 233 | /* |
---|
[df49c60] | 234 | * RPCTEST is a test program which is accessible on every rpc |
---|
[4721cf1] | 235 | * transport/port. It is used for testing, performance evaluation, |
---|
| 236 | * and network administration. |
---|
| 237 | */ |
---|
| 238 | |
---|
[50e3b3f] | 239 | #define RPCTEST_PROGRAM ((rpcprog_t)1) |
---|
| 240 | #define RPCTEST_VERSION ((rpcvers_t)1) |
---|
| 241 | #define RPCTEST_NULL_PROC ((rpcproc_t)2) |
---|
| 242 | #define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3) |
---|
[4721cf1] | 243 | |
---|
| 244 | /* |
---|
| 245 | * By convention, procedure 0 takes null arguments and returns them |
---|
| 246 | */ |
---|
| 247 | |
---|
[50e3b3f] | 248 | #define NULLPROC ((rpcproc_t)0) |
---|
[4721cf1] | 249 | |
---|
| 250 | /* |
---|
| 251 | * Below are the client handle creation routines for the various |
---|
[df49c60] | 252 | * implementations of client side rpc. They can return NULL if a |
---|
[4721cf1] | 253 | * creation failure occurs. |
---|
| 254 | */ |
---|
| 255 | |
---|
| 256 | /* |
---|
[df49c60] | 257 | * Generic client creation routine. Supported protocols are "udp", "tcp" |
---|
| 258 | * and "unix". |
---|
[4721cf1] | 259 | */ |
---|
[df49c60] | 260 | __BEGIN_DECLS |
---|
[1f5986b] | 261 | extern CLIENT *clnt_create(const char *, const rpcprog_t, const rpcvers_t, |
---|
| 262 | const char *); |
---|
[df49c60] | 263 | __END_DECLS |
---|
[4721cf1] | 264 | |
---|
| 265 | /* |
---|
[fd6a994] | 266 | * Added for compatibility to old rpc 4.0. Obsoleted by clnt_vc_create(). |
---|
[4721cf1] | 267 | */ |
---|
[5fd92cc] | 268 | __BEGIN_DECLS |
---|
[fd6a994] | 269 | extern CLIENT *clntunix_create(struct sockaddr_un *, |
---|
| 270 | u_long, u_long, int *, u_int, u_int); |
---|
[df49c60] | 271 | __END_DECLS |
---|
| 272 | |
---|
[4721cf1] | 273 | |
---|
| 274 | /* |
---|
| 275 | * Print why creation failed |
---|
| 276 | */ |
---|
[df49c60] | 277 | __BEGIN_DECLS |
---|
[fd6a994] | 278 | extern void clnt_pcreateerror(const char *); /* stderr */ |
---|
| 279 | extern char *clnt_spcreateerror(const char *); /* string */ |
---|
[df49c60] | 280 | __END_DECLS |
---|
[4721cf1] | 281 | |
---|
| 282 | /* |
---|
| 283 | * Like clnt_perror(), but is more verbose in its output |
---|
[df49c60] | 284 | */ |
---|
| 285 | __BEGIN_DECLS |
---|
[50e3b3f] | 286 | extern void clnt_perrno(enum clnt_stat); /* stderr */ |
---|
| 287 | extern char *clnt_sperrno(enum clnt_stat); /* string */ |
---|
[df49c60] | 288 | __END_DECLS |
---|
[4721cf1] | 289 | |
---|
| 290 | /* |
---|
| 291 | * Print an English error message, given the client error code |
---|
| 292 | */ |
---|
[df49c60] | 293 | __BEGIN_DECLS |
---|
[fd6a994] | 294 | extern void clnt_perror(CLIENT *, const char *); /* stderr */ |
---|
| 295 | extern char *clnt_sperror(CLIENT *, const char *); /* string */ |
---|
[df49c60] | 296 | __END_DECLS |
---|
[4721cf1] | 297 | |
---|
[df49c60] | 298 | |
---|
| 299 | /* |
---|
[4721cf1] | 300 | * If a creation fails, the following allows the user to figure out why. |
---|
| 301 | */ |
---|
| 302 | struct rpc_createerr { |
---|
| 303 | enum clnt_stat cf_stat; |
---|
| 304 | struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ |
---|
| 305 | }; |
---|
| 306 | |
---|
| 307 | extern struct rpc_createerr rpc_createerr; |
---|
| 308 | |
---|
[50e3b3f] | 309 | /* For backward compatibility */ |
---|
| 310 | #include <rpc/clnt_soc.h> |
---|
| 311 | |
---|
| 312 | #endif /* !_RPC_CLNT_H_ */ |
---|