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