1 .\" @(#)rpc.3n 1.31 93/08/31 SMI; from SVr4
2 .\" Copyright 1989 AT&T
8 .Nd library routines for remote procedure calls
16 routines allow C language programs to make procedure
17 calls on other machines across a network.
18 First, the client sends a request to the server.
19 On receipt of the request, the server calls a dispatch routine
20 to perform the requested service, and then sends back a reply.
23 RPC routines require the header
26 .Vt "struct netconfig"
31 Some of the high-level
32 RPC interface routines take a
34 string as one of the arguments
40 This string defines a class of transports which can be used
41 for a particular application.
46 can be one of the following:
47 .Bl -tag -width datagram_v
49 Choose from the transports which have been
50 indicated by their token names in the
62 Choose the transports which have the visible flag (v)
69 except that it chooses only the connection oriented transports
74 from the entries in the
80 except that it chooses only the connectionless datagram transports
83 from the entries in the
89 except that it chooses only the connection oriented datagram transports
97 except that it chooses only the connectionless datagram transports
101 This refers to Internet UDP, both version 4 and 6.
103 This refers to Internet TCP, both version 4 and 6.
112 The transports are tried in left to right order in the
114 variable or in top to down order in the
118 The derived types used in the RPC interfaces are defined as follows:
120 typedef u_int32_t rpcprog_t;
121 typedef u_int32_t rpcvers_t;
122 typedef u_int32_t rpcproc_t;
123 typedef u_int32_t rpcprot_t;
124 typedef u_int32_t rpcport_t;
125 typedef int32_t rpc_inline_t;
127 .Sh "Data Structures"
128 Some of the data structures used by the
129 RPC package are shown below.
130 .Sh "The AUTH Structure"
133 * Authentication info. Opaque to client.
136 enum_t oa_flavor; /* flavor of auth */
137 caddr_t oa_base; /* address of more auth stuff */
138 u_int oa_length; /* not to exceed MAX_AUTH_BYTES */
142 * Auth handle, interface to client side authenticators.
145 struct opaque_auth ah_cred;
146 struct opaque_auth ah_verf;
148 void (*ah_nextverf)(\|);
149 int (*ah_marshal)(\|); /* nextverf & serialize */
150 int (*ah_validate)(\|); /* validate verifier */
151 int (*ah_refresh)(\|); /* refresh credentials */
152 void (*ah_destroy)(\|); /* destroy this structure */
157 .Sh "The CLIENT Structure"
161 * Created by individual implementations.
162 * Client is responsible for initializing auth.
166 AUTH *cl_auth; /* authenticator */
168 enum clnt_stat (*cl_call)(); /* call remote procedure */
169 void (*cl_abort)(); /* abort a call */
170 void (*cl_geterr)(); /* get specific error code */
171 bool_t (*cl_freeres)(); /* frees results */
172 void (*cl_destroy)(); /* destroy this structure */
173 bool_t (*cl_control)(); /* the ioctl() of rpc */
175 caddr_t cl_private; /* private stuff */
176 char *cl_netid; /* network identifier */
177 char *cl_tp; /* device name */
180 .Sh "The SVCXPRT structure"
189 * Server side transport handle
192 int xp_fd; /* file descriptor for the server handle */
193 u_short xp_port; /* obsolete */
194 const struct xp_ops {
195 bool_t (*xp_recv)(); /* receive incoming requests */
196 enum xprt_stat (*xp_stat)(); /* get transport status */
197 bool_t (*xp_getargs)(); /* get arguments */
198 bool_t (*xp_reply)(); /* send reply */
199 bool_t (*xp_freeargs)(); /* free mem allocated for args */
200 void (*xp_destroy)(); /* destroy this struct */
202 int xp_addrlen; /* length of remote addr. Obsolete */
203 struct sockaddr_in xp_raddr; /* Obsolete */
204 const struct xp_ops2 {
205 bool_t (*xp_control)(); /* catch-all function */
207 char *xp_tp; /* transport provider device name */
208 char *xp_netid; /* network identifier */
209 struct netbuf xp_ltaddr; /* local transport address */
210 struct netbuf xp_rtaddr; /* remote transport address */
211 struct opaque_auth xp_verf; /* raw response verifier */
212 caddr_t xp_p1; /* private: for use by svc ops */
213 caddr_t xp_p2; /* private: for use by svc ops */
214 caddr_t xp_p3; /* private: for use by svc lib */
215 int xp_type /* transport type */
218 .Sh "The svc_reg structure"
221 rpcprog_t rq_prog; /* service program number */
222 rpcvers_t rq_vers; /* service protocol version */
223 rpcproc_t rq_proc; /* the desired procedure */
224 struct opaque_auth rq_cred; /* raw creds from the wire */
225 caddr_t rq_clntcred; /* read only cooked cred */
226 SVCXPRT *rq_xprt; /* associated transport */
229 .Sh "The XDR structure"
233 * XDR_ENCODE causes the type to be encoded into the stream.
234 * XDR_DECODE causes the type to be extracted from the stream.
235 * XDR_FREE can be used to release the space allocated by an XDR_DECODE
244 * This is the number of bytes per unit of external data.
246 #define BYTES_PER_XDR_UNIT (4)
247 #define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) /
248 BYTES_PER_XDR_UNIT) \e * BYTES_PER_XDR_UNIT)
251 * A xdrproc_t exists for each data type which is to be encoded or
252 * decoded. The second argument to the xdrproc_t is a pointer to
253 * an opaque pointer. The opaque pointer generally points to a
254 * structure of the data type to be decoded. If this points to 0,
255 * then the type routines should allocate dynamic storage of the
256 * appropriate size and return it.
257 * bool_t (*xdrproc_t)(XDR *, caddr_t *);
259 typedef bool_t (*xdrproc_t)();
263 * Contains operation which is being applied to the stream,
264 * an operations vector for the particular implementation
267 enum xdr_op x_op; /* operation; fast additional param */
269 bool_t (*x_getlong)(); /* get a long from underlying stream */
270 bool_t (*x_putlong)(); /* put a long to underlying stream */
271 bool_t (*x_getbytes)(); /* get bytes from underlying stream */
272 bool_t (*x_putbytes)(); /* put bytes to underlying stream */
273 u_int (*x_getpostn)(); /* returns bytes off from beginning */
274 bool_t (*x_setpostn)(); /* lets you reposition the stream */
275 long * (*x_inline)(); /* buf quick ptr to buffered data */
276 void (*x_destroy)(); /* free privates of this xdr_stream */
278 caddr_t x_public; /* users' data */
279 caddr_t x_private; /* pointer to private data */
280 caddr_t x_base; /* private used for position info */
281 u_int x_handy; /* extra private word */
285 * The netbuf structure. This structure is defined in <xti.h> on SysV
286 * systems, but NetBSD / FreeBSD do not use XTI.
288 * Usually, buf will point to a struct sockaddr, and len and maxlen
289 * will contain the length and maximum length of that socket address,
299 * The format of the address and options arguments of the XTI t_bind call.
300 * Only provided for compatibility, it should not be used other than
301 * as an argument to svc_tli_create().
309 .Sh "Index to Routines"
310 The following table lists RPC routines and the manual reference
311 pages on which they are described:
313 .Bl -tag -width "authunix_create_default()" -compact
315 .Em "Manual Reference Page"
319 .It Fn authdes_create
321 .It Fn authnone_create
323 .It Fn authsys_create
325 .It Fn authsys_create_default
327 .It Fn authunix_create
329 .It Fn authunix_create_default
333 .It Fn clnt_broadcast
338 .Xr rpc_clnt_create 3
340 .Xr rpc_clnt_create 3
341 .It Fn clnt_create_timed
342 .Xr rpc_clnt_create 3
343 .It Fn clnt_create_vers
344 .Xr rpc_clnt_create 3
345 .It Fn clnt_create_vers_timed
346 .Xr rpc_clnt_create 3
348 .Xr rpc_clnt_create 3
349 .It Fn clnt_dg_create
350 .Xr rpc_clnt_create 3
355 .It Fn clnt_pcreateerror
356 .Xr rpc_clnt_create 3
361 .It Fn clnt_raw_create
362 .Xr rpc_clnt_create 3
363 .It Fn clnt_spcreateerror
364 .Xr rpc_clnt_create 3
369 .It Fn clnt_tli_create
370 .Xr rpc_clnt_create 3
371 .It Fn clnt_tp_create
372 .Xr rpc_clnt_create 3
373 .It Fn clnt_tp_create_timed
374 .Xr rpc_clnt_create 3
375 .It Fn clnt_udpcreate
377 .It Fn clnt_vc_create
378 .Xr rpc_clnt_create 3
379 .It Fn clntraw_create
381 .It Fn clnttcp_create
383 .It Fn clntudp_bufcreate
401 .It Fn rpc_broadcast_exp
413 .It Fn svc_dg_enablecache
429 .It Fn svc_getrpccaller
433 .It Fn svc_raw_create
443 .It Fn svc_tli_create
449 .It Fn svc_unregister
461 .It Fn svcerr_progvers
463 .It Fn svcerr_systemerr
465 .It Fn svcerr_weakauth
473 .It Fn svcudp_bufcreate
477 .It Fn xdr_accepted_reply
479 .It Fn xdr_authsys_parms
481 .It Fn xdr_authunix_parms
487 .It Fn xdr_opaque_auth
489 .It Fn xdr_rejected_reply
495 .It Fn xprt_unregister
499 .Bl -tag -width /etc/netconfig
500 .It Pa /etc/netconfig
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 ,