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