xref: /netbsd-src/lib/libc/rpc/rpc_clnt_calls.3 (revision 347f995ceac2870f65de6f61bad07a6126df2d49)
17df0ccbaSfvdl.\" @(#)rpc_clnt_calls.3n 1.30 93/08/31 SMI; from SVr4
27df0ccbaSfvdl.\" Copyright 1989 AT&T
37df0ccbaSfvdl.\" @(#)rpc_clnt_calls 1.4 89/07/20 SMI;
47df0ccbaSfvdl.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
5*347f995cSyamt.\"	$NetBSD: rpc_clnt_calls.3,v 1.7 2005/12/03 15:16:19 yamt Exp $
6*347f995cSyamt.Dd December 4, 2005
77df0ccbaSfvdl.Dt RPC_CLNT_CALLS 3
87df0ccbaSfvdl.Os
97df0ccbaSfvdl.Sh NAME
107df0ccbaSfvdl.Nm rpc_clnt_calls ,
117df0ccbaSfvdl.Nm clnt_call ,
127df0ccbaSfvdl.Nm clnt_freeres ,
137df0ccbaSfvdl.Nm clnt_geterr ,
147df0ccbaSfvdl.Nm clnt_perrno ,
157df0ccbaSfvdl.Nm clnt_perror ,
167df0ccbaSfvdl.Nm clnt_sperrno ,
177df0ccbaSfvdl.Nm clnt_sperror ,
187df0ccbaSfvdl.Nm rpc_broadcast ,
197df0ccbaSfvdl.Nm rpc_broadcast_exp ,
207df0ccbaSfvdl.Nm rpc_call
217df0ccbaSfvdl.Nd library routines for client side calls
227df0ccbaSfvdl.Sh LIBRARY
237df0ccbaSfvdl.Lb libc
247df0ccbaSfvdl.Sh SYNOPSIS
25472351e1Swiz.In rpc/rpc.h
267df0ccbaSfvdl.Ft "enum clnt_stat"
27*347f995cSyamt.Fn clnt_call "CLIENT *clnt" "const rpcproc_t procnum" "const xdrproc_t inproc" "const char *in" "const xdrproc_t outproc" "caddr_t out" "const struct timeval tout"
287df0ccbaSfvdl.Ft bool_t
297df0ccbaSfvdl.Fn clnt_freeres "CLIENT *clnt" "const xdrproc_t outproc" "caddr_t out"
307df0ccbaSfvdl.Ft void
317df0ccbaSfvdl.Fn clnt_geterr "const CLIENT * clnt" "struct rpc_err * errp"
327df0ccbaSfvdl.Ft void
337df0ccbaSfvdl.Fn clnt_perrno "const enum clnt_stat stat"
347df0ccbaSfvdl.Ft void
357df0ccbaSfvdl.Fn clnt_perror "const CLIENT * clnt" "const char *s"
367df0ccbaSfvdl.Ft "char *"
377df0ccbaSfvdl.Fn clnt_sperrno "const enum clnt_stat stat"
387df0ccbaSfvdl.Ft "char *"
397df0ccbaSfvdl.Fn clnt_sperror "const CLIENT *clnt" "const char * s"
407df0ccbaSfvdl.\" Note the clustered Fn arguments. It can't take more than 9. XXX
417df0ccbaSfvdl.Ft "enum clnt_stat"
42*347f995cSyamt.Fn rpc_broadcast "const rpcprog_t prognum, const rpcvers_t versnum" "const rpcproc_t procnum" "const xdrproc_t inproc" "const char *in" "const xdrproc_t outproc" "caddr_t out" "const resultproc_t eachresult" "const char *nettype"
437df0ccbaSfvdl.Ft "enum clnt_stat"
447df0ccbaSfvdl.Fn rpc_broadcast_exp "rpcprog_t prognum, const rpcvers_t versnum" "const rpcproc_t procnum, const xdrproc_t xargs" "caddr_t argsp, const xdrproc_t xresults" "caddr_t resultsp" "const int inittime" "const int waittime" "const resultproc_t eachresult" "const char * nettype"
457df0ccbaSfvdl.Ft "enum clnt_stat"
467df0ccbaSfvdl.Fn rpc_call "const char *host, const rpcprog_t prognum" "const rpcvers_t versnum" "const rpcproc_t procnum, const xdrproc_t inproc" "const char *in" "const xdrproc_t outproc" "char *out" "const char *nettype"
477df0ccbaSfvdl.Sh DESCRIPTION
487df0ccbaSfvdlRPC library routines allow C language programs to make procedure
497df0ccbaSfvdlcalls on other machines across the network.
507df0ccbaSfvdlFirst, the client calls a procedure to send a request to the server.
517df0ccbaSfvdlUpon receipt of the request, the server calls a dispatch routine
527df0ccbaSfvdlto perform the requested service, and then sends back a reply.
537df0ccbaSfvdl.Pp
547df0ccbaSfvdlThe
557df0ccbaSfvdl.Fn clnt_call ,
567df0ccbaSfvdl.Fn rpc_call ,
577df0ccbaSfvdland
587df0ccbaSfvdl.Fn rpc_broadcast
597df0ccbaSfvdlroutines handle the client side of the procedure call.
607df0ccbaSfvdlThe remaining routines deal with error handling in the case of errors.
617df0ccbaSfvdl.Pp
627df0ccbaSfvdlSome of the routines take a
637df0ccbaSfvdl.Dv CLIENT
647df0ccbaSfvdlhandle as one of the parameters.
657df0ccbaSfvdlA
667df0ccbaSfvdl.Dv CLIENT
677df0ccbaSfvdlhandle can be created by an RPC creation routine such as
687df0ccbaSfvdl.Fn clnt_create
697df0ccbaSfvdl(see
707df0ccbaSfvdl.Xr rpc_clnt_create 3 ) .
717df0ccbaSfvdl.Pp
727df0ccbaSfvdlThese routines are safe for use in multithreaded applications.
737df0ccbaSfvdl.Dv CLIENT
747df0ccbaSfvdlhandles can be shared between threads, however in this implementation
757df0ccbaSfvdlrequests by different threads are serialized (that is, the first request will
767df0ccbaSfvdlreceive its results before the second request is sent).
77723dbf64Swiz.Sh ROUTINES
787df0ccbaSfvdlSee
797df0ccbaSfvdl.Xr rpc 3
807df0ccbaSfvdlfor the definition of the
817df0ccbaSfvdl.Dv CLIENT
827df0ccbaSfvdldata structure.
837df0ccbaSfvdl.Pp
847df0ccbaSfvdl.Bl -tag -width XXXXX
857df0ccbaSfvdl.It Fn clnt_call
867df0ccbaSfvdlA function macro that calls the remote procedure
877df0ccbaSfvdl.Fa procnum
887df0ccbaSfvdlassociated with the client handle,
897df0ccbaSfvdl.Fa clnt ,
907df0ccbaSfvdlwhich is obtained with an RPC
917df0ccbaSfvdlclient creation routine such as
927df0ccbaSfvdl.Fn clnt_create
937df0ccbaSfvdl(see
947df0ccbaSfvdl.Xr rpc_clnt_create 3 ) .
957df0ccbaSfvdlThe parameter
967df0ccbaSfvdl.Fn inproc
977df0ccbaSfvdlis the XDR function used to encode the procedure's parameters, and
987df0ccbaSfvdl.Fn outproc
997df0ccbaSfvdlis the XDR function used to decode the procedure's results;
1007df0ccbaSfvdl.Fn in
1017df0ccbaSfvdlis the address of the procedure's argument(s), and
1027df0ccbaSfvdl.Fn out
1037df0ccbaSfvdlis the address of where to place the result(s).
1047df0ccbaSfvdl.Fn tout
1057df0ccbaSfvdlis the time allowed for results to be returned, which is overridden by
1067df0ccbaSfvdla time-out set explicitly through
1077df0ccbaSfvdl.Fn clnt_control ,
1087df0ccbaSfvdlsee
1097df0ccbaSfvdl.Xr rpc_clnt_create 3 .
1107df0ccbaSfvdlIf the remote call succeeds, the status returned is
1117df0ccbaSfvdl.Dv RPC_SUCCESS ,
1127df0ccbaSfvdlotherwise an appropriate status is returned.
1137df0ccbaSfvdl.Pp
1147df0ccbaSfvdl.It Fn clnt_freeres
1157df0ccbaSfvdlA function macro that frees any data allocated by the
1167df0ccbaSfvdlRPC/XDR system when it decoded the results of an RPC call.
1177df0ccbaSfvdlThe parameter
1187df0ccbaSfvdl.Fa out
1197df0ccbaSfvdlis the address of the results, and
1207df0ccbaSfvdl.Fa outproc
1217df0ccbaSfvdlis the XDR routine describing the results.
1227df0ccbaSfvdlThis routine returns 1 if the results were successfully freed,
1237df0ccbaSfvdland 0 otherwise.
1247df0ccbaSfvdl.Pp
1257df0ccbaSfvdl.It Fn clnt_geterr
1267df0ccbaSfvdlA function macro that copies the error structure out of the client
1277df0ccbaSfvdlhandle to the structure at address
1287df0ccbaSfvdl.Fa errp .
1297df0ccbaSfvdl.Pp
1307df0ccbaSfvdl.It Fn clnt_perrno
1317df0ccbaSfvdlPrint a message to standard error corresponding
1327df0ccbaSfvdlto the condition indicated by
1337df0ccbaSfvdl.Fa stat .
1347df0ccbaSfvdlA newline is appended.
1357df0ccbaSfvdlNormally used after a procedure call fails for a routine
1367df0ccbaSfvdlfor which a client handle is not needed, for instance
1377df0ccbaSfvdl.Fn rpc_call .
1387df0ccbaSfvdl.Pp
1397df0ccbaSfvdl.It Fn clnt_perror
1407df0ccbaSfvdlPrint a message to the standard error indicating why an
1417df0ccbaSfvdlRPC call failed;
1427df0ccbaSfvdl.Fa clnt
1437df0ccbaSfvdlis the handle used to do the call.
1447df0ccbaSfvdlThe message is prepended with string
1457df0ccbaSfvdl.Fa s
1467df0ccbaSfvdland a colon.
1477df0ccbaSfvdlA newline is appended.
1487df0ccbaSfvdlNormally used after a remote procedure call fails
1497df0ccbaSfvdlfor a routine which requires a client handle,
1507df0ccbaSfvdlfor instance
1517df0ccbaSfvdl.Fn clnt_call .
1527df0ccbaSfvdl.Pp
1537df0ccbaSfvdl.It Fn clnt_sperrno
1547df0ccbaSfvdlTake the same arguments as
1557df0ccbaSfvdl.Fn clnt_perrno ,
1567df0ccbaSfvdlbut instead of sending a message to the standard error
1577df0ccbaSfvdlindicating why an RPC
1587df0ccbaSfvdlcall failed, return a pointer to a string which contains the message.
1597df0ccbaSfvdl.Fn clnt_sperrno
1607df0ccbaSfvdlis normally used instead of
1617df0ccbaSfvdl.Fn clnt_perrno
1627df0ccbaSfvdlwhen the program does not have a standard error (as a program
1637df0ccbaSfvdlrunning as a server quite likely does not), or if the programmer
1647df0ccbaSfvdldoes not want the message to be output with
1657df0ccbaSfvdl.Fn printf
1667df0ccbaSfvdl(see
1677df0ccbaSfvdl.Xr printf 3 ) ,
1687df0ccbaSfvdlor if a message format different than that supported by
1697df0ccbaSfvdl.Fn clnt_perrno
1707df0ccbaSfvdlis to be used.
1717df0ccbaSfvdlNote:
1727df0ccbaSfvdlunlike
1737df0ccbaSfvdl.Fn clnt_sperror
1747df0ccbaSfvdland
1757df0ccbaSfvdl.Fn clnt_spcreaterror
1767df0ccbaSfvdl(see
1777df0ccbaSfvdl.Xr rpc_clnt_create 3 ) ,
1787df0ccbaSfvdl.Fn clnt_sperrno
1797df0ccbaSfvdldoes not return pointer to static data so the
1807df0ccbaSfvdlresult will not get overwritten on each call.
1817df0ccbaSfvdl.Pp
1827df0ccbaSfvdl.It Fn clnt_sperror
1837df0ccbaSfvdlLike
1847df0ccbaSfvdl.Fn clnt_perror ,
1857df0ccbaSfvdlexcept that (like
1867df0ccbaSfvdl.Fn clnt_sperrno )
1877df0ccbaSfvdlit returns a string instead of printing to standard error.
1887df0ccbaSfvdlHowever,
1897df0ccbaSfvdl.Fn clnt_sperror
1907df0ccbaSfvdldoes not append a newline at the end of the message.
1917df0ccbaSfvdlWarning:
1927df0ccbaSfvdlreturns pointer to a buffer that is overwritten
1937df0ccbaSfvdlon each call.
1947df0ccbaSfvdl.Pp
1957df0ccbaSfvdl.It Fn rpc_broadcast
1967df0ccbaSfvdlLike
1977df0ccbaSfvdl.Fn rpc_call ,
1987df0ccbaSfvdlexcept the call message is broadcast to
1997df0ccbaSfvdlall the connectionless transports specified by
2007df0ccbaSfvdl.Fa nettype .
2017df0ccbaSfvdlIf
2027df0ccbaSfvdl.Fa nettype
2037df0ccbaSfvdlis
2047df0ccbaSfvdl.Dv NULL ,
205723dbf64Swizit defaults to
206723dbf64Swiz.Dq netpath .
2077df0ccbaSfvdlEach time it receives a response,
2087df0ccbaSfvdlthis routine calls
2097df0ccbaSfvdl.Fn eachresult ,
2107df0ccbaSfvdlwhose form is:
2117df0ccbaSfvdl.Ft bool_t
2127df0ccbaSfvdl.Fn eachresult "caddr_t out" "const struct netbuf * addr" "const struct netconfig * netconf"
2137df0ccbaSfvdlwhere
2147df0ccbaSfvdl.Fa out
2157df0ccbaSfvdlis the same as
2167df0ccbaSfvdl.Fa out
2177df0ccbaSfvdlpassed to
2187df0ccbaSfvdl.Fn rpc_broadcast ,
2197df0ccbaSfvdlexcept that the remote procedure's output is decoded there;
2207df0ccbaSfvdl.Fa addr
2217df0ccbaSfvdlpoints to the address of the machine that sent the results, and
2227df0ccbaSfvdl.Fa netconf
2237df0ccbaSfvdlis the netconfig structure of the transport on which the remote
2247df0ccbaSfvdlserver responded.
2257df0ccbaSfvdlIf
2267df0ccbaSfvdl.Fn eachresult
2277df0ccbaSfvdlreturns 0,
2287df0ccbaSfvdl.Fn rpc_broadcast
2297df0ccbaSfvdlwaits for more replies;
2307df0ccbaSfvdlotherwise it returns with appropriate status.
2317df0ccbaSfvdlWarning:
2327df0ccbaSfvdlbroadcast file descriptors are limited in size to the
2337df0ccbaSfvdlmaximum transfer size of that transport.
2347df0ccbaSfvdlFor Ethernet, this value is 1500 bytes.
2357df0ccbaSfvdl.Fn rpc_broadcast
2367df0ccbaSfvdluses
2377df0ccbaSfvdl.Dv AUTH_SYS
2387df0ccbaSfvdlcredentials by default (see
2397df0ccbaSfvdl.Xr rpc_clnt_auth 3 ) .
2407df0ccbaSfvdl.Pp
2417df0ccbaSfvdl.It Fn rpc_broadcast_exp
2427df0ccbaSfvdlLike
2437df0ccbaSfvdl.Fn rpc_broadcast ,
2447df0ccbaSfvdlexcept that the initial timeout,
2457df0ccbaSfvdl.Fa inittime
2467df0ccbaSfvdland the maximum timeout,
2477df0ccbaSfvdl.Fa waittime
2487df0ccbaSfvdlare specified in milliseconds.
2497df0ccbaSfvdl.Fa inittime
2507df0ccbaSfvdlis the initial time that
2517df0ccbaSfvdl.Fn rpc_broadcast_exp
2527df0ccbaSfvdlwaits before resending the request.
2537df0ccbaSfvdlAfter the first resend, the re-transmission interval
2547df0ccbaSfvdlincreases exponentially until it exceeds
2557df0ccbaSfvdl.Fa waittime .
2567df0ccbaSfvdl.Pp
2577df0ccbaSfvdl.It Fn rpc_call
2587df0ccbaSfvdlCall the remote procedure associated with
2597df0ccbaSfvdl.Fa prognum ,
2607df0ccbaSfvdl.Fa versnum ,
2617df0ccbaSfvdland
2627df0ccbaSfvdl.Fa procnum
2637df0ccbaSfvdlon the machine,
2647df0ccbaSfvdl.Fa host .
2657df0ccbaSfvdlThe parameter
2667df0ccbaSfvdl.Fa inproc
2677df0ccbaSfvdlis used to encode the procedure's parameters, and
2687df0ccbaSfvdl.Fa outproc
2697df0ccbaSfvdlis used to decode the procedure's results;
2707df0ccbaSfvdl.Fa in
2717df0ccbaSfvdlis the address of the procedure's argument(s), and
2727df0ccbaSfvdl.Fa out
2737df0ccbaSfvdlis the address of where to place the result(s).
2747df0ccbaSfvdl.Fa nettype
2757df0ccbaSfvdlcan be any of the values listed on
2767df0ccbaSfvdl.Xr rpc 3 .
2777df0ccbaSfvdlThis routine returns
278723dbf64Swiz.Dv RPC_SUCCESS
279723dbf64Swizif it succeeds, or an appropriate status is returned.
2807df0ccbaSfvdlUse the
2817df0ccbaSfvdl.Fn clnt_perrno
2827df0ccbaSfvdlroutine to translate failure status into error messages.
2837df0ccbaSfvdlWarning:
2847df0ccbaSfvdl.Fn rpc_call
2857df0ccbaSfvdluses the first available transport belonging
2867df0ccbaSfvdlto the class
2877df0ccbaSfvdl.Fa nettype ,
2887df0ccbaSfvdlon which it can create a connection.
2897df0ccbaSfvdlYou do not have control of timeouts or authentication
2907df0ccbaSfvdlusing this routine.
2917df0ccbaSfvdl.El
2927df0ccbaSfvdl.Sh SEE ALSO
2937df0ccbaSfvdl.Xr printf 3 ,
2947df0ccbaSfvdl.Xr rpc 3 ,
2957df0ccbaSfvdl.Xr rpc_clnt_auth 3 ,
2967df0ccbaSfvdl.Xr rpc_clnt_create 3
297