]>
Commit | Line | Data |
---|---|---|
03fb6eb0 A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
ad21edcc A |
6 | * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights |
7 | * Reserved. This file contains Original Code and/or Modifications of | |
8 | * Original Code as defined in and that are subject to the Apple Public | |
9 | * Source License Version 1.1 (the "License"). You may not use this file | |
10 | * except in compliance with the License. Please obtain a copy of the | |
11 | * License at http://www.apple.com/publicsource and read it before using | |
12 | * this file. | |
03fb6eb0 A |
13 | * |
14 | * The Original Code and all software distributed under the License are | |
ad21edcc | 15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
03fb6eb0 A |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
ad21edcc A |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the |
19 | * License for the specific language governing rights and limitations | |
20 | * under the License. | |
03fb6eb0 A |
21 | * |
22 | * @APPLE_LICENSE_HEADER_END@ | |
23 | */ | |
24 | /* | |
25 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for | |
26 | * unrestricted use provided that this legend is included on all tape | |
27 | * media and as a part of the software program in whole or part. Users | |
28 | * may copy or modify Sun RPC without charge, but are not authorized | |
29 | * to license or distribute it to anyone else except as part of a product or | |
30 | * program developed by the user. | |
31 | * | |
32 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE | |
33 | * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR | |
34 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. | |
35 | * | |
36 | * Sun RPC is provided with no support and without any obligation on the | |
37 | * part of Sun Microsystems, Inc. to assist in its use, correction, | |
38 | * modification or enhancement. | |
39 | * | |
40 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE | |
41 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC | |
42 | * OR ANY PART THEREOF. | |
43 | * | |
44 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue | |
45 | * or profits or other special, indirect and consequential damages, even if | |
46 | * Sun has been advised of the possibility of such damages. | |
47 | * | |
48 | * Sun Microsystems, Inc. | |
49 | * 2550 Garcia Avenue | |
50 | * Mountain View, California 94043 | |
51 | * | |
52 | * from: @(#)clnt.h 1.31 88/02/08 SMI | |
53 | * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC | |
c29f2fcc | 54 | * $Id: clnt.h,v 1.4 2004/10/28 21:58:22 emoy Exp $ |
03fb6eb0 A |
55 | */ |
56 | ||
57 | /* | |
58 | * clnt.h - Client side remote procedure call interface. | |
59 | * | |
60 | * Copyright (C) 1984, Sun Microsystems, Inc. | |
61 | */ | |
62 | ||
63 | #ifndef _RPC_CLNT_H_ | |
64 | #define _RPC_CLNT_H_ | |
65 | #include <sys/cdefs.h> | |
66 | ||
67 | /* | |
68 | * Rpc calls return an enum clnt_stat. This should be looked at more, | |
69 | * since each implementation is required to live with this (implementation | |
70 | * independent) list of errors. | |
71 | */ | |
72 | ||
73 | /* Avoid collision with mach definition */ | |
74 | #if defined(RPC_SUCCESS) | |
75 | #undef RPC_SUCCESS | |
76 | #endif | |
77 | ||
78 | enum clnt_stat { | |
79 | RPC_SUCCESS=0, /* call succeeded */ | |
80 | /* | |
81 | * local errors | |
82 | */ | |
83 | RPC_CANTENCODEARGS=1, /* can't encode arguments */ | |
84 | RPC_CANTDECODERES=2, /* can't decode results */ | |
85 | RPC_CANTSEND=3, /* failure in sending call */ | |
86 | RPC_CANTRECV=4, /* failure in receiving result */ | |
87 | RPC_TIMEDOUT=5, /* call timed out */ | |
88 | /* | |
89 | * remote errors | |
90 | */ | |
91 | RPC_VERSMISMATCH=6, /* rpc versions not compatible */ | |
92 | RPC_AUTHERROR=7, /* authentication error */ | |
93 | RPC_PROGUNAVAIL=8, /* program not available */ | |
94 | RPC_PROGVERSMISMATCH=9, /* program version mismatched */ | |
95 | RPC_PROCUNAVAIL=10, /* procedure unavailable */ | |
96 | RPC_CANTDECODEARGS=11, /* decode arguments error */ | |
97 | RPC_SYSTEMERROR=12, /* generic "other problem" */ | |
98 | ||
99 | /* | |
100 | * callrpc & clnt_create errors | |
101 | */ | |
102 | RPC_UNKNOWNHOST=13, /* unknown host name */ | |
103 | RPC_UNKNOWNPROTO=17, /* unkown protocol */ | |
104 | ||
105 | /* | |
106 | * _ create errors | |
107 | */ | |
108 | RPC_PMAPFAILURE=14, /* the pmapper failed in its call */ | |
109 | RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ | |
110 | /* | |
111 | * unspecified error | |
112 | */ | |
113 | RPC_FAILED=16 | |
114 | }; | |
115 | ||
116 | ||
117 | /* | |
118 | * Error info. | |
119 | */ | |
120 | struct rpc_err { | |
121 | enum clnt_stat re_status; | |
122 | union { | |
123 | int RE_errno; /* realated system error */ | |
124 | enum auth_stat RE_why; /* why the auth error occurred */ | |
125 | struct { | |
b3dd680f A |
126 | #ifdef __LP64__ |
127 | unsigned int low; /* lowest verion supported */ | |
128 | unsigned int high; /* highest verion supported */ | |
129 | #else | |
c29f2fcc A |
130 | unsigned long low; /* lowest verion supported */ |
131 | unsigned long high; /* highest verion supported */ | |
b3dd680f | 132 | #endif |
03fb6eb0 A |
133 | } RE_vers; |
134 | struct { /* maybe meaningful if RPC_FAILED */ | |
b3dd680f A |
135 | #ifdef __LP64__ |
136 | int s1; | |
137 | int s2; | |
138 | #else | |
03fb6eb0 A |
139 | long s1; |
140 | long s2; | |
b3dd680f | 141 | #endif |
03fb6eb0 A |
142 | } RE_lb; /* life boot & debugging only */ |
143 | } ru; | |
144 | #define re_errno ru.RE_errno | |
145 | #define re_why ru.RE_why | |
146 | #define re_vers ru.RE_vers | |
147 | #define re_lb ru.RE_lb | |
148 | }; | |
149 | ||
150 | ||
151 | /* | |
152 | * Client rpc handle. | |
153 | * Created by individual implementations, see e.g. rpc_udp.c. | |
154 | * Client is responsible for initializing auth, see e.g. auth_none.c. | |
155 | */ | |
ccd4a120 A |
156 | typedef struct CLIENT CLIENT; |
157 | struct CLIENT | |
158 | { | |
159 | AUTH *cl_auth; /* authenticator */ | |
03fb6eb0 | 160 | struct clnt_ops { |
b3dd680f A |
161 | #ifdef __LP64__ |
162 | enum clnt_stat (*cl_call)(CLIENT *, unsigned int, xdrproc_t, void *, xdrproc_t, void *, struct timeval); /* call remote procedure */ | |
163 | #else | |
c29f2fcc | 164 | enum clnt_stat (*cl_call)(CLIENT *, unsigned long, xdrproc_t, void *, xdrproc_t, void *, struct timeval); /* call remote procedure */ |
b3dd680f | 165 | #endif |
ccd4a120 A |
166 | void (*cl_abort)(void); /* abort a call */ |
167 | void (*cl_geterr)(CLIENT *, struct rpc_err *); /* get specific error code */ | |
168 | bool_t (*cl_freeres)(CLIENT *, xdrproc_t, void *); /* frees results */ | |
169 | void (*cl_destroy)(CLIENT *); /* destroy this structure */ | |
170 | bool_t (*cl_control)(CLIENT *, int, char *); /* the ioctl() of rpc */ | |
03fb6eb0 | 171 | } *cl_ops; |
ccd4a120 A |
172 | caddr_t cl_private; /* private stuff */ |
173 | }; | |
03fb6eb0 A |
174 | |
175 | /* | |
176 | * client side rpc interface ops | |
177 | * | |
178 | * Parameter types are: | |
179 | * | |
180 | */ | |
181 | ||
182 | /* | |
183 | * enum clnt_stat | |
184 | * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) | |
185 | * CLIENT *rh; | |
b3dd680f | 186 | * u_long proc; |
03fb6eb0 A |
187 | * xdrproc_t xargs; |
188 | * caddr_t argsp; | |
189 | * xdrproc_t xres; | |
190 | * caddr_t resp; | |
191 | * struct timeval timeout; | |
192 | */ | |
193 | #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ | |
194 | ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) | |
195 | #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ | |
196 | ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) | |
197 | ||
198 | /* | |
199 | * void | |
200 | * CLNT_ABORT(rh); | |
201 | * CLIENT *rh; | |
202 | */ | |
203 | #define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) | |
204 | #define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) | |
205 | ||
206 | /* | |
207 | * struct rpc_err | |
208 | * CLNT_GETERR(rh); | |
209 | * CLIENT *rh; | |
210 | */ | |
211 | #define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) | |
212 | #define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) | |
213 | ||
214 | ||
215 | /* | |
216 | * bool_t | |
217 | * CLNT_FREERES(rh, xres, resp); | |
218 | * CLIENT *rh; | |
219 | * xdrproc_t xres; | |
220 | * caddr_t resp; | |
221 | */ | |
222 | #define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) | |
223 | #define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) | |
224 | ||
225 | /* | |
226 | * bool_t | |
227 | * CLNT_CONTROL(cl, request, info) | |
228 | * CLIENT *cl; | |
c29f2fcc | 229 | * unsigned int request; |
03fb6eb0 A |
230 | * char *info; |
231 | */ | |
232 | #define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) | |
233 | #define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) | |
234 | ||
235 | /* | |
236 | * control operations that apply to both udp and tcp transports | |
237 | */ | |
238 | #define CLSET_TIMEOUT 1 /* set timeout (timeval) */ | |
239 | #define CLGET_TIMEOUT 2 /* get timeout (timeval) */ | |
240 | #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ | |
241 | /* | |
242 | * udp only control operations | |
243 | */ | |
244 | #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ | |
245 | #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ | |
246 | ||
247 | /* | |
248 | * void | |
249 | * CLNT_DESTROY(rh); | |
250 | * CLIENT *rh; | |
251 | */ | |
252 | #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) | |
253 | #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) | |
254 | ||
255 | ||
256 | /* | |
257 | * RPCTEST is a test program which is accessable on every rpc | |
258 | * transport/port. It is used for testing, performance evaluation, | |
259 | * and network administration. | |
260 | */ | |
261 | ||
b3dd680f A |
262 | #ifdef __LP64__ |
263 | #define RPCTEST_PROGRAM ((unsigned int)1) | |
264 | #define RPCTEST_VERSION ((unsigned int)1) | |
265 | #define RPCTEST_NULL_PROC ((unsigned int)2) | |
266 | #define RPCTEST_NULL_BATCH_PROC ((unsigned int)3) | |
267 | #else | |
c29f2fcc A |
268 | #define RPCTEST_PROGRAM ((unsigned long)1) |
269 | #define RPCTEST_VERSION ((unsigned long)1) | |
270 | #define RPCTEST_NULL_PROC ((unsigned long)2) | |
271 | #define RPCTEST_NULL_BATCH_PROC ((unsigned long)3) | |
b3dd680f | 272 | #endif |
03fb6eb0 A |
273 | |
274 | /* | |
275 | * By convention, procedure 0 takes null arguments and returns them | |
276 | */ | |
277 | ||
b3dd680f A |
278 | #ifdef __LP64__ |
279 | #define NULLPROC ((unsigned int)0) | |
280 | #else | |
c29f2fcc | 281 | #define NULLPROC ((unsigned long)0) |
b3dd680f | 282 | #endif |
03fb6eb0 A |
283 | |
284 | /* | |
285 | * Below are the client handle creation routines for the various | |
286 | * implementations of client side rpc. They can return NULL if a | |
287 | * creation failure occurs. | |
288 | */ | |
289 | ||
290 | /* | |
291 | * Memory based rpc (for speed check and testing) | |
292 | * CLIENT * | |
293 | * clntraw_create(prog, vers) | |
b3dd680f A |
294 | * u_long prog; |
295 | * u_long vers; | |
03fb6eb0 A |
296 | */ |
297 | __BEGIN_DECLS | |
b3dd680f A |
298 | #ifdef __LP64__ |
299 | extern CLIENT *clntraw_create __P((unsigned int, unsigned int)); | |
300 | #else | |
c29f2fcc | 301 | extern CLIENT *clntraw_create __P((unsigned long, unsigned long)); |
b3dd680f | 302 | #endif |
03fb6eb0 A |
303 | __END_DECLS |
304 | ||
305 | ||
306 | /* | |
307 | * Generic client creation routine. Supported protocols are "udp" and "tcp" | |
308 | * CLIENT * | |
309 | * clnt_create(host, prog, vers, prot); | |
310 | * char *host; -- hostname | |
b3dd680f A |
311 | * u_long prog; -- program number |
312 | * u_long vers; -- version number | |
03fb6eb0 A |
313 | * char *prot; -- protocol |
314 | */ | |
315 | __BEGIN_DECLS | |
b3dd680f A |
316 | #ifdef __LP64__ |
317 | extern CLIENT *clnt_create __P((char *, unsigned int, unsigned int, char *)); | |
318 | #else | |
c29f2fcc | 319 | extern CLIENT *clnt_create __P((char *, unsigned long, unsigned long, char *)); |
b3dd680f | 320 | #endif |
03fb6eb0 A |
321 | __END_DECLS |
322 | ||
323 | ||
324 | /* | |
325 | * TCP based rpc | |
326 | * CLIENT * | |
327 | * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) | |
328 | * struct sockaddr_in *raddr; | |
b3dd680f A |
329 | * u_long prog; |
330 | * u_long version; | |
03fb6eb0 | 331 | * register int *sockp; |
c29f2fcc A |
332 | * unsigned int sendsz; |
333 | * unsigned int recvsz; | |
03fb6eb0 A |
334 | */ |
335 | __BEGIN_DECLS | |
b3dd680f A |
336 | #ifdef __LP64__ |
337 | extern CLIENT *clnttcp_create __P((struct sockaddr_in *, | |
338 | unsigned int, | |
339 | unsigned int, | |
340 | int *, | |
341 | unsigned int, | |
342 | unsigned int)); | |
343 | #else | |
03fb6eb0 | 344 | extern CLIENT *clnttcp_create __P((struct sockaddr_in *, |
b3dd680f A |
345 | unsigned long, |
346 | unsigned long, | |
347 | int *, | |
348 | unsigned int, | |
349 | unsigned int)); | |
350 | #endif | |
03fb6eb0 A |
351 | __END_DECLS |
352 | ||
353 | ||
354 | /* | |
355 | * UDP based rpc. | |
356 | * CLIENT * | |
357 | * clntudp_create(raddr, program, version, wait, sockp) | |
358 | * struct sockaddr_in *raddr; | |
b3dd680f A |
359 | * u_long program; |
360 | * u_long version; | |
03fb6eb0 A |
361 | * struct timeval wait; |
362 | * int *sockp; | |
363 | * | |
364 | * Same as above, but you specify max packet sizes. | |
365 | * CLIENT * | |
366 | * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) | |
367 | * struct sockaddr_in *raddr; | |
b3dd680f A |
368 | * u_long program; |
369 | * u_long version; | |
03fb6eb0 A |
370 | * struct timeval wait; |
371 | * int *sockp; | |
c29f2fcc A |
372 | * unsigned int sendsz; |
373 | * unsigned int recvsz; | |
03fb6eb0 A |
374 | */ |
375 | __BEGIN_DECLS | |
b3dd680f | 376 | #ifdef __LP64__ |
03fb6eb0 | 377 | extern CLIENT *clntudp_create __P((struct sockaddr_in *, |
b3dd680f A |
378 | unsigned int, |
379 | unsigned int, | |
380 | struct timeval, | |
381 | int *)); | |
03fb6eb0 | 382 | extern CLIENT *clntudp_bufcreate __P((struct sockaddr_in *, |
b3dd680f A |
383 | unsigned int, |
384 | unsigned int, | |
385 | struct timeval, | |
386 | int *, | |
387 | unsigned int, | |
388 | unsigned int)); | |
389 | #else | |
390 | extern CLIENT *clntudp_create __P((struct sockaddr_in *, | |
391 | unsigned long, | |
392 | unsigned long, | |
393 | struct timeval, | |
394 | int *)); | |
395 | extern CLIENT *clntudp_bufcreate __P((struct sockaddr_in *, | |
396 | unsigned long, | |
397 | unsigned long, | |
398 | struct timeval, | |
399 | int *, | |
400 | unsigned int, | |
401 | unsigned int)); | |
402 | #endif | |
03fb6eb0 A |
403 | __END_DECLS |
404 | ||
405 | ||
406 | /* | |
407 | * Print why creation failed | |
408 | */ | |
409 | __BEGIN_DECLS | |
410 | extern void clnt_pcreateerror __P((char *)); /* stderr */ | |
411 | extern char *clnt_spcreateerror __P((char *)); /* string */ | |
412 | __END_DECLS | |
413 | ||
414 | /* | |
415 | * Like clnt_perror(), but is more verbose in its output | |
416 | */ | |
417 | __BEGIN_DECLS | |
418 | extern void clnt_perrno __P((enum clnt_stat)); /* stderr */ | |
419 | extern char *clnt_sperrno __P((enum clnt_stat)); /* string */ | |
420 | __END_DECLS | |
421 | ||
422 | /* | |
423 | * Print an English error message, given the client error code | |
424 | */ | |
425 | __BEGIN_DECLS | |
426 | extern void clnt_perror __P((CLIENT *, char *)); /* stderr */ | |
427 | extern char *clnt_sperror __P((CLIENT *, char *)); /* string */ | |
428 | __END_DECLS | |
429 | ||
430 | ||
431 | /* | |
432 | * If a creation fails, the following allows the user to figure out why. | |
433 | */ | |
434 | struct rpc_createerr { | |
435 | enum clnt_stat cf_stat; | |
436 | struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ | |
437 | }; | |
438 | ||
439 | extern struct rpc_createerr rpc_createerr; | |
440 | ||
441 | ||
442 | #define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ | |
443 | #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ | |
444 | ||
445 | #endif /* !_RPC_CLNT_H */ |