1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 * Copyright 2020 Tintri by DDN. All rights reserved. 25 */ 26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 27 /* All Rights Reserved */ 28 /* 29 * Portions of this source code were derived from Berkeley 30 * 4.3 BSD under license from the Regents of the University of 31 * California. 32 */ 33 34 /* 35 * clnt.h - Client side remote procedure call interface. 36 */ 37 38 #ifndef _RPC_CLNT_H 39 #define _RPC_CLNT_H 40 41 #include <sys/types.h> 42 #include <rpc/rpc_com.h> 43 #include <rpc/clnt_stat.h> 44 #include <rpc/auth.h> 45 46 /* 47 * rpc calls return an enum clnt_stat. This should be looked at more, 48 * since each implementation is required to live with this (implementation 49 * independent) list of errors. 50 */ 51 #include <sys/netconfig.h> 52 #ifdef _KERNEL 53 #include <sys/t_kuser.h> 54 #endif /* _KERNEL */ 55 56 #ifdef __cplusplus 57 extern "C" { 58 #endif 59 60 /* 61 * Following defines the multicast group address used by IPV6 enabled 62 * client to do the broadcast. IPv6 doesn't have any broadcast support 63 * as IPv4 provides, thus it used this reserved address which is joined 64 * by all rpc clients. 65 */ 66 67 #define RPCB_MULTICAST_ADDR "FF02::202" 68 69 /* 70 * the following errors are in general unrecoverable. The caller 71 * should give up rather than retry. 72 */ 73 #define IS_UNRECOVERABLE_RPC(s) (((s) == RPC_AUTHERROR) || \ 74 ((s) == RPC_CANTENCODEARGS) || \ 75 ((s) == RPC_CANTDECODERES) || \ 76 ((s) == RPC_VERSMISMATCH) || \ 77 ((s) == RPC_PROCUNAVAIL) || \ 78 ((s) == RPC_PROGUNAVAIL) || \ 79 ((s) == RPC_PROGVERSMISMATCH) || \ 80 ((s) == RPC_SYSTEMERROR) || \ 81 ((s) == RPC_CANTDECODEARGS)) 82 83 /* Maximum rpc backoff time */ 84 #define RPC_MAX_BACKOFF 30 85 86 /* 87 * Error info. 88 */ 89 struct rpc_err { 90 enum clnt_stat re_status; 91 union { 92 struct { 93 int RE_errno; /* related system error */ 94 int RE_t_errno; /* related tli error number */ 95 } RE_err; 96 enum auth_stat RE_why; /* why the auth error occurred */ 97 struct { 98 rpcvers_t low; /* lowest verion supported */ 99 rpcvers_t high; /* highest verion supported */ 100 } RE_vers; 101 struct { /* maybe meaningful if RPC_FAILED */ 102 int32_t s1; 103 int32_t s2; 104 } RE_lb; /* life boot & debugging only */ 105 } ru; 106 #define re_errno ru.RE_err.RE_errno 107 #define re_terrno ru.RE_err.RE_t_errno 108 #define re_why ru.RE_why 109 #define re_vers ru.RE_vers 110 #define re_lb ru.RE_lb 111 }; 112 113 114 /* 115 * Timers used for the pseudo-transport protocol when using datagrams 116 */ 117 struct rpc_timers { 118 clock_t rt_srtt; /* smoothed round-trip time */ 119 clock_t rt_deviate; /* estimated deviation */ 120 clock_t rt_rtxcur; /* current (backed-off) rto */ 121 }; 122 123 /* 124 * PSARC 2003/523 Contract Private Interface 125 * CLIENT 126 * Changes must be reviewed by Solaris File Sharing 127 * Changes must be communicated to contract-2003-523@sun.com 128 * 129 * Client rpc handle. 130 * Created by individual implementations 131 * Client is responsible for initializing auth, see e.g. auth_none.c. 132 */ 133 134 typedef struct __client { 135 AUTH *cl_auth; /* authenticator */ 136 struct clnt_ops { 137 #ifdef __STDC__ 138 /* call remote procedure */ 139 enum clnt_stat (*cl_call)(struct __client *, rpcproc_t, 140 xdrproc_t, caddr_t, xdrproc_t, 141 caddr_t, struct timeval); 142 /* abort a call */ 143 void (*cl_abort)(/* various */); 144 /* get specific error code */ 145 void (*cl_geterr)(struct __client *, 146 struct rpc_err *); 147 /* frees results */ 148 bool_t (*cl_freeres)(struct __client *, xdrproc_t, 149 caddr_t); 150 /* destroy this structure */ 151 void (*cl_destroy)(struct __client *); 152 /* the ioctl() of rpc */ 153 bool_t (*cl_control)(struct __client *, int, char *); 154 /* set rpc level timers */ 155 int (*cl_settimers)(struct __client *, 156 struct rpc_timers *, struct rpc_timers *, 157 int, void (*)(), caddr_t, uint32_t); 158 #ifndef _KERNEL 159 /* send a one-way asynchronous call to remote procedure */ 160 enum clnt_stat (*cl_send)(struct __client *, rpcproc_t, 161 xdrproc_t, caddr_t); 162 #endif /* !_KERNEL */ 163 #else 164 enum clnt_stat (*cl_call)(); /* call remote procedure */ 165 void (*cl_abort)(); /* abort a call */ 166 void (*cl_geterr)(); /* get specific error code */ 167 bool_t (*cl_freeres)(); /* frees results */ 168 void (*cl_destroy)(); /* destroy this structure */ 169 bool_t (*cl_control)(); /* the ioctl() of rpc */ 170 int (*cl_settimers)(); /* set rpc level timers */ 171 #ifndef _KERNEL 172 enum clnt_stat (*cl_send)(); /* send one-way request */ 173 #endif /* !_KERNEL */ 174 #endif 175 } *cl_ops; 176 caddr_t cl_private; /* private stuff */ 177 #ifndef _KERNEL 178 char *cl_netid; /* network token */ 179 char *cl_tp; /* device name */ 180 #else 181 bool_t cl_nosignal; /* to handle NOINTR */ 182 #endif 183 } CLIENT; 184 185 /* 186 * Feedback values used for possible congestion and rate control 187 */ 188 #define FEEDBACK_REXMIT1 1 /* first retransmit */ 189 #define FEEDBACK_OK 2 /* no retransmits */ 190 191 /* 192 * The following defines the control routines 193 * for rpcbind. 194 */ 195 196 #define CLCR_GET_RPCB_TIMEOUT 1 197 #define CLCR_SET_RPCB_TIMEOUT 2 198 #define CLCR_SET_LOWVERS 3 199 #define CLCR_GET_LOWVERS 4 200 #define CLCR_SET_RPCB_RMTTIME 5 201 #define CLCR_GET_RPCB_RMTTIME 6 202 #define CLCR_SET_CRED_CACHE_SZ 7 203 #define CLCR_GET_CRED_CACHE_SZ 8 204 205 #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ 206 207 #define KNC_STRSIZE 128 /* maximum length of knetconfig strings */ 208 /* 209 * PSARC 2003/523 Contract Private Interface 210 * knetconfig 211 * Changes must be reviewed by Solaris File Sharing 212 * Changes must be communicated to contract-2003-523@sun.com 213 * 214 * Note that the knetconfig strings can either be dynamically allocated, or 215 * they can be string literals. The code that sets up the knetconfig is 216 * responsible for keeping track of this and freeing the strings if 217 * necessary when the knetconfig is destroyed. 218 */ 219 struct knetconfig { 220 unsigned int knc_semantics; /* token name */ 221 caddr_t knc_protofmly; /* protocol family */ 222 caddr_t knc_proto; /* protocol */ 223 dev_t knc_rdev; /* device id */ 224 unsigned int knc_unused[8]; 225 }; 226 227 #ifdef _SYSCALL32 228 struct knetconfig32 { 229 uint32_t knc_semantics; /* token name */ 230 caddr32_t knc_protofmly; /* protocol family */ 231 caddr32_t knc_proto; /* protocol */ 232 dev32_t knc_rdev; /* device id */ 233 uint32_t knc_unused[8]; 234 }; 235 #endif /* _SYSCALL32 */ 236 237 #ifdef _KERNEL 238 239 /* 240 * Bucket defined for the call table. Padded out to 64 bytes so that 241 * false sharing won't be induced. 242 */ 243 typedef union call_table { 244 struct { 245 struct calllist_s *uct_call_next; 246 struct calllist_s *uct_call_prev; 247 uint_t uct_len; 248 kmutex_t uct_lock; 249 } ct_s; 250 char uct_pad[64]; 251 } call_table_t; 252 253 /* 254 * Define some macros for easy access into the call table structure 255 */ 256 #define ct_call_next ct_s.uct_call_next 257 #define ct_call_prev ct_s.uct_call_prev 258 #define ct_len ct_s.uct_len 259 #define ct_lock ct_s.uct_lock 260 261 /* 262 * List of outstanding calls awaiting replies, for COTS, CLTS 263 */ 264 typedef struct calllist_s { 265 struct calllist_s *call_next; /* hash chain, MUST BE FIRST */ 266 struct calllist_s *call_prev; 267 bool_t call_notified; 268 uint_t call_xid; /* the xid on the call */ 269 uint_t call_hash; /* hash value */ 270 call_table_t *call_bucket; /* back pointer to bucket */ 271 mblk_t *call_reply; /* the reply to the call */ 272 kcondvar_t call_cv; /* cv to notify when reply is done */ 273 kmutex_t call_lock; /* lock for cv */ 274 struct rpc_err call_err; /* status on reply */ 275 #define call_status call_err.re_status /* error on reply (rep is invalid) */ 276 #define call_reason call_err.re_errno /* reason code on T_DISCON_IND */ 277 queue_t *call_wq; /* the write queue the call is using */ 278 zoneid_t call_zoneid; /* zoneid the call was made from */ 279 } calllist_t; 280 281 /* 282 * Define macros for call table hashing 283 */ 284 /* 285 * A simple hash function. Due to the way XID's get allocated, this may be 286 * sufficient. This hash function provides round robin bucket selection so 287 * that the next time a particular bucket gets picked is when there have 288 * been N-1 calls. N is the number of buckets. 289 */ 290 #define call_hash(xid, hashsize) \ 291 (xid % hashsize); 292 293 #define call_table_enter(e) \ 294 { \ 295 call_table_t *ctp = (e)->call_bucket; \ 296 mutex_enter(&ctp->ct_lock); \ 297 ctp->ct_len++; \ 298 (e)->call_next = ctp->ct_call_next; \ 299 (e)->call_prev = (calllist_t *)ctp; \ 300 ctp->ct_call_next->call_prev = (e); \ 301 ctp->ct_call_next = (e); \ 302 mutex_exit(&ctp->ct_lock); \ 303 } 304 305 #define call_table_remove(e) \ 306 { \ 307 call_table_t *ctp = (e)->call_bucket; \ 308 mutex_enter(&ctp->ct_lock); \ 309 ctp->ct_len--; \ 310 (e)->call_prev->call_next = (e)->call_next; \ 311 (e)->call_next->call_prev = (e)->call_prev; \ 312 mutex_exit(&ctp->ct_lock); \ 313 } 314 315 #define call_table_find(ctp, xid, ele) \ 316 { \ 317 calllist_t *cp; \ 318 (ele) = NULL; \ 319 mutex_enter(&(ctp)->ct_lock); \ 320 for (cp = (ctp)->ct_call_next; \ 321 cp != (calllist_t *)(ctp); \ 322 cp = cp->call_next) { \ 323 if (cp->call_xid == (xid)) \ 324 (ele) = cp; \ 325 } \ 326 } 327 328 #define DEFAULT_MIN_HASH_SIZE 32 329 #define DEFAULT_HASH_SIZE 1024 330 331 #define RESERVED_PORTSPACE (IPPORT_RESERVED - (IPPORT_RESERVED/2)) 332 #define NONRESERVED_PORTSPACE (0xFFFF - IPPORT_RESERVED) 333 334 /* 335 * Alloc_xid presents an interface which kernel RPC clients 336 * should use to allocate their XIDs. Its implementation 337 * may change over time (for example, to allow sharing of 338 * XIDs between the kernel and user-level applications, so 339 * all XID allocation should be done by calling alloc_xid(). 340 */ 341 extern uint32_t alloc_xid(void); 342 343 extern struct zone *rpc_zone(void); 344 extern zoneid_t rpc_zoneid(void); 345 346 extern int clnt_tli_kcreate(struct knetconfig *config, struct netbuf *svcaddr, 347 rpcprog_t, rpcvers_t, uint_t max_msgsize, int retrys, 348 struct cred *cred, CLIENT **ncl); 349 350 extern int clnt_tli_kinit(CLIENT *h, struct knetconfig *config, 351 struct netbuf *addr, uint_t max_msgsize, int retries, 352 struct cred *cred); 353 354 extern int rpc_uaddr2port(int af, char *addr); 355 356 extern void clnt_init_netbuf(struct netbuf *, int); 357 extern void clnt_free_netbuf(struct netbuf *); 358 extern void clnt_dup_netbuf(const struct netbuf *, struct netbuf *); 359 extern int clnt_cmp_netaddr(const struct netbuf *, struct netbuf *); 360 361 /* 362 * kRPC internal function. Not for general use. Subject to rapid change. 363 */ 364 extern int bindresvport(TIUSER *tiptr, struct netbuf *addr, 365 struct netbuf *bound_addr, bool_t istcp); 366 367 /* 368 * kRPC internal function. Not for general use. Subject to rapid change. 369 */ 370 extern int clnt_clts_kcreate(struct knetconfig *config, struct netbuf *addr, 371 rpcprog_t, rpcvers_t, int retries, struct cred *cred, CLIENT **cl); 372 373 /* 374 * kRPC internal function. Not for general use. Subject to rapid change. 375 */ 376 extern int clnt_cots_kcreate(dev_t dev, struct netbuf *addr, int family, 377 rpcprog_t, rpcvers_t, uint_t max_msgsize, struct cred *cred, 378 CLIENT **ncl); 379 /* 380 * kRPC internal function. Not for general use. Subject to rapid change. 381 */ 382 extern int clnt_rdma_kcreate(char *proto, void *handle, struct netbuf *raddr, 383 int family, rpcprog_t pgm, rpcvers_t vers, struct cred *cred, 384 CLIENT **cl); 385 /* 386 * kRPC internal function. Not for general use. Subject to rapid change. 387 */ 388 extern int rdma_reachable(int addr_type, struct netbuf *addr, 389 struct knetconfig **knconf); 390 391 /* 392 * kRPC internal function. Not for general use. Subject to rapid change. 393 */ 394 extern void clnt_clts_kinit(CLIENT *h, struct netbuf *addr, int retries, 395 struct cred *cred); 396 397 /* 398 * kRPC internal function. Not for general use. Subject to rapid change. 399 */ 400 extern void clnt_cots_kinit(CLIENT *h, dev_t dev, int family, 401 struct netbuf *addr, int max_msgsize, struct cred *cred); 402 403 /* 404 * kRPC internal function. Not for general use. Subject to rapid change. 405 */ 406 extern void clnt_rdma_kinit(CLIENT *h, char *proto, void *handle, 407 struct netbuf *addr, struct cred *cred); 408 409 /* 410 * kRPC internal function. Not for general use. Subject to rapid change. 411 */ 412 extern bool_t clnt_dispatch_notify(mblk_t *, zoneid_t, uint32_t); 413 414 /* 415 * kRPC internal function. Not for general use. Subject to rapid change. 416 */ 417 extern bool_t clnt_dispatch_notifyconn(queue_t *, mblk_t *); 418 419 /* 420 * kRPC internal function. Not for general use. Subject to rapid change. 421 */ 422 extern void clnt_dispatch_notifyall(queue_t *, int32_t, int32_t); 423 424 /* 425 * kRPC internal function. Not for general use. Subject to rapid change. 426 */ 427 extern enum clnt_stat clnt_clts_kcallit_addr(CLIENT *, rpcproc_t, xdrproc_t, 428 caddr_t, xdrproc_t, caddr_t, struct timeval, struct netbuf *); 429 430 /* 431 * kRPC internal function. Not for general use. Subject to rapid change. 432 */ 433 extern call_table_t *call_table_init(int); 434 435 /* 436 * kRPC internal function. Not for general use. Subject to rapid change. 437 */ 438 extern void clnt_init(void); 439 440 /* 441 * kRPC internal function. Not for general use. Subject to rapid change. 442 */ 443 extern void clnt_fini(void); 444 445 /* 446 * kRPC internal function. Not for general use. Subject to rapid change. 447 */ 448 extern void clnt_clts_init(void); 449 450 /* 451 * kRPC internal function. Not for general use. Subject to rapid change. 452 */ 453 extern void clnt_clts_fini(void); 454 455 /* 456 * kRPC internal function. Not for general use. Subject to rapid change. 457 */ 458 extern void clnt_cots_init(void); 459 460 /* 461 * kRPC internal function. Not for general use. Subject to rapid change. 462 */ 463 extern void clnt_cots_fini(void); 464 465 /* 466 * kRPC internal function. Not for general use. Subject to rapid change. 467 */ 468 extern void clnt_clts_dispatch_notify(mblk_t *, int, zoneid_t); 469 extern int connmgr_cb_create(void *, rpcprog_t, rpcvers_t, int, void *); 470 extern void connmgr_cb_destroy(queue_t *); 471 472 extern void rpc_poptimod(struct vnode *); 473 extern int kstr_push(struct vnode *, char *); 474 extern void t_kadvise(TIUSER *, uchar_t *, int); 475 476 extern boolean_t connmgr_cpr_reset(void *, int); 477 extern void connmgr_destroy(queue_t *); 478 479 extern void put_inet_port(struct netbuf *, ushort_t); 480 extern void put_inet6_port(struct netbuf *, ushort_t); 481 extern void put_loopback_port(struct netbuf *, char *); 482 extern enum clnt_stat rpcbind_getaddr(struct knetconfig *, rpcprog_t, 483 rpcvers_t, struct netbuf *); 484 extern enum clnt_stat rpcbind_getaddr5(struct knetconfig *, rpcprog_t, 485 rpcvers_t, struct netbuf *, struct netbuf *); 486 487 /* 488 * Kstat stuff 489 */ 490 #include <sys/zone.h> 491 492 extern zone_key_t rpcstat_zone_key; 493 494 struct rpc_clts_client; /* unix:0:rpc_clts_client */ 495 struct rpc_clts_server; /* unix:0:rpc_clts_server */ 496 struct rpc_cots_client; /* unix:0:rpc_cots_client */ 497 struct rpc_cots_server; /* unix:0:rpc_cots_server */ 498 499 struct rpcstat { 500 struct rpc_clts_client *rpc_clts_client; 501 struct rpc_clts_server *rpc_clts_server; 502 struct rpc_cots_client *rpc_cots_client; 503 struct rpc_cots_server *rpc_cots_server; 504 }; 505 506 extern kstat_named_t *rpcstat_zone_init_common(zoneid_t, const char *, 507 const char *, const kstat_named_t *, size_t); 508 extern void rpcstat_zone_fini_common(zoneid_t, const char *, const char *); 509 510 extern void clnt_clts_stats_init(zoneid_t, struct rpc_clts_client **); 511 extern void clnt_clts_stats_fini(zoneid_t, struct rpc_clts_client **); 512 513 extern void svc_clts_stats_init(zoneid_t, struct rpc_clts_server **); 514 extern void svc_clts_stats_fini(zoneid_t, struct rpc_clts_server **); 515 516 extern void clnt_cots_stats_init(zoneid_t, struct rpc_cots_client **); 517 extern void clnt_cots_stats_fini(zoneid_t, struct rpc_cots_client **); 518 519 extern void svc_cots_stats_init(zoneid_t, struct rpc_cots_server **); 520 extern void svc_cots_stats_fini(zoneid_t, struct rpc_cots_server **); 521 522 #endif /* _KERNEL */ 523 524 /* 525 * client side rpc interface ops 526 */ 527 528 /* 529 * enum clnt_stat 530 * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) 531 * CLIENT *rh; 532 * rpcproc_t proc; 533 * xdrproc_t xargs; 534 * caddr_t argsp; 535 * xdrproc_t xres; 536 * caddr_t resp; 537 * struct timeval timeout; 538 * 539 * PSARC 2003/523 Contract Private Interface 540 * CLNT_CALL 541 * Changes must be reviewed by Solaris File Sharing 542 * Changes must be communicated to contract-2003-523@sun.com 543 */ 544 #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ 545 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) 546 #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ 547 ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) 548 549 #ifndef _KERNEL 550 /* 551 * enum clnt_stat 552 * CLNT_SEND(rh, proc, xargs, argsp) 553 * CLIENT *rh; 554 * rpcproc_t proc; 555 * xdrproc_t xargs; 556 * caddr_t argsp; 557 * 558 * PSARC 2000/428 Contract Private Interface 559 */ 560 #define CLNT_SEND(rh, proc, xargs, argsp) \ 561 ((*(rh)->cl_ops->cl_send)(rh, proc, xargs, argsp)) 562 #define clnt_send(rh, proc, xargs, argsp) \ 563 ((*(rh)->cl_ops->cl_send)(rh, proc, xargs, argsp)) 564 #endif /* !_KERNEL */ 565 566 /* 567 * void 568 * CLNT_ABORT(rh); 569 * CLIENT *rh; 570 */ 571 #define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) 572 #define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) 573 574 /* 575 * struct rpc_err 576 * CLNT_GETERR(rh); 577 * CLIENT *rh; 578 */ 579 #define CLNT_GETERR(rh, errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) 580 #define clnt_geterr(rh, errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) 581 582 /* 583 * bool_t 584 * CLNT_FREERES(rh, xres, resp); 585 * CLIENT *rh; 586 * xdrproc_t xres; 587 * caddr_t resp; 588 */ 589 #define CLNT_FREERES(rh, xres, resp) \ 590 ((*(rh)->cl_ops->cl_freeres)(rh, xres, resp)) 591 #define clnt_freeres(rh, xres, resp) \ 592 ((*(rh)->cl_ops->cl_freeres)(rh, xres, resp)) 593 594 /* 595 * bool_t 596 * CLNT_CONTROL(cl, request, info) 597 * CLIENT *cl; 598 * uint_t request; 599 * char *info; 600 * 601 * PSARC 2003/523 Contract Private Interface 602 * CLNT_CONTROL 603 * Changes must be reviewed by Solaris File Sharing 604 * Changes must be communicated to contract-2003-523@sun.com 605 */ 606 #define CLNT_CONTROL(cl, rq, in) ((*(cl)->cl_ops->cl_control)(cl, rq, in)) 607 #define clnt_control(cl, rq, in) ((*(cl)->cl_ops->cl_control)(cl, rq, in)) 608 609 610 /* 611 * control operations that apply to all transports 612 */ 613 #define CLSET_TIMEOUT 1 /* set timeout (timeval) */ 614 #define CLGET_TIMEOUT 2 /* get timeout (timeval) */ 615 #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ 616 #define CLGET_FD 6 /* get connections file descriptor */ 617 #define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */ 618 #define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ 619 #define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ 620 #define CLGET_XID 10 /* Get xid */ 621 #define CLSET_XID 11 /* Set xid */ 622 #define CLGET_VERS 12 /* Get version number */ 623 #define CLSET_VERS 13 /* Set version number */ 624 #define CLGET_PROG 14 /* Get program number */ 625 #define CLSET_PROG 15 /* Set program number */ 626 #define CLSET_SVC_ADDR 16 /* get server's address (netbuf) */ 627 #define CLSET_PUSH_TIMOD 17 /* push timod if not already present */ 628 #define CLSET_POP_TIMOD 18 /* pop timod */ 629 #ifndef _KERNEL 630 /* 00-08-17 - NON STANDARD CONTROL PARAMETER */ 631 #define CLSET_IO_MODE 19 /* clnt_send behavior */ 632 #define CLGET_IO_MODE 20 /* clnt_send behavior */ 633 #define CLSET_FLUSH_MODE 21 /* flush behavior */ 634 #define CLGET_FLUSH_MODE 22 /* flush behavior */ 635 #define CLFLUSH 23 /* flush now (user wants it) */ 636 #define CLSET_CONNMAXREC_SIZE 24 /* set pending request buffer size */ 637 #define CLGET_CONNMAXREC_SIZE 25 /* set pending request buffer size */ 638 #define CLGET_CURRENT_REC_SIZE 26 /* get pending request buffer size */ 639 640 typedef enum { 641 RPC_CL_BESTEFFORT_FLUSH = 100, /* flush as much as possible */ 642 /* without blocking */ 643 RPC_CL_BLOCKING_FLUSH, /* flush the buffer completely */ 644 /* (possibly blocking) */ 645 RPC_CL_DEFAULT_FLUSH /* flush according to the currently */ 646 /* defined policy. */ 647 } rpcflushmode_t; 648 649 650 typedef enum { 651 RPC_CL_BLOCKING = 10, /* PASSED CLNT_CONTROL SET_IO_MODE */ 652 RPC_CL_NONBLOCKING 653 } rpciomode_t; 654 #endif /* !_KERNEL */ 655 /* 656 * Connectionless only control operations 657 */ 658 #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ 659 #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ 660 661 #ifdef _KERNEL 662 /* 663 * Connection oriented only control operation. 664 */ 665 #define CLSET_PROGRESS 10000 /* Report RPC_INPROGRESS if a request */ 666 /* has been sent but no reply */ 667 /* received yet. */ 668 #define CLSET_BCAST 10001 /* Set RPC Broadcast hint */ 669 #define CLGET_BCAST 10002 /* Get RPC Broadcast hint */ 670 #define CLSET_NODELAYONERR 10003 /* Set enable/disable of delay on */ 671 /* connection setup error */ 672 #define CLGET_NODELAYONERR 10004 /* Get enable/disable of delay on */ 673 /* connection setup error */ 674 #define CLSET_BINDRESVPORT 10005 /* Set preference for reserve port */ 675 #define CLGET_BINDRESVPORT 10006 /* Get preference for reserve port */ 676 #define CLSET_BINDSRCADDR 10007 /* Set preference for interface */ 677 /* and end port */ 678 #define CLSET_CBSERVER_SETUP 10008 /* Init back channel info */ 679 #define CLSET_CBSERVER_CLEAR 10009 /* Clear bc setup flags */ 680 #define CLSET_BACKCHANNEL 10010 /* Use backchannel connection */ 681 #define CLSET_BACKCHANNEL_CLEAR 10011 /* Clear backchannel flag */ 682 #define CLSET_TAG 10012 /* set rpc tags */ 683 #define CLSET_TAG_CLEAR 10013 /* clear rpc tags */ 684 #define CLSET_TAG_SWAP 10014 /* swap the tags */ 685 #define CLSET_CB_TEST 10015 /* used to test cb conn's */ 686 /* for a specific tag */ 687 688 #define CLGET_CB_UNTESTED 10016 /* return untested */ 689 /* callback connections */ 690 691 #define CLSET_CB_TEST_CLEAR 10017 /* clear previous flag */ 692 #define CLSET_NON_BIRPC 10018 /* non bi-directional rpc */ 693 #define CLSET_BINDCONN_TO_TAG 10019 /* associate a connection */ 694 /* with the tag */ 695 #define CLSET_CLEAR_BINDCONN 10020 /* clear the previous flag */ 696 #define CLSET_TAG_CONN_UNBIND 10021 /* remove associated conn */ 697 /* for the tag */ 698 #define CLSET_TAG_DESTROY 10022 /* destroy the tag and */ 699 /* dis-associate any conn */ 700 #define CLSET_CBSERVER_CLEANUP 10023 /* clear cbinfo in a */ 701 #define CLSET_CBCLIENT 10024 /* Use callback conn */ 702 /* nfs server side only */ 703 704 #endif 705 706 /* 707 * void 708 * CLNT_SETTIMERS(rh); 709 * CLIENT *rh; 710 * struct rpc_timers *t; 711 * struct rpc_timers *all; 712 * unsigned int min; 713 * void (*fdbck)(); 714 * caddr_t arg; 715 * uint_t xid; 716 */ 717 #define CLNT_SETTIMERS(rh, t, all, min, fdbck, arg, xid) \ 718 ((*(rh)->cl_ops->cl_settimers)(rh, t, all, min, \ 719 fdbck, arg, xid)) 720 #define clnt_settimers(rh, t, all, min, fdbck, arg, xid) \ 721 ((*(rh)->cl_ops->cl_settimers)(rh, t, all, min, \ 722 fdbck, arg, xid)) 723 724 725 /* 726 * void 727 * CLNT_DESTROY(rh); 728 * CLIENT *rh; 729 * 730 * PSARC 2003/523 Contract Private Interface 731 * CLNT_DESTROY 732 * Changes must be reviewed by Solaris File Sharing 733 * Changes must be communicated to contract-2003-523@sun.com 734 */ 735 #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) 736 #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) 737 738 739 /* 740 * RPCTEST is a test program which is accessable on every rpc 741 * transport/port. It is used for testing, performance evaluation, 742 * and network administration. 743 */ 744 745 #define RPCTEST_PROGRAM ((rpcprog_t)1) 746 #define RPCTEST_VERSION ((rpcvers_t)1) 747 #define RPCTEST_NULL_PROC ((rpcproc_t)2) 748 #define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3) 749 750 /* 751 * By convention, procedure 0 takes null arguments and returns them 752 */ 753 754 #define NULLPROC ((rpcproc_t)0) 755 756 /* 757 * Below are the client handle creation routines for the various 758 * implementations of client side rpc. They can return NULL if a 759 * creation failure occurs. 760 */ 761 762 #ifndef _KERNEL 763 764 /* 765 * Generic client creation routine. Supported protocols are which belong 766 * to the nettype name space 767 */ 768 #ifdef __STDC__ 769 extern CLIENT * clnt_create(const char *, const rpcprog_t, const rpcvers_t, 770 const char *); 771 /* 772 * 773 * const char *hostname; -- hostname 774 * const rpcprog_t prog; -- program number 775 * const rpcvers_t vers; -- version number 776 * const char *nettype; -- network type 777 */ 778 #else 779 extern CLIENT * clnt_create(); 780 #endif 781 782 /* 783 * Generic client creation routine. Just like clnt_create(), except 784 * it takes an additional timeout parameter. 785 */ 786 #ifdef __STDC__ 787 extern CLIENT * clnt_create_timed(const char *, const rpcprog_t, 788 const rpcvers_t, const char *, const struct timeval *); 789 /* 790 * 791 * const char *hostname; -- hostname 792 * const rpcprog_t prog; -- program number 793 * const rpcvers_t vers; -- version number 794 * const char *nettype; -- network type 795 * const struct timeval *tp; -- timeout 796 */ 797 #else 798 extern CLIENT * clnt_create_timed(); 799 #endif 800 801 /* 802 * Generic client creation routine. Supported protocols are which belong 803 * to the nettype name space. 804 */ 805 #ifdef __STDC__ 806 extern CLIENT * clnt_create_vers(const char *, const rpcprog_t, rpcvers_t *, 807 const rpcvers_t, const rpcvers_t, const char *); 808 /* 809 * const char *host; -- hostname 810 * const rpcprog_t prog; -- program number 811 * rpcvers_t *vers_out; -- servers highest available version number 812 * const rpcvers_t vers_low; -- low version number 813 * const rpcvers_t vers_high; -- high version number 814 * const char *nettype; -- network type 815 */ 816 #else 817 extern CLIENT * clnt_create_vers(); 818 #endif 819 820 /* 821 * Generic client creation routine. Supported protocols are which belong 822 * to the nettype name space. 823 */ 824 #ifdef __STDC__ 825 extern CLIENT * clnt_create_vers_timed(const char *, const rpcprog_t, 826 rpcvers_t *, const rpcvers_t, const rpcvers_t, const char *, 827 const struct timeval *); 828 /* 829 * const char *host; -- hostname 830 * const rpcprog_t prog; -- program number 831 * rpcvers_t *vers_out; -- servers highest available version number 832 * const rpcvers_t vers_low; -- low version number 833 * const prcvers_t vers_high; -- high version number 834 * const char *nettype; -- network type 835 * const struct timeval *tp -- timeout 836 */ 837 #else 838 extern CLIENT * clnt_create_vers_timed(); 839 #endif 840 841 842 /* 843 * Generic client creation routine. It takes a netconfig structure 844 * instead of nettype 845 */ 846 #ifdef __STDC__ 847 extern CLIENT * clnt_tp_create(const char *, const rpcprog_t, const rpcvers_t, 848 const struct netconfig *); 849 /* 850 * const char *hostname; -- hostname 851 * const rpcprog_t prog; -- program number 852 * const rpcvers_t vers; -- version number 853 * const struct netconfig *netconf; -- network config structure 854 */ 855 #else 856 extern CLIENT * clnt_tp_create(); 857 #endif 858 859 /* 860 * Generic client creation routine. Just like clnt_tp_create(), except 861 * it takes an additional timeout parameter. 862 */ 863 #ifdef __STDC__ 864 extern CLIENT * clnt_tp_create_timed(const char *, const rpcprog_t, 865 const rpcvers_t, const struct netconfig *, const struct timeval *); 866 /* 867 * const char *hostname; -- hostname 868 * const rpcprog_t prog; -- program number 869 * const rpcvers_t vers; -- version number 870 * const struct netconfig *netconf; -- network config structure 871 * const struct timeval *tp; -- timeout 872 */ 873 #else 874 extern CLIENT * clnt_tp_create_timed(); 875 #endif 876 877 /* 878 * Generic TLI create routine 879 */ 880 881 #ifdef __STDC__ 882 extern CLIENT * clnt_tli_create(const int, const struct netconfig *, 883 struct netbuf *, const rpcprog_t, const rpcvers_t, const uint_t, 884 const uint_t); 885 /* 886 * const int fd; -- fd 887 * const struct netconfig *nconf; -- netconfig structure 888 * struct netbuf *svcaddr; -- servers address 889 * const rpcprog_t prog; -- program number 890 * const rpcvers_t vers; -- version number 891 * const uint_t sendsz; -- send size 892 * const uint_t recvsz; -- recv size 893 */ 894 895 #else 896 extern CLIENT * clnt_tli_create(); 897 #endif 898 899 /* 900 * Low level clnt create routine for connectionful transports, e.g. tcp. 901 */ 902 #ifdef __STDC__ 903 extern CLIENT * clnt_vc_create(const int, struct netbuf *, 904 const rpcprog_t, const rpcvers_t, const uint_t, const uint_t); 905 /* 906 * const int fd; -- open file descriptor 907 * const struct netbuf *svcaddr; -- servers address 908 * const rpcprog_t prog; -- program number 909 * const rpcvers_t vers; -- version number 910 * const uint_t sendsz; -- buffer recv size 911 * const uint_t recvsz; -- buffer send size 912 */ 913 #else 914 extern CLIENT * clnt_vc_create(); 915 #endif 916 917 /* 918 * Low level clnt create routine for connectionless transports, e.g. udp. 919 */ 920 #ifdef __STDC__ 921 extern CLIENT * clnt_dg_create(const int, struct netbuf *, 922 const rpcprog_t, const rpcvers_t, const uint_t, const uint_t); 923 /* 924 * const int fd; -- open file descriptor 925 * const struct netbuf *svcaddr; -- servers address 926 * const rpcprog_t program; -- program number 927 * const rpcvers_t version; -- version number 928 * const uint_t sendsz; -- buffer recv size 929 * const uint_t recvsz; -- buffer send size 930 */ 931 #else 932 extern CLIENT * clnt_dg_create(); 933 #endif 934 935 /* 936 * Memory based rpc (for speed check and testing) 937 * CLIENT * 938 * clnt_raw_create(prog, vers) 939 * const rpcprog_t prog; -- program number 940 * const rpcvers_t vers; -- version number 941 */ 942 #ifdef __STDC__ 943 extern CLIENT *clnt_raw_create(const rpcprog_t, const rpcvers_t); 944 #else 945 extern CLIENT *clnt_raw_create(); 946 #endif 947 948 /* 949 * Client creation routine over doors transport. 950 */ 951 #ifdef __STDC__ 952 extern CLIENT * clnt_door_create(const rpcprog_t, const rpcvers_t, 953 const uint_t); 954 /* 955 * const rpcprog_t prog; -- program number 956 * const rpcvers_t vers; -- version number 957 * const uint_t sendsz; -- max send size 958 */ 959 #else 960 extern CLIENT * clnt_door_create(); 961 #endif 962 963 /* 964 * internal function. Not for general use. Subject to rapid change. 965 */ 966 #ifdef __STDC__ 967 extern CLIENT *clnt_create_service_timed(const char *, 968 const char *, 969 const rpcprog_t, 970 const rpcvers_t, 971 const ushort_t, 972 const char *, 973 const struct timeval *); 974 #else 975 extern CLIENT *clnt_create_service_timed(); 976 #endif 977 978 /* 979 * Print why creation failed 980 */ 981 #ifdef __STDC__ 982 void clnt_pcreateerror(const char *); /* stderr */ 983 char *clnt_spcreateerror(const char *); /* string */ 984 #else 985 void clnt_pcreateerror(); 986 char *clnt_spcreateerror(); 987 #endif 988 989 /* 990 * Like clnt_perror(), but is more verbose in its output 991 */ 992 #ifdef __STDC__ 993 void clnt_perrno(const enum clnt_stat); /* stderr */ 994 #else 995 void clnt_perrno(); 996 #endif 997 998 /* 999 * Print an error message, given the client error code 1000 */ 1001 #ifdef __STDC__ 1002 void clnt_perror(const CLIENT *, const char *); 1003 #else 1004 void clnt_perror(); 1005 #endif 1006 1007 /* 1008 * If a creation fails, the following allows the user to figure out why. 1009 */ 1010 struct rpc_createerr { 1011 enum clnt_stat cf_stat; 1012 struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ 1013 }; 1014 1015 #ifdef _REENTRANT 1016 extern struct rpc_createerr *__rpc_createerr(); 1017 #define rpc_createerr (*(__rpc_createerr())) 1018 #else 1019 extern struct rpc_createerr rpc_createerr; 1020 #endif /* _REENTRANT */ 1021 1022 /* 1023 * The simplified interface: 1024 * enum clnt_stat 1025 * rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype) 1026 * const char *host; 1027 * const rpcprog_t prognum; 1028 * const rpcvers_t versnum; 1029 * const rpcproc_t procnum; 1030 * const xdrproc_t inproc, outproc; 1031 * const char *in; 1032 * char *out; 1033 * const char *nettype; 1034 */ 1035 #ifdef __STDC__ 1036 extern enum clnt_stat rpc_call(const char *, const rpcprog_t, const rpcvers_t, 1037 const rpcproc_t, const xdrproc_t, const char *, const xdrproc_t, 1038 char *, const char *); 1039 #else 1040 extern enum clnt_stat rpc_call(); 1041 #endif 1042 1043 #ifdef _REENTRANT 1044 extern struct rpc_err *__rpc_callerr(); 1045 #define rpc_callerr (*(__rpc_callerr())) 1046 #else 1047 extern struct rpc_err rpc_callerr; 1048 #endif /* _REENTRANT */ 1049 1050 /* 1051 * RPC broadcast interface 1052 * The call is broadcasted to all locally connected nets. 1053 * 1054 * extern enum clnt_stat 1055 * rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, 1056 * eachresult, nettype) 1057 * const rpcprog_t prog; -- program number 1058 * const rpcvers_t vers; -- version number 1059 * const rpcproc_t proc; -- procedure number 1060 * const xdrproc_t xargs; -- xdr routine for args 1061 * caddr_t argsp; -- pointer to args 1062 * const xdrproc_t xresults; -- xdr routine for results 1063 * caddr_t resultsp; -- pointer to results 1064 * const resultproc_t eachresult; -- call with each result 1065 * const char *nettype; -- Transport type 1066 * 1067 * For each valid response received, the procedure eachresult is called. 1068 * Its form is: 1069 * done = eachresult(resp, raddr, nconf) 1070 * bool_t done; 1071 * caddr_t resp; 1072 * struct netbuf *raddr; 1073 * struct netconfig *nconf; 1074 * where resp points to the results of the call and raddr is the 1075 * address if the responder to the broadcast. nconf is the transport 1076 * on which the response was received. 1077 * 1078 * extern enum clnt_stat 1079 * rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, 1080 * eachresult, inittime, waittime, nettype) 1081 * const rpcprog_t prog; -- program number 1082 * const rpcvers_t vers; -- version number 1083 * const rpcproc_t proc; -- procedure number 1084 * const xdrproc_t xargs; -- xdr routine for args 1085 * caddr_t argsp; -- pointer to args 1086 * const xdrproc_t xresults; -- xdr routine for results 1087 * caddr_t resultsp; -- pointer to results 1088 * const resultproc_t eachresult; -- call with each result 1089 * const int inittime; -- how long to wait initially 1090 * const int waittime; -- maximum time to wait 1091 * const char *nettype; -- Transport type 1092 */ 1093 1094 typedef bool_t(*resultproc_t)( 1095 #ifdef __STDC__ 1096 caddr_t, 1097 ... /* for backward compatibility */ 1098 #endif /* __STDC__ */ 1099 ); 1100 #ifdef __STDC__ 1101 extern enum clnt_stat rpc_broadcast(const rpcprog_t, const rpcvers_t, 1102 const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t, 1103 caddr_t, const resultproc_t, const char *); 1104 extern enum clnt_stat rpc_broadcast_exp(const rpcprog_t, const rpcvers_t, 1105 const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t, caddr_t, 1106 const resultproc_t, const int, const int, const char *); 1107 #else 1108 extern enum clnt_stat rpc_broadcast(); 1109 extern enum clnt_stat rpc_broadcast_exp(); 1110 #endif 1111 #endif /* !_KERNEL */ 1112 1113 /* 1114 * Copy error message to buffer. 1115 */ 1116 #ifdef __STDC__ 1117 const char *clnt_sperrno(const enum clnt_stat); 1118 #else 1119 char *clnt_sperrno(); /* string */ 1120 #endif 1121 1122 /* 1123 * Print an error message, given the client error code 1124 */ 1125 #ifdef __STDC__ 1126 char *clnt_sperror(const CLIENT *, const char *); 1127 #else 1128 char *clnt_sperror(); 1129 #endif 1130 1131 /* 1132 * Client side rpc control routine for rpcbind. 1133 */ 1134 #ifdef __STDC__ 1135 bool_t __rpc_control(int, void *); 1136 #else 1137 bool_t __rpc_control(); 1138 #endif 1139 1140 #ifdef __cplusplus 1141 } 1142 #endif 1143 1144 #ifdef PORTMAP 1145 /* For backward compatibility */ 1146 #include <rpc/clnt_soc.h> 1147 #endif 1148 1149 #endif /* !_RPC_CLNT_H */ 1150