Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/tirpc/rpc/clnt.h
$ cat -n /usr/include/tirpc/rpc/clnt.h 1 /* $NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $ */ 2 3 /* 4 * Copyright (c) 2010, Oracle America, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: 9 * - Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * - Neither the name of the "Oracle America, Inc." nor the names of its 15 * contributors may be used to endorse or promote products derived 16 * from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 * 30 * from: @(#)clnt.h 1.31 94/04/29 SMI 31 * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC 32 * $FreeBSD: src/include/rpc/clnt.h,v 1.21 2003/01/24 01:47:55 fjoe Exp $ 33 */ 34 35 /* 36 * clnt.h - Client side remote procedure call interface. 37 */ 38 39 #ifndef _TIRPC_CLNT_H_ 40 #define _TIRPC_CLNT_H_ 41 42 #include
43 #include
44 45 #include
46 #include
47 48 /* 49 * Well-known IPV6 RPC broadcast address. 50 */ 51 #define RPCB_MULTICAST_ADDR "ff02::202" 52 53 /* 54 * the following errors are in general unrecoverable. The caller 55 * should give up rather than retry. 56 */ 57 #define IS_UNRECOVERABLE_RPC(s) (((s) == RPC_AUTHERROR) || \ 58 ((s) == RPC_CANTENCODEARGS) || \ 59 ((s) == RPC_CANTDECODERES) || \ 60 ((s) == RPC_VERSMISMATCH) || \ 61 ((s) == RPC_PROCUNAVAIL) || \ 62 ((s) == RPC_PROGUNAVAIL) || \ 63 ((s) == RPC_PROGVERSMISMATCH) || \ 64 ((s) == RPC_CANTDECODEARGS)) 65 66 /* 67 * Error info. 68 */ 69 struct rpc_err { 70 enum clnt_stat re_status; 71 union { 72 int RE_errno; /* related system error */ 73 enum auth_stat RE_why; /* why the auth error occurred */ 74 struct { 75 rpcvers_t low; /* lowest version supported */ 76 rpcvers_t high; /* highest version supported */ 77 } RE_vers; 78 struct { /* maybe meaningful if RPC_FAILED */ 79 int32_t s1; 80 int32_t s2; 81 } RE_lb; /* life boot & debugging only */ 82 } ru; 83 #define re_errno ru.RE_errno 84 #define re_why ru.RE_why 85 #define re_vers ru.RE_vers 86 #define re_lb ru.RE_lb 87 }; 88 89 90 /* 91 * Client rpc handle. 92 * Created by individual implementations 93 * Client is responsible for initializing auth, see e.g. auth_none.c. 94 */ 95 typedef struct __rpc_client { 96 AUTH *cl_auth; /* authenticator */ 97 struct clnt_ops { 98 /* call remote procedure */ 99 enum clnt_stat (*cl_call)(struct __rpc_client *, 100 rpcproc_t, xdrproc_t, void *, xdrproc_t, 101 void *, struct timeval); 102 /* abort a call */ 103 void (*cl_abort)(struct __rpc_client *); 104 /* get specific error code */ 105 void (*cl_geterr)(struct __rpc_client *, 106 struct rpc_err *); 107 /* frees results */ 108 bool_t (*cl_freeres)(struct __rpc_client *, 109 xdrproc_t, void *); 110 /* destroy this structure */ 111 void (*cl_destroy)(struct __rpc_client *); 112 /* the ioctl() of rpc */ 113 bool_t (*cl_control)(struct __rpc_client *, u_int, 114 void *); 115 } *cl_ops; 116 void *cl_private; /* private stuff */ 117 char *cl_netid; /* network token */ 118 char *cl_tp; /* device name */ 119 } CLIENT; 120 121 122 /* 123 * Timers used for the pseudo-transport protocol when using datagrams 124 */ 125 struct rpc_timers { 126 u_short rt_srtt; /* smoothed round-trip time */ 127 u_short rt_deviate; /* estimated deviation */ 128 u_long rt_rtxcur; /* current (backed-off) rto */ 129 }; 130 131 /* 132 * Feedback values used for possible congestion and rate control 133 */ 134 #define FEEDBACK_REXMIT1 1 /* first retransmit */ 135 #define FEEDBACK_OK 2 /* no retransmits */ 136 137 /* Used to set version of portmapper used in broadcast */ 138 139 #define CLCR_SET_LOWVERS 3 140 #define CLCR_GET_LOWVERS 4 141 142 #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ 143 144 /* 145 * client side rpc interface ops 146 * 147 * Parameter types are: 148 * 149 */ 150 151 /* 152 * enum clnt_stat 153 * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) 154 * CLIENT *rh; 155 * rpcproc_t proc; 156 * xdrproc_t xargs; 157 * void *argsp; 158 * xdrproc_t xres; 159 * void *resp; 160 * struct timeval timeout; 161 */ 162 #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ 163 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ 164 argsp, xres, resp, secs)) 165 #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ 166 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ 167 argsp, xres, resp, secs)) 168 169 /* 170 * void 171 * CLNT_ABORT(rh); 172 * CLIENT *rh; 173 */ 174 #define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) 175 #define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) 176 177 /* 178 * struct rpc_err 179 * CLNT_GETERR(rh); 180 * CLIENT *rh; 181 */ 182 #define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) 183 #define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) 184 185 186 /* 187 * bool_t 188 * CLNT_FREERES(rh, xres, resp); 189 * CLIENT *rh; 190 * xdrproc_t xres; 191 * void *resp; 192 */ 193 #define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) 194 #define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) 195 196 /* 197 * bool_t 198 * CLNT_CONTROL(cl, request, info) 199 * CLIENT *cl; 200 * u_int request; 201 * char *info; 202 */ 203 #define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) 204 #define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) 205 206 /* 207 * control operations that apply to both udp and tcp transports 208 */ 209 #define CLSET_TIMEOUT 1 /* set timeout (timeval) */ 210 #define CLGET_TIMEOUT 2 /* get timeout (timeval) */ 211 #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ 212 #define CLGET_FD 6 /* get connections file descriptor */ 213 #define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */ 214 #define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ 215 #define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ 216 #define CLGET_XID 10 /* Get xid */ 217 #define CLSET_XID 11 /* Set xid */ 218 #define CLGET_VERS 12 /* Get version number */ 219 #define CLSET_VERS 13 /* Set version number */ 220 #define CLGET_PROG 14 /* Get program number */ 221 #define CLSET_PROG 15 /* Set program number */ 222 #define CLSET_SVC_ADDR 16 /* get server's address (netbuf) */ 223 #define CLSET_PUSH_TIMOD 17 /* push timod if not already present */ 224 #define CLSET_POP_TIMOD 18 /* pop timod */ 225 /* 226 * Connectionless only control operations 227 */ 228 #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ 229 #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ 230 #define CLSET_ASYNC 19 231 #define CLSET_CONNECT 20 /* Use connect() for UDP. (int) */ 232 233 /* 234 * void 235 * CLNT_DESTROY(rh); 236 * CLIENT *rh; 237 */ 238 #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) 239 #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) 240 241 242 /* 243 * RPCTEST is a test program which is accessible on every rpc 244 * transport/port. It is used for testing, performance evaluation, 245 * and network administration. 246 */ 247 248 #define RPCTEST_PROGRAM ((rpcprog_t)1) 249 #define RPCTEST_VERSION ((rpcvers_t)1) 250 #define RPCTEST_NULL_PROC ((rpcproc_t)2) 251 #define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3) 252 253 /* 254 * By convention, procedure 0 takes null arguments and returns them 255 */ 256 257 #define NULLPROC ((rpcproc_t)0) 258 259 /* 260 * Below are the client handle creation routines for the various 261 * implementations of client side rpc. They can return NULL if a 262 * creation failure occurs. 263 */ 264 265 /* 266 * Generic client creation routine. Supported protocols are those that 267 * belong to the nettype namespace (/etc/netconfig). 268 */ 269 #ifdef __cplusplus 270 extern "C" { 271 #endif 272 extern CLIENT *clnt_create(const char *, const rpcprog_t, const rpcvers_t, 273 const char *); 274 /* 275 * 276 * const char *hostname; -- hostname 277 * const rpcprog_t prog; -- program number 278 * const rpcvers_t vers; -- version number 279 * const char *nettype; -- network type 280 */ 281 282 /* 283 * Generic client creation routine. Just like clnt_create(), except 284 * it takes an additional timeout parameter. 285 */ 286 extern CLIENT * clnt_create_timed(const char *, const rpcprog_t, 287 const rpcvers_t, const char *, const struct timeval *); 288 /* 289 * 290 * const char *hostname; -- hostname 291 * const rpcprog_t prog; -- program number 292 * const rpcvers_t vers; -- version number 293 * const char *nettype; -- network type 294 * const struct timeval *tp; -- timeout 295 */ 296 297 /* 298 * Generic client creation routine. Supported protocols are which belong 299 * to the nettype name space. 300 */ 301 extern CLIENT *clnt_create_vers(const char *, const rpcprog_t, rpcvers_t *, 302 const rpcvers_t, const rpcvers_t, 303 const char *); 304 /* 305 * const char *host; -- hostname 306 * const rpcprog_t prog; -- program number 307 * rpcvers_t *vers_out; -- servers highest available version 308 * const rpcvers_t vers_low; -- low version number 309 * const rpcvers_t vers_high; -- high version number 310 * const char *nettype; -- network type 311 */ 312 313 /* 314 * Generic client creation routine. Supported protocols are which belong 315 * to the nettype name space. 316 */ 317 extern CLIENT * clnt_create_vers_timed(const char *, const rpcprog_t, 318 rpcvers_t *, const rpcvers_t, const rpcvers_t, const char *, 319 const struct timeval *); 320 /* 321 * const char *host; -- hostname 322 * const rpcprog_t prog; -- program number 323 * rpcvers_t *vers_out; -- servers highest available version 324 * const rpcvers_t vers_low; -- low version number 325 * const rpcvers_t vers_high; -- high version number 326 * const char *nettype; -- network type 327 * const struct timeval *tp -- timeout 328 */ 329 330 /* 331 * Generic client creation routine. It takes a netconfig structure 332 * instead of nettype 333 */ 334 extern CLIENT *clnt_tp_create(const char *, const rpcprog_t, 335 const rpcvers_t, const struct netconfig *); 336 /* 337 * const char *hostname; -- hostname 338 * const rpcprog_t prog; -- program number 339 * const rpcvers_t vers; -- version number 340 * const struct netconfig *netconf; -- network config structure 341 */ 342 343 /* 344 * Generic client creation routine. Just like clnt_tp_create(), except 345 * it takes an additional timeout parameter. 346 */ 347 extern CLIENT * clnt_tp_create_timed(const char *, const rpcprog_t, 348 const rpcvers_t, const struct netconfig *, const struct timeval *); 349 /* 350 * const char *hostname; -- hostname 351 * const rpcprog_t prog; -- program number 352 * const rpcvers_t vers; -- version number 353 * const struct netconfig *netconf; -- network config structure 354 * const struct timeval *tp -- timeout 355 */ 356 357 /* 358 * Generic TLI create routine. Only provided for compatibility. 359 */ 360 361 extern CLIENT *clnt_tli_create(const int, const struct netconfig *, 362 struct netbuf *, const rpcprog_t, 363 const rpcvers_t, const u_int, const u_int); 364 /* 365 * const register int fd; -- fd 366 * const struct netconfig *nconf; -- netconfig structure 367 * struct netbuf *svcaddr; -- servers address 368 * const u_long prog; -- program number 369 * const u_long vers; -- version number 370 * const u_int sendsz; -- send size 371 * const u_int recvsz; -- recv size 372 */ 373 374 /* 375 * Low level clnt create routine for connectionful transports, e.g. tcp. 376 */ 377 extern CLIENT *clnt_vc_create(const int, const struct netbuf *, 378 const rpcprog_t, const rpcvers_t, 379 u_int, u_int); 380 /* 381 * Added for compatibility to old rpc 4.0. Obsoleted by clnt_vc_create(). 382 */ 383 extern CLIENT *clntunix_create(struct sockaddr_un *, 384 u_long, u_long, int *, u_int, u_int); 385 /* 386 * const int fd; -- open file descriptor 387 * const struct netbuf *svcaddr; -- servers address 388 * const rpcprog_t prog; -- program number 389 * const rpcvers_t vers; -- version number 390 * const u_int sendsz; -- buffer recv size 391 * const u_int recvsz; -- buffer send size 392 */ 393 394 /* 395 * Low level clnt create routine for connectionless transports, e.g. udp. 396 */ 397 extern CLIENT *clnt_dg_create(const int, const struct netbuf *, 398 const rpcprog_t, const rpcvers_t, 399 const u_int, const u_int); 400 /* 401 * const int fd; -- open file descriptor 402 * const struct netbuf *svcaddr; -- servers address 403 * const rpcprog_t program; -- program number 404 * const rpcvers_t version; -- version number 405 * const u_int sendsz; -- buffer recv size 406 * const u_int recvsz; -- buffer send size 407 */ 408 409 /* 410 * Memory based rpc (for speed check and testing) 411 * CLIENT * 412 * clnt_raw_create(prog, vers) 413 * u_long prog; 414 * u_long vers; 415 */ 416 extern CLIENT *clnt_raw_create(rpcprog_t, rpcvers_t); 417 418 #ifdef __cplusplus 419 } 420 #endif 421 422 423 /* 424 * Print why creation failed 425 */ 426 #ifdef __cplusplus 427 extern "C" { 428 #endif 429 extern void clnt_pcreateerror(const char *); /* stderr */ 430 extern char *clnt_spcreateerror(const char *); /* string */ 431 #ifdef __cplusplus 432 } 433 #endif 434 435 /* 436 * Like clnt_perror(), but is more verbose in its output 437 */ 438 #ifdef __cplusplus 439 extern "C" { 440 #endif 441 extern void clnt_perrno(enum clnt_stat); /* stderr */ 442 extern char *clnt_sperrno(enum clnt_stat); /* string */ 443 #ifdef __cplusplus 444 } 445 #endif 446 447 /* 448 * Print an English error message, given the client error code 449 */ 450 #ifdef __cplusplus 451 extern "C" { 452 #endif 453 extern void clnt_perror(CLIENT *, const char *); /* stderr */ 454 extern char *clnt_sperror(CLIENT *, const char *); /* string */ 455 #ifdef __cplusplus 456 } 457 #endif 458 459 460 /* 461 * If a creation fails, the following allows the user to figure out why. 462 */ 463 struct rpc_createerr { 464 enum clnt_stat cf_stat; 465 struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ 466 }; 467 468 #ifdef __cplusplus 469 extern "C" { 470 #endif 471 extern struct rpc_createerr *__rpc_createerr(void); 472 #ifdef __cplusplus 473 } 474 #endif 475 #define get_rpc_createerr() (*(__rpc_createerr())) 476 #define rpc_createerr (*(__rpc_createerr())) 477 478 /* 479 * The simplified interface: 480 * enum clnt_stat 481 * rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype) 482 * const char *host; 483 * const rpcprog_t prognum; 484 * const rpcvers_t versnum; 485 * const rpcproc_t procnum; 486 * const xdrproc_t inproc, outproc; 487 * const char *in; 488 * char *out; 489 * const char *nettype; 490 */ 491 #ifdef __cplusplus 492 extern "C" { 493 #endif 494 extern enum clnt_stat rpc_call(const char *, const rpcprog_t, 495 const rpcvers_t, const rpcproc_t, 496 const xdrproc_t, const char *, 497 const xdrproc_t, char *, const char *); 498 #ifdef __cplusplus 499 } 500 #endif 501 502 /* 503 * RPC broadcast interface 504 * The call is broadcasted to all locally connected nets. 505 * 506 * extern enum clnt_stat 507 * rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, 508 * eachresult, nettype) 509 * const rpcprog_t prog; -- program number 510 * const rpcvers_t vers; -- version number 511 * const rpcproc_t proc; -- procedure number 512 * const xdrproc_t xargs; -- xdr routine for args 513 * caddr_t argsp; -- pointer to args 514 * const xdrproc_t xresults; -- xdr routine for results 515 * caddr_t resultsp; -- pointer to results 516 * const resultproc_t eachresult; -- call with each result 517 * const char *nettype; -- Transport type 518 * 519 * For each valid response received, the procedure eachresult is called. 520 * Its form is: 521 * done = eachresult(resp, raddr, nconf) 522 * bool_t done; 523 * caddr_t resp; 524 * struct netbuf *raddr; 525 * struct netconfig *nconf; 526 * where resp points to the results of the call and raddr is the 527 * address if the responder to the broadcast. nconf is the transport 528 * on which the response was received. 529 * 530 * extern enum clnt_stat 531 * rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, 532 * eachresult, inittime, waittime, nettype) 533 * const rpcprog_t prog; -- program number 534 * const rpcvers_t vers; -- version number 535 * const rpcproc_t proc; -- procedure number 536 * const xdrproc_t xargs; -- xdr routine for args 537 * caddr_t argsp; -- pointer to args 538 * const xdrproc_t xresults; -- xdr routine for results 539 * caddr_t resultsp; -- pointer to results 540 * const resultproc_t eachresult; -- call with each result 541 * const int inittime; -- how long to wait initially 542 * const int waittime; -- maximum time to wait 543 * const char *nettype; -- Transport type 544 */ 545 546 typedef bool_t (*resultproc_t)(caddr_t, ...); 547 548 #ifdef __cplusplus 549 extern "C" { 550 #endif 551 extern enum clnt_stat rpc_broadcast(const rpcprog_t, const rpcvers_t, 552 const rpcproc_t, const xdrproc_t, 553 caddr_t, const xdrproc_t, caddr_t, 554 const resultproc_t, const char *); 555 extern enum clnt_stat rpc_broadcast_exp(const rpcprog_t, const rpcvers_t, 556 const rpcproc_t, const xdrproc_t, 557 caddr_t, const xdrproc_t, caddr_t, 558 const resultproc_t, const int, 559 const int, const char *); 560 #ifdef __cplusplus 561 } 562 #endif 563 564 /* For backward compatibility */ 565 #include
566 567 #endif /* !_TIRPC_CLNT_H_ */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™