| 1 |
.\" @(#)rpc.3n 2.4 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI |
| 2 |
.\" $NetBSD: rpc_soc.3,v 1.2 2000/06/07 13:39:43 simonb Exp $ |
| 3 |
.\" $FreeBSD: src/lib/libc/rpc/rpc_soc.3,v 1.12 2003/02/06 11:04:47 charnier Exp $ |
| 4 |
.\" |
| 5 |
.Dd February 16, 1988 |
| 6 |
.Dt RPC_SOC 3 |
| 7 |
.Os |
| 8 |
.Sh NAME |
| 9 |
.Nm rpc_soc , |
| 10 |
.Nm auth_destroy , |
| 11 |
.Nm authnone_create , |
| 12 |
.Nm authunix_create , |
| 13 |
.Nm authunix_create_default , |
| 14 |
.Nm callrpc , |
| 15 |
.Nm clnt_broadcast , |
| 16 |
.Nm clnt_call , |
| 17 |
.Nm clnt_control , |
| 18 |
.Nm clnt_create , |
| 19 |
.Nm clnt_destroy , |
| 20 |
.Nm clnt_freeres , |
| 21 |
.Nm clnt_geterr , |
| 22 |
.Nm clnt_pcreateerror , |
| 23 |
.Nm clnt_perrno , |
| 24 |
.Nm clnt_perror , |
| 25 |
.Nm clnt_spcreateerror , |
| 26 |
.Nm clnt_sperrno , |
| 27 |
.Nm clnt_sperror , |
| 28 |
.Nm clntraw_create , |
| 29 |
.Nm clnttcp_create , |
| 30 |
.Nm clntudp_bufcreate , |
| 31 |
.Nm clntudp_create , |
| 32 |
.Nm clntunix_create , |
| 33 |
.Nm get_myaddress , |
| 34 |
.Nm pmap_getmaps , |
| 35 |
.Nm pmap_getport , |
| 36 |
.Nm pmap_rmtcall , |
| 37 |
.Nm pmap_set , |
| 38 |
.Nm pmap_unset , |
| 39 |
.Nm registerrpc , |
| 40 |
.Nm rpc_createerr , |
| 41 |
.Nm svc_destroy , |
| 42 |
.Nm svc_fds , |
| 43 |
.Nm svc_fdset , |
| 44 |
.Nm svc_getargs , |
| 45 |
.Nm svc_getcaller , |
| 46 |
.Nm svc_getreq , |
| 47 |
.Nm svc_getreqset , |
| 48 |
.Nm svc_register , |
| 49 |
.Nm svc_run , |
| 50 |
.Nm svc_sendreply , |
| 51 |
.Nm svc_unregister , |
| 52 |
.Nm svcerr_auth , |
| 53 |
.Nm svcerr_decode , |
| 54 |
.Nm svcerr_noproc , |
| 55 |
.Nm svcerr_noprog , |
| 56 |
.Nm svcerr_progvers , |
| 57 |
.Nm svcerr_systemerr , |
| 58 |
.Nm svcerr_weakauth , |
| 59 |
.Nm svcfd_create , |
| 60 |
.Nm svcunixfd_create , |
| 61 |
.Nm svcraw_create , |
| 62 |
.Nm svcunix_create , |
| 63 |
.Nm xdr_accepted_reply , |
| 64 |
.Nm xdr_authunix_parms , |
| 65 |
.Nm xdr_callhdr , |
| 66 |
.Nm xdr_callmsg , |
| 67 |
.Nm xdr_opaque_auth , |
| 68 |
.Nm xdr_pmap , |
| 69 |
.Nm xdr_pmaplist , |
| 70 |
.Nm xdr_rejected_reply , |
| 71 |
.Nm xdr_replymsg , |
| 72 |
.Nm xprt_register , |
| 73 |
.Nm xprt_unregister |
| 74 |
.Nd "library routines for remote procedure calls" |
| 75 |
.Sh SYNOPSIS |
| 76 |
.In rpc/rpc.h |
| 77 |
.Pp |
| 78 |
See |
| 79 |
.Sx DESCRIPTION |
| 80 |
for function declarations. |
| 81 |
.Sh DESCRIPTION |
| 82 |
.Bf -symbolic |
| 83 |
The |
| 84 |
.Fn svc_* |
| 85 |
and |
| 86 |
.Fn clnt_* |
| 87 |
functions described in this page are the old, TS-RPC |
| 88 |
interface to the XDR and RPC library, and exist for backward compatibility. |
| 89 |
The new interface is described in the pages |
| 90 |
referenced from |
| 91 |
.Xr rpc 3 . |
| 92 |
.Ef |
| 93 |
.Pp |
| 94 |
These routines allow C programs to make procedure |
| 95 |
calls on other machines across the network. |
| 96 |
First, the client calls a procedure to send a |
| 97 |
data packet to the server. |
| 98 |
Upon receipt of the packet, the server calls a dispatch routine |
| 99 |
to perform the requested service, and then sends back a |
| 100 |
reply. |
| 101 |
Finally, the procedure call returns to the client. |
| 102 |
.Pp |
| 103 |
Routines that are used for Secure |
| 104 |
.Tn RPC ( DES |
| 105 |
authentication) are described in |
| 106 |
.Xr rpc_secure 3 . |
| 107 |
Secure |
| 108 |
.Tn RPC |
| 109 |
can be used only if |
| 110 |
.Tn DES |
| 111 |
encryption is available. |
| 112 |
.Bl -tag -width indent -compact |
| 113 |
.Pp |
| 114 |
.It Xo |
| 115 |
.Ft void |
| 116 |
.Xc |
| 117 |
.It Xo |
| 118 |
.Fn auth_destroy "AUTH *auth" |
| 119 |
.Xc |
| 120 |
.Pp |
| 121 |
A macro that destroys the authentication information associated with |
| 122 |
.Fa auth . |
| 123 |
Destruction usually involves deallocation of private data |
| 124 |
structures. |
| 125 |
The use of |
| 126 |
.Fa auth |
| 127 |
is undefined after calling |
| 128 |
.Fn auth_destroy . |
| 129 |
.Pp |
| 130 |
.It Xo |
| 131 |
.Ft "AUTH *" |
| 132 |
.Xc |
| 133 |
.It Xo |
| 134 |
.Fn authnone_create |
| 135 |
.Xc |
| 136 |
.Pp |
| 137 |
Create and return an |
| 138 |
.Tn RPC |
| 139 |
authentication handle that passes nonusable authentication |
| 140 |
information with each remote procedure call. |
| 141 |
This is the |
| 142 |
default authentication used by |
| 143 |
.Tn RPC . |
| 144 |
.Pp |
| 145 |
.It Xo |
| 146 |
.Ft "AUTH *" |
| 147 |
.Xc |
| 148 |
.It Xo |
| 149 |
.Fn authunix_create "char *host" "int uid" "int gid" "int len" "int *aup_gids" |
| 150 |
.Xc |
| 151 |
.Pp |
| 152 |
Create and return an |
| 153 |
.Tn RPC |
| 154 |
authentication handle that contains |
| 155 |
.Ux |
| 156 |
authentication information. |
| 157 |
The |
| 158 |
.Fa host |
| 159 |
argument |
| 160 |
is the name of the machine on which the information was |
| 161 |
created; |
| 162 |
.Fa uid |
| 163 |
is the user's user ID; |
| 164 |
.Fa gid |
| 165 |
is the user's current group ID; |
| 166 |
.Fa len |
| 167 |
and |
| 168 |
.Fa aup_gids |
| 169 |
refer to a counted array of groups to which the user belongs. |
| 170 |
It is easy to impersonate a user. |
| 171 |
.Pp |
| 172 |
.It Xo |
| 173 |
.Ft "AUTH *" |
| 174 |
.Xc |
| 175 |
.It Xo |
| 176 |
.Fn authunix_create_default |
| 177 |
.Xc |
| 178 |
.Pp |
| 179 |
Calls |
| 180 |
.Fn authunix_create |
| 181 |
with the appropriate arguments. |
| 182 |
.Pp |
| 183 |
.It Xo |
| 184 |
.Ft int |
| 185 |
.Fo callrpc |
| 186 |
.Fa "char *host" |
| 187 |
.Fa "u_long prognum" |
| 188 |
.Fa "u_long versnum" |
| 189 |
.Fa "u_long procnum" |
| 190 |
.Fa "xdrproc_t inproc" |
| 191 |
.Fa "void *in" |
| 192 |
.Fa "xdrproc_t outproc" |
| 193 |
.Fa "void *out" |
| 194 |
.Fc |
| 195 |
.Xc |
| 196 |
.Pp |
| 197 |
Call the remote procedure associated with |
| 198 |
.Fa prognum , |
| 199 |
.Fa versnum , |
| 200 |
and |
| 201 |
.Fa procnum |
| 202 |
on the machine |
| 203 |
.Fa host . |
| 204 |
The |
| 205 |
.Fa in |
| 206 |
argument |
| 207 |
is the address of the procedure's argument(s), and |
| 208 |
.Fa out |
| 209 |
is the address of where to place the result(s); |
| 210 |
.Fa inproc |
| 211 |
is used to encode the procedure's arguments, and |
| 212 |
.Fa outproc |
| 213 |
is used to decode the procedure's results. |
| 214 |
This routine returns zero if it succeeds, or the value of |
| 215 |
.Vt "enum clnt_stat" |
| 216 |
cast to an integer if it fails. |
| 217 |
The routine |
| 218 |
.Fn clnt_perrno |
| 219 |
is handy for translating failure statuses into messages. |
| 220 |
.Pp |
| 221 |
Warning: calling remote procedures with this routine |
| 222 |
uses |
| 223 |
.Tn UDP/IP |
| 224 |
as a transport; see |
| 225 |
.Fn clntudp_create |
| 226 |
for restrictions. |
| 227 |
You do not have control of timeouts or authentication using |
| 228 |
this routine. |
| 229 |
.Pp |
| 230 |
.It Xo |
| 231 |
.Ft "enum clnt_stat" |
| 232 |
.Xc |
| 233 |
.It Xo |
| 234 |
.Fo clnt_broadcast |
| 235 |
.Fa "u_long prognum" |
| 236 |
.Fa "u_long versnum" |
| 237 |
.Fa "u_long procnum" |
| 238 |
.Fa "xdrproc_t inproc" |
| 239 |
.Fa "char *in" |
| 240 |
.Fa "xdrproc_t outproc" |
| 241 |
.Fa "char *out" |
| 242 |
.Fa "bool_t (*eachresult)(caddr_t, struct sockaddr_in *)" |
| 243 |
.Fc |
| 244 |
.Xc |
| 245 |
.Pp |
| 246 |
Like |
| 247 |
.Fn callrpc , |
| 248 |
except the call message is broadcast to all locally |
| 249 |
connected broadcast nets. |
| 250 |
Each time it receives a |
| 251 |
response, this routine calls |
| 252 |
.Fn eachresult , |
| 253 |
whose form is: |
| 254 |
.Bd -ragged -offset indent |
| 255 |
.Ft bool_t |
| 256 |
.Fn eachresult "caddr_t out" "struct sockaddr_in *addr" |
| 257 |
.Ed |
| 258 |
.Pp |
| 259 |
where |
| 260 |
.Fa out |
| 261 |
is the same as |
| 262 |
.Fa out |
| 263 |
passed to |
| 264 |
.Fn clnt_broadcast , |
| 265 |
except that the remote procedure's output is decoded there; |
| 266 |
.Fa addr |
| 267 |
points to the address of the machine that sent the results. |
| 268 |
If |
| 269 |
.Fn eachresult |
| 270 |
returns zero, |
| 271 |
.Fn clnt_broadcast |
| 272 |
waits for more replies; otherwise it returns with appropriate |
| 273 |
status. |
| 274 |
.Pp |
| 275 |
Warning: broadcast sockets are limited in size to the |
| 276 |
maximum transfer unit of the data link. |
| 277 |
For ethernet, |
| 278 |
this value is 1500 bytes. |
| 279 |
.Pp |
| 280 |
.It Xo |
| 281 |
.Ft "enum clnt_stat" |
| 282 |
.Xc |
| 283 |
.It Xo |
| 284 |
.Fo clnt_call |
| 285 |
.Fa "CLIENT *clnt" |
| 286 |
.Fa "u_long procnum" |
| 287 |
.Fa "xdrproc_t inproc" |
| 288 |
.Fa "char *in" |
| 289 |
.Fa "xdrproc_t outproc" |
| 290 |
.Fa "char *out" |
| 291 |
.Fa "struct timeval tout" |
| 292 |
.Fc |
| 293 |
.Xc |
| 294 |
.Pp |
| 295 |
A macro that calls the remote procedure |
| 296 |
.Fa procnum |
| 297 |
associated with the client handle, |
| 298 |
.Fa clnt , |
| 299 |
which is obtained with an |
| 300 |
.Tn RPC |
| 301 |
client creation routine such as |
| 302 |
.Fn clnt_create . |
| 303 |
The |
| 304 |
.Fa in |
| 305 |
argument |
| 306 |
is the address of the procedure's argument(s), and |
| 307 |
.Fa out |
| 308 |
is the address of where to place the result(s); |
| 309 |
.Fa inproc |
| 310 |
is used to encode the procedure's arguments, and |
| 311 |
.Fa outproc |
| 312 |
is used to decode the procedure's results; |
| 313 |
.Fa tout |
| 314 |
is the time allowed for results to come back. |
| 315 |
.Pp |
| 316 |
.It Xo |
| 317 |
.Ft void |
| 318 |
.Fn clnt_destroy "CLIENT *clnt" |
| 319 |
.Xc |
| 320 |
.Pp |
| 321 |
A macro that destroys the client's |
| 322 |
.Tn RPC |
| 323 |
handle. |
| 324 |
Destruction usually involves deallocation |
| 325 |
of private data structures, including |
| 326 |
.Fa clnt |
| 327 |
itself. |
| 328 |
Use of |
| 329 |
.Fa clnt |
| 330 |
is undefined after calling |
| 331 |
.Fn clnt_destroy . |
| 332 |
If the |
| 333 |
.Tn RPC |
| 334 |
library opened the associated socket, it will close it also. |
| 335 |
Otherwise, the socket remains open. |
| 336 |
.Pp |
| 337 |
.It Xo |
| 338 |
.Ft CLIENT * |
| 339 |
.Xc |
| 340 |
.It Xo |
| 341 |
.Fn clnt_create "char *host" "u_long prog" "u_long vers" "char *proto" |
| 342 |
.Xc |
| 343 |
.Pp |
| 344 |
Generic client creation routine. |
| 345 |
The |
| 346 |
.Fa host |
| 347 |
argument |
| 348 |
identifies the name of the remote host where the server |
| 349 |
is located. |
| 350 |
The |
| 351 |
.Fa proto |
| 352 |
argument |
| 353 |
indicates which kind of transport protocol to use. |
| 354 |
The |
| 355 |
currently supported values for this field are |
| 356 |
.Qq Li udp |
| 357 |
and |
| 358 |
.Qq Li tcp . |
| 359 |
Default timeouts are set, but can be modified using |
| 360 |
.Fn clnt_control . |
| 361 |
.Pp |
| 362 |
Warning: Using |
| 363 |
.Tn UDP |
| 364 |
has its shortcomings. |
| 365 |
Since |
| 366 |
.Tn UDP Ns \-based |
| 367 |
.Tn RPC |
| 368 |
messages can only hold up to 8 Kbytes of encoded data, |
| 369 |
this transport cannot be used for procedures that take |
| 370 |
large arguments or return huge results. |
| 371 |
.Pp |
| 372 |
.It Xo |
| 373 |
.Ft bool_t |
| 374 |
.Xc |
| 375 |
.It Xo |
| 376 |
.Fn clnt_control "CLIENT *cl" "u_int req" "char *info" |
| 377 |
.Xc |
| 378 |
.Pp |
| 379 |
A macro used to change or retrieve various information |
| 380 |
about a client object. |
| 381 |
The |
| 382 |
.Fa req |
| 383 |
argument |
| 384 |
indicates the type of operation, and |
| 385 |
.Fa info |
| 386 |
is a pointer to the information. |
| 387 |
For both |
| 388 |
.Tn UDP |
| 389 |
and |
| 390 |
.Tn TCP , |
| 391 |
the supported values of |
| 392 |
.Fa req |
| 393 |
and their argument types and what they do are: |
| 394 |
.Bl -column "CLSET_RETRY_TIMEOUT" "struct sockaddr_in" |
| 395 |
.It Dv CLSET_TIMEOUT Ta Xo |
| 396 |
.Vt "struct timeval" Ta "set total timeout" |
| 397 |
.Xc |
| 398 |
.It Dv CLGET_TIMEOUT Ta Xo |
| 399 |
.Vt "struct timeval" Ta "get total timeout" |
| 400 |
.Xc |
| 401 |
.El |
| 402 |
.Pp |
| 403 |
Note: if you set the timeout using |
| 404 |
.Fn clnt_control , |
| 405 |
the timeout argument passed to |
| 406 |
.Fn clnt_call |
| 407 |
will be ignored in all future calls. |
| 408 |
.Bl -column "CLSET_RETRY_TIMEOUT" "struct sockaddr_in" |
| 409 |
.It Dv CLGET_SERVER_ADDR Ta Xo |
| 410 |
.Vt "struct sockaddr_in" Ta "get server's address" |
| 411 |
.Xc |
| 412 |
.El |
| 413 |
.Pp |
| 414 |
The following operations are valid for |
| 415 |
.Tn UDP |
| 416 |
only: |
| 417 |
.Bl -column "CLSET_RETRY_TIMEOUT" "struct sockaddr_in" |
| 418 |
.It Dv CLSET_RETRY_TIMEOUT Ta Xo |
| 419 |
.Vt "struct timeval" Ta "set the retry timeout" |
| 420 |
.Xc |
| 421 |
.It Dv CLGET_RETRY_TIMEOUT Ta Xo |
| 422 |
.Vt "struct timeval" Ta "get the retry timeout" |
| 423 |
.Xc |
| 424 |
.El |
| 425 |
.Pp |
| 426 |
The retry timeout is the time that |
| 427 |
.Tn "UDP RPC" |
| 428 |
waits for the server to reply before |
| 429 |
retransmitting the request. |
| 430 |
.Pp |
| 431 |
.It Xo |
| 432 |
.Ft bool_t |
| 433 |
.Fn clnt_freeres "CLIENT *clnt" "xdrproc_t outproc" "char *out" |
| 434 |
.Xc |
| 435 |
.Pp |
| 436 |
A macro that frees any data allocated by the |
| 437 |
.Tn RPC/XDR |
| 438 |
system when it decoded the results of an |
| 439 |
.Tn RPC |
| 440 |
call. |
| 441 |
The |
| 442 |
.Fa out |
| 443 |
argument |
| 444 |
is the address of the results, and |
| 445 |
.Fa outproc |
| 446 |
is the |
| 447 |
.Tn XDR |
| 448 |
routine describing the results. |
| 449 |
This routine returns one if the results were successfully |
| 450 |
freed, |
| 451 |
and zero otherwise. |
| 452 |
.Pp |
| 453 |
.It Xo |
| 454 |
.Ft void |
| 455 |
.Xc |
| 456 |
.It Xo |
| 457 |
.Fn clnt_geterr "CLIENT *clnt" "struct rpc_err *errp" |
| 458 |
.Xc |
| 459 |
.Pp |
| 460 |
A macro that copies the error structure out of the client |
| 461 |
handle |
| 462 |
to the structure at address |
| 463 |
.Fa errp . |
| 464 |
.Pp |
| 465 |
.It Xo |
| 466 |
.Ft void |
| 467 |
.Xc |
| 468 |
.It Xo |
| 469 |
.Fn clnt_pcreateerror "char *s" |
| 470 |
.Xc |
| 471 |
.Pp |
| 472 |
prints a message to standard error indicating |
| 473 |
why a client |
| 474 |
.Tn RPC |
| 475 |
handle could not be created. |
| 476 |
The message is prepended with string |
| 477 |
.Fa s |
| 478 |
and a colon. |
| 479 |
A newline is appended at the end of the message. |
| 480 |
Used when a |
| 481 |
.Fn clnt_create , |
| 482 |
.Fn clntraw_create , |
| 483 |
.Fn clnttcp_create , |
| 484 |
or |
| 485 |
.Fn clntudp_create |
| 486 |
call fails. |
| 487 |
.Pp |
| 488 |
.It Xo |
| 489 |
.Ft void |
| 490 |
.Xc |
| 491 |
.It Xo |
| 492 |
.Fn clnt_perrno "enum clnt_stat stat" |
| 493 |
.Xc |
| 494 |
.Pp |
| 495 |
Print a message to standard error corresponding |
| 496 |
to the condition indicated by |
| 497 |
.Fa stat . |
| 498 |
A newline is appended at the end of the message. |
| 499 |
Used after |
| 500 |
.Fn callrpc . |
| 501 |
.Pp |
| 502 |
.It Xo |
| 503 |
.Ft void |
| 504 |
.Fn clnt_perror "CLIENT *clnt" "char *s" |
| 505 |
.Xc |
| 506 |
.Pp |
| 507 |
Print a message to standard error indicating why an |
| 508 |
.Tn RPC |
| 509 |
call failed; |
| 510 |
.Fa clnt |
| 511 |
is the handle used to do the call. |
| 512 |
The message is prepended with string |
| 513 |
.Fa s |
| 514 |
and a colon. |
| 515 |
A newline is appended at the end of the message. |
| 516 |
Used after |
| 517 |
.Fn clnt_call . |
| 518 |
.Pp |
| 519 |
.It Xo |
| 520 |
.Ft "char *" |
| 521 |
.Xc |
| 522 |
.It Xo |
| 523 |
.Fn clnt_spcreateerror "char *s" |
| 524 |
.Xc |
| 525 |
.Pp |
| 526 |
Like |
| 527 |
.Fn clnt_pcreateerror , |
| 528 |
except that it returns a string |
| 529 |
instead of printing to the standard error. |
| 530 |
.Pp |
| 531 |
Bugs: returns pointer to static data that is overwritten |
| 532 |
on each call. |
| 533 |
.Pp |
| 534 |
.It Xo |
| 535 |
.Ft "char *" |
| 536 |
.Xc |
| 537 |
.It Xo |
| 538 |
.Fn clnt_sperrno "enum clnt_stat stat" |
| 539 |
.Xc |
| 540 |
.Pp |
| 541 |
Take the same arguments as |
| 542 |
.Fn clnt_perrno , |
| 543 |
but instead of sending a message to the standard error |
| 544 |
indicating why an |
| 545 |
.Tn RPC |
| 546 |
call failed, return a pointer to a string which contains |
| 547 |
the message. |
| 548 |
.Pp |
| 549 |
The |
| 550 |
.Fn clnt_sperrno |
| 551 |
function |
| 552 |
is used instead of |
| 553 |
.Fn clnt_perrno |
| 554 |
if the program does not have a standard error (as a program |
| 555 |
running as a server quite likely does not), or if the |
| 556 |
programmer |
| 557 |
does not want the message to be output with |
| 558 |
.Fn printf , |
| 559 |
or if a message format different from that supported by |
| 560 |
.Fn clnt_perrno |
| 561 |
is to be used. |
| 562 |
.Pp |
| 563 |
Note: unlike |
| 564 |
.Fn clnt_sperror |
| 565 |
and |
| 566 |
.Fn clnt_spcreateerror , |
| 567 |
.Fn clnt_sperrno |
| 568 |
returns pointer to static data, but the |
| 569 |
result will not get overwritten on each call. |
| 570 |
.Pp |
| 571 |
.It Xo |
| 572 |
.Ft "char *" |
| 573 |
.Xc |
| 574 |
.It Xo |
| 575 |
.Fn clnt_sperror "CLIENT *rpch" "char *s" |
| 576 |
.Xc |
| 577 |
.Pp |
| 578 |
Like |
| 579 |
.Fn clnt_perror , |
| 580 |
except that (like |
| 581 |
.Fn clnt_sperrno ) |
| 582 |
it returns a string instead of printing to standard error. |
| 583 |
.Pp |
| 584 |
Bugs: returns pointer to static data that is overwritten |
| 585 |
on each call. |
| 586 |
.Pp |
| 587 |
.It Xo |
| 588 |
.Ft "CLIENT *" |
| 589 |
.Xc |
| 590 |
.It Xo |
| 591 |
.Fn clntraw_create "u_long prognum" "u_long versnum" |
| 592 |
.Xc |
| 593 |
.Pp |
| 594 |
This routine creates a toy |
| 595 |
.Tn RPC |
| 596 |
client for the remote program |
| 597 |
.Fa prognum , |
| 598 |
version |
| 599 |
.Fa versnum . |
| 600 |
The transport used to pass messages to the service is |
| 601 |
actually a buffer within the process's address space, so the |
| 602 |
corresponding |
| 603 |
.Tn RPC |
| 604 |
server should live in the same address space; see |
| 605 |
.Fn svcraw_create . |
| 606 |
This allows simulation of |
| 607 |
.Tn RPC |
| 608 |
and acquisition of |
| 609 |
.Tn RPC |
| 610 |
overheads, such as round trip times, without any |
| 611 |
kernel interference. |
| 612 |
This routine returns |
| 613 |
.Dv NULL |
| 614 |
if it fails. |
| 615 |
.Pp |
| 616 |
.It Xo |
| 617 |
.Ft "CLIENT *" |
| 618 |
.Xc |
| 619 |
.It Xo |
| 620 |
.Fo clnttcp_create |
| 621 |
.Fa "struct sockaddr_in *addr" |
| 622 |
.Fa "u_long prognum" |
| 623 |
.Fa "u_long versnum" |
| 624 |
.Fa "int *sockp" |
| 625 |
.Fa "u_int sendsz" |
| 626 |
.Fa "u_int recvsz" |
| 627 |
.Fc |
| 628 |
.Xc |
| 629 |
.Pp |
| 630 |
This routine creates an |
| 631 |
.Tn RPC |
| 632 |
client for the remote program |
| 633 |
.Fa prognum , |
| 634 |
version |
| 635 |
.Fa versnum ; |
| 636 |
the client uses |
| 637 |
.Tn TCP/IP |
| 638 |
as a transport. |
| 639 |
The remote program is located at Internet |
| 640 |
address |
| 641 |
.Fa addr . |
| 642 |
If |
| 643 |
.Fa addr\->sin_port |
| 644 |
is zero, then it is set to the actual port that the remote |
| 645 |
program is listening on (the remote |
| 646 |
.Xr rpcbind 8 |
| 647 |
service is consulted for this information). |
| 648 |
The |
| 649 |
.Fa sockp |
| 650 |
argument |
| 651 |
is a socket; if it is |
| 652 |
.Dv RPC_ANYSOCK , |
| 653 |
then this routine opens a new one and sets |
| 654 |
.Fa sockp . |
| 655 |
Since |
| 656 |
.Tn TCP Ns \-based |
| 657 |
.Tn RPC |
| 658 |
uses buffered |
| 659 |
.Tn I/O , |
| 660 |
the user may specify the size of the send and receive buffers |
| 661 |
with the |
| 662 |
.Fa sendsz |
| 663 |
and |
| 664 |
.Fa recvsz |
| 665 |
arguments; |
| 666 |
values of zero choose suitable defaults. |
| 667 |
This routine returns |
| 668 |
.Dv NULL |
| 669 |
if it fails. |
| 670 |
.Pp |
| 671 |
.It Xo |
| 672 |
.Ft "CLIENT *" |
| 673 |
.Xc |
| 674 |
.It Xo |
| 675 |
.Fo clntudp_create |
| 676 |
.Fa "struct sockaddr_in *addr" |
| 677 |
.Fa "u_long prognum" |
| 678 |
.Fa "u_long versnum" |
| 679 |
.Fa "struct timeval wait" |
| 680 |
.Fa "int *sockp" |
| 681 |
.Fc |
| 682 |
.Xc |
| 683 |
.Pp |
| 684 |
This routine creates an |
| 685 |
.Tn RPC |
| 686 |
client for the remote program |
| 687 |
.Fa prognum , |
| 688 |
version |
| 689 |
.Fa versnum ; |
| 690 |
the client uses |
| 691 |
.Tn UDP/IP |
| 692 |
as a transport. |
| 693 |
The remote program is located at Internet |
| 694 |
address |
| 695 |
.Fa addr . |
| 696 |
If |
| 697 |
.Fa addr\->sin_port |
| 698 |
is zero, then it is set to actual port that the remote |
| 699 |
program is listening on (the remote |
| 700 |
.Xr rpcbind 8 |
| 701 |
service is consulted for this information). |
| 702 |
The |
| 703 |
.Fa sockp |
| 704 |
argument |
| 705 |
is a socket; if it is |
| 706 |
.Dv RPC_ANYSOCK , |
| 707 |
then this routine opens a new one and sets |
| 708 |
.Fa sockp . |
| 709 |
The |
| 710 |
.Tn UDP |
| 711 |
transport resends the call message in intervals of |
| 712 |
.Fa wait |
| 713 |
time until a response is received or until the call times |
| 714 |
out. |
| 715 |
The total time for the call to time out is specified by |
| 716 |
.Fn clnt_call . |
| 717 |
.Pp |
| 718 |
Warning: since |
| 719 |
.Tn UDP Ns \-based |
| 720 |
.Tn RPC |
| 721 |
messages can only hold up to 8 Kbytes |
| 722 |
of encoded data, this transport cannot be used for procedures |
| 723 |
that take large arguments or return huge results. |
| 724 |
.Pp |
| 725 |
.It Xo |
| 726 |
.Ft "CLIENT *" |
| 727 |
.Xc |
| 728 |
.It Xo |
| 729 |
.Fo clntudp_bufcreate |
| 730 |
.Fa "struct sockaddr_in *addr" |
| 731 |
.Fa "u_long prognum" |
| 732 |
.Fa "u_long versnum" |
| 733 |
.Fa "struct timeval wait" |
| 734 |
.Fa "int *sockp" |
| 735 |
.Fa "unsigned int sendsize" |
| 736 |
.Fa "unsigned int recosize" |
| 737 |
.Fc |
| 738 |
.Xc |
| 739 |
.Pp |
| 740 |
This routine creates an |
| 741 |
.Tn RPC |
| 742 |
client for the remote program |
| 743 |
.Fa prognum , |
| 744 |
on |
| 745 |
.Fa versnum ; |
| 746 |
the client uses |
| 747 |
.Tn UDP/IP |
| 748 |
as a transport. |
| 749 |
The remote program is located at Internet |
| 750 |
address |
| 751 |
.Fa addr . |
| 752 |
If |
| 753 |
.Fa addr\->sin_port |
| 754 |
is zero, then it is set to actual port that the remote |
| 755 |
program is listening on (the remote |
| 756 |
.Xr rpcbind 8 |
| 757 |
service is consulted for this information). |
| 758 |
The |
| 759 |
.Fa sockp |
| 760 |
argument |
| 761 |
is a socket; if it is |
| 762 |
.Dv RPC_ANYSOCK , |
| 763 |
then this routine opens a new one and sets |
| 764 |
.Fa sockp . |
| 765 |
The |
| 766 |
.Tn UDP |
| 767 |
transport resends the call message in intervals of |
| 768 |
.Fa wait |
| 769 |
time until a response is received or until the call times |
| 770 |
out. |
| 771 |
The total time for the call to time out is specified by |
| 772 |
.Fn clnt_call . |
| 773 |
.Pp |
| 774 |
This allows the user to specify the maximum packet size |
| 775 |
for sending and receiving |
| 776 |
.Tn UDP Ns \-based |
| 777 |
.Tn RPC |
| 778 |
messages. |
| 779 |
.Pp |
| 780 |
.It Xo |
| 781 |
.Ft "CLIENT *" |
| 782 |
.Xc |
| 783 |
.It Xo |
| 784 |
.Fo clntunix_create |
| 785 |
.Fa "struct sockaddr_un *raddr" |
| 786 |
.Fa "u_long prognum" |
| 787 |
.Fa "u_long versnum" |
| 788 |
.Fa "int *sockp" |
| 789 |
.Fa "u_int sendsz" |
| 790 |
.Fa "u_int recvsz" |
| 791 |
.Fc |
| 792 |
.Xc |
| 793 |
.Pp |
| 794 |
This routine creates an |
| 795 |
.Tn RPC |
| 796 |
client for the local |
| 797 |
program |
| 798 |
.Fa prognum , |
| 799 |
version |
| 800 |
.Fa versnum ; |
| 801 |
the client uses |
| 802 |
.Ux Ns -domain |
| 803 |
sockets as a transport. |
| 804 |
The local program is located at the |
| 805 |
.Fa *raddr . |
| 806 |
The |
| 807 |
.Fa sockp |
| 808 |
argument |
| 809 |
is a socket; if it is |
| 810 |
.Dv RPC_ANYSOCK , |
| 811 |
then this routine opens a new one and sets |
| 812 |
.Fa sockp . |
| 813 |
Since |
| 814 |
.Ux Ns -based |
| 815 |
.Tn RPC |
| 816 |
uses buffered |
| 817 |
.Tn I/O , |
| 818 |
the user may specify the size of the send and receive buffers |
| 819 |
with the |
| 820 |
.Fa sendsz |
| 821 |
and |
| 822 |
.Fa recvsz |
| 823 |
arguments; |
| 824 |
values of zero choose suitable defaults. |
| 825 |
This routine returns |
| 826 |
.Dv NULL |
| 827 |
if it fails. |
| 828 |
.Pp |
| 829 |
.It Xo |
| 830 |
.Ft int |
| 831 |
.Xc |
| 832 |
.It Xo |
| 833 |
.Fn get_myaddress "struct sockaddr_in *addr" |
| 834 |
.Xc |
| 835 |
.Pp |
| 836 |
Stuff the machine's |
| 837 |
.Tn IP |
| 838 |
address into |
| 839 |
.Fa addr , |
| 840 |
without consulting the library routines that deal with |
| 841 |
.Pa /etc/hosts . |
| 842 |
The port number is always set to |
| 843 |
.Fn htons PMAPPORT . |
| 844 |
Returns zero on success, non-zero on failure. |
| 845 |
.Pp |
| 846 |
.It Xo |
| 847 |
.Ft "struct pmaplist *" |
| 848 |
.Xc |
| 849 |
.It Xo |
| 850 |
.Fn pmap_getmaps "struct sockaddr_in *addr" |
| 851 |
.Xc |
| 852 |
.Pp |
| 853 |
A user interface to the |
| 854 |
.Xr rpcbind 8 |
| 855 |
service, which returns a list of the current |
| 856 |
.Tn RPC |
| 857 |
program\-to\-port mappings |
| 858 |
on the host located at |
| 859 |
.Tn IP |
| 860 |
address |
| 861 |
.Fa addr . |
| 862 |
This routine can return |
| 863 |
.Dv NULL . |
| 864 |
The command |
| 865 |
.Dq Nm rpcinfo Fl p |
| 866 |
uses this routine. |
| 867 |
.Pp |
| 868 |
.It Xo |
| 869 |
.Ft u_short |
| 870 |
.Xc |
| 871 |
.It Xo |
| 872 |
.Fo pmap_getport |
| 873 |
.Fa "struct sockaddr_in *addr" |
| 874 |
.Fa "u_long prognum" |
| 875 |
.Fa "u_long versnum" |
| 876 |
.Fa "u_long protocol" |
| 877 |
.Fc |
| 878 |
.Xc |
| 879 |
.Pp |
| 880 |
A user interface to the |
| 881 |
.Xr rpcbind 8 |
| 882 |
service, which returns the port number |
| 883 |
on which waits a service that supports program number |
| 884 |
.Fa prognum , |
| 885 |
version |
| 886 |
.Fa versnum , |
| 887 |
and speaks the transport protocol associated with |
| 888 |
.Fa protocol . |
| 889 |
The value of |
| 890 |
.Fa protocol |
| 891 |
is most likely |
| 892 |
.Dv IPPROTO_UDP |
| 893 |
or |
| 894 |
.Dv IPPROTO_TCP . |
| 895 |
A return value of zero means that the mapping does not exist |
| 896 |
or that |
| 897 |
the |
| 898 |
.Tn RPC |
| 899 |
system failed to contact the remote |
| 900 |
.Xr rpcbind 8 |
| 901 |
service. |
| 902 |
In the latter case, the global variable |
| 903 |
.Va rpc_createerr |
| 904 |
contains the |
| 905 |
.Tn RPC |
| 906 |
status. |
| 907 |
.Pp |
| 908 |
.It Xo |
| 909 |
.Ft "enum clnt_stat" |
| 910 |
.Xc |
| 911 |
.It Xo |
| 912 |
.Fo pmap_rmtcall |
| 913 |
.Fa "struct sockaddr_in *addr" |
| 914 |
.Fa "u_long prognum" |
| 915 |
.Fa "u_long versnum" |
| 916 |
.Fa "u_long procnum" |
| 917 |
.Fa "xdrproc_t inproc" |
| 918 |
.Fa "char *in" |
| 919 |
.Fa "xdrproc_t outproc" |
| 920 |
.Fa "char *out" |
| 921 |
.Fa "struct timeval tout" |
| 922 |
.Fa "u_long *portp" |
| 923 |
.Fc |
| 924 |
.Xc |
| 925 |
.Pp |
| 926 |
A user interface to the |
| 927 |
.Xr rpcbind 8 |
| 928 |
service, which instructs |
| 929 |
.Xr rpcbind 8 |
| 930 |
on the host at |
| 931 |
.Tn IP |
| 932 |
address |
| 933 |
.Fa addr |
| 934 |
to make an |
| 935 |
.Tn RPC |
| 936 |
call on your behalf to a procedure on that host. |
| 937 |
The |
| 938 |
.Fa portp |
| 939 |
argument |
| 940 |
will be modified to the program's port number if the |
| 941 |
procedure |
| 942 |
succeeds. |
| 943 |
The definitions of other arguments are discussed |
| 944 |
in |
| 945 |
.Fn callrpc |
| 946 |
and |
| 947 |
.Fn clnt_call . |
| 948 |
This procedure should be used for a |
| 949 |
.Dq ping |
| 950 |
and nothing |
| 951 |
else. |
| 952 |
See also |
| 953 |
.Fn clnt_broadcast . |
| 954 |
.Pp |
| 955 |
.It Xo |
| 956 |
.Ft bool_t |
| 957 |
.Fn pmap_set "u_long prognum" "u_long versnum" "u_long protocol" "u_short port" |
| 958 |
.Xc |
| 959 |
.Pp |
| 960 |
A user interface to the |
| 961 |
.Xr rpcbind 8 |
| 962 |
service, which establishes a mapping between the triple |
| 963 |
.Pq Fa prognum , versnum , protocol |
| 964 |
and |
| 965 |
.Fa port |
| 966 |
on the machine's |
| 967 |
.Xr rpcbind 8 |
| 968 |
service. |
| 969 |
The value of |
| 970 |
.Fa protocol |
| 971 |
is most likely |
| 972 |
.Dv IPPROTO_UDP |
| 973 |
or |
| 974 |
.Dv IPPROTO_TCP . |
| 975 |
This routine returns one if it succeeds, zero otherwise. |
| 976 |
Automatically done by |
| 977 |
.Fn svc_register . |
| 978 |
.Pp |
| 979 |
.It Xo |
| 980 |
.Ft bool_t |
| 981 |
.Fn pmap_unset "u_long prognum" "u_long versnum" |
| 982 |
.Xc |
| 983 |
.Pp |
| 984 |
A user interface to the |
| 985 |
.Xr rpcbind 8 |
| 986 |
service, which destroys all mapping between the triple |
| 987 |
.Pq Fa prognum , versnum , * |
| 988 |
and |
| 989 |
.Fa ports |
| 990 |
on the machine's |
| 991 |
.Xr rpcbind 8 |
| 992 |
service. |
| 993 |
This routine returns one if it succeeds, zero |
| 994 |
otherwise. |
| 995 |
.Pp |
| 996 |
.It Xo |
| 997 |
.Ft bool_t |
| 998 |
.Fo registerrpc |
| 999 |
.Fa "u_long prognum" |
| 1000 |
.Fa "u_long versnum" |
| 1001 |
.Fa "u_long procnum" |
| 1002 |
.Fa "char *(*procname)(void)" |
| 1003 |
.Fa "xdrproc_t inproc" |
| 1004 |
.Fa "xdrproc_t outproc" |
| 1005 |
.Fc |
| 1006 |
.Xc |
| 1007 |
.Pp |
| 1008 |
Register procedure |
| 1009 |
.Fa procname |
| 1010 |
with the |
| 1011 |
.Tn RPC |
| 1012 |
service package. |
| 1013 |
If a request arrives for program |
| 1014 |
.Fa prognum , |
| 1015 |
version |
| 1016 |
.Fa versnum , |
| 1017 |
and procedure |
| 1018 |
.Fa procnum , |
| 1019 |
.Fa procname |
| 1020 |
is called with a pointer to its argument(s); |
| 1021 |
.Fa progname |
| 1022 |
should return a pointer to its static result(s); |
| 1023 |
.Fa inproc |
| 1024 |
is used to decode the arguments while |
| 1025 |
.Fa outproc |
| 1026 |
is used to encode the results. |
| 1027 |
This routine returns zero if the registration succeeded, \-1 |
| 1028 |
otherwise. |
| 1029 |
.Pp |
| 1030 |
Warning: remote procedures registered in this form |
| 1031 |
are accessed using the |
| 1032 |
.Tn UDP/IP |
| 1033 |
transport; see |
| 1034 |
.Fn svcudp_create |
| 1035 |
for restrictions. |
| 1036 |
.Pp |
| 1037 |
.It Xo |
| 1038 |
.Vt "struct rpc_createerr" rpc_createerr ; |
| 1039 |
.Xc |
| 1040 |
.Pp |
| 1041 |
A global variable whose value is set by any |
| 1042 |
.Tn RPC |
| 1043 |
client creation routine |
| 1044 |
that does not succeed. |
| 1045 |
Use the routine |
| 1046 |
.Fn clnt_pcreateerror |
| 1047 |
to print the reason why. |
| 1048 |
.Pp |
| 1049 |
.It Xo |
| 1050 |
.Ft bool_t |
| 1051 |
.Fn svc_destroy "SVCXPRT * xprt" |
| 1052 |
.Xc |
| 1053 |
.Pp |
| 1054 |
A macro that destroys the |
| 1055 |
.Tn RPC |
| 1056 |
service transport handle, |
| 1057 |
.Fa xprt . |
| 1058 |
Destruction usually involves deallocation |
| 1059 |
of private data structures, including |
| 1060 |
.Fa xprt |
| 1061 |
itself. |
| 1062 |
Use of |
| 1063 |
.Fa xprt |
| 1064 |
is undefined after calling this routine. |
| 1065 |
.Pp |
| 1066 |
.It Xo |
| 1067 |
.Vt fd_set svc_fdset ; |
| 1068 |
.Xc |
| 1069 |
.Pp |
| 1070 |
A global variable reflecting the |
| 1071 |
.Tn RPC |
| 1072 |
service side's |
| 1073 |
read file descriptor bit mask; it is suitable as a template argument |
| 1074 |
to the |
| 1075 |
.Xr select 2 |
| 1076 |
system call. |
| 1077 |
This is only of interest |
| 1078 |
if a service implementor does not call |
| 1079 |
.Fn svc_run , |
| 1080 |
but rather does his own asynchronous event processing. |
| 1081 |
This variable is read\-only (do not pass its address to |
| 1082 |
.Xr select 2 ! ) , |
| 1083 |
yet it may change after calls to |
| 1084 |
.Fn svc_getreqset |
| 1085 |
or any creation routines. |
| 1086 |
As well, note that if the process has descriptor limits |
| 1087 |
which are extended beyond |
| 1088 |
.Dv FD_SETSIZE , |
| 1089 |
this variable will only be usable for the first |
| 1090 |
.Dv FD_SETSIZE |
| 1091 |
descriptors. |
| 1092 |
.Pp |
| 1093 |
.It Xo |
| 1094 |
.Vt int svc_fds ; |
| 1095 |
.Xc |
| 1096 |
.Pp |
| 1097 |
Similar to |
| 1098 |
.Va svc_fdset , |
| 1099 |
but limited to 32 descriptors. |
| 1100 |
This |
| 1101 |
interface is obsoleted by |
| 1102 |
.Va svc_fdset . |
| 1103 |
.Pp |
| 1104 |
.It Xo |
| 1105 |
.Ft bool_t |
| 1106 |
.Fn svc_freeargs "SVCXPRT *xprt" "xdrproc_t inproc" "char *in" |
| 1107 |
.Xc |
| 1108 |
.Pp |
| 1109 |
A macro that frees any data allocated by the |
| 1110 |
.Tn RPC/XDR |
| 1111 |
system when it decoded the arguments to a service procedure |
| 1112 |
using |
| 1113 |
.Fn svc_getargs . |
| 1114 |
This routine returns 1 if the results were successfully |
| 1115 |
freed, |
| 1116 |
and zero otherwise. |
| 1117 |
.Pp |
| 1118 |
.It Xo |
| 1119 |
.Ft bool_t |
| 1120 |
.Fn svc_getargs "SVCXPRT *xprt" "xdrproc_t inproc" "char *in" |
| 1121 |
.Xc |
| 1122 |
.Pp |
| 1123 |
A macro that decodes the arguments of an |
| 1124 |
.Tn RPC |
| 1125 |
request |
| 1126 |
associated with the |
| 1127 |
.Tn RPC |
| 1128 |
service transport handle, |
| 1129 |
.Fa xprt . |
| 1130 |
The |
| 1131 |
.Fa in |
| 1132 |
argument |
| 1133 |
is the address where the arguments will be placed; |
| 1134 |
.Fa inproc |
| 1135 |
is the |
| 1136 |
.Tn XDR |
| 1137 |
routine used to decode the arguments. |
| 1138 |
This routine returns one if decoding succeeds, and zero |
| 1139 |
otherwise. |
| 1140 |
.Pp |
| 1141 |
.It Xo |
| 1142 |
.Ft "struct sockaddr_in *" |
| 1143 |
.Xc |
| 1144 |
.It Xo |
| 1145 |
.Fn svc_getcaller "SVCXPRT *xprt" |
| 1146 |
.Xc |
| 1147 |
.Pp |
| 1148 |
The approved way of getting the network address of the caller |
| 1149 |
of a procedure associated with the |
| 1150 |
.Tn RPC |
| 1151 |
service transport handle, |
| 1152 |
.Fa xprt . |
| 1153 |
.Pp |
| 1154 |
.It Xo |
| 1155 |
.Ft void |
| 1156 |
.Fn svc_getreqset "fd_set *rdfds" |
| 1157 |
.Xc |
| 1158 |
.Pp |
| 1159 |
This routine is only of interest if a service implementor |
| 1160 |
does not call |
| 1161 |
.Fn svc_run , |
| 1162 |
but instead implements custom asynchronous event processing. |
| 1163 |
It is called when the |
| 1164 |
.Xr select 2 |
| 1165 |
system call has determined that an |
| 1166 |
.Tn RPC |
| 1167 |
request has arrived on some |
| 1168 |
.Tn RPC |
| 1169 |
socket(s); |
| 1170 |
.Fa rdfds |
| 1171 |
is the resultant read file descriptor bit mask. |
| 1172 |
The routine returns when all sockets associated with the |
| 1173 |
value of |
| 1174 |
.Fa rdfds |
| 1175 |
have been serviced. |
| 1176 |
.Pp |
| 1177 |
.It Xo |
| 1178 |
.Ft void |
| 1179 |
.Fn svc_getreq "int rdfds" |
| 1180 |
.Xc |
| 1181 |
.Pp |
| 1182 |
Similar to |
| 1183 |
.Fn svc_getreqset , |
| 1184 |
but limited to 32 descriptors. |
| 1185 |
This interface is obsoleted by |
| 1186 |
.Fn svc_getreqset . |
| 1187 |
.Pp |
| 1188 |
.It Xo |
| 1189 |
.Ft bool_t |
| 1190 |
.Fo svc_register |
| 1191 |
.Fa "SVCXPRT *xprt" |
| 1192 |
.Fa "u_long prognum" |
| 1193 |
.Fa "u_long versnum" |
| 1194 |
.Fa "void (*dispatch)(struct svc_req *, SVCXPRT *)" |
| 1195 |
.Fa "int protocol" |
| 1196 |
.Fc |
| 1197 |
.Xc |
| 1198 |
.Pp |
| 1199 |
Associates |
| 1200 |
.Fa prognum |
| 1201 |
and |
| 1202 |
.Fa versnum |
| 1203 |
with the service dispatch procedure, |
| 1204 |
.Fn dispatch . |
| 1205 |
If |
| 1206 |
.Fa protocol |
| 1207 |
is zero, the service is not registered with the |
| 1208 |
.Xr rpcbind 8 |
| 1209 |
service. |
| 1210 |
If |
| 1211 |
.Fa protocol |
| 1212 |
is non-zero, then a mapping of the triple |
| 1213 |
.Pq Fa prognum , versnum , protocol |
| 1214 |
to |
| 1215 |
.Fa xprt\->xp_port |
| 1216 |
is established with the local |
| 1217 |
.Xr rpcbind 8 |
| 1218 |
service (generally |
| 1219 |
.Fa protocol |
| 1220 |
is zero, |
| 1221 |
.Dv IPPROTO_UDP |
| 1222 |
or |
| 1223 |
.Dv IPPROTO_TCP ) . |
| 1224 |
The procedure |
| 1225 |
.Fn dispatch |
| 1226 |
has the following form: |
| 1227 |
.Bd -ragged -offset indent |
| 1228 |
.Ft bool_t |
| 1229 |
.Fn dispatch "struct svc_req *request" "SVCXPRT *xprt" |
| 1230 |
.Ed |
| 1231 |
.Pp |
| 1232 |
The |
| 1233 |
.Fn svc_register |
| 1234 |
routine returns one if it succeeds, and zero otherwise. |
| 1235 |
.Pp |
| 1236 |
.It Xo |
| 1237 |
.Fn svc_run |
| 1238 |
.Xc |
| 1239 |
.Pp |
| 1240 |
This routine never returns. |
| 1241 |
It waits for |
| 1242 |
.Tn RPC |
| 1243 |
requests to arrive, and calls the appropriate service |
| 1244 |
procedure using |
| 1245 |
.Fn svc_getreq |
| 1246 |
when one arrives. |
| 1247 |
This procedure is usually waiting for a |
| 1248 |
.Xr select 2 |
| 1249 |
system call to return. |
| 1250 |
.Pp |
| 1251 |
.It Xo |
| 1252 |
.Ft bool_t |
| 1253 |
.Fn svc_sendreply "SVCXPRT *xprt" "xdrproc_t outproc" "char *out" |
| 1254 |
.Xc |
| 1255 |
.Pp |
| 1256 |
Called by an |
| 1257 |
.Tn RPC |
| 1258 |
service's dispatch routine to send the results of a |
| 1259 |
remote procedure call. |
| 1260 |
The |
| 1261 |
.Fa xprt |
| 1262 |
argument |
| 1263 |
is the request's associated transport handle; |
| 1264 |
.Fa outproc |
| 1265 |
is the |
| 1266 |
.Tn XDR |
| 1267 |
routine which is used to encode the results; and |
| 1268 |
.Fa out |
| 1269 |
is the address of the results. |
| 1270 |
This routine returns one if it succeeds, zero otherwise. |
| 1271 |
.Pp |
| 1272 |
.It Xo |
| 1273 |
.Ft void |
| 1274 |
.Xc |
| 1275 |
.It Xo |
| 1276 |
.Fn svc_unregister "u_long prognum" "u_long versnum" |
| 1277 |
.Xc |
| 1278 |
.Pp |
| 1279 |
Remove all mapping of the double |
| 1280 |
.Pq Fa prognum , versnum |
| 1281 |
to dispatch routines, and of the triple |
| 1282 |
.Pq Fa prognum , versnum , * |
| 1283 |
to port number. |
| 1284 |
.Pp |
| 1285 |
.It Xo |
| 1286 |
.Ft void |
| 1287 |
.Xc |
| 1288 |
.It Xo |
| 1289 |
.Fn svcerr_auth "SVCXPRT *xprt" "enum auth_stat why" |
| 1290 |
.Xc |
| 1291 |
.Pp |
| 1292 |
Called by a service dispatch routine that refuses to perform |
| 1293 |
a remote procedure call due to an authentication error. |
| 1294 |
.Pp |
| 1295 |
.It Xo |
| 1296 |
.Ft void |
| 1297 |
.Xc |
| 1298 |
.It Xo |
| 1299 |
.Fn svcerr_decode "SVCXPRT *xprt" |
| 1300 |
.Xc |
| 1301 |
.Pp |
| 1302 |
Called by a service dispatch routine that cannot successfully |
| 1303 |
decode its arguments. |
| 1304 |
See also |
| 1305 |
.Fn svc_getargs . |
| 1306 |
.Pp |
| 1307 |
.It Xo |
| 1308 |
.Ft void |
| 1309 |
.Xc |
| 1310 |
.It Xo |
| 1311 |
.Fn svcerr_noproc "SVCXPRT *xprt" |
| 1312 |
.Xc |
| 1313 |
.Pp |
| 1314 |
Called by a service dispatch routine that does not implement |
| 1315 |
the procedure number that the caller requests. |
| 1316 |
.Pp |
| 1317 |
.It Xo |
| 1318 |
.Ft void |
| 1319 |
.Xc |
| 1320 |
.It Xo |
| 1321 |
.Fn svcerr_noprog "SVCXPRT *xprt" |
| 1322 |
.Xc |
| 1323 |
.Pp |
| 1324 |
Called when the desired program is not registered with the |
| 1325 |
.Tn RPC |
| 1326 |
package. |
| 1327 |
Service implementors usually do not need this routine. |
| 1328 |
.Pp |
| 1329 |
.It Xo |
| 1330 |
.Ft void |
| 1331 |
.Xc |
| 1332 |
.It Xo |
| 1333 |
.Fn svcerr_progvers "SVCXPRT *xprt" "u_long low_vers" "u_long high_vers" |
| 1334 |
.Xc |
| 1335 |
.Pp |
| 1336 |
Called when the desired version of a program is not registered |
| 1337 |
with the |
| 1338 |
.Tn RPC |
| 1339 |
package. |
| 1340 |
Service implementors usually do not need this routine. |
| 1341 |
.Pp |
| 1342 |
.It Xo |
| 1343 |
.Ft void |
| 1344 |
.Xc |
| 1345 |
.It Xo |
| 1346 |
.Fn svcerr_systemerr "SVCXPRT *xprt" |
| 1347 |
.Xc |
| 1348 |
.Pp |
| 1349 |
Called by a service dispatch routine when it detects a system |
| 1350 |
error |
| 1351 |
not covered by any particular protocol. |
| 1352 |
For example, if a service can no longer allocate storage, |
| 1353 |
it may call this routine. |
| 1354 |
.Pp |
| 1355 |
.It Xo |
| 1356 |
.Ft void |
| 1357 |
.Xc |
| 1358 |
.It Xo |
| 1359 |
.Fn svcerr_weakauth "SVCXPRT *xprt" |
| 1360 |
.Xc |
| 1361 |
.Pp |
| 1362 |
Called by a service dispatch routine that refuses to perform |
| 1363 |
a remote procedure call due to insufficient |
| 1364 |
authentication arguments. |
| 1365 |
The routine calls |
| 1366 |
.Fn svcerr_auth xprt AUTH_TOOWEAK . |
| 1367 |
.Pp |
| 1368 |
.It Xo |
| 1369 |
.Ft "SVCXPRT *" |
| 1370 |
.Xc |
| 1371 |
.It Xo |
| 1372 |
.Fn svcraw_create void |
| 1373 |
.Xc |
| 1374 |
.Pp |
| 1375 |
This routine creates a toy |
| 1376 |
.Tn RPC |
| 1377 |
service transport, to which it returns a pointer. |
| 1378 |
The transport |
| 1379 |
is really a buffer within the process's address space, |
| 1380 |
so the corresponding |
| 1381 |
.Tn RPC |
| 1382 |
client should live in the same |
| 1383 |
address space; |
| 1384 |
see |
| 1385 |
.Fn clntraw_create . |
| 1386 |
This routine allows simulation of |
| 1387 |
.Tn RPC |
| 1388 |
and acquisition of |
| 1389 |
.Tn RPC |
| 1390 |
overheads (such as round trip times), without any kernel |
| 1391 |
interference. |
| 1392 |
This routine returns |
| 1393 |
.Dv NULL |
| 1394 |
if it fails. |
| 1395 |
.Pp |
| 1396 |
.It Xo |
| 1397 |
.Ft "SVCXPRT *" |
| 1398 |
.Xc |
| 1399 |
.It Xo |
| 1400 |
.Fn svctcp_create "int sock" "u_int send_buf_size" "u_int recv_buf_size" |
| 1401 |
.Xc |
| 1402 |
.Pp |
| 1403 |
This routine creates a |
| 1404 |
.Tn TCP/IP Ns \-based |
| 1405 |
.Tn RPC |
| 1406 |
service transport, to which it returns a pointer. |
| 1407 |
The transport is associated with the socket |
| 1408 |
.Fa sock , |
| 1409 |
which may be |
| 1410 |
.Dv RPC_ANYSOCK , |
| 1411 |
in which case a new socket is created. |
| 1412 |
If the socket is not bound to a local |
| 1413 |
.Tn TCP |
| 1414 |
port, then this routine binds it to an arbitrary port. |
| 1415 |
Upon completion, |
| 1416 |
.Fa xprt\->xp_fd |
| 1417 |
is the transport's socket descriptor, and |
| 1418 |
.Fa xprt\->xp_port |
| 1419 |
is the transport's port number. |
| 1420 |
This routine returns |
| 1421 |
.Dv NULL |
| 1422 |
if it fails. |
| 1423 |
Since |
| 1424 |
.Tn TCP Ns \-based |
| 1425 |
.Tn RPC |
| 1426 |
uses buffered |
| 1427 |
.Tn I/O , |
| 1428 |
users may specify the size of buffers; values of zero |
| 1429 |
choose suitable defaults. |
| 1430 |
.Pp |
| 1431 |
.It Xo |
| 1432 |
.Ft "SVCXPRT *" |
| 1433 |
.Xc |
| 1434 |
.It Xo |
| 1435 |
.Fn svcunix_create "int sock" "u_int send_buf_size" "u_int recv_buf_size" "char *path" |
| 1436 |
.Xc |
| 1437 |
.Pp |
| 1438 |
This routine creates a |
| 1439 |
.Ux Ns -based |
| 1440 |
.Tn RPC |
| 1441 |
service transport, to which it returns a pointer. |
| 1442 |
The transport is associated with the socket |
| 1443 |
.Fa sock , |
| 1444 |
which may be |
| 1445 |
.Dv RPC_ANYSOCK , |
| 1446 |
in which case a new socket is created. |
| 1447 |
The |
| 1448 |
.Fa *path |
| 1449 |
argument |
| 1450 |
is a variable-length file system pathname of |
| 1451 |
at most 104 characters. |
| 1452 |
This file is |
| 1453 |
.Em not |
| 1454 |
removed when the socket is closed. |
| 1455 |
The |
| 1456 |
.Xr unlink 2 |
| 1457 |
system call must be used to remove the file. |
| 1458 |
Upon completion, |
| 1459 |
.Fa xprt\->xp_fd |
| 1460 |
is the transport's socket descriptor. |
| 1461 |
This routine returns |
| 1462 |
.Dv NULL |
| 1463 |
if it fails. |
| 1464 |
Since |
| 1465 |
.Ux Ns -based |
| 1466 |
.Tn RPC |
| 1467 |
uses buffered |
| 1468 |
.Tn I/O , |
| 1469 |
users may specify the size of buffers; values of zero |
| 1470 |
choose suitable defaults. |
| 1471 |
.Pp |
| 1472 |
.It Xo |
| 1473 |
.Ft "SVCXPRT *" |
| 1474 |
.Xc |
| 1475 |
.It Xo |
| 1476 |
.Fn svcunixfd_create "int fd" "u_int sendsize" "u_int recvsize" |
| 1477 |
.Xc |
| 1478 |
.Pp |
| 1479 |
Create a service on top of any open descriptor. |
| 1480 |
The |
| 1481 |
.Fa sendsize |
| 1482 |
and |
| 1483 |
.Fa recvsize |
| 1484 |
arguments |
| 1485 |
indicate sizes for the send and receive buffers. |
| 1486 |
If they are |
| 1487 |
zero, a reasonable default is chosen. |
| 1488 |
.Pp |
| 1489 |
.It Xo |
| 1490 |
.Ft "SVCXPRT *" |
| 1491 |
.Xc |
| 1492 |
.It Xo |
| 1493 |
.Fn svcfd_create "int fd" "u_int sendsize" "u_int recvsize" |
| 1494 |
.Xc |
| 1495 |
.Pp |
| 1496 |
Create a service on top of any open descriptor. |
| 1497 |
Typically, |
| 1498 |
this |
| 1499 |
descriptor is a connected socket for a stream protocol such |
| 1500 |
as |
| 1501 |
.Tn TCP . |
| 1502 |
The |
| 1503 |
.Fa sendsize |
| 1504 |
and |
| 1505 |
.Fa recvsize |
| 1506 |
arguments |
| 1507 |
indicate sizes for the send and receive buffers. |
| 1508 |
If they are |
| 1509 |
zero, a reasonable default is chosen. |
| 1510 |
.Pp |
| 1511 |
.It Xo |
| 1512 |
.Ft "SVCXPRT *" |
| 1513 |
.Xc |
| 1514 |
.It Xo |
| 1515 |
.Fn svcudp_bufcreate "int sock" "u_int sendsize" "u_int recvsize" |
| 1516 |
.Xc |
| 1517 |
.Pp |
| 1518 |
This routine creates a |
| 1519 |
.Tn UDP/IP Ns \-based |
| 1520 |
.Tn RPC |
| 1521 |
service transport, to which it returns a pointer. |
| 1522 |
The transport is associated with the socket |
| 1523 |
.Fa sock , |
| 1524 |
which may be |
| 1525 |
.Dv RPC_ANYSOCK , |
| 1526 |
in which case a new socket is created. |
| 1527 |
If the socket is not bound to a local |
| 1528 |
.Tn UDP |
| 1529 |
port, then this routine binds it to an arbitrary port. |
| 1530 |
Upon |
| 1531 |
completion, |
| 1532 |
.Fa xprt\->xp_fd |
| 1533 |
is the transport's socket descriptor, and |
| 1534 |
.Fa xprt\->xp_port |
| 1535 |
is the transport's port number. |
| 1536 |
This routine returns |
| 1537 |
.Dv NULL |
| 1538 |
if it fails. |
| 1539 |
.Pp |
| 1540 |
This allows the user to specify the maximum packet size for sending and |
| 1541 |
receiving |
| 1542 |
.Tn UDP Ns \-based |
| 1543 |
.Tn RPC |
| 1544 |
messages. |
| 1545 |
.Pp |
| 1546 |
.It Xo |
| 1547 |
.Ft bool_t |
| 1548 |
.Fn xdr_accepted_reply "XDR *xdrs" "struct accepted_reply *ar" |
| 1549 |
.Xc |
| 1550 |
.Pp |
| 1551 |
Used for encoding |
| 1552 |
.Tn RPC |
| 1553 |
reply messages. |
| 1554 |
This routine is useful for users who |
| 1555 |
wish to generate |
| 1556 |
.Tn RPC Ns \-style |
| 1557 |
messages without using the |
| 1558 |
.Tn RPC |
| 1559 |
package. |
| 1560 |
.Pp |
| 1561 |
.It Xo |
| 1562 |
.Ft bool_t |
| 1563 |
.Fn xdr_authunix_parms "XDR *xdrs" "struct authunix_parms *aupp" |
| 1564 |
.Xc |
| 1565 |
.Pp |
| 1566 |
Used for describing |
| 1567 |
.Ux |
| 1568 |
credentials. |
| 1569 |
This routine is useful for users |
| 1570 |
who wish to generate these credentials without using the |
| 1571 |
.Tn RPC |
| 1572 |
authentication package. |
| 1573 |
.Pp |
| 1574 |
.It Xo |
| 1575 |
.Ft void |
| 1576 |
.Xc |
| 1577 |
.It Xo |
| 1578 |
.Ft bool_t |
| 1579 |
.Fn xdr_callhdr "XDR *xdrs" "struct rpc_msg *chdr" |
| 1580 |
.Xc |
| 1581 |
.Pp |
| 1582 |
Used for describing |
| 1583 |
.Tn RPC |
| 1584 |
call header messages. |
| 1585 |
This routine is useful for users who wish to generate |
| 1586 |
.Tn RPC Ns \-style |
| 1587 |
messages without using the |
| 1588 |
.Tn RPC |
| 1589 |
package. |
| 1590 |
.Pp |
| 1591 |
.It Xo |
| 1592 |
.Ft bool_t |
| 1593 |
.Fn xdr_callmsg "XDR *xdrs" "struct rpc_msg *cmsg" |
| 1594 |
.Xc |
| 1595 |
.Pp |
| 1596 |
Used for describing |
| 1597 |
.Tn RPC |
| 1598 |
call messages. |
| 1599 |
This routine is useful for users who wish to generate |
| 1600 |
.Tn RPC Ns \-style |
| 1601 |
messages without using the |
| 1602 |
.Tn RPC |
| 1603 |
package. |
| 1604 |
.Pp |
| 1605 |
.It Xo |
| 1606 |
.Ft bool_t |
| 1607 |
.Fn xdr_opaque_auth "XDR *xdrs" "struct opaque_auth *ap" |
| 1608 |
.Xc |
| 1609 |
.Pp |
| 1610 |
Used for describing |
| 1611 |
.Tn RPC |
| 1612 |
authentication information messages. |
| 1613 |
This routine is useful for users who wish to generate |
| 1614 |
.Tn RPC Ns \-style |
| 1615 |
messages without using the |
| 1616 |
.Tn RPC |
| 1617 |
package. |
| 1618 |
.Pp |
| 1619 |
.It Xo |
| 1620 |
.Vt struct pmap ; |
| 1621 |
.Xc |
| 1622 |
.It Xo |
| 1623 |
.Ft bool_t |
| 1624 |
.Fn xdr_pmap "XDR *xdrs" "struct pmap *regs" |
| 1625 |
.Xc |
| 1626 |
.Pp |
| 1627 |
Used for describing arguments to various |
| 1628 |
.Xr rpcbind 8 |
| 1629 |
procedures, externally. |
| 1630 |
This routine is useful for users who wish to generate |
| 1631 |
these arguments without using the |
| 1632 |
.Fn pmap_* |
| 1633 |
interface. |
| 1634 |
.Pp |
| 1635 |
.It Xo |
| 1636 |
.Ft bool_t |
| 1637 |
.Fn xdr_pmaplist "XDR *xdrs" "struct pmaplist **rp" |
| 1638 |
.Xc |
| 1639 |
.Pp |
| 1640 |
Used for describing a list of port mappings, externally. |
| 1641 |
This routine is useful for users who wish to generate |
| 1642 |
these arguments without using the |
| 1643 |
.Fn pmap_* |
| 1644 |
interface. |
| 1645 |
.Pp |
| 1646 |
.It Xo |
| 1647 |
.Ft bool_t |
| 1648 |
.Fn xdr_rejected_reply "XDR *xdrs" "struct rejected_reply *rr" |
| 1649 |
.Xc |
| 1650 |
.Pp |
| 1651 |
Used for describing |
| 1652 |
.Tn RPC |
| 1653 |
reply messages. |
| 1654 |
This routine is useful for users who wish to generate |
| 1655 |
.Tn RPC Ns \-style |
| 1656 |
messages without using the |
| 1657 |
.Tn RPC |
| 1658 |
package. |
| 1659 |
.Pp |
| 1660 |
.It Xo |
| 1661 |
.Ft bool_t |
| 1662 |
.Fn xdr_replymsg "XDR *xdrs" "struct rpc_msg *rmsg" |
| 1663 |
.Xc |
| 1664 |
.Pp |
| 1665 |
Used for describing |
| 1666 |
.Tn RPC |
| 1667 |
reply messages. |
| 1668 |
This routine is useful for users who wish to generate |
| 1669 |
.Tn RPC |
| 1670 |
style messages without using the |
| 1671 |
.Tn RPC |
| 1672 |
package. |
| 1673 |
.Pp |
| 1674 |
.It Xo |
| 1675 |
.Ft void |
| 1676 |
.Xc |
| 1677 |
.It Xo |
| 1678 |
.Fn xprt_register "SVCXPRT *xprt" |
| 1679 |
.Xc |
| 1680 |
.Pp |
| 1681 |
After |
| 1682 |
.Tn RPC |
| 1683 |
service transport handles are created, |
| 1684 |
they should register themselves with the |
| 1685 |
.Tn RPC |
| 1686 |
service package. |
| 1687 |
This routine modifies the global variable |
| 1688 |
.Va svc_fds . |
| 1689 |
Service implementors usually do not need this routine. |
| 1690 |
.Pp |
| 1691 |
.It Xo |
| 1692 |
.Ft void |
| 1693 |
.Xc |
| 1694 |
.It Xo |
| 1695 |
.Fn xprt_unregister "SVCXPRT *xprt" |
| 1696 |
.Xc |
| 1697 |
.Pp |
| 1698 |
Before an |
| 1699 |
.Tn RPC |
| 1700 |
service transport handle is destroyed, |
| 1701 |
it should unregister itself with the |
| 1702 |
.Tn RPC |
| 1703 |
service package. |
| 1704 |
This routine modifies the global variable |
| 1705 |
.Va svc_fds . |
| 1706 |
Service implementors usually do not need this routine. |
| 1707 |
.El |
| 1708 |
.Sh AVAILABILITY |
| 1709 |
These functions are part of libtirpc. |
| 1710 |
.Sh SEE ALSO |
| 1711 |
.Xr rpc_secure 3 , |
| 1712 |
.Xr xdr 3 |
| 1713 |
.Rs |
| 1714 |
.%T "Remote Procedure Calls: Protocol Specification" |
| 1715 |
.Re |
| 1716 |
.Rs |
| 1717 |
.%T "Remote Procedure Call Programming Guide" |
| 1718 |
.Re |
| 1719 |
.Rs |
| 1720 |
.%T "rpcgen Programming Guide" |
| 1721 |
.Re |
| 1722 |
.Rs |
| 1723 |
.%T "RPC: Remote Procedure Call Protocol Specification" |
| 1724 |
.%O RFC1050 |
| 1725 |
.%Q "Sun Microsystems, Inc., USC-ISI" |
| 1726 |
.Re |