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