1 .\" @(#)rpc.3n 2.4 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI
4 .TH RPC 3 "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
45 is undefined after calling
46 .BR auth_destroy(\|) .
60 authentication handle that passes nonusable authentication
61 information with each remote procedure call.
63 default authentication used by
71 authunix_create(host, uid, gid, len, aup_gids)
73 int uid, gid, len, *aup.gids;
79 authentication handle that contains
81 authentication information.
84 is the name of the machine on which the information was
90 is the user's current group
95 refer to a counted array of groups to which the user belongs.
96 It is easy to impersonate a user.
104 authunix_create_default(\|)
109 .B authunix_create(\|)
110 with the appropriate parameters.
117 callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
119 u_long prognum, versnum, procnum;
121 xdrproc_t inproc, outproc;
125 Call the remote procedure associated with
134 is the address of the procedure's argument(s), and
136 is the address of where to place the result(s);
138 is used to encode the procedure's parameters, and
140 is used to decode the procedure's results.
141 This routine returns zero if it succeeds, or the value of
143 cast to an integer if it fails.
146 is handy for translating failure statuses into messages.
148 Warning: calling remote procedures with this routine
152 .B clntudp_create(\|)
154 You do not have control of timeouts or authentication using
163 clnt_broadcast(prognum, versnum, procnum, inproc, in, outproc, out, eachresult)
164 u_long prognum, versnum, procnum;
166 xdrproc_t inproc, outproc;
167 resultproc_t eachresult;
173 except the call message is broadcast to all locally
174 connected broadcast nets.
175 Each time it receives a
176 response, this routine calls
183 eachresult(out, addr)
185 struct sockaddr_in *addr;
195 .BR clnt_broadcast(\|) ,
196 except that the remote procedure's output is decoded there;
198 points to the address of the machine that sent the results.
202 .B clnt_broadcast(\|)
203 waits for more replies; otherwise it returns with appropriate
206 Warning: broadcast sockets are limited in size to the
207 maximum transfer unit of the data link.
209 this value is 1500 bytes.
217 clnt_call(clnt, procnum, inproc, in, outproc, out, tout)
221 xdrproc_t inproc, outproc;
227 A macro that calls the remote procedure
229 associated with the client handle,
231 which is obtained with an
233 client creation routine such as
234 .BR clnt_create(\|) .
237 is the address of the procedure's argument(s), and
239 is the address of where to place the result(s);
241 is used to encode the procedure's parameters, and
243 is used to decode the procedure's results;
245 is the time allowed for results to come back.
257 A macro that destroys the client's
260 Destruction usually involves deallocation
261 of private data structures, including
265 is undefined after calling
266 .BR clnt_destroy(\|) .
269 library opened the associated socket, it will close it also.
270 Otherwise, the socket remains open.
278 clnt_create(host, prog, vers, proto)
285 Generic client creation routine.
287 identifies the name of the remote host where the server
290 indicates which kind of transport protocol to use.
292 currently supported values for this field are \(lqudp\(rq
294 Default timeouts are set, but can be modified using
295 .BR clnt_control(\|) .
299 has its shortcomings. Since
302 messages can only hold up to 8 Kbytes of encoded data,
303 this transport cannot be used for procedures that take
304 large arguments or return huge results.
312 clnt_control(cl, req, info)
319 A macro used to change or retrieve various information
320 about a client object.
322 indicates the type of operation, and
324 is a pointer to the information.
329 the supported values of
331 and their argument types and what they do are:
334 .ta +2.0i +2.0i +2.0i
335 .SM CLSET_TIMEOUT\s0 struct timeval set total timeout
336 .SM CLGET_TIMEOUT\s0 struct timeval get total timeout
339 Note: if you set the timeout using
340 .BR clnt_control(\|) ,
341 the timeout parameter passed to
343 will be ignored in all future calls.
346 .SM CLGET_SERVER_ADDR\s0 struct sockaddr_in get server's address
350 The following operations are valid for
355 .ta +2.0i ; +2.0i ; +2.0i
356 .SM CLSET_RETRY_TIMEOUT\s0 struct timeval set the retry timeout
357 .SM CLGET_RETRY_TIMEOUT\s0 struct timeval get the retry timeout
361 The retry timeout is the time that
363 waits for the server to reply before
364 retransmitting the request.
371 clnt_freeres(clnt, outproc, out)
378 A macro that frees any data allocated by the
380 system when it decoded the results of an
385 is the address of the results, and
389 routine describing the results.
390 This routine returns one if the results were successfully
400 clnt_geterr(clnt, errp)
402 struct rpc_err *errp;
406 A macro that copies the error structure out of the client
408 to the structure at address
422 Print a message to standard error indicating
425 handle could not be created.
426 The message is prepended with string
430 .BR clnt_create(\|) ,
431 .BR clntraw_create(\|) ,
432 .BR clnttcp_create(\|) ,
434 .B clntudp_create(\|)
448 Print a message to standard error corresponding
449 to the condition indicated by
465 Print a message to standard error indicating why an
469 is the handle used to do the call.
470 The message is prepended with string
488 .BR clnt_pcreateerror(\|) ,
489 except that it returns a string
490 instead of printing to the standard error.
492 Bugs: returns pointer to static data that is overwritten
506 Take the same arguments as
507 .BR clnt_perrno(\|) ,
508 but instead of sending a message to the standard error
511 call failed, return a pointer to a string which contains
512 the message. The string ends with a
518 if the program does not have a standard error (as a program
519 running as a server quite likely does not), or if the
521 does not want the message to be output with
523 or if a message format different from that supported by
529 .BR clnt_spcreaterror(\|) ,
531 returns pointer to static data, but the
532 result will not get overwritten on each call.
540 clnt_sperror(rpch, s)
547 .BR clnt_perror(\|) ,
549 .BR clnt_sperrno(\|) )
550 it returns a string instead of printing to standard error.
552 Bugs: returns pointer to static data that is overwritten
561 clntraw_create(prognum, versnum)
562 u_long prognum, versnum;
566 This routine creates a toy
568 client for the remote program
572 The transport used to pass messages to the service is
573 actually a buffer within the process's address space, so the
576 server should live in the same address space; see
577 .BR svcraw_create(\|) .
578 This allows simulation of
582 overheads, such as round trip times, without any
594 clnttcp_create(addr, prognum, versnum, sockp, sendsz, recvsz)
595 struct sockaddr_in *addr;
596 u_long prognum, versnum;
598 u_int sendsz, recvsz;
602 This routine creates an
604 client for the remote program
611 The remote program is located at Internet
615 .\"The following in-line font conversion is necessary for the hyphen indicator
616 \fB\%addr\->sin_port\fR
617 is zero, then it is set to the actual port that the remote
618 program is listening on (the remote
620 service is consulted for this information). The parameter
622 is a socket; if it is
623 .BR \s-1RPC_ANYSOCK\s0 ,
624 then this routine opens a new one and sets
631 the user may specify the size of the send and receive buffers
636 values of zero choose suitable defaults.
647 clntudp_create(addr, prognum, versnum, wait, sockp)
648 struct sockaddr_in *addr;
649 u_long prognum, versnum;
655 This routine creates an
657 client for the remote program
664 The remote program is located at Internet
668 \fB\%addr\->sin_port\fR
669 is zero, then it is set to actual port that the remote
670 program is listening on (the remote
672 service is consulted for this information). The parameter
674 is a socket; if it is
675 .BR \s-1RPC_ANYSOCK\s0 ,
676 then this routine opens a new one and sets
680 transport resends the call message in intervals of
682 time until a response is received or until the call times
684 The total time for the call to time out is specified by
690 messages can only hold up to 8 Kbytes
691 of encoded data, this transport cannot be used for procedures
692 that take large arguments or return huge results.
700 clntudp_bufcreate(addr, prognum, versnum, wait, sockp, sendsize, recosize)
701 struct sockaddr_in *addr;
702 u_long prognum, versnum;
705 unsigned int sendsize;
706 unsigned int recosize;
710 This routine creates an
712 client for the remote program
719 The remote program is located at Internet
723 \fB\%addr\->sin_port\fR
724 is zero, then it is set to actual port that the remote
725 program is listening on (the remote
727 service is consulted for this information). The parameter
729 is a socket; if it is
730 .BR \s-1RPC_ANYSOCK\s0 ,
731 then this routine opens a new one and sets
735 transport resends the call message in intervals of
737 time until a response is received or until the call times
739 The total time for the call to time out is specified by
742 This allows the user to specify the maximum packet size for sending and receiving
754 struct sockaddr_in *addr;
762 without consulting the library routines that deal with
764 The port number is always set to
765 .BR htons(\s-1PMAPPORT\s0) .
766 Returns zero on success, non-zero on failure.
775 struct sockaddr_in *addr;
779 A user interface to the
781 service, which returns a list of the current
783 program-to-port mappings
784 on the host located at
788 This routine can return
791 .RB ` "rpcinfo \-p" '
800 pmap_getport(addr, prognum, versnum, protocol)
801 struct sockaddr_in *addr;
802 u_long prognum, versnum, protocol;
806 A user interface to the
808 service, which returns the port number
809 on which waits a service that supports program number
813 and speaks the transport protocol associated with
821 .BR \s-1IPPROTO_TCP\s0 .
822 A return value of zero means that the mapping does not exist
826 system failed to contact the remote
828 service. In the latter case, the global variable
840 pmap_rmtcall(addr, prognum, versnum, procnum, inproc, in, outproc, out, tout, portp)
841 struct sockaddr_in *addr;
842 u_long prognum, versnum, procnum;
844 xdrproc_t inproc, outproc;
850 A user interface to the
852 service, which instructs
860 call on your behalf to a procedure on that host.
863 will be modified to the program's port number if the
866 The definitions of other parameters are discussed
871 This procedure should be used for a \(lqping\(rq and nothing
874 .BR clnt_broadcast(\|) .
881 pmap_set(prognum, versnum, protocol, port)
882 u_long prognum, versnum, protocol;
887 A user interface to the
889 service, which establishes a mapping between the triple
890 .RI [ prognum , versnum , protocol\fR]
902 .BR \s-1IPPROTO_TCP\s0 .
903 This routine returns one if it succeeds, zero otherwise.
904 Automatically done by
905 .BR svc_register(\|) .
912 pmap_unset(prognum, versnum)
913 u_long prognum, versnum;
917 A user interface to the
919 service, which destroys all mapping between the triple
920 .RI [ prognum , versnum , *\fR]
926 This routine returns one if it succeeds, zero
934 registerrpc(prognum, versnum, procnum, procname, inproc, outproc)
935 u_long prognum, versnum, procnum;
936 char *(*procname) (\|) ;
937 xdrproc_t inproc, outproc;
945 service package. If a request arrives for program
952 is called with a pointer to its parameter(s);
954 should return a pointer to its static result(s);
956 is used to decode the parameters while
958 is used to encode the results.
959 This routine returns zero if the registration succeeded, \-1
962 Warning: remote procedures registered in this form
963 are accessed using the
974 struct rpc_createerr rpc_createerr;
978 A global variable whose value is set by any
980 client creation routine
981 that does not succeed. Use the routine
982 .B clnt_pcreateerror(\|)
983 to print the reason why.
995 A macro that destroys the
997 service transport handle,
999 Destruction usually involves deallocation
1000 of private data structures, including
1004 is undefined after calling this routine.
1015 A global variable reflecting the
1018 read file descriptor bit mask; it is suitable as a template parameter
1022 This is only of interest
1023 if a service implementor does not call
1025 but rather does his own asynchronous event processing.
1026 This variable is read-only (do not pass its address to
1028 yet it may change after calls to
1029 .B svc_getreqset(\|)
1030 or any creation routines.
1032 As well, note that if the process has descriptor limits
1033 which are extended beyond
1035 this variable will only be usable for the first
1049 .BR svc_fedset(\|) ,
1050 but limited to 32 descriptors.
1052 interface is obsoleted by
1060 svc_freeargs(xprt, inproc, in)
1061 \s-1SVCXPRT\s0 *xprt;
1067 A macro that frees any data allocated by the
1069 system when it decoded the arguments to a service procedure
1071 .BR svc_getargs(\|) .
1072 This routine returns 1 if the results were successfully
1081 svc_getargs(xprt, inproc, in)
1082 \s-1SVCXPRT\s0 *xprt;
1088 A macro that decodes the arguments of an
1093 service transport handle,
1097 is the address where the arguments will be placed;
1101 routine used to decode the arguments.
1102 This routine returns one if decoding succeeds, and zero
1110 struct sockaddr_in *
1112 \s-1SVCXPRT\s0 *xprt;
1116 The approved way of getting the network address of the caller
1117 of a procedure associated with the
1119 service transport handle,
1127 svc_getreqset(rdfds)
1132 This routine is only of interest if a service implementor
1135 but instead implements custom asynchronous event processing.
1136 It is called when the
1138 system call has determined that an
1140 request has arrived on some
1144 is the resultant read file descriptor bit mask.
1145 The routine returns when all sockets associated with the
1161 .BR svc_getreqset(\|) ,
1162 but limited to 32 descriptors.
1163 This interface is obsoleted by
1164 .BR svc_getreqset(\|) .
1171 svc_register(xprt, prognum, versnum, dispatch, protocol)
1172 \s-1SVCXPRT\s0 *xprt;
1173 u_long prognum, versnum;
1174 void (*dispatch) (\|);
1183 with the service dispatch procedure,
1187 is zero, the service is not registered with the
1191 is non-zero, then a mapping of the triple
1192 .RI [ prognum , versnum , protocol\fR]
1194 \fB\%xprt\->xp_port\fR
1195 is established with the local
1208 has the following form:
1212 dispatch(request, xprt)
1213 struct svc_req *request;
1214 \s-1SVCXPRT\s0 *xprt;
1221 routine returns one if it succeeds, and zero otherwise.
1232 This routine never returns.
1235 requests to arrive, and calls the appropriate service
1239 This procedure is usually waiting for a
1241 system call to return.
1248 svc_sendreply(xprt, outproc, out)
1249 \s-1SVCXPRT\s0 *xprt;
1257 service's dispatch routine to send the results of a
1258 remote procedure call. The parameter
1260 is the request's associated transport handle;
1264 routine which is used to encode the results; and
1266 is the address of the results.
1267 This routine returns one if it succeeds, zero otherwise.
1275 svc_unregister(prognum, versnum)
1276 u_long prognum, versnum;
1280 Remove all mapping of the double
1281 .RI [ prognum , versnum ]
1282 to dispatch routines, and of the triple
1283 .RI [ prognum , versnum , *\fR]
1292 svcerr_auth(xprt, why)
1293 \s-1SVCXPRT\s0 *xprt;
1298 Called by a service dispatch routine that refuses to perform
1299 a remote procedure call due to an authentication error.
1308 \s-1SVCXPRT\s0 *xprt;
1312 Called by a service dispatch routine that cannot successfully
1313 decode its parameters.
1315 .BR svc_getargs(\|) .
1324 \s-1SVCXPRT\s0 *xprt;
1328 Called by a service dispatch routine that does not implement
1329 the procedure number that the caller requests.
1338 \s-1SVCXPRT\s0 *xprt;
1342 Called when the desired program is not registered with the
1345 Service implementors usually do not need this routine.
1353 svcerr_progvers(xprt)
1354 \s-1SVCXPRT\s0 *xprt;
1358 Called when the desired version of a program is not registered
1362 Service implementors usually do not need this routine.
1370 svcerr_systemerr(xprt)
1371 \s-1SVCXPRT\s0 *xprt;
1375 Called by a service dispatch routine when it detects a system
1377 not covered by any particular protocol.
1378 For example, if a service can no longer allocate storage,
1379 it may call this routine.
1387 svcerr_weakauth(xprt)
1388 \s-1SVCXPRT\s0 *xprt;
1392 Called by a service dispatch routine that refuses to perform
1393 a remote procedure call due to insufficient
1394 authentication parameters. The routine calls
1395 .BR "svcerr_auth(xprt, \s-1AUTH_TOOWEAK\s0)" .
1407 This routine creates a toy
1409 service transport, to which it returns a pointer. The
1411 is really a buffer within the process's address space,
1412 so the corresponding
1414 client should live in the same
1417 .BR clntraw_create(\|) .
1418 This routine allows simulation of
1422 overheads (such as round trip times), without any kernel
1424 This routine returns
1434 svctcp_create(sock, send_buf_size, recv_buf_size)
1436 u_int send_buf_size, recv_buf_size;
1440 This routine creates a
1443 service transport, to which it returns a pointer.
1444 The transport is associated with the socket
1447 .BR \s-1RPC_ANYSOCK\s0 ,
1448 in which case a new socket is created.
1449 If the socket is not bound to a local
1451 port, then this routine binds it to an arbitrary port. Upon
1453 \fB\%xprt\->xp_sock\fR
1454 is the transport's socket descriptor, and
1455 \fB\%xprt\->xp_port\fR
1456 is the transport's port number.
1457 This routine returns
1465 users may specify the size of buffers; values of zero
1466 choose suitable defaults.
1474 svcfd_create(fd, sendsize, recvsize)
1481 Create a service on top of any open descriptor.
1484 descriptor is a connected socket for a stream protocol such
1490 indicate sizes for the send and receive buffers. If they are
1491 zero, a reasonable default is chosen.
1499 svcudp_bufcreate(sock, sendsize, recosize)
1504 This routine creates a
1507 service transport, to which it returns a pointer.
1508 The transport is associated with the socket
1511 .B \s-1RPC_ANYSOCK\s0 ,
1512 in which case a new socket is created.
1513 If the socket is not bound to a local
1515 port, then this routine binds it to an arbitrary port.
1518 \fB\%xprt\->xp_sock\fR
1519 is the transport's socket descriptor, and
1520 \fB\%xprt\->xp_port\fR
1521 is the transport's port number.
1522 This routine returns
1526 This allows the user to specify the maximum packet size for sending and
1536 xdr_accepted_reply(xdrs, ar)
1538 struct accepted_reply *ar;
1545 This routine is useful for users who
1548 messages without using the
1557 xdr_authunix_parms(xdrs, aupp)
1559 struct authunix_parms *aupp;
1566 This routine is useful for users
1567 who wish to generate these credentials without using the
1569 authentication package.
1577 xdr_callhdr(xdrs, chdr)
1579 struct rpc_msg *chdr;
1585 call header messages.
1586 This routine is useful for users who wish to generate
1588 messages without using the
1597 xdr_callmsg(xdrs, cmsg)
1599 struct rpc_msg *cmsg;
1606 This routine is useful for users who wish to generate
1608 messages without using the
1617 xdr_opaque_auth(xdrs, ap)
1619 struct opaque_auth *ap;
1625 authentication information messages.
1626 This routine is useful for users who wish to generate
1628 messages without using the
1637 xdr_pmap(xdrs, regs)
1643 Used for describing parameters to various
1645 procedures, externally.
1646 This routine is useful for users who wish to generate
1647 these parameters without using the
1656 xdr_pmaplist(xdrs, rp)
1658 struct pmaplist **rp;
1662 Used for describing a list of port mappings, externally.
1663 This routine is useful for users who wish to generate
1664 these parameters without using the
1673 xdr_rejected_reply(xdrs, rr)
1675 struct rejected_reply *rr;
1682 This routine is useful for users who wish to generate
1684 messages without using the
1693 xdr_replymsg(xdrs, rmsg)
1695 struct rpc_msg *rmsg;
1702 This routine is useful for users who wish to generate
1704 style messages without using the
1715 \s-1SVCXPRT\s0 *xprt;
1721 service transport handles are created,
1722 they should register themselves with the
1725 This routine modifies the global variable
1727 Service implementors usually do not need this routine.
1735 xprt_unregister(xprt)
1736 \s-1SVCXPRT\s0 *xprt;
1742 service transport handle is destroyed,
1743 it should unregister itself with the
1746 This routine modifies the global variable
1748 Service implementors usually do not need this routine.
1753 The following manuals:
1756 Remote Procedure Calls: Protocol Specification
1758 Remote Procedure Call Programming Guide
1760 rpcgen Programming Guide
1764 .IR "\s-1RPC\s0: Remote Procedure Call Protocol Specification" ,
1765 .SM RFC1050, Sun Microsystems, Inc.,