xref: /dflybsd-src/lib/libc/rpc/rpc_svc_create.3 (revision 277a81d9fe2047f1a89439c4bc1659f09a1cdea0)
1ce0e08e2SPeter Avalos.\" @(#)rpc_svc_create.3n 1.26 93/08/26 SMI; from SVr4
2ce0e08e2SPeter Avalos.\" Copyright 1989 AT&T
3ce0e08e2SPeter Avalos.\" @(#)rpc_svc_create 1.3 89/06/28 SMI;
4ce0e08e2SPeter Avalos.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
5ce0e08e2SPeter Avalos.\" $FreeBSD: src/lib/libc/rpc/rpc_svc_create.3,v 1.7 2003/09/08 19:57:15 ru Exp $
6ce0e08e2SPeter Avalos.Dd May 3, 1993
7ce0e08e2SPeter Avalos.Dt RPC_SVC_CREATE 3
8ce0e08e2SPeter Avalos.Os
9ce0e08e2SPeter Avalos.Sh NAME
10ce0e08e2SPeter Avalos.Nm rpc_svc_create ,
11*08f3c0daSSascha Wildner.\".Nm svc_control ,
12ce0e08e2SPeter Avalos.Nm svc_create ,
13ce0e08e2SPeter Avalos.Nm svc_destroy ,
14ce0e08e2SPeter Avalos.Nm svc_dg_create ,
15ce0e08e2SPeter Avalos.Nm svc_fd_create ,
16ce0e08e2SPeter Avalos.Nm svc_raw_create ,
17ce0e08e2SPeter Avalos.Nm svc_tli_create ,
18ce0e08e2SPeter Avalos.Nm svc_tp_create ,
19ce0e08e2SPeter Avalos.Nm svc_vc_create
20ce0e08e2SPeter Avalos.Nd library routines for the creation of server handles
21ce0e08e2SPeter Avalos.Sh LIBRARY
22ce0e08e2SPeter Avalos.Lb libc
23ce0e08e2SPeter Avalos.Sh SYNOPSIS
24ce0e08e2SPeter Avalos.In rpc/rpc.h
25*08f3c0daSSascha Wildner.\".Ft bool_t
26*08f3c0daSSascha Wildner.\".Fn svc_control "SVCXPRT *svc" "const u_int req" "void *info"
27ce0e08e2SPeter Avalos.Ft int
28ce0e08e2SPeter Avalos.Fn svc_create "void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype"
29ce0e08e2SPeter Avalos.Ft SVCXPRT *
30ce0e08e2SPeter Avalos.Fn svc_dg_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
31ce0e08e2SPeter Avalos.Ft void
32ce0e08e2SPeter Avalos.Fn svc_destroy "SVCXPRT *xprt"
33ce0e08e2SPeter Avalos.Ft "SVCXPRT *"
34ce0e08e2SPeter Avalos.Fn svc_fd_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
35ce0e08e2SPeter Avalos.Ft "SVCXPRT *"
36ce0e08e2SPeter Avalos.Fn svc_raw_create "void"
37ce0e08e2SPeter Avalos.Ft "SVCXPRT *"
38ce0e08e2SPeter Avalos.Fn svc_tli_create "const int fildes" "const struct netconfig *netconf" "const struct t_bind *bindaddr" "const u_int sendsz" "const u_int recvsz"
39ce0e08e2SPeter Avalos.Ft "SVCXPRT *"
40ce0e08e2SPeter Avalos.Fn svc_tp_create "void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf"
41ce0e08e2SPeter Avalos.Ft "SVCXPRT *"
42ce0e08e2SPeter Avalos.Fn svc_vc_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
43ce0e08e2SPeter Avalos.Sh DESCRIPTION
44ce0e08e2SPeter AvalosThese routines are part of the RPC
45ce0e08e2SPeter Avaloslibrary which allows C language programs to make procedure
46ce0e08e2SPeter Avaloscalls on servers across the network.
47ce0e08e2SPeter AvalosThese routines deal with the creation of service handles.
48ce0e08e2SPeter AvalosOnce the handle is created, the server can be invoked by calling
49ce0e08e2SPeter Avalos.Fn svc_run .
50ce0e08e2SPeter Avalos.Sh Routines
51ce0e08e2SPeter AvalosSee
52ce0e08e2SPeter Avalos.Xr rpc 3
53ce0e08e2SPeter Avalosfor the definition of the
54ce0e08e2SPeter Avalos.Vt SVCXPRT
55ce0e08e2SPeter Avalosdata structure.
56ce0e08e2SPeter Avalos.Bl -tag -width XXXXX
57*08f3c0daSSascha Wildner.\".It Fn svc_control
58*08f3c0daSSascha Wildner.\"A function to change or retrieve various information
59*08f3c0daSSascha Wildner.\"about a service object.
60*08f3c0daSSascha Wildner.\"The
61*08f3c0daSSascha Wildner.\".Fa req
62*08f3c0daSSascha Wildner.\"argument
63*08f3c0daSSascha Wildner.\"indicates the type of operation and
64*08f3c0daSSascha Wildner.\".Fa info
65*08f3c0daSSascha Wildner.\"is a pointer to the information.
66*08f3c0daSSascha Wildner.\"The supported values of
67*08f3c0daSSascha Wildner.\".Fa req ,
68*08f3c0daSSascha Wildner.\"their argument types, and what they do are:
69*08f3c0daSSascha Wildner.\".Bl -tag -width SVCGET_XID
70*08f3c0daSSascha Wildner.\".It Dv SVCGET_VERSQUIET
71*08f3c0daSSascha Wildner.\"If a request is received for a program number
72*08f3c0daSSascha Wildner.\"served by this server but the version number
73*08f3c0daSSascha Wildner.\"is outside the range registered with the server,
74*08f3c0daSSascha Wildner.\"an
75*08f3c0daSSascha Wildner.\".Dv RPC_PROGVERSMISMATCH
76*08f3c0daSSascha Wildner.\"error will normally
77*08f3c0daSSascha Wildner.\"be returned.
78*08f3c0daSSascha Wildner.\"The
79*08f3c0daSSascha Wildner.\".Fa info
80*08f3c0daSSascha Wildner.\"argument
81*08f3c0daSSascha Wildner.\"should be a pointer to an
82*08f3c0daSSascha Wildner.\"integer.
83*08f3c0daSSascha Wildner.\"Upon successful completion of the
84*08f3c0daSSascha Wildner.\".Dv SVCGET_VERSQUIET
85*08f3c0daSSascha Wildner.\"request,
86*08f3c0daSSascha Wildner.\".Fa *info
87*08f3c0daSSascha Wildner.\"contains an
88*08f3c0daSSascha Wildner.\"integer which describes the server's current
89*08f3c0daSSascha Wildner.\"behavior: 0 indicates normal server behavior
90*08f3c0daSSascha Wildner.\"(that is, an
91*08f3c0daSSascha Wildner.\".Dv RPC_PROGVERSMISMATCH
92*08f3c0daSSascha Wildner.\"error
93*08f3c0daSSascha Wildner.\"will be returned); 1 indicates that the out of
94*08f3c0daSSascha Wildner.\"range request will be silently ignored.
95*08f3c0daSSascha Wildner.\".It Dv SVCSET_VERSQUIET
96*08f3c0daSSascha Wildner.\"If a request is received for a program number
97*08f3c0daSSascha Wildner.\"served by this server but the version number
98*08f3c0daSSascha Wildner.\"is outside the range registered with the server,
99*08f3c0daSSascha Wildner.\"an
100*08f3c0daSSascha Wildner.\".Dv RPC_PROGVERSMISMATCH
101*08f3c0daSSascha Wildner.\"error will normally
102*08f3c0daSSascha Wildner.\"be returned.
103*08f3c0daSSascha Wildner.\"It is sometimes desirable to
104*08f3c0daSSascha Wildner.\"change this behavior.
105*08f3c0daSSascha Wildner.\"The
106*08f3c0daSSascha Wildner.\".Fa info
107*08f3c0daSSascha Wildner.\"argument
108*08f3c0daSSascha Wildner.\"should be a
109*08f3c0daSSascha Wildner.\"pointer to an integer which is either 0
110*08f3c0daSSascha Wildner.\"(indicating normal server behavior - an
111*08f3c0daSSascha Wildner.\".Dv RPC_PROGVERSMISMATCH
112*08f3c0daSSascha Wildner.\"error will be returned),
113*08f3c0daSSascha Wildner.\"or 1 (indicating that the out of range request
114*08f3c0daSSascha Wildner.\"should be silently ignored).
115*08f3c0daSSascha Wildner.\".El
116ce0e08e2SPeter Avalos.It Fn svc_create
117ce0e08e2SPeter AvalosThe
118ce0e08e2SPeter Avalos.Fn svc_create
119ce0e08e2SPeter Avalosfunction
120ce0e08e2SPeter Avaloscreates server handles for all the transports
121ce0e08e2SPeter Avalosbelonging to the class
122ce0e08e2SPeter Avalos.Fa nettype .
123ce0e08e2SPeter AvalosThe
124ce0e08e2SPeter Avalos.Fa nettype
125ce0e08e2SPeter Avalosargument
126ce0e08e2SPeter Avalosdefines a class of transports which can be used
127ce0e08e2SPeter Avalosfor a particular application.
128ce0e08e2SPeter AvalosThe transports are tried in left to right order in
129ce0e08e2SPeter Avalos.Ev NETPATH
130ce0e08e2SPeter Avalosvariable or in top to bottom order in the netconfig database.
131ce0e08e2SPeter AvalosIf
132ce0e08e2SPeter Avalos.Fa nettype
133ce0e08e2SPeter Avalosis
134ce0e08e2SPeter Avalos.Dv NULL ,
135ce0e08e2SPeter Avalosit defaults to
136ce0e08e2SPeter Avalos.Qq netpath .
137ce0e08e2SPeter Avalos.Pp
138ce0e08e2SPeter AvalosThe
139ce0e08e2SPeter Avalos.Fn svc_create
140ce0e08e2SPeter Avalosfunction
141ce0e08e2SPeter Avalosregisters itself with the rpcbind
142ce0e08e2SPeter Avalosservice (see
143ce0e08e2SPeter Avalos.Xr rpcbind 8 ) .
144ce0e08e2SPeter AvalosThe
145ce0e08e2SPeter Avalos.Fa dispatch
146ce0e08e2SPeter Avalosfunction
147ce0e08e2SPeter Avalosis called when there is a remote procedure call for the given
148ce0e08e2SPeter Avalos.Fa prognum
149ce0e08e2SPeter Avalosand
150ce0e08e2SPeter Avalos.Fa versnum ;
151ce0e08e2SPeter Avalosthis requires calling
152ce0e08e2SPeter Avalos.Fn svc_run
153ce0e08e2SPeter Avalos(see
154ce0e08e2SPeter Avalos.Fn svc_run
155ce0e08e2SPeter Avalosin
156ce0e08e2SPeter Avalos.Xr rpc_svc_reg 3 ) .
157ce0e08e2SPeter AvalosIf
158ce0e08e2SPeter Avalos.Fn svc_create
159ce0e08e2SPeter Avalossucceeds, it returns the number of server
160ce0e08e2SPeter Avaloshandles it created,
161ce0e08e2SPeter Avalosotherwise it returns 0 and an error message is logged.
162ce0e08e2SPeter Avalos.It Fn svc_destroy
163ce0e08e2SPeter AvalosA function macro that destroys the RPC
164ce0e08e2SPeter Avalosservice handle
165ce0e08e2SPeter Avalos.Fa xprt .
166ce0e08e2SPeter AvalosDestruction usually involves deallocation
167ce0e08e2SPeter Avalosof private data structures,
168ce0e08e2SPeter Avalosincluding
169ce0e08e2SPeter Avalos.Fa xprt
170ce0e08e2SPeter Avalositself.
171ce0e08e2SPeter AvalosUse of
172ce0e08e2SPeter Avalos.Fa xprt
173ce0e08e2SPeter Avalosis undefined after calling this routine.
174ce0e08e2SPeter Avalos.It Fn svc_dg_create
175ce0e08e2SPeter AvalosThis routine creates a connectionless RPC
176ce0e08e2SPeter Avalosservice handle, and returns a pointer to it.
177ce0e08e2SPeter AvalosThis routine returns
178ce0e08e2SPeter Avalos.Dv NULL
179ce0e08e2SPeter Avalosif it fails, and an error message is logged.
180ce0e08e2SPeter AvalosThe
181ce0e08e2SPeter Avalos.Fa sendsz
182ce0e08e2SPeter Avalosand
183ce0e08e2SPeter Avalos.Fa recvsz
184ce0e08e2SPeter Avalosarguments
185ce0e08e2SPeter Avalosare arguments used to specify the size of the buffers.
186ce0e08e2SPeter AvalosIf they are 0, suitable defaults are chosen.
187ce0e08e2SPeter AvalosThe file descriptor
188ce0e08e2SPeter Avalos.Fa fildes
189ce0e08e2SPeter Avalosshould be open and bound.
190ce0e08e2SPeter AvalosThe server is not registered with
191ce0e08e2SPeter Avalos.Xr rpcbind 8 .
192ce0e08e2SPeter Avalos.Pp
193ce0e08e2SPeter AvalosWarning:
194ce0e08e2SPeter Avalossince connectionless-based RPC
195ce0e08e2SPeter Avalosmessages can only hold limited amount of encoded data,
196ce0e08e2SPeter Avalosthis transport cannot be used for procedures
197ce0e08e2SPeter Avalosthat take large arguments or return huge results.
198ce0e08e2SPeter Avalos.It Fn svc_fd_create
199ce0e08e2SPeter AvalosThis routine creates a service on top of an open and bound file descriptor,
200ce0e08e2SPeter Avalosand returns the handle to it.
201ce0e08e2SPeter AvalosTypically, this descriptor is a connected file descriptor for a
202ce0e08e2SPeter Avalosconnection-oriented transport.
203ce0e08e2SPeter AvalosThe
204ce0e08e2SPeter Avalos.Fa sendsz
205ce0e08e2SPeter Avalosand
206ce0e08e2SPeter Avalos.Fa recvsz
207ce0e08e2SPeter Avalosarguments
208ce0e08e2SPeter Avalosindicate sizes for the send and receive buffers.
209ce0e08e2SPeter AvalosIf they are 0, reasonable defaults are chosen.
210ce0e08e2SPeter AvalosThis routine returns
211ce0e08e2SPeter Avalos.Dv NULL
212ce0e08e2SPeter Avalosif it fails, and an error message is logged.
213ce0e08e2SPeter Avalos.It Fn svc_raw_create
214ce0e08e2SPeter AvalosThis routine creates an RPC
215ce0e08e2SPeter Avalosservice handle and returns a pointer to it.
216ce0e08e2SPeter AvalosThe transport is really a buffer within the process's
217ce0e08e2SPeter Avalosaddress space, so the corresponding RPC
218ce0e08e2SPeter Avalosclient should live in the same address space;
219ce0e08e2SPeter Avalos(see
220ce0e08e2SPeter Avalos.Fn clnt_raw_create
221ce0e08e2SPeter Avalosin
222ce0e08e2SPeter Avalos.Xr rpc_clnt_create 3 ) .
223ce0e08e2SPeter AvalosThis routine allows simulation of RPC and acquisition of
224ce0e08e2SPeter AvalosRPC overheads (such as round trip times),
225ce0e08e2SPeter Avaloswithout any kernel and networking interference.
226ce0e08e2SPeter AvalosThis routine returns
227ce0e08e2SPeter Avalos.Dv NULL
228ce0e08e2SPeter Avalosif it fails, and an error message is logged.
229ce0e08e2SPeter Avalos.Pp
230ce0e08e2SPeter AvalosNote:
231ce0e08e2SPeter Avalos.Fn svc_run
232ce0e08e2SPeter Avalosshould not be called when the raw interface is being used.
233ce0e08e2SPeter Avalos.It Fn svc_tli_create
234ce0e08e2SPeter AvalosThis routine creates an RPC
235ce0e08e2SPeter Avalosserver handle, and returns a pointer to it.
236ce0e08e2SPeter AvalosThe
237ce0e08e2SPeter Avalos.Fa fildes
238ce0e08e2SPeter Avalosargument
239ce0e08e2SPeter Avalosis the file descriptor on which the service is listening.
240ce0e08e2SPeter AvalosIf
241ce0e08e2SPeter Avalos.Fa fildes
242ce0e08e2SPeter Avalosis
243ce0e08e2SPeter Avalos.Dv RPC_ANYFD ,
244ce0e08e2SPeter Avalosit opens a file descriptor on the transport specified by
245ce0e08e2SPeter Avalos.Fa netconf .
246ce0e08e2SPeter AvalosIf the file descriptor is unbound and
247ce0e08e2SPeter Avalos.Fa bindaddr
248ce0e08e2SPeter Avalosis not
249ce0e08e2SPeter Avalos.Dv NULL ,
250ce0e08e2SPeter Avalos.Fa fildes
251ce0e08e2SPeter Avalosis bound to the address specified by
252ce0e08e2SPeter Avalos.Fa bindaddr ,
253ce0e08e2SPeter Avalosotherwise
254ce0e08e2SPeter Avalos.Fa fildes
255ce0e08e2SPeter Avalosis bound to a default address chosen by the transport.
256ce0e08e2SPeter Avalos.Pp
257ce0e08e2SPeter AvalosNote: the
258ce0e08e2SPeter Avalos.Vt t_bind
259ce0e08e2SPeter Avalosstructure comes from the TLI/XTI SysV interface, which
260ce0e08e2SPeter Avalos.Nx
261ce0e08e2SPeter Avalosdoes not use.
262ce0e08e2SPeter AvalosThe structure is defined in
263ce0e08e2SPeter Avalos.In rpc/types.h
264ce0e08e2SPeter Avalosfor compatibility as:
265ce0e08e2SPeter Avalos.Bd -literal
266ce0e08e2SPeter Avalosstruct t_bind {
267ce0e08e2SPeter Avalos    struct netbuf addr;	/* network address, see rpc(3) */
268ce0e08e2SPeter Avalos    unsigned int  qlen;	/* queue length (for listen(2)) */
269ce0e08e2SPeter Avalos};
270ce0e08e2SPeter Avalos.Ed
271ce0e08e2SPeter Avalos.Pp
272ce0e08e2SPeter AvalosIn the case where the default address is chosen,
273ce0e08e2SPeter Avalosthe number of outstanding connect requests is set to 8
274ce0e08e2SPeter Avalosfor connection-oriented transports.
275ce0e08e2SPeter AvalosThe user may specify the size of the send and receive buffers
276ce0e08e2SPeter Avaloswith the arguments
277ce0e08e2SPeter Avalos.Fa sendsz
278ce0e08e2SPeter Avalosand
279ce0e08e2SPeter Avalos.Fa recvsz ;
280ce0e08e2SPeter Avalosvalues of 0 choose suitable defaults.
281ce0e08e2SPeter AvalosThis routine returns
282ce0e08e2SPeter Avalos.Dv NULL
283ce0e08e2SPeter Avalosif it fails,
284ce0e08e2SPeter Avalosand an error message is logged.
285ce0e08e2SPeter AvalosThe server is not registered with the
286ce0e08e2SPeter Avalos.Xr rpcbind 8
287ce0e08e2SPeter Avalosservice.
288ce0e08e2SPeter Avalos.It Fn svc_tp_create
289ce0e08e2SPeter AvalosThe
290ce0e08e2SPeter Avalos.Fn svc_tp_create
291ce0e08e2SPeter Avalosfunction
292ce0e08e2SPeter Avaloscreates a server handle for the network
293ce0e08e2SPeter Avalosspecified by
294ce0e08e2SPeter Avalos.Fa netconf ,
295ce0e08e2SPeter Avalosand registers itself with the rpcbind service.
296ce0e08e2SPeter AvalosThe
297ce0e08e2SPeter Avalos.Fa dispatch
298ce0e08e2SPeter Avalosfunction
299ce0e08e2SPeter Avalosis called when there is a remote procedure call
300ce0e08e2SPeter Avalosfor the given
301ce0e08e2SPeter Avalos.Fa prognum
302ce0e08e2SPeter Avalosand
303ce0e08e2SPeter Avalos.Fa versnum ;
304ce0e08e2SPeter Avalosthis requires calling
305ce0e08e2SPeter Avalos.Fn svc_run .
306ce0e08e2SPeter AvalosThe
307ce0e08e2SPeter Avalos.Fn svc_tp_create
308ce0e08e2SPeter Avalosfunction
309ce0e08e2SPeter Avalosreturns the service handle if it succeeds,
310ce0e08e2SPeter Avalosotherwise a
311ce0e08e2SPeter Avalos.Dv NULL
312ce0e08e2SPeter Avalosis returned and an error message is logged.
313ce0e08e2SPeter Avalos.It Fn svc_vc_create
314ce0e08e2SPeter AvalosThis routine creates a connection-oriented RPC
315ce0e08e2SPeter Avalosservice and returns a pointer to it.
316ce0e08e2SPeter AvalosThis routine returns
317ce0e08e2SPeter Avalos.Dv NULL
318ce0e08e2SPeter Avalosif it fails, and an error message is logged.
319ce0e08e2SPeter AvalosThe users may specify the size of the send and receive buffers
320ce0e08e2SPeter Avaloswith the arguments
321ce0e08e2SPeter Avalos.Fa sendsz
322ce0e08e2SPeter Avalosand
323ce0e08e2SPeter Avalos.Fa recvsz ;
324ce0e08e2SPeter Avalosvalues of 0 choose suitable defaults.
325ce0e08e2SPeter AvalosThe file descriptor
326ce0e08e2SPeter Avalos.Fa fildes
327ce0e08e2SPeter Avalosshould be open and bound.
328ce0e08e2SPeter AvalosThe server is not registered with the
329ce0e08e2SPeter Avalos.Xr rpcbind 8
330ce0e08e2SPeter Avalosservice.
331ce0e08e2SPeter Avalos.El
332ce0e08e2SPeter Avalos.Sh SEE ALSO
333ce0e08e2SPeter Avalos.Xr rpc 3 ,
334ce0e08e2SPeter Avalos.Xr rpc_svc_calls 3 ,
335ce0e08e2SPeter Avalos.Xr rpc_svc_err 3 ,
336ce0e08e2SPeter Avalos.Xr rpc_svc_reg 3 ,
337ce0e08e2SPeter Avalos.Xr rpcbind 8
338