1 .\" @(#)rpc.3n 1.31 93/08/31 SMI; from SVr4
2 .\" Copyright 1989 AT&T
8 .Nd library routines for remote procedure calls
14 routines allow C language programs to make procedure
15 calls on other machines across a network.
16 First, the client sends a request to the server.
17 On receipt of the request, the server calls a dispatch routine
18 to perform the requested service, and then sends back a reply.
21 RPC routines require the header
24 .Vt "struct netconfig"
29 Some of the high-level
30 RPC interface routines take a
32 string as one of the arguments
38 This string defines a class of transports which can be used
39 for a particular application.
44 can be one of the following:
45 .Bl -tag -width datagram_v
47 Choose from the transports which have been
48 indicated by their token names in the
60 Choose the transports which have the visible flag (v)
67 except that it chooses only the connection oriented transports
72 from the entries in the
78 except that it chooses only the connectionless datagram transports
81 from the entries in the
87 except that it chooses only the connection oriented datagram transports
95 except that it chooses only the connectionless datagram transports
99 This refers to Internet UDP, both version 4 and 6.
101 This refers to Internet TCP, both version 4 and 6.
110 The transports are tried in left to right order in the
112 variable or in top to down order in the
116 The derived types used in the RPC interfaces are defined as follows:
118 typedef u_int32_t rpcprog_t;
119 typedef u_int32_t rpcvers_t;
120 typedef u_int32_t rpcproc_t;
121 typedef u_int32_t rpcprot_t;
122 typedef u_int32_t rpcport_t;
123 typedef int32_t rpc_inline_t;
125 .Sh "Data Structures"
126 Some of the data structures used by the
127 RPC package are shown below.
128 .Sh "The AUTH Structure"
131 * Authentication info. Opaque to client.
134 enum_t oa_flavor; /* flavor of auth */
135 caddr_t oa_base; /* address of more auth stuff */
136 u_int oa_length; /* not to exceed MAX_AUTH_BYTES */
140 * Auth handle, interface to client side authenticators.
143 struct opaque_auth ah_cred;
144 struct opaque_auth ah_verf;
146 void (*ah_nextverf)(\|);
147 int (*ah_marshal)(\|); /* nextverf & serialize */
148 int (*ah_validate)(\|); /* validate verifier */
149 int (*ah_refresh)(\|); /* refresh credentials */
150 void (*ah_destroy)(\|); /* destroy this structure */
155 .Sh "The CLIENT Structure"
159 * Created by individual implementations.
160 * Client is responsible for initializing auth.
164 AUTH *cl_auth; /* authenticator */
166 enum clnt_stat (*cl_call)(); /* call remote procedure */
167 void (*cl_abort)(); /* abort a call */
168 void (*cl_geterr)(); /* get specific error code */
169 bool_t (*cl_freeres)(); /* frees results */
170 void (*cl_destroy)(); /* destroy this structure */
171 bool_t (*cl_control)(); /* the ioctl() of rpc */
173 caddr_t cl_private; /* private stuff */
174 char *cl_netid; /* network identifier */
175 char *cl_tp; /* device name */
178 .Sh "The SVCXPRT structure"
187 * Server side transport handle
190 int xp_fd; /* file descriptor for the server handle */
191 u_short xp_port; /* obsolete */
192 const struct xp_ops {
193 bool_t (*xp_recv)(); /* receive incoming requests */
194 enum xprt_stat (*xp_stat)(); /* get transport status */
195 bool_t (*xp_getargs)(); /* get arguments */
196 bool_t (*xp_reply)(); /* send reply */
197 bool_t (*xp_freeargs)(); /* free mem allocated for args */
198 void (*xp_destroy)(); /* destroy this struct */
200 int xp_addrlen; /* length of remote addr. Obsolete */
201 struct sockaddr_in xp_raddr; /* Obsolete */
202 const struct xp_ops2 {
203 bool_t (*xp_control)(); /* catch-all function */
205 char *xp_tp; /* transport provider device name */
206 char *xp_netid; /* network identifier */
207 struct netbuf xp_ltaddr; /* local transport address */
208 struct netbuf xp_rtaddr; /* remote transport address */
209 struct opaque_auth xp_verf; /* raw response verifier */
210 caddr_t xp_p1; /* private: for use by svc ops */
211 caddr_t xp_p2; /* private: for use by svc ops */
212 caddr_t xp_p3; /* private: for use by svc lib */
213 int xp_type /* transport type */
216 .Sh "The svc_reg structure"
219 rpcprog_t rq_prog; /* service program number */
220 rpcvers_t rq_vers; /* service protocol version */
221 rpcproc_t rq_proc; /* the desired procedure */
222 struct opaque_auth rq_cred; /* raw creds from the wire */
223 caddr_t rq_clntcred; /* read only cooked cred */
224 SVCXPRT *rq_xprt; /* associated transport */
227 .Sh "The XDR structure"
231 * XDR_ENCODE causes the type to be encoded into the stream.
232 * XDR_DECODE causes the type to be extracted from the stream.
233 * XDR_FREE can be used to release the space allocated by an XDR_DECODE
242 * This is the number of bytes per unit of external data.
244 #define BYTES_PER_XDR_UNIT (4)
245 #define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) /
246 BYTES_PER_XDR_UNIT) \e * BYTES_PER_XDR_UNIT)
249 * A xdrproc_t exists for each data type which is to be encoded or
250 * decoded. The second argument to the xdrproc_t is a pointer to
251 * an opaque pointer. The opaque pointer generally points to a
252 * structure of the data type to be decoded. If this points to 0,
253 * then the type routines should allocate dynamic storage of the
254 * appropriate size and return it.
255 * bool_t (*xdrproc_t)(XDR *, caddr_t *);
257 typedef bool_t (*xdrproc_t)();
261 * Contains operation which is being applied to the stream,
262 * an operations vector for the particular implementation
265 enum xdr_op x_op; /* operation; fast additional param */
267 bool_t (*x_getlong)(); /* get a long from underlying stream */
268 bool_t (*x_putlong)(); /* put a long to underlying stream */
269 bool_t (*x_getbytes)(); /* get bytes from underlying stream */
270 bool_t (*x_putbytes)(); /* put bytes to underlying stream */
271 u_int (*x_getpostn)(); /* returns bytes off from beginning */
272 bool_t (*x_setpostn)(); /* lets you reposition the stream */
273 long * (*x_inline)(); /* buf quick ptr to buffered data */
274 void (*x_destroy)(); /* free privates of this xdr_stream */
276 caddr_t x_public; /* users' data */
277 caddr_t x_private; /* pointer to private data */
278 caddr_t x_base; /* private used for position info */
279 u_int x_handy; /* extra private word */
283 * The netbuf structure. This structure is defined in <xti.h> on SysV
284 * systems, but NetBSD / FreeBSD do not use XTI.
286 * Usually, buf will point to a struct sockaddr, and len and maxlen
287 * will contain the length and maximum length of that socket address,
297 * The format of the address and options arguments of the XTI t_bind call.
298 * Only provided for compatibility, it should not be used other than
299 * as an argument to svc_tli_create().
307 .Sh "Index to Routines"
308 The following table lists RPC routines and the manual reference
309 pages on which they are described:
311 .Bl -tag -width "authunix_create_default()" -compact
313 .Em "Manual Reference Page"
317 .It Fn authdes_create
319 .It Fn authnone_create
321 .It Fn authsys_create
323 .It Fn authsys_create_default
325 .It Fn authunix_create
327 .It Fn authunix_create_default
331 .It Fn clnt_broadcast
336 .Xr rpc_clnt_create 3
338 .Xr rpc_clnt_create 3
339 .It Fn clnt_create_timed
340 .Xr rpc_clnt_create 3
341 .It Fn clnt_create_vers
342 .Xr rpc_clnt_create 3
343 .It Fn clnt_create_vers_timed
344 .Xr rpc_clnt_create 3
346 .Xr rpc_clnt_create 3
347 .It Fn clnt_dg_create
348 .Xr rpc_clnt_create 3
353 .It Fn clnt_pcreateerror
354 .Xr rpc_clnt_create 3
359 .It Fn clnt_raw_create
360 .Xr rpc_clnt_create 3
361 .It Fn clnt_spcreateerror
362 .Xr rpc_clnt_create 3
367 .It Fn clnt_tli_create
368 .Xr rpc_clnt_create 3
369 .It Fn clnt_tp_create
370 .Xr rpc_clnt_create 3
371 .It Fn clnt_tp_create_timed
372 .Xr rpc_clnt_create 3
373 .It Fn clnt_udpcreate
375 .It Fn clnt_vc_create
376 .Xr rpc_clnt_create 3
377 .It Fn clntraw_create
379 .It Fn clnttcp_create
381 .It Fn clntudp_bufcreate
399 .It Fn rpc_broadcast_exp
411 .It Fn svc_dg_enablecache
427 .It Fn svc_getrpccaller
431 .It Fn svc_raw_create
441 .It Fn svc_tli_create
447 .It Fn svc_unregister
459 .It Fn svcerr_progvers
461 .It Fn svcerr_systemerr
463 .It Fn svcerr_weakauth
471 .It Fn svcudp_bufcreate
475 .It Fn xdr_accepted_reply
477 .It Fn xdr_authsys_parms
479 .It Fn xdr_authunix_parms
485 .It Fn xdr_opaque_auth
487 .It Fn xdr_rejected_reply
493 .It Fn xprt_unregister
497 .Bl -tag -width /etc/netconfig
498 .It Pa /etc/netconfig
501 These functions are part of libtirpc.
506 .Xr rpc_clnt_auth 3 ,
507 .Xr rpc_clnt_calls 3 ,
508 .Xr rpc_clnt_create 3 ,
509 .Xr rpc_svc_calls 3 ,
510 .Xr rpc_svc_create 3 ,