]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/rpc.3
system.3: ffix
[thirdparty/man-pages.git] / man3 / rpc.3
CommitLineData
2297bf0e
MK
1.\" This page was taken from the 4.4BSD-Lite CDROM (BSD license)
2.\"
6d1cd1d7 3.\" %%%LICENSE_START(BSD_ONELINE_CDROM)
cc3832e9 4.\" This page was taken from the 4.4BSD-Lite CDROM (BSD license)
8ff7380d 5.\" %%%LICENSE_END
cc3832e9 6.\"
fea681da 7.\" @(#)rpc.3n 2.4 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI
e5d79c81 8.\"
9a06b299 9.\" 2007-12-30, mtk, Convert function prototypes to modern C syntax
e5d79c81 10.\"
4b8c67d9 11.TH RPC 3 2017-09-15 "" "Linux Programmer's Manual"
fea681da
MK
12.SH NAME
13rpc \- library routines for remote procedure calls
47297adb 14.SH SYNOPSIS AND DESCRIPTION
fea681da
MK
15These routines allow C programs to make procedure
16calls on other machines across the network.
9a06b299 17First, the client calls a procedure to send a data packet to the server.
fea681da 18Upon receipt of the packet, the server calls a dispatch routine
9a06b299 19to perform the requested service, and then sends back a reply.
fea681da 20Finally, the procedure call returns to the client.
57734e82 21.\" .LP
9a06b299 22.\" We don't have an rpc_secure.3 page at the moment -- MTK, 19 Sep 05
57734e82
MK
23.\" Routines that are used for Secure RPC (DES authentication) are described in
24.\" .BR rpc_secure (3).
25.\" Secure RPC can be used only if DES encryption is available.
dd3568a1 26.PP
9a06b299
MK
27To take use of these routines, include the header file
28.IR "<rpc/rpc.h>" .
633af52d 29
9a06b299 30The prototypes below make use of the following types:
dbfe9c70 31.PP
9a06b299 32.in +4n
b8302363 33.EX
a2ce40b6 34.BI "typedef int " bool_t ;
dbfe9c70 35.PP
a2ce40b6 36.BI "typedef bool_t (*" xdrproc_t ") (XDR *, void *, ...);"
dbfe9c70 37.PP
a2ce40b6
MK
38.BI "typedef bool_t (*" resultproc_t ") (caddr_t " resp ,
39.BI " struct sockaddr_in *" raddr );
b8302363 40.EE
633af52d 41.in
dd3568a1 42.PP
9a06b299
MK
43See the header files for the declarations of the
44.IR AUTH ,
45.IR CLIENT ,
46.IR SVCXPRT ,
47and
48.IR XDR
49types.
dd3568a1 50.PP
fea681da 51.nf
9a06b299 52.BI "void auth_destroy(AUTH *" auth );
fea681da 53.fi
fea681da
MK
54.IP
55A macro that destroys the authentication information associated with
56.IR auth .
9a06b299 57Destruction usually involves deallocation of private data structures.
c13182ef 58The use of
fea681da
MK
59.I auth
60is undefined after calling
63aa9df0 61.BR auth_destroy ().
dd3568a1 62.PP
fea681da 63.nf
9a06b299 64.BI "AUTH *authnone_create(void);"
fea681da 65.fi
fea681da 66.IP
9a06b299 67Create and return an RPC
24b74457 68authentication handle that passes nonusable authentication
c13182ef 69information with each remote procedure call.
9a06b299 70This is the default authentication used by RPC.
dd3568a1 71.PP
fea681da 72.nf
9a06b299
MK
73.BI "AUTH *authunix_create(char *" host ", int " uid ", int " gid ,
74.BI " int " len ", int *" aup_gids );
fea681da 75.fi
fea681da 76.IP
9a06b299 77Create and return an RPC authentication handle that contains
fea681da
MK
78authentication information.
79The parameter
80.I host
9a06b299 81is the name of the machine on which the information was created;
fea681da 82.I uid
9a06b299 83is the user's user ID;
fea681da 84.I gid
9a06b299 85is the user's current group ID;
fea681da
MK
86.I len
87and
88.I aup_gids
89refer to a counted array of groups to which the user belongs.
90It is easy to impersonate a user.
dd3568a1 91.PP
fea681da 92.nf
9a06b299 93.BI "AUTH *authunix_create_default(void);"
fea681da 94.fi
fea681da
MK
95.IP
96Calls
63aa9df0 97.BR authunix_create ()
fea681da 98with the appropriate parameters.
dd3568a1 99.PP
fea681da 100.nf
a49d636c 101.BI "int callrpc(char *" host ", unsigned long " prognum ,
9a06b299 102.BI " unsigned long " versnum ", unsigned long " procnum ,
39a22d92
MK
103.BI " xdrproc_t " inproc ", char *" in ,
104.BI " xdrproc_t " outproc ", char *" out );
fea681da 105.fi
fea681da
MK
106.IP
107Call the remote procedure associated with
108.IR prognum ,
109.IR versnum ,
110and
111.I procnum
112on the machine,
113.IR host .
114The parameter
115.I in
116is the address of the procedure's argument(s), and
117.I out
118is the address of where to place the result(s);
119.I inproc
120is used to encode the procedure's parameters, and
121.I outproc
122is used to decode the procedure's results.
123This routine returns zero if it succeeds, or the value of
124.B "enum clnt_stat"
125cast to an integer if it fails.
126The routine
63aa9df0 127.BR clnt_perrno ()
fea681da
MK
128is handy for translating failure statuses into messages.
129.IP
130Warning: calling remote procedures with this routine
9a06b299 131uses UDP/IP as a transport; see
63aa9df0 132.BR clntudp_create ()
fea681da 133for restrictions.
9a06b299 134You do not have control of timeouts or authentication using this routine.
dd3568a1 135.PP
fea681da 136.nf
9a06b299
MK
137.BI "enum clnt_stat clnt_broadcast(unsigned long " prognum ,
138.BI " unsigned long " versnum ", unsigned long " procnum ,
39a22d92
MK
139.BI " xdrproc_t " inproc ", char *" in ,
140.BI " xdrproc_t " outproc ", char *" out ,
9a06b299 141.BI " resultproc_t " eachresult );
fea681da 142.fi
fea681da
MK
143.IP
144Like
63aa9df0 145.BR callrpc (),
fea681da 146except the call message is broadcast to all locally
c13182ef 147connected broadcast nets.
9a06b299 148Each time it receives a response, this routine calls
63aa9df0 149.BR eachresult (),
fea681da
MK
150whose form is:
151.IP
9a06b299 152.in +4n
b8302363 153.EX
9a06b299 154.BI "eachresult(char *" out ", struct sockaddr_in *" addr );
b8302363 155.EE
9a06b299 156.in
fea681da
MK
157.IP
158where
159.I out
160is the same as
161.I out
162passed to
63aa9df0 163.BR clnt_broadcast (),
fea681da
MK
164except that the remote procedure's output is decoded there;
165.I addr
166points to the address of the machine that sent the results.
167If
63aa9df0 168.BR eachresult ()
fea681da 169returns zero,
63aa9df0 170.BR clnt_broadcast ()
9a06b299 171waits for more replies; otherwise it returns with appropriate status.
fea681da
MK
172.IP
173Warning: broadcast sockets are limited in size to the
c13182ef 174maximum transfer unit of the data link.
9a06b299 175For ethernet, this value is 1500 bytes.
dd3568a1 176.PP
fea681da 177.nf
9a06b299 178.BI "enum clnt_stat clnt_call(CLIENT *" clnt ", unsigned long " procnum ,
39a22d92
MK
179.BI " xdrproc_t " inproc ", char *" in ,
180.BI " xdrproc_t " outproc ", char *" out ,
181.BI " struct timeval " tout );
fea681da 182.fi
fea681da
MK
183.IP
184A macro that calls the remote procedure
185.I procnum
186associated with the client handle,
187.IR clnt ,
9a06b299 188which is obtained with an RPC client creation routine such as
63aa9df0 189.BR clnt_create ().
fea681da
MK
190The parameter
191.I in
192is the address of the procedure's argument(s), and
193.I out
194is the address of where to place the result(s);
195.I inproc
196is used to encode the procedure's parameters, and
197.I outproc
198is used to decode the procedure's results;
199.I tout
200is the time allowed for results to come back.
dd3568a1 201.PP
fea681da 202.nf
9a06b299 203.BI "clnt_destroy(CLIENT *" clnt );
fea681da 204.fi
fea681da 205.IP
9a06b299 206A macro that destroys the client's RPC handle.
c13182ef 207Destruction usually involves deallocation
fea681da
MK
208of private data structures, including
209.I clnt
c13182ef
MK
210itself.
211Use of
fea681da
MK
212.I clnt
213is undefined after calling
63aa9df0 214.BR clnt_destroy ().
9a06b299 215If the RPC library opened the associated socket, it will close it also.
fea681da 216Otherwise, the socket remains open.
dd3568a1 217.PP
fea681da 218.nf
9a06b299
MK
219.BI "CLIENT *clnt_create(char *" host ", unsigned long " prog ,
220.BI " unsigned long " vers ", char *" proto );
fea681da 221.fi
fea681da
MK
222.IP
223Generic client creation routine.
224.I host
9a06b299 225identifies the name of the remote host where the server is located.
fea681da 226.I proto
c13182ef
MK
227indicates which kind of transport protocol to use.
228The currently supported values for this field are \(lqudp\(rq
fea681da
MK
229and \(lqtcp\(rq.
230Default timeouts are set, but can be modified using
63aa9df0 231.BR clnt_control ().
fea681da 232.IP
f64cc745 233Warning: using UDP has its shortcomings.
33a0ccb2 234Since UDP-based RPC messages can hold only up to 8 Kbytes of encoded data,
fea681da
MK
235this transport cannot be used for procedures that take
236large arguments or return huge results.
dd3568a1 237.PP
fea681da 238.nf
9a06b299 239.BI "bool_t clnt_control(CLIENT *" cl ", int " req ", char *" info );
fea681da 240.fi
fea681da
MK
241.IP
242A macro used to change or retrieve various information
243about a client object.
244.I req
245indicates the type of operation, and
246.I info
c13182ef 247is a pointer to the information.
9a06b299 248For both UDP and TCP, the supported values of
fea681da
MK
249.I req
250and their argument types and what they do are:
251.IP
bf337635 252.in +4n
b8302363 253.EX
9a06b299
MK
254\fBCLSET_TIMEOUT\fP \fIstruct timeval\fP // set total timeout
255\fBCLGET_TIMEOUT\fP \fIstruct timeval\fP // get total timeout
b8302363 256.EE
bf337635 257.in
fea681da
MK
258.IP
259Note: if you set the timeout using
63aa9df0 260.BR clnt_control (),
fea681da 261the timeout parameter passed to
63aa9df0 262.BR clnt_call ()
fea681da
MK
263will be ignored in all future calls.
264.IP
bf337635 265.in +4n
b8302363 266.EX
9a06b299 267\fBCLGET_SERVER_ADDR\fP \fIstruct sockaddr_in \fP // get server's address
b8302363 268.EE
bf337635 269.in
fea681da 270.IP
9a06b299 271The following operations are valid for UDP only:
fea681da 272.IP
bf337635 273.in +4n
b8302363 274.EX
9a06b299
MK
275\fBCLSET_RETRY_TIMEOUT\fP \fIstruct timeval\fP // set the retry timeout
276\fBCLGET_RETRY_TIMEOUT\fP \fIstruct timeval\fP // get the retry timeout
b8302363 277.EE
bf337635 278.in
fea681da 279.IP
9a06b299 280The retry timeout is the time that "UDP RPC"
fea681da
MK
281waits for the server to reply before
282retransmitting the request.
dd3568a1 283.PP
fea681da 284.nf
9a06b299 285.BI "clnt_freeres(CLIENT * " clnt ", xdrproc_t " outproc ", char *" out );
fea681da 286.fi
fea681da 287.IP
9a06b299
MK
288A macro that frees any data allocated by the RPC/XDR
289system when it decoded the results of an RPC call.
c13182ef 290The parameter
fea681da
MK
291.I out
292is the address of the results, and
293.I outproc
9a06b299
MK
294is the XDR routine describing the results.
295This routine returns one if the results were successfully freed,
fea681da 296and zero otherwise.
dd3568a1 297.PP
fea681da 298.nf
9a06b299 299.BI "void clnt_geterr(CLIENT *" clnt ", struct rpc_err *" errp );
fea681da 300.fi
fea681da
MK
301.IP
302A macro that copies the error structure out of the client
9a06b299 303handle to the structure at address
fea681da 304.IR errp .
dd3568a1 305.PP
fea681da 306.nf
9a06b299 307.BI "void clnt_pcreateerror(char *" s );
fea681da 308.fi
fea681da 309.IP
9a06b299 310Print a message to standard error indicating why a client RPC
fea681da
MK
311handle could not be created.
312The message is prepended with string
313.I s
314and a colon.
315Used when a
63aa9df0
MK
316.BR clnt_create (),
317.BR clntraw_create (),
318.BR clnttcp_create (),
fea681da 319or
63aa9df0 320.BR clntudp_create ()
fea681da 321call fails.
dd3568a1 322.PP
fea681da 323.nf
9a06b299 324.BI "void clnt_perrno(enum clnt_stat " stat );
fea681da 325.fi
fea681da
MK
326.IP
327Print a message to standard error corresponding
328to the condition indicated by
329.IR stat .
330Used after
63aa9df0 331.BR callrpc ().
dd3568a1 332.PP
fea681da 333.nf
9a06b299 334.BI "clnt_perror(CLIENT *" clnt ", char *" s );
fea681da 335.fi
fea681da 336.IP
9a06b299 337Print a message to standard error indicating why an RPC call failed;
fea681da
MK
338.I clnt
339is the handle used to do the call.
340The message is prepended with string
341.I s
342and a colon.
343Used after
63aa9df0 344.BR clnt_call ().
dd3568a1 345.PP
fea681da 346.nf
9a06b299 347.BI "char *clnt_spcreateerror(char *" s );
fea681da 348.fi
fea681da
MK
349.IP
350Like
63aa9df0 351.BR clnt_pcreateerror (),
9a06b299 352except that it returns a string instead of printing to the standard error.
fea681da 353.IP
9a06b299 354Bugs: returns pointer to static data that is overwritten on each call.
dd3568a1 355.PP
fea681da 356.nf
9a06b299 357.BI "char *clnt_sperrno(enum clnt_stat " stat );
fea681da 358.fi
fea681da
MK
359.IP
360Take the same arguments as
63aa9df0 361.BR clnt_perrno (),
9a06b299
MK
362but instead of sending a message to the standard error indicating why an RPC
363call failed, return a pointer to a string which contains the message.
364The string ends with a NEWLINE.
fea681da 365.IP
63aa9df0 366.BR clnt_sperrno ()
fea681da 367is used instead of
63aa9df0 368.BR clnt_perrno ()
fea681da 369if the program does not have a standard error (as a program
9a06b299 370running as a server quite likely does not), or if the programmer
fea681da 371does not want the message to be output with
9daa4fb9 372.BR printf (3),
fea681da 373or if a message format different than that supported by
63aa9df0 374.BR clnt_perrno ()
fea681da
MK
375is to be used.
376Note: unlike
63aa9df0 377.BR clnt_sperror ()
fea681da 378and
33ec0e54 379.BR clnt_spcreateerror (),
63aa9df0 380.BR clnt_sperrno ()
fea681da
MK
381returns pointer to static data, but the
382result will not get overwritten on each call.
dd3568a1 383.PP
fea681da 384.nf
9a06b299 385.BI "char *clnt_sperror(CLIENT *" rpch ", char *" s );
fea681da 386.fi
fea681da
MK
387.IP
388Like
63aa9df0 389.BR clnt_perror (),
fea681da 390except that (like
63aa9df0 391.BR clnt_sperrno ())
fea681da
MK
392it returns a string instead of printing to standard error.
393.IP
9a06b299 394Bugs: returns pointer to static data that is overwritten on each call.
dd3568a1 395.PP
fea681da 396.nf
9a06b299
MK
397.BI "CLIENT *clntraw_create(unsigned long " prognum \
398", unsigned long " versnum );
fea681da 399.fi
fea681da 400.IP
9a06b299 401This routine creates a toy RPC client for the remote program
fea681da
MK
402.IR prognum ,
403version
404.IR versnum .
405The transport used to pass messages to the service is
406actually a buffer within the process's address space, so the
9a06b299 407corresponding RPC server should live in the same address space; see
63aa9df0 408.BR svcraw_create ().
9a06b299
MK
409This allows simulation of RPC and acquisition of RPC
410overheads, such as round trip times, without any kernel interference.
411This routine returns NULL if it fails.
dd3568a1 412.PP
fea681da 413.nf
9a06b299
MK
414.BI "CLIENT *clnttcp_create(struct sockaddr_in *" addr ,
415.BI " unsigned long " prognum ", unsigned long " versnum ,
416.BI " int *" sockp ", unsigned int " sendsz \
417", unsigned int " recvsz );
fea681da 418.fi
fea681da 419.IP
9a06b299 420This routine creates an RPC client for the remote program
fea681da
MK
421.IR prognum ,
422version
423.IR versnum ;
9a06b299
MK
424the client uses TCP/IP as a transport.
425The remote program is located at Internet address
fea681da
MK
426.IR *addr .
427If
d6115148 428.\"The following inline font conversion is necessary for the hyphen indicator
c6fa0841 429.I addr\->sin_port
fea681da
MK
430is zero, then it is set to the actual port that the remote
431program is listening on (the remote
432.B portmap
c13182ef
MK
433service is consulted for this information).
434The parameter
fea681da
MK
435.I sockp
436is a socket; if it is
066cb3d6 437.BR RPC_ANYSOCK ,
fea681da
MK
438then this routine opens a new one and sets
439.IR sockp .
9a06b299 440Since TCP-based RPC uses buffered I/O,
fea681da
MK
441the user may specify the size of the send and receive buffers
442with the parameters
443.I sendsz
444and
445.IR recvsz ;
446values of zero choose suitable defaults.
9a06b299 447This routine returns NULL if it fails.
dd3568a1 448.PP
fea681da 449.nf
a49d636c 450.BI "CLIENT *clntudp_create(struct sockaddr_in *" addr ,
9a06b299
MK
451.BI " unsigned long " prognum ", unsigned long " versnum ,
452.BI " struct timeval " wait ", int *" sockp );
fea681da 453.fi
fea681da 454.IP
9a06b299 455This routine creates an RPC client for the remote program
fea681da
MK
456.IR prognum ,
457version
458.IR versnum ;
9a06b299
MK
459the client uses use UDP/IP as a transport.
460The remote program is located at Internet address
fea681da
MK
461.IR addr .
462If
c6fa0841 463.I addr\->sin_port
fea681da
MK
464is zero, then it is set to actual port that the remote
465program is listening on (the remote
466.B portmap
c13182ef
MK
467service is consulted for this information).
468The parameter
fea681da
MK
469.I sockp
470is a socket; if it is
066cb3d6 471.BR RPC_ANYSOCK ,
fea681da
MK
472then this routine opens a new one and sets
473.IR sockp .
9a06b299 474The UDP transport resends the call message in intervals of
d9a10d9d 475.I wait
9a06b299 476time until a response is received or until the call times out.
fea681da 477The total time for the call to time out is specified by
63aa9df0 478.BR clnt_call ().
fea681da 479.IP
33a0ccb2 480Warning: since UDP-based RPC messages can hold only up to 8 Kbytes
fea681da
MK
481of encoded data, this transport cannot be used for procedures
482that take large arguments or return huge results.
dd3568a1 483.PP
9a06b299
MK
484.nf
485.BI "CLIENT *clntudp_bufcreate(struct sockaddr_in *" addr ,
486.BI " unsigned long " prognum ", unsigned long " versnum ,
487.BI " struct timeval " wait ", int *" sockp ,
488.BI " unsigned int " sendsize ", unsigned int "recosize );
489.fi
490.IP
491This routine creates an RPC client for the remote program
fea681da
MK
492.IR prognum ,
493on
494.IR versnum ;
9a06b299
MK
495the client uses use UDP/IP as a transport.
496The remote program is located at Internet address
fea681da
MK
497.IR addr .
498If
c6fa0841 499.I addr\->sin_port
fea681da
MK
500is zero, then it is set to actual port that the remote
501program is listening on (the remote
502.B portmap
c13182ef
MK
503service is consulted for this information).
504The parameter
fea681da
MK
505.I sockp
506is a socket; if it is
066cb3d6 507.BR RPC_ANYSOCK ,
fea681da 508then this routine opens a new one and sets
a3c5b73c 509.IR sockp .
9a06b299 510The UDP transport resends the call message in intervals of
d9a10d9d 511.I wait
9a06b299 512time until a response is received or until the call times out.
fea681da 513The total time for the call to time out is specified by
63aa9df0 514.BR clnt_call ().
fea681da 515.IP
9a06b299
MK
516This allows the user to specify the maximum packet
517size for sending and receiving UDP-based RPC messages.
dd3568a1 518.PP
fea681da 519.nf
9a06b299 520.BI "void get_myaddress(struct sockaddr_in *" addr );
fea681da 521.fi
fea681da 522.IP
9a06b299 523Stuff the machine's IP address into
fea681da
MK
524.IR *addr ,
525without consulting the library routines that deal with
8478ee02 526.IR /etc/hosts .
fea681da 527The port number is always set to
066cb3d6 528.BR htons(PMAPPORT) .
dd3568a1 529.PP
fea681da 530.nf
9a06b299 531.BI "struct pmaplist *pmap_getmaps(struct sockaddr_in *" addr );
fea681da 532.fi
fea681da
MK
533.IP
534A user interface to the
535.B portmap
9a06b299
MK
536service, which returns a list of the current RPC
537program-to-port mappings on the host located at IP address
fea681da 538.IR *addr .
9a06b299 539This routine can return NULL.
fea681da 540The command
2d986c92 541.IR "rpcinfo\ \-p"
fea681da 542uses this routine.
dd3568a1 543.PP
fea681da 544.nf
9a06b299
MK
545.BI "unsigned short pmap_getport(struct sockaddr_in *" addr ,
546.BI " unsigned long " prognum ", unsigned long " versnum ,
547.BI " unsigned int " protocol );
fea681da 548.fi
fea681da
MK
549.IP
550A user interface to the
551.B portmap
552service, which returns the port number
553on which waits a service that supports program number
554.IR prognum ,
555version
556.IR versnum ,
557and speaks the transport protocol associated with
558.IR protocol .
559The value of
560.I protocol
561is most likely
9a06b299 562.B IPPROTO_UDP
c13182ef 563or
066cb3d6 564.BR IPPROTO_TCP .
fea681da 565A return value of zero means that the mapping does not exist
9a06b299 566or that the RPC system failed to contact the remote
fea681da 567.B portmap
c13182ef
MK
568service.
569In the latter case, the global variable
9a06b299
MK
570.I rpc_createerr
571contains the RPC status.
dd3568a1 572.PP
fea681da 573.nf
9a06b299
MK
574.BI "enum clnt_stat pmap_rmtcall(struct sockaddr_in *" addr ,
575.BI " unsigned long " prognum ", unsigned long " versnum ,
39a22d92
MK
576.BI " unsigned long " procnum ,
577.BI " xdrproc_t " inproc ", char *" in ,
578.BI " xdrproc_t " outproc ", char *" out ,
9a06b299 579.BI " struct timeval " tout ", unsigned long *" portp );
fea681da 580.fi
fea681da
MK
581.IP
582A user interface to the
583.B portmap
584service, which instructs
585.B portmap
9a06b299 586on the host at IP address
fea681da 587.I *addr
9a06b299 588to make an RPC call on your behalf to a procedure on that host.
fea681da
MK
589The parameter
590.I *portp
9a06b299 591will be modified to the program's port number if the procedure succeeds.
c13182ef 592The definitions of other parameters are discussed
fea681da 593in
63aa9df0 594.BR callrpc ()
fea681da 595and
63aa9df0 596.BR clnt_call ().
9a06b299 597This procedure should be used for a \(lqping\(rq and nothing else.
fea681da 598See also
63aa9df0 599.BR clnt_broadcast ().
dd3568a1 600.PP
fea681da 601.nf
9a06b299
MK
602.BI "bool_t pmap_set(unsigned long " prognum ", unsigned long " versnum ,
603.BI " unsigned int " protocol ", unsigned short " port );
fea681da 604.fi
fea681da
MK
605.IP
606A user interface to the
607.B portmap
608service, which establishes a mapping between the triple
c6fa0841 609.RI [ prognum , versnum , protocol ]
fea681da
MK
610and
611.I port
612on the machine's
613.B portmap
c13182ef
MK
614service.
615The value of
fea681da
MK
616.I protocol
617is most likely
9a06b299 618.B IPPROTO_UDP
c13182ef 619or
066cb3d6 620.BR IPPROTO_TCP .
fea681da
MK
621This routine returns one if it succeeds, zero otherwise.
622Automatically done by
63aa9df0 623.BR svc_register ().
dd3568a1 624.PP
fea681da 625.nf
9a06b299 626.BI "bool_t pmap_unset(unsigned long " prognum ", unsigned long " versnum );
fea681da 627.fi
fea681da
MK
628.IP
629A user interface to the
630.B portmap
631service, which destroys all mapping between the triple
c6fa0841 632.RI [ prognum , versnum , * ]
fea681da
MK
633and
634.B ports
635on the machine's
636.B portmap
c13182ef 637service.
9a06b299 638This routine returns one if it succeeds, zero otherwise.
dd3568a1 639.PP
fea681da 640.nf
9a06b299 641.BI "int registerrpc(unsigned long " prognum ", unsigned long " versnum ,
da8cb51e 642.BI " unsigned long " procnum ", char *(*" procname ")(char *),"
9a06b299 643.BI " xdrproc_t " inproc ", xdrproc_t " outproc );
fea681da 644.fi
fea681da
MK
645.IP
646Register procedure
647.I procname
9a06b299 648with the RPC service package.
c13182ef 649If a request arrives for program
fea681da
MK
650.IR prognum ,
651version
652.IR versnum ,
653and procedure
654.IR procnum ,
655.I procname
656is called with a pointer to its parameter(s);
69f32fc0 657.I procname
fea681da
MK
658should return a pointer to its static result(s);
659.I inproc
660is used to decode the parameters while
661.I outproc
662is used to encode the results.
9a06b299 663This routine returns zero if the registration succeeded, \-1 otherwise.
fea681da
MK
664.IP
665Warning: remote procedures registered in this form
9a06b299 666are accessed using the UDP/IP transport; see
63aa9df0 667.BR svcudp_create ()
fea681da 668for restrictions.
dd3568a1 669.PP
fea681da 670.nf
9a06b299 671.BI "struct rpc_createerr " rpc_createerr ;
fea681da 672.fi
fea681da 673.IP
9a06b299 674A global variable whose value is set by any RPC client creation routine
c13182ef
MK
675that does not succeed.
676Use the routine
63aa9df0 677.BR clnt_pcreateerror ()
fea681da 678to print the reason why.
dd3568a1 679.PP
fea681da 680.nf
9a06b299 681.BI "void svc_destroy(SVCXPRT *" xprt );
fea681da 682.fi
fea681da 683.IP
9a06b299 684A macro that destroys the RPC service transport handle,
fea681da
MK
685.IR xprt .
686Destruction usually involves deallocation
687of private data structures, including
688.I xprt
c13182ef
MK
689itself.
690Use of
fea681da
MK
691.I xprt
692is undefined after calling this routine.
dd3568a1 693.PP
fea681da 694.nf
9a06b299 695.BI "fd_set " svc_fdset ;
fea681da 696.fi
fea681da 697.IP
9a06b299
MK
698A global variable reflecting the RPC service side's
699read file descriptor bit mask; it is suitable as a parameter to the
9daa4fb9 700.BR select (2)
c13182ef 701system call.
886ea57d
MK
702This is of interest only if a service implementor does their own
703asynchronous event processing, instead of calling
704.BR svc_run ().
fea681da 705This variable is read-only (do not pass its address to
9daa4fb9 706.BR select (2)!),
fea681da 707yet it may change after calls to
63aa9df0 708.BR svc_getreqset ()
fea681da 709or any creation routines.
dd3568a1 710.PP
fea681da 711.nf
9a06b299 712.BI "int " svc_fds ;
fea681da 713.fi
fea681da
MK
714.IP
715Similar to
716.BR svc_fdset ,
d9cb0d7d 717but limited to 32 file descriptors.
c13182ef 718This interface is obsoleted by
fea681da 719.BR svc_fdset .
dd3568a1 720.PP
fea681da 721.nf
9a06b299 722.BI "svc_freeargs(SVCXPRT *" xprt ", xdrproc_t " inproc ", char *" in );
fea681da 723.fi
fea681da 724.IP
9a06b299
MK
725A macro that frees any data allocated by the RPC/XDR
726system when it decoded the arguments to a service procedure using
63aa9df0 727.BR svc_getargs ().
9a06b299 728This routine returns 1 if the results were successfully freed,
fea681da 729and zero otherwise.
dd3568a1 730.PP
fea681da 731.nf
9a06b299 732.BI "svc_getargs(SVCXPRT *" xprt ", xdrproc_t " inproc ", char *" in );
fea681da 733.fi
fea681da 734.IP
9a06b299
MK
735A macro that decodes the arguments of an RPC request
736associated with the RPC service transport handle,
fea681da
MK
737.IR xprt .
738The parameter
739.I in
740is the address where the arguments will be placed;
741.I inproc
9a06b299
MK
742is the XDR routine used to decode the arguments.
743This routine returns one if decoding succeeds, and zero otherwise.
dd3568a1 744.PP
fea681da 745.nf
9a06b299 746.BI "struct sockaddr_in *svc_getcaller(SVCXPRT *" xprt );
fea681da 747.fi
fea681da
MK
748.IP
749The approved way of getting the network address of the caller
9a06b299 750of a procedure associated with the RPC service transport handle,
fea681da 751.IR xprt .
dd3568a1 752.PP
fea681da 753.nf
9a06b299 754.BI "void svc_getreqset(fd_set *" rdfds );
fea681da 755.fi
fea681da 756.IP
33a0ccb2 757This routine is of interest only if a service implementor does not call
63aa9df0 758.BR svc_run (),
fea681da
MK
759but instead implements custom asynchronous event processing.
760It is called when the
9daa4fb9 761.BR select (2)
9a06b299
MK
762system call has determined that an RPC request has arrived on some
763RPC socket(s);
fea681da
MK
764.I rdfds
765is the resultant read file descriptor bit mask.
9a06b299 766The routine returns when all sockets associated with the value of
fea681da
MK
767.I rdfds
768have been serviced.
dd3568a1 769.PP
fea681da 770.nf
9a06b299 771.BI "void svc_getreq(int " rdfds );
fea681da 772.fi
fea681da
MK
773.IP
774Similar to
63aa9df0 775.BR svc_getreqset (),
d9cb0d7d 776but limited to 32 file descriptors.
c13182ef 777This interface is obsoleted by
63aa9df0 778.BR svc_getreqset ().
dd3568a1 779.PP
fea681da 780.nf
9a06b299
MK
781.BI "bool_t svc_register(SVCXPRT *" xprt ", unsigned long " prognum ,
782.BI " unsigned long " versnum ,
783.BI " void (*" dispatch ")(svc_req *, SVCXPRT *),"
784.BI " unsigned long " protocol );
fea681da 785.fi
fea681da
MK
786.IP
787Associates
788.I prognum
789and
790.I versnum
791with the service dispatch procedure,
792.IR dispatch .
793If
794.I protocol
795is zero, the service is not registered with the
796.B portmap
c13182ef
MK
797service.
798If
fea681da 799.I protocol
c7094399 800is nonzero, then a mapping of the triple
c6fa0841 801.RI [ prognum , versnum , protocol ]
fea681da 802to
c6fa0841 803.I xprt\->xp_port
fea681da
MK
804is established with the local
805.B portmap
806service (generally
807.I protocol
808is zero,
9a06b299 809.B IPPROTO_UDP
c13182ef 810or
9a06b299 811.BR IPPROTO_TCP ).
fea681da
MK
812The procedure
813.I dispatch
814has the following form:
e646a1ba 815.IP
11d4a2cf 816.in +4n
e646a1ba 817.EX
11d4a2cf 818dispatch(struct svc_req *request, SVCXPRT *xprt);
b8302363 819.EE
11d4a2cf 820.in
fea681da
MK
821.IP
822The
63aa9df0 823.BR svc_register ()
fea681da 824routine returns one if it succeeds, and zero otherwise.
dd3568a1 825.PP
fea681da 826.nf
9a06b299 827.B "void svc_run(void);"
fea681da 828.fi
fea681da 829.IP
c13182ef 830This routine never returns.
9a06b299 831It waits for RPC requests to arrive, and calls the appropriate service
fea681da 832procedure using
63aa9df0 833.BR svc_getreq ()
c13182ef
MK
834when one arrives.
835This procedure is usually waiting for a
9daa4fb9 836.BR select (2)
fea681da 837system call to return.
dd3568a1 838.PP
fea681da 839.nf
9a06b299
MK
840.BI "bool_t svc_sendreply(SVCXPRT *" xprt ", xdrproc_t " outproc \
841", char *" out );
fea681da 842.fi
fea681da 843.IP
9a06b299 844Called by an RPC service's dispatch routine to send the results of a
c13182ef
MK
845remote procedure call.
846The parameter
fea681da
MK
847.I xprt
848is the request's associated transport handle;
849.I outproc
9a06b299 850is the XDR routine which is used to encode the results; and
fea681da
MK
851.I out
852is the address of the results.
853This routine returns one if it succeeds, zero otherwise.
dd3568a1 854.PP
fea681da 855.nf
9a06b299 856.BI "void svc_unregister(unsigned long " prognum ", unsigned long " versnum );
fea681da 857.fi
fea681da
MK
858.IP
859Remove all mapping of the double
860.RI [ prognum , versnum ]
861to dispatch routines, and of the triple
c6fa0841 862.RI [ prognum , versnum , * ]
fea681da 863to port number.
dd3568a1 864.PP
fea681da 865.nf
9a06b299 866.BI "void svcerr_auth(SVCXPRT *" xprt ", enum auth_stat " why );
fea681da 867.fi
fea681da
MK
868.IP
869Called by a service dispatch routine that refuses to perform
870a remote procedure call due to an authentication error.
dd3568a1 871.PP
fea681da 872.nf
9a06b299 873.BI "void svcerr_decode(SVCXPRT *" xprt );
fea681da 874.fi
fea681da
MK
875.IP
876Called by a service dispatch routine that cannot successfully
c13182ef
MK
877decode its parameters.
878See also
63aa9df0 879.BR svc_getargs ().
dd3568a1 880.PP
fea681da 881.nf
9a06b299 882.BI "void svcerr_noproc(SVCXPRT *" xprt );
fea681da 883.fi
fea681da
MK
884.IP
885Called by a service dispatch routine that does not implement
886the procedure number that the caller requests.
dd3568a1 887.PP
fea681da 888.nf
9a06b299 889.BI "void svcerr_noprog(SVCXPRT *" xprt );
fea681da 890.fi
fea681da 891.IP
9a06b299 892Called when the desired program is not registered with the RPC package.
c13182ef 893Service implementors usually do not need this routine.
dd3568a1 894.PP
fea681da 895.nf
9a06b299 896.BI "void svcerr_progvers(SVCXPRT *" xprt );
fea681da 897.fi
fea681da
MK
898.IP
899Called when the desired version of a program is not registered
9a06b299 900with the RPC package.
c13182ef 901Service implementors usually do not need this routine.
dd3568a1 902.PP
fea681da 903.nf
9a06b299 904.BI "void svcerr_systemerr(SVCXPRT *" xprt );
fea681da 905.fi
fea681da
MK
906.IP
907Called by a service dispatch routine when it detects a system
9a06b299 908error not covered by any particular protocol.
fea681da
MK
909For example, if a service can no longer allocate storage,
910it may call this routine.
dd3568a1 911.PP
fea681da 912.nf
9a06b299 913.BI "void svcerr_weakauth(SVCXPRT *" xprt );
fea681da 914.fi
fea681da
MK
915.IP
916Called by a service dispatch routine that refuses to perform
9a06b299 917a remote procedure call due to insufficient authentication parameters.
c13182ef 918The routine calls
066cb3d6 919.BR "svcerr_auth(xprt, AUTH_TOOWEAK)" .
dd3568a1 920.PP
fea681da 921.nf
9a06b299
MK
922.BI "SVCXPRT *svcfd_create(int " fd ", unsigned int " sendsize ,
923.BI " unsigned int " recvsize );
fea681da 924.fi
fea681da 925.IP
d9cb0d7d
MK
926Create a service on top of any open file descriptor.
927Typically, this file descriptor is a connected socket for a stream protocol such
9a06b299 928as TCP.
fea681da
MK
929.I sendsize
930and
931.I recvsize
c13182ef 932indicate sizes for the send and receive buffers.
9a06b299 933If they are zero, a reasonable default is chosen.
dd3568a1 934.PP
fea681da 935.nf
9a06b299 936.BI "SVCXPRT *svcraw_create(void);"
fea681da 937.fi
fea681da 938.IP
9a06b299 939This routine creates a toy RPC
c13182ef
MK
940service transport, to which it returns a pointer.
941The transport is really a buffer within the process's address space,
9a06b299 942so the corresponding RPC client should live in the same address space; see
63aa9df0 943.BR clntraw_create ().
9a06b299
MK
944This routine allows simulation of RPC and acquisition of RPC
945overheads (such as round trip times), without any kernel interference.
946This routine returns NULL if it fails.
dd3568a1 947.PP
fea681da 948.nf
9a06b299
MK
949.BI "SVCXPRT *svctcp_create(int " sock ", unsigned int " send_buf_size ,
950.BI " unsigned int " recv_buf_size );
fea681da 951.fi
fea681da 952.IP
9a06b299 953This routine creates a TCP/IP-based RPC
fea681da
MK
954service transport, to which it returns a pointer.
955The transport is associated with the socket
956.IR sock ,
957which may be
066cb3d6 958.BR RPC_ANYSOCK ,
fea681da 959in which case a new socket is created.
9a06b299 960If the socket is not bound to a local TCP
c13182ef
MK
961port, then this routine binds it to an arbitrary port.
962Upon completion,
c6fa0841 963.I xprt\->xp_sock
fea681da 964is the transport's socket descriptor, and
c6fa0841 965.I xprt\->xp_port
fea681da 966is the transport's port number.
9a06b299
MK
967This routine returns NULL if it fails.
968Since TCP-based RPC uses buffered I/O,
fea681da
MK
969users may specify the size of buffers; values of zero
970choose suitable defaults.
dd3568a1 971.PP
fea681da 972.nf
9a06b299
MK
973.BI "SVCXPRT *svcudp_bufcreate(int " sock ", unsigned int " sendsize ,
974.BI " unsigned int " recosize );
fea681da 975.fi
fea681da 976.IP
9a06b299 977This routine creates a UDP/IP-based RPC
fea681da
MK
978service transport, to which it returns a pointer.
979The transport is associated with the socket
980.IR sock ,
981which may be
066cb3d6 982.BR RPC_ANYSOCK ,
fea681da 983in which case a new socket is created.
9a06b299 984If the socket is not bound to a local UDP
c13182ef
MK
985port, then this routine binds it to an arbitrary port.
986Upon completion,
c6fa0841 987.I xprt\->xp_sock
fea681da 988is the transport's socket descriptor, and
c6fa0841 989.I xprt\->xp_port
fea681da 990is the transport's port number.
9a06b299 991This routine returns NULL if it fails.
fea681da 992.IP
c13182ef 993This allows the user to specify the maximum packet size for sending and
9a06b299 994receiving UDP-based RPC messages.
dd3568a1 995.PP
fea681da 996.nf
9a06b299 997.BI "SVCXPRT *svcudp_create(int " sock );
fea681da 998.fi
fea681da
MK
999.IP
1000This call is equivalent to
c6fa0841
MK
1001.I svcudp_bufcreate(sock,SZ,SZ)
1002for some default size
1003.IR SZ .
dd3568a1 1004.PP
fea681da 1005.nf
9a06b299 1006.BI "bool_t xdr_accepted_reply(XDR *" xdrs ", struct accepted_reply *" ar );
fea681da 1007.fi
fea681da 1008.IP
9a06b299 1009Used for encoding RPC reply messages.
c13182ef 1010This routine is useful for users who wish to generate
9a06b299 1011RPC-style messages without using the RPC package.
dd3568a1 1012.PP
fea681da 1013.nf
9a06b299 1014.BI "bool_t xdr_authunix_parms(XDR *" xdrs ", struct authunix_parms *" aupp );
fea681da 1015.fi
fea681da 1016.IP
008f1ecc 1017Used for describing UNIX credentials.
c13182ef 1018This routine is useful for users
9a06b299 1019who wish to generate these credentials without using the RPC
fea681da 1020authentication package.
dd3568a1 1021.PP
fea681da 1022.nf
9a06b299 1023.BI "void xdr_callhdr(XDR *" xdrs ", struct rpc_msg *" chdr );
fea681da 1024.fi
fea681da 1025.IP
9a06b299 1026Used for describing RPC call header messages.
fea681da 1027This routine is useful for users who wish to generate
9a06b299 1028RPC-style messages without using the RPC package.
dd3568a1 1029.PP
fea681da 1030.nf
9a06b299 1031.BI "bool_t xdr_callmsg(XDR *" xdrs ", struct rpc_msg *" cmsg );
fea681da 1032.fi
fea681da 1033.IP
9a06b299
MK
1034Used for describing RPC call messages.
1035This routine is useful for users who wish to generate RPC-style
1036messages without using the RPC package.
dd3568a1 1037.PP
fea681da 1038.nf
9a06b299 1039.BI "bool_t xdr_opaque_auth(XDR *" xdrs ", struct opaque_auth *" ap );
fea681da 1040.fi
fea681da 1041.IP
9a06b299 1042Used for describing RPC authentication information messages.
fea681da 1043This routine is useful for users who wish to generate
9a06b299 1044RPC-style messages without using the RPC package.
dd3568a1 1045.PP
fea681da 1046.nf
9a06b299 1047.BI "bool_t xdr_pmap(XDR *" xdrs ", struct pmap *" regs );
fea681da 1048.fi
fea681da
MK
1049.IP
1050Used for describing parameters to various
1051.B portmap
1052procedures, externally.
1053This routine is useful for users who wish to generate
1054these parameters without using the
1055.B pmap
1056interface.
dd3568a1 1057.PP
fea681da 1058.nf
9a06b299 1059.BI "bool_t xdr_pmaplist(XDR *" xdrs ", struct pmaplist **" rp );
fea681da 1060.fi
fea681da
MK
1061.IP
1062Used for describing a list of port mappings, externally.
1063This routine is useful for users who wish to generate
1064these parameters without using the
1065.B pmap
1066interface.
dd3568a1 1067.PP
fea681da 1068.nf
9a06b299 1069.BI "bool_t xdr_rejected_reply(XDR *" xdrs ", struct rejected_reply *" rr );
fea681da 1070.fi
fea681da 1071.IP
9a06b299 1072Used for describing RPC reply messages.
fea681da 1073This routine is useful for users who wish to generate
9a06b299 1074RPC-style messages without using the RPC package.
dd3568a1 1075.PP
fea681da 1076.nf
9a06b299 1077.BI "bool_t xdr_replymsg(XDR *" xdrs ", struct rpc_msg *" rmsg );
fea681da 1078.fi
fea681da 1079.IP
9a06b299 1080Used for describing RPC reply messages.
fea681da 1081This routine is useful for users who wish to generate
9a06b299 1082RPC style messages without using the RPC package.
dd3568a1 1083.PP
fea681da 1084.nf
9a06b299 1085.BI "void xprt_register(SVCXPRT *" xprt );
fea681da 1086.fi
fea681da 1087.IP
9a06b299
MK
1088After RPC service transport handles are created,
1089they should register themselves with the RPC service package.
fea681da 1090This routine modifies the global variable
26d4d0d6 1091.IR svc_fds .
fea681da 1092Service implementors usually do not need this routine.
dd3568a1 1093.PP
fea681da 1094.nf
9a06b299 1095.BI "void xprt_unregister(SVCXPRT *" xprt );
fea681da 1096.fi
fea681da 1097.IP
9a06b299
MK
1098Before an RPC service transport handle is destroyed,
1099it should unregister itself with the RPC service package.
fea681da 1100This routine modifies the global variable
9a06b299 1101.IR svc_fds .
fea681da 1102Service implementors usually do not need this routine.
7d30e395
ZL
1103.SH ATTRIBUTES
1104For an explanation of the terms used in this section, see
1105.BR attributes (7).
74714ea8 1106.ad l
7d30e395
ZL
1107.TS
1108allbox;
1109lbw35 lb lb
1110l l l.
1111Interface Attribute Value
1112T{
1113.BR auth_destroy (),
1114.BR authnone_create (),
1115.br
1116.BR authunix_create (),
1117.br
1118.BR authunix_create_default (),
1119.br
1120.BR callrpc (),
1121.BR clnt_broadcast (),
1122.br
1123.BR clnt_call (),
1124.BR clnt_destroy (),
1125.br
1126.BR clnt_create (),
1127.BR clnt_control (),
1128.br
1129.BR clnt_freeres (),
1130.BR clnt_geterr (),
1131.br
1132.BR clnt_pcreateerror (),
1133.BR clnt_perrno (),
1134.br
1135.BR clnt_perror (),
1136.br
1137.BR clnt_spcreateerror (),
1138.br
1139.BR clnt_sperrno (),
1140.BR clnt_sperror (),
1141.br
1142.BR clntraw_create (),
1143.BR clnttcp_create (),
1144.br
1145.BR clntudp_create (),
1146.br
1147.BR clntudp_bufcreate (),
1148.br
1149.BR get_myaddress (),
1150.BR pmap_getmaps (),
1151.br
1152.BR pmap_getport (),
1153.BR pmap_rmtcall (),
1154.br
1155.BR pmap_set (),
1156.BR pmap_unset (),
1157.br
1158.BR registerrpc (),
1159.BR svc_destroy (),
1160.br
1161.BR svc_freeargs (),
1162.BR svc_getargs (),
1163.br
1164.BR svc_getcaller (),
1165.BR svc_getreqset (),
1166.br
1167.BR svc_getreq (),
1168.BR svc_register (),
1169.br
1170.BR svc_run (),
1171.BR svc_sendreply (),
1172.br
1173.BR svc_unregister (),
1174.BR svcerr_auth (),
1175.br
1176.BR svcerr_decode (),
1177.BR svcerr_noproc (),
1178.br
1179.BR svcerr_noprog (),
1180.BR svcerr_progvers (),
1181.br
1182.BR svcerr_systemerr (),
1183.BR svcerr_weakauth (),
1184.br
1185.BR svcfd_create (),
1186.BR svcraw_create (),
1187.br
1188.BR svctcp_create (),
1189.br
1190.BR svcudp_bufcreate (),
1191.br
1192.BR svcudp_create (),
1193.BR xdr_accepted_reply (),
1194.br
1195.BR xdr_authunix_parms (),
1196.br
1197.BR xdr_callhdr (),
1198.br
1199.BR xdr_callmsg (),
1200.BR xdr_opaque_auth (),
1201.br
1202.BR xdr_pmap (),
1203.BR xdr_pmaplist (),
1204.br
1205.BR xdr_rejected_reply (),
1206.br
1207.BR xdr_replymsg (),
1208.br
1209.BR xprt_register (),
1210.BR xprt_unregister ()
1211T} Thread safety MT-Safe
1212.TE
74714ea8 1213.ad
47297adb 1214.SH SEE ALSO
57734e82
MK
1215.\" We don't have an rpc_secure.3 page in the set at the moment -- MTK, 19 Sep 05
1216.\" .BR rpc_secure (3),
fea681da 1217.BR xdr (3)
847e0d88 1218.PP
fea681da
MK
1219The following manuals:
1220.RS
fea681da
MK
1221Remote Procedure Calls: Protocol Specification
1222.br
1223Remote Procedure Call Programming Guide
1224.br
1225rpcgen Programming Guide
1226.br
fea681da 1227.RE
847e0d88 1228.PP
066cb3d6 1229.IR "RPC: Remote Procedure Call Protocol Specification" ,
d2d293ba
MK
1230RFC\ 1050, Sun Microsystems, Inc.,
1231USC-ISI.