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