1 .\" from: @(#)rpc.3n 2.4 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI
2 .\" $Id: rpc.3,v 1.1 1999/04/13 23:15:37 wsanchez Exp $
4 .TH RPC 3N "16 February 1988"
6 rpc \- library routines for remote procedure calls
7 .SH SYNOPSIS AND DESCRIPTION
8 These routines allow C programs to make procedure
9 calls on other machines across the network.
10 First, the client calls a procedure to send a
11 data packet to the server.
12 Upon receipt of the packet, the server calls a dispatch routine
13 to perform the requested service, and then sends back a
15 Finally, the procedure call returns to the client.
17 Routines that are used for Secure RPC (DES authentication) are described in
19 Secure RPC can be used only if DES encryption is available.
39 A macro that destroys the authentication information associated with
41 Destruction usually involves deallocation of private data
42 structures. The use of
44 is undefined after calling
45 .BR auth_destroy(\|) .
59 authentication handle that passes nonusable authentication
60 information with each remote procedure call. This is the
61 default authentication used by
69 authunix_create(host, uid, gid, len, aup_gids)
71 int uid, gid, len, *aup.gids;
77 authentication handle that contains
79 authentication information.
82 is the name of the machine on which the information was
88 is the user's current group
93 refer to a counted array of groups to which the user belongs.
94 It is easy to impersonate a user.
102 authunix_create_default(\|)
107 .B authunix_create(\|)
108 with the appropriate parameters.
115 callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
117 u_long prognum, versnum, procnum;
119 xdrproc_t inproc, outproc;
123 Call the remote procedure associated with
132 is the address of the procedure's argument(s), and
134 is the address of where to place the result(s);
136 is used to encode the procedure's parameters, and
138 is used to decode the procedure's results.
139 This routine returns zero if it succeeds, or the value of
141 cast to an integer if it fails.
144 is handy for translating failure statuses into messages.
146 Warning: calling remote procedures with this routine
150 .B clntudp_create(\|)
152 You do not have control of timeouts or authentication using
161 clnt_broadcast(prognum, versnum, procnum, inproc, in, outproc, out, eachresult)
162 u_long prognum, versnum, procnum;
164 xdrproc_t inproc, outproc;
165 resultproc_t eachresult;
171 except the call message is broadcast to all locally
172 connected broadcast nets. Each time it receives a
173 response, this routine calls
180 eachresult(out, addr)
182 struct sockaddr_in *addr;
192 .BR clnt_broadcast(\|) ,
193 except that the remote procedure's output is decoded there;
195 points to the address of the machine that sent the results.
199 .B clnt_broadcast(\|)
200 waits for more replies; otherwise it returns with appropriate
203 Warning: broadcast sockets are limited in size to the
204 maximum transfer unit of the data link. For ethernet,
205 this value is 1500 bytes.
213 clnt_call(clnt, procnum, inproc, in, outproc, out, tout)
217 xdrproc_t inproc, outproc;
223 A macro that calls the remote procedure
225 associated with the client handle,
227 which is obtained with an
229 client creation routine such as
230 .BR clnt_create(\|) .
233 is the address of the procedure's argument(s), and
235 is the address of where to place the result(s);
237 is used to encode the procedure's parameters, and
239 is used to decode the procedure's results;
241 is the time allowed for results to come back.
253 A macro that destroys the client's
255 handle. Destruction usually involves deallocation
256 of private data structures, including
260 is undefined after calling
261 .BR clnt_destroy(\|) .
264 library opened the associated socket, it will close it also.
265 Otherwise, the socket remains open.
273 clnt_create(host, prog, vers, proto)
280 Generic client creation routine.
282 identifies the name of the remote host where the server
285 indicates which kind of transport protocol to use. The
286 currently supported values for this field are \(lqudp\(rq
288 Default timeouts are set, but can be modified using
289 .BR clnt_control(\|) .
293 has its shortcomings. Since
296 messages can only hold up to 8 Kbytes of encoded data,
297 this transport cannot be used for procedures that take
298 large arguments or return huge results.
306 clnt_control(cl, req, info)
312 A macro used to change or retrieve various information
313 about a client object.
315 indicates the type of operation, and
317 is a pointer to the information. For both
321 the supported values of
323 and their argument types and what they do are:
326 .ta +2.0i +2.0i +2.0i
327 .SM CLSET_TIMEOUT\s0 struct timeval set total timeout
328 .SM CLGET_TIMEOUT\s0 struct timeval get total timeout
331 Note: if you set the timeout using
332 .BR clnt_control(\|) ,
333 the timeout parameter passed to
335 will be ignored in all future calls.
338 .SM CLGET_SERVER_ADDR\s0 struct sockaddr_in get server's address
342 The following operations are valid for
347 .ta +2.0i +2.0i +2.0i
348 .SM CLSET_RETRY_TIMEOUT\s0 struct timeval set the retry timeout
349 .SM CLGET_RETRY_TIMEOUT\s0 struct timeval get the retry timeout
353 The retry timeout is the time that
355 waits for the server to reply before
356 retransmitting the request.
363 clnt_freeres(clnt, outproc, out)
370 A macro that frees any data allocated by the
372 system when it decoded the results of an
377 is the address of the results, and
381 routine describing the results.
382 This routine returns one if the results were successfully
392 clnt_geterr(clnt, errp)
394 struct rpc_err *errp;
398 A macro that copies the error structure out of the client
400 to the structure at address
414 Print a message to standard error indicating
417 handle could not be created.
418 The message is prepended with string
422 .BR clnt_create(\|) ,
423 .BR clntraw_create(\|) ,
424 .BR clnttcp_create(\|) ,
426 .B clntudp_create(\|)
440 Print a message to standard error corresponding
441 to the condition indicated by
457 Print a message to standard error indicating why an
461 is the handle used to do the call.
462 The message is prepended with string
480 .BR clnt_pcreateerror(\|) ,
481 except that it returns a string
482 instead of printing to the standard error.
484 Bugs: returns pointer to static data that is overwritten
498 Take the same arguments as
499 .BR clnt_perrno(\|) ,
500 but instead of sending a message to the standard error
503 call failed, return a pointer to a string which contains
504 the message. The string ends with a
510 if the program does not have a standard error (as a program
511 running as a server quite likely does not), or if the
513 does not want the message to be output with
515 or if a message format different than that supported by
521 .BR clnt_spcreaterror(\|) ,
523 returns pointer to static data, but the
524 result will not get overwritten on each call.
532 clnt_sperror(rpch, s)
539 .BR clnt_perror(\|) ,
541 .BR clnt_sperrno(\|) )
542 it returns a string instead of printing to standard error.
544 Bugs: returns pointer to static data that is overwritten
553 clntraw_create(prognum, versnum)
554 u_long prognum, versnum;
558 This routine creates a toy
560 client for the remote program
564 The transport used to pass messages to the service is
565 actually a buffer within the process's address space, so the
568 server should live in the same address space; see
569 .BR svcraw_create(\|) .
570 This allows simulation of
574 overheads, such as round trip times, without any
575 kernel interference. This routine returns
585 clnttcp_create(addr, prognum, versnum, sockp, sendsz, recvsz)
586 struct sockaddr_in *addr;
587 u_long prognum, versnum;
589 u_int sendsz, recvsz;
593 This routine creates an
595 client for the remote program
601 as a transport. The remote program is located at Internet
605 .\"The following in-line font conversion is necessary for the hyphen indicator
606 \fB\%addr\->sin_port\fR
607 is zero, then it is set to the actual port that the remote
608 program is listening on (the remote
610 service is consulted for this information). The parameter
612 is a socket; if it is
613 .BR \s-1RPC_ANYSOCK\s0 ,
614 then this routine opens a new one and sets
621 the user may specify the size of the send and receive buffers
626 values of zero choose suitable defaults.
637 clntudp_create(addr, prognum, versnum, wait, sockp)
638 struct sockaddr_in *addr;
639 u_long prognum, versnum;
645 This routine creates an
647 client for the remote program
653 as a transport. The remote program is located at Internet
657 \fB\%addr\->sin_port\fR
658 is zero, then it is set to actual port that the remote
659 program is listening on (the remote
661 service is consulted for this information). The parameter
663 is a socket; if it is
664 .BR \s-1RPC_ANYSOCK\s0 ,
665 then this routine opens a new one and sets
669 transport resends the call message in intervals of
671 time until a response is received or until the call times
673 The total time for the call to time out is specified by
679 messages can only hold up to 8 Kbytes
680 of encoded data, this transport cannot be used for procedures
681 that take large arguments or return huge results.
689 clntudp_bufcreate(addr, prognum, versnum, wait, sockp, sendsize, recosize)
690 struct sockaddr_in *addr;
691 u_long prognum, versnum;
694 unsigned int sendsize;
695 unsigned int recosize;
699 This routine creates an
701 client for the remote program
707 as a transport. The remote program is located at Internet
711 \fB\%addr\->sin_port\fR
712 is zero, then it is set to actual port that the remote
713 program is listening on (the remote
715 service is consulted for this information). The parameter
717 is a socket; if it is
718 .BR \s-1RPC_ANYSOCK\s0 ,
719 then this routine opens a new one and sets
723 transport resends the call message in intervals of
725 time until a response is received or until the call times
727 The total time for the call to time out is specified by
730 This allows the user to specify the maximun packet size for sending and receiving
742 struct sockaddr_in *addr;
750 without consulting the library routines that deal with
752 The port number is always set to
753 .BR htons(\s-1PMAPPORT\s0) .
762 struct sockaddr_in *addr;
766 A user interface to the
768 service, which returns a list of the current
770 program-to-port mappings
771 on the host located at
775 This routine can return
778 .RB ` "rpcinfo \-p" '
787 pmap_getport(addr, prognum, versnum, protocol)
788 struct sockaddr_in *addr;
789 u_long prognum, versnum, protocol;
793 A user interface to the
795 service, which returns the port number
796 on which waits a service that supports program number
800 and speaks the transport protocol associated with
808 .BR \s-1IPPROTO_TCP\s0 .
809 A return value of zero means that the mapping does not exist
813 system failured to contact the remote
815 service. In the latter case, the global variable
827 pmap_rmtcall(addr, prognum, versnum, procnum, inproc, in, outproc, out, tout, portp)
828 struct sockaddr_in *addr;
829 u_long prognum, versnum, procnum;
831 xdrproc_t inproc, outproc;
837 A user interface to the
839 service, which instructs
847 call on your behalf to a procedure on that host.
850 will be modified to the program's port number if the
852 succeeds. The definitions of other parameters are discussed
857 This procedure should be used for a \(lqping\(rq and nothing
860 .BR clnt_broadcast(\|) .
867 pmap_set(prognum, versnum, protocol, port)
868 u_long prognum, versnum, protocol;
873 A user interface to the
875 service, which establishes a mapping between the triple
876 .RI [ prognum , versnum , protocol\fR]
881 service. The value of
887 .BR \s-1IPPROTO_TCP\s0 .
888 This routine returns one if it succeeds, zero otherwise.
889 Automatically done by
890 .BR svc_register(\|) .
897 pmap_unset(prognum, versnum)
898 u_long prognum, versnum;
902 A user interface to the
904 service, which destroys all mapping between the triple
905 .RI [ prognum , versnum , *\fR]
910 service. This routine returns one if it succeeds, zero
918 registerrpc(prognum, versnum, procnum, procname, inproc, outproc)
919 u_long prognum, versnum, procnum;
920 char *(*procname) (\|) ;
921 xdrproc_t inproc, outproc;
929 service package. If a request arrives for program
936 is called with a pointer to its parameter(s);
938 should return a pointer to its static result(s);
940 is used to decode the parameters while
942 is used to encode the results.
943 This routine returns zero if the registration succeeded, \-1
946 Warning: remote procedures registered in this form
947 are accessed using the
958 struct rpc_createerr rpc_createerr;
962 A global variable whose value is set by any
964 client creation routine
965 that does not succeed. Use the routine
966 .B clnt_pcreateerror(\|)
967 to print the reason why.
979 A macro that destroys the
981 service transport handle,
983 Destruction usually involves deallocation
984 of private data structures, including
988 is undefined after calling this routine.
999 A global variable reflecting the
1002 read file descriptor bit mask; it is suitable as a parameter
1005 system call. This is only of interest
1006 if a service implementor does not call
1008 but rather does his own asynchronous event processing.
1009 This variable is read-only (do not pass its address to
1011 yet it may change after calls to
1012 .B svc_getreqset(\|)
1013 or any creation routines.
1025 .BR svc_fedset(\|) ,
1026 but limited to 32 descriptors. This
1027 interface is obsoleted by
1035 svc_freeargs(xprt, inproc, in)
1036 \s-1SVCXPRT\s0 *xprt;
1042 A macro that frees any data allocated by the
1044 system when it decoded the arguments to a service procedure
1046 .BR svc_getargs(\|) .
1047 This routine returns 1 if the results were successfully
1056 svc_getargs(xprt, inproc, in)
1057 \s-1SVCXPRT\s0 *xprt;
1063 A macro that decodes the arguments of an
1068 service transport handle,
1072 is the address where the arguments will be placed;
1076 routine used to decode the arguments.
1077 This routine returns one if decoding succeeds, and zero
1085 struct sockaddr_in *
1087 \s-1SVCXPRT\s0 *xprt;
1091 The approved way of getting the network address of the caller
1092 of a procedure associated with the
1094 service transport handle,
1102 svc_getreqset(rdfds)
1107 This routine is only of interest if a service implementor
1110 but instead implements custom asynchronous event processing.
1111 It is called when the
1113 system call has determined that an
1115 request has arrived on some
1119 is the resultant read file descriptor bit mask.
1120 The routine returns when all sockets associated with the
1136 .BR svc_getreqset(\|) ,
1137 but limited to 32 descriptors. This interface is obsoleted by
1138 .BR svc_getreqset(\|) .
1145 svc_register(xprt, prognum, versnum, dispatch, protocol)
1146 \s-1SVCXPRT\s0 *xprt;
1147 u_long prognum, versnum;
1148 void (*dispatch) (\|);
1157 with the service dispatch procedure,
1161 is zero, the service is not registered with the
1165 is non-zero, then a mapping of the triple
1166 .RI [ prognum , versnum , protocol\fR]
1168 \fB\%xprt\->xp_port\fR
1169 is established with the local
1182 has the following form:
1186 dispatch(request, xprt)
1187 struct svc_req *request;
1188 \s-1SVCXPRT\s0 *xprt;
1195 routine returns one if it succeeds, and zero otherwise.
1206 This routine never returns. It waits for
1208 requests to arrive, and calls the appropriate service
1211 when one arrives. This procedure is usually waiting for a
1213 system call to return.
1220 svc_sendreply(xprt, outproc, out)
1221 \s-1SVCXPRT\s0 *xprt;
1229 service's dispatch routine to send the results of a
1230 remote procedure call. The parameter
1232 is the request's associated transport handle;
1236 routine which is used to encode the results; and
1238 is the address of the results.
1239 This routine returns one if it succeeds, zero otherwise.
1247 svc_unregister(prognum, versnum)
1248 u_long prognum, versnum;
1252 Remove all mapping of the double
1253 .RI [ prognum , versnum ]
1254 to dispatch routines, and of the triple
1255 .RI [ prognum , versnum , *\fR]
1264 svcerr_auth(xprt, why)
1265 \s-1SVCXPRT\s0 *xprt;
1270 Called by a service dispatch routine that refuses to perform
1271 a remote procedure call due to an authentication error.
1280 \s-1SVCXPRT\s0 *xprt;
1284 Called by a service dispatch routine that cannot successfully
1285 decode its parameters. See also
1286 .BR svc_getargs(\|) .
1295 \s-1SVCXPRT\s0 *xprt;
1299 Called by a service dispatch routine that does not implement
1300 the procedure number that the caller requests.
1309 \s-1SVCXPRT\s0 *xprt;
1313 Called when the desired program is not registered with the
1315 package. Service implementors usually do not need this routine.
1323 svcerr_progvers(xprt)
1324 \s-1SVCXPRT\s0 *xprt;
1328 Called when the desired version of a program is not registered
1331 package. Service implementors usually do not need this routine.
1339 svcerr_systemerr(xprt)
1340 \s-1SVCXPRT\s0 *xprt;
1344 Called by a service dispatch routine when it detects a system
1346 not covered by any particular protocol.
1347 For example, if a service can no longer allocate storage,
1348 it may call this routine.
1356 svcerr_weakauth(xprt)
1357 \s-1SVCXPRT\s0 *xprt;
1361 Called by a service dispatch routine that refuses to perform
1362 a remote procedure call due to insufficient
1363 authentication parameters. The routine calls
1364 .BR "svcerr_auth(xprt, \s-1AUTH_TOOWEAK\s0)" .
1376 This routine creates a toy
1378 service transport, to which it returns a pointer. The
1380 is really a buffer within the process's address space,
1381 so the corresponding
1383 client should live in the same
1386 .BR clntraw_create(\|) .
1387 This routine allows simulation of
1391 overheads (such as round trip times), without any kernel
1393 This routine returns
1403 svctcp_create(sock, send_buf_size, recv_buf_size)
1405 u_int send_buf_size, recv_buf_size;
1409 This routine creates a
1412 service transport, to which it returns a pointer.
1413 The transport is associated with the socket
1416 .BR \s-1RPC_ANYSOCK\s0 ,
1417 in which case a new socket is created.
1418 If the socket is not bound to a local
1420 port, then this routine binds it to an arbitrary port. Upon
1422 \fB\%xprt\->xp_sock\fR
1423 is the transport's socket descriptor, and
1424 \fB\%xprt\->xp_port\fR
1425 is the transport's port number.
1426 This routine returns
1433 users may specify the size of buffers; values of zero
1434 choose suitable defaults.
1442 svcfd_create(fd, sendsize, recvsize)
1449 Create a service on top of any open descriptor. Typically,
1451 descriptor is a connected socket for a stream protocol such
1457 indicate sizes for the send and receive buffers. If they are
1458 zero, a reasonable default is chosen.
1466 svcudp_bufcreate(sock, sendsize, recosize)
1471 This routine creates a
1474 service transport, to which it returns a pointer.
1475 The transport is associated with the socket
1478 .B \s-1RPC_ANYSOCK\s0 ,
1479 in which case a new socket is created.
1480 If the socket is not bound to a local
1482 port, then this routine binds it to an arbitrary port. Upon
1484 \fB\%xprt\->xp_sock\fR
1485 is the transport's socket descriptor, and
1486 \fB\%xprt\->xp_port\fR
1487 is the transport's port number.
1488 This routine returns
1492 This allows the user to specify the maximun packet size for sending and
1502 xdr_accepted_reply(xdrs, ar)
1504 struct accepted_reply *ar;
1510 reply messages. This routine is useful for users who
1513 messages without using the
1522 xdr_authunix_parms(xdrs, aupp)
1524 struct authunix_parms *aupp;
1530 credentials. This routine is useful for users
1531 who wish to generate these credentials without using the
1533 authentication package.
1541 xdr_callhdr(xdrs, chdr)
1543 struct rpc_msg *chdr;
1549 call header messages.
1550 This routine is useful for users who wish to generate
1552 messages without using the
1561 xdr_callmsg(xdrs, cmsg)
1563 struct rpc_msg *cmsg;
1570 This routine is useful for users who wish to generate
1572 messages without using the
1581 xdr_opaque_auth(xdrs, ap)
1583 struct opaque_auth *ap;
1589 authentication information messages.
1590 This routine is useful for users who wish to generate
1592 messages without using the
1601 xdr_pmap(xdrs, regs)
1607 Used for describing parameters to various
1609 procedures, externally.
1610 This routine is useful for users who wish to generate
1611 these parameters without using the
1620 xdr_pmaplist(xdrs, rp)
1622 struct pmaplist **rp;
1626 Used for describing a list of port mappings, externally.
1627 This routine is useful for users who wish to generate
1628 these parameters without using the
1637 xdr_rejected_reply(xdrs, rr)
1639 struct rejected_reply *rr;
1646 This routine is useful for users who wish to generate
1648 messages without using the
1657 xdr_replymsg(xdrs, rmsg)
1659 struct rpc_msg *rmsg;
1666 This routine is useful for users who wish to generate
1668 style messages without using the
1679 \s-1SVCXPRT\s0 *xprt;
1685 service transport handles are created,
1686 they should register themselves with the
1689 This routine modifies the global variable
1691 Service implementors usually do not need this routine.
1699 xprt_unregister(xprt)
1700 \s-1SVCXPRT\s0 *xprt;
1706 service transport handle is destroyed,
1707 it should unregister itself with the
1710 This routine modifies the global variable
1712 Service implementors usually do not need this routine.
1714 .BR rpc_secure (3N),
1717 The following manuals:
1720 Remote Procedure Calls: Protocol Specification
1722 Remote Procedure Call Programming Guide
1724 rpcgen Programming Guide
1728 .IR "\s-1RPC\s0: Remote Procedure Call Protocol Specification" ,
1729 .SM RFC1050, Sun Microsystems, Inc.,