summaryrefslogtreecommitdiffstats
path: root/lib/libc/rpc/rpc_svc_create.3
blob: b9788b2e3a70f30b7f83bd0ca8a96c36e58575df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
.\" @(#)rpc_svc_create.3n 1.26 93/08/26 SMI; from SVr4
.\" Copyright 1989 AT&T
.\" @(#)rpc_svc_create 1.3 89/06/28 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.\" $FreeBSD$
.Dd May 3, 1993
.Dt RPC_SVC_CREATE 3
.Os
.Sh NAME
.Nm rpc_svc_create ,
.Nm svc_control ,
.Nm svc_create ,
.Nm svc_destroy ,
.Nm svc_dg_create ,
.Nm svc_fd_create ,
.Nm svc_raw_create ,
.Nm svc_tli_create ,
.Nm svc_tp_create ,
.Nm svc_vc_create
.Nd library routines for the creation of server handles
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.Fd #include <rpc/rpc.h>
.Ft bool_t
.Fn svc_control "SVCXPRT *svc" "const u_int req" "void *info"
.Ft int
.Fn svc_create "const void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype"
.Ft SVCXPRT *"
.Fn svc_dg_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
.Ft void
.Fn svc_destroy "SVCXPRT *xprt"
.Ft "SVCXPRT *"
.Fn svc_fd_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
.Ft "SVCXPRT *"
.Fn svc_raw_create "void"
.Ft "SVCXPRT *"
.Fn svc_tli_create "const int fildes" "const struct netconfig *netconf" "const struct t_bind *bindaddr" "const u_int sendsz" "const u_int recvsz"
.Ft "SVCXPRT *"
.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"
.Ft "SVCXPRT *"
.Fn svc_vc_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
.Sh DESCRIPTION
These routines are part of the RPC
library which allows C language programs to make procedure
calls on servers across the network.
These routines deal with the creation of service handles.
Once the handle is created, the server can be invoked by calling
.Fn svc_run .
.Sh Routines
See
.Xr rpc 3
for the definition of the
.Vt SVCXPRT
data structure.
.Bl -tag -width XXXXX
.It Fn svc_control
A function to change or retrieve various information
about a service object.
.Fa req
indicates the type of operation and
.Fa info
is a pointer to the information.
The supported values of
.Fa req ,
their argument types, and what they do are:
.Bl -tag -width SVCGET_XID
.It Dv SVCGET_VERSQUIET
If a request is received for a program number
served by this server but the version number
is outside the range registered with the server,
an
.Dv RPC_PROGVERSMISMATCH
error will normally
be returned.
.Fa info
should be a pointer to an
integer.
Upon successful completion of the
.Dv SVCGET_VERSQUIET
request,
.Fa *info
contains an
integer which describes the server's current
behavior: 0 indicates normal server behavior
(that is, an
.Dv RPC_PROGVERSMISMATCH
error
will be returned); 1 indicates that the out of
range request will be silently ignored.
.It Dv SVCSET_VERSQUIET
If a request is received for a program number
served by this server but the version number
is outside the range registered with the server,
an
.Dv RPC_PROGVERSMISMATCH
error will normally
be returned.
It is sometimes desirable to
change this behavior.
.Fa info
should be a
pointer to an integer which is either 0
(indicating normal server behavior - an
.Dv RPC_PROGVERSMISMATCH
error will be returned),
or 1 (indicating that the out of range request
should be silently ignored).
.El
.It Fn svc_create
.Fn svc_create
creates server handles for all the transports
belonging to the class
.Fa nettype .
.Fa nettype
defines a class of transports which can be used
for a particular application.
The transports are tried in left to right order in
.Ev NETPATH
variable or in top to bottom order in the netconfig database.
If
.Fa nettype
is
.Dv NULL ,
it defaults to
.Qq netpath .
.Pp
.Fn svc_create
registers itself with the rpcbind
service (see
.Xr rpcbind 8 ) .
.Fa dispatch
is called when there is a remote procedure call for the given
.Fa prognum
and
.Fa versnum ;
this requires calling
.Fn svc_run
(see
.Fn svc_run
in
.Xr rpc_svc_reg 3 ) .
If
.Fn svc_create
succeeds, it returns the number of server
handles it created,
otherwise it returns 0 and an error message is logged.
.It Fn svc_destroy
A function macro that destroys the RPC
service handle
.Fa xprt .
Destruction usually involves deallocation
of private data structures,
including
.Fa xprt
itself.
Use of
.Fa xprt
is undefined after calling this routine.
.It Fn svc_dg_create
This routine creates a connectionless RPC
service handle, and returns a pointer to it.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
.Fa sendsz
and
.Fa recvsz
are parameters used to specify the size of the buffers.
If they are 0, suitable defaults are chosen.
The file descriptor
.Fa fildes
should be open and bound.
The server is not registered with
.Xr rpcbind 8 .
.Pp
Warning:
since connectionless-based RPC
messages can only hold limited amount of encoded data,
this transport cannot be used for procedures
that take large arguments or return huge results.
.It Fn svc_fd_create
This routine creates a service on top of an open and bound file descriptor,
and returns the handle to it.
Typically, this descriptor is a connected file descriptor for a
connection-oriented transport.
.Fa sendsz
and
.Fa recvsz
indicate sizes for the send and receive buffers.
If they are 0, reasonable defaults are chosen.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
.It Fn svc_raw_create
This routine creates an RPC
service handle and returns a pointer to it.
The transport is really a buffer within the process's
address space, so the corresponding RPC
client should live in the same address space;
(see
.Fn clnt_raw_create
in
.Xr rpc_clnt_create 3 ) .
This routine allows simulation of RPC and acquisition of
RPC overheads (such as round trip times),
without any kernel and networking interference.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
.Pp
Note:
.Fn svc_run
should not be called when the raw interface is being used.
.It Fn svc_tli_create
This routine creates an RPC
server handle, and returns a pointer to it.
.Fa fildes
is the file descriptor on which the service is listening.
If
.Fa fildes
is
.Dv RPC_ANYFD ,
it opens a file descriptor on the transport specified by
.Fa netconf .
If the file descriptor is unbound and
.Fa bindaddr
is not
.Dv NULL ,
.Fa fildes
is bound to the address specified by
.Fa bindaddr ,
otherwise
.Fa fildes
is bound to a default address chosen by the transport.
.Pp
Note: the
.Vt t_bind
structure comes from the TLI/XTI SysV interface, which
.Nx
does not use.
The structure is defined in
.Aq Pa rpc/types.h
for compatibility as:
.Bd -literal
struct t_bind {
    struct netbuf addr;	/* network address, see rpc(3) */
    unsigned int  qlen;	/* queue length (for listen(2)) */
};
.Ed
.Pp
In the case where the default address is chosen,
the number of outstanding connect requests is set to 8
for connection-oriented transports.
The user may specify the size of the send and receive buffers
with the parameters
.Fa sendsz
and
.Fa recvsz ;
values of 0 choose suitable defaults.
This routine returns
.Dv NULL
if it fails,
and an error message is logged.
The server is not registered with the
.Xr rpcbind 8
service.
.It Fn svc_tp_create
.Fn svc_tp_create
creates a server handle for the network
specified by
.Fa netconf ,
and registers itself with the rpcbind service.
.Fa dispatch
is called when there is a remote procedure call
for the given
.Fa prognum
and
.Fa versnum ;
this requires calling
.Fn svc_run .
.Fn svc_tp_create
returns the service handle if it succeeds,
otherwise a
.Dv NULL
is returned and an error message is logged.
.It Fn svc_vc_create
This routine creates a connection-oriented RPC
service and returns a pointer to it.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
The users may specify the size of the send and receive buffers
with the parameters
.Fa sendsz
and
.Fa recvsz ;
values of 0 choose suitable defaults.
The file descriptor
.Fa fildes
should be open and bound.
The server is not registered with the
.Xr rpcbind 8
service.
.El
.Sh SEE ALSO
.Xr rpc 3 ,
.Xr rpc_svc_calls 3 ,
.Xr rpc_svc_err 3 ,
.Xr rpc_svc_reg 3 ,
.Xr rpcbind 8
.\" @(#)rpc_svc_create.3n 1.26 93/08/26 SMI; from SVr4
.\" Copyright 1989 AT&T
.\" @(#)rpc_svc_create 1.3 89/06/28 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.\" $FreeBSD$
.Dd May 3, 1993
.Dt RPC_SVC_CREATE 3
.Os
.Sh NAME
.Nm rpc_svc_create ,
.Nm svc_control ,
.Nm svc_create ,
.Nm svc_destroy ,
.Nm svc_dg_create ,
.Nm svc_fd_create ,
.Nm svc_raw_create ,
.Nm svc_tli_create ,
.Nm svc_tp_create ,
.Nm svc_vc_create
.Nd library routines for the creation of server handles
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.Fd #include <rpc/rpc.h>
.Ft bool_t
.Fn svc_control "SVCXPRT *svc" "const u_int req" "void *info"
.Ft int
.Fn svc_create "const void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype"
.Ft SVCXPRT *"
.Fn svc_dg_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
.Ft void
.Fn svc_destroy "SVCXPRT *xprt"
.Ft "SVCXPRT *"
.Fn svc_fd_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
.Ft "SVCXPRT *"
.Fn svc_raw_create "void"
.Ft "SVCXPRT *"
.Fn svc_tli_create "const int fildes" "const struct netconfig *netconf" "const struct t_bind *bindaddr" "const u_int sendsz" "const u_int recvsz"
.Ft "SVCXPRT *"
.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"
.Ft "SVCXPRT *"
.Fn svc_vc_create "const int fildes" "const u_int sendsz" "const u_int recvsz"
.Sh DESCRIPTION
These routines are part of the RPC
library which allows C language programs to make procedure
calls on servers across the network.
These routines deal with the creation of service handles.
Once the handle is created, the server can be invoked by calling
.Fn svc_run .
.Sh Routines
See
.Xr rpc 3
for the definition of the
.Vt SVCXPRT
data structure.
.Bl -tag -width XXXXX
.It Fn svc_control
A function to change or retrieve various information
about a service object.
.Fa req
indicates the type of operation and
.Fa info
is a pointer to the information.
The supported values of
.Fa req ,
their argument types, and what they do are:
.Bl -tag -width SVCGET_XID
.It Dv SVCGET_VERSQUIET
If a request is received for a program number
served by this server but the version number
is outside the range registered with the server,
an
.Dv RPC_PROGVERSMISMATCH
error will normally
be returned.
.Fa info
should be a pointer to an
integer.
Upon successful completion of the
.Dv SVCGET_VERSQUIET
request,
.Fa *info
contains an
integer which describes the server's current
behavior: 0 indicates normal server behavior
(that is, an
.Dv RPC_PROGVERSMISMATCH
error
will be returned); 1 indicates that the out of
range request will be silently ignored.
.It Dv SVCSET_VERSQUIET
If a request is received for a program number
served by this server but the version number
is outside the range registered with the server,
an
.Dv RPC_PROGVERSMISMATCH
error will normally
be returned.
It is sometimes desirable to
change this behavior.
.Fa info
should be a
pointer to an integer which is either 0
(indicating normal server behavior - an
.Dv RPC_PROGVERSMISMATCH
error will be returned),
or 1 (indicating that the out of range request
should be silently ignored).
.El
.It Fn svc_create
.Fn svc_create
creates server handles for all the transports
belonging to the class
.Fa nettype .
.Fa nettype
defines a class of transports which can be used
for a particular application.
The transports are tried in left to right order in
.Ev NETPATH
variable or in top to bottom order in the netconfig database.
If
.Fa nettype
is
.Dv NULL ,
it defaults to
.Qq netpath .
.Pp
.Fn svc_create
registers itself with the rpcbind
service (see
.Xr rpcbind 8 ) .
.Fa dispatch
is called when there is a remote procedure call for the given
.Fa prognum
and
.Fa versnum ;
this requires calling
.Fn svc_run
(see
.Fn svc_run
in
.Xr rpc_svc_reg 3 ) .
If
.Fn svc_create
succeeds, it returns the number of server
handles it created,
otherwise it returns 0 and an error message is logged.
.It Fn svc_destroy
A function macro that destroys the RPC
service handle
.Fa xprt .
Destruction usually involves deallocation
of private data structures,
including
.Fa xprt
itself.
Use of
.Fa xprt
is undefined after calling this routine.
.It Fn svc_dg_create
This routine creates a connectionless RPC
service handle, and returns a pointer to it.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
.Fa sendsz
and
.Fa recvsz
are parameters used to specify the size of the buffers.
If they are 0, suitable defaults are chosen.
The file descriptor
.Fa fildes
should be open and bound.
The server is not registered with
.Xr rpcbind 8 .
.Pp
Warning:
since connectionless-based RPC
messages can only hold limited amount of encoded data,
this transport cannot be used for procedures
that take large arguments or return huge results.
.It Fn svc_fd_create
This routine creates a service on top of an open and bound file descriptor,
and returns the handle to it.
Typically, this descriptor is a connected file descriptor for a
connection-oriented transport.
.Fa sendsz
and
.Fa recvsz
indicate sizes for the send and receive buffers.
If they are 0, reasonable defaults are chosen.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
.It Fn svc_raw_create
This routine creates an RPC
service handle and returns a pointer to it.
The transport is really a buffer within the process's
address space, so the corresponding RPC
client should live in the same address space;
(see
.Fn clnt_raw_create
in
.Xr rpc_clnt_create 3 ) .
This routine allows simulation of RPC and acquisition of
RPC overheads (such as round trip times),
without any kernel and networking interference.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
.Pp
Note:
.Fn svc_run
should not be called when the raw interface is being used.
.It Fn svc_tli_create
This routine creates an RPC
server handle, and returns a pointer to it.
.Fa fildes
is the file descriptor on which the service is listening.
If
.Fa fildes
is
.Dv RPC_ANYFD ,
it opens a file descriptor on the transport specified by
.Fa netconf .
If the file descriptor is unbound and
.Fa bindaddr
is not
.Dv NULL ,
.Fa fildes
is bound to the address specified by
.Fa bindaddr ,
otherwise
.Fa fildes
is bound to a default address chosen by the transport.
.Pp
Note: the
.Vt t_bind
structure comes from the TLI/XTI SysV interface, which
.Nx
does not use.
The structure is defined in
.Aq Pa rpc/types.h
for compatibility as:
.Bd -literal
struct t_bind {
    struct netbuf addr;	/* network address, see rpc(3) */
    unsigned int  qlen;	/* queue length (for listen(2)) */
};
.Ed
.Pp
In the case where the default address is chosen,
the number of outstanding connect requests is set to 8
for connection-oriented transports.
The user may specify the size of the send and receive buffers
with the parameters
.Fa sendsz
and
.Fa recvsz ;
values of 0 choose suitable defaults.
This routine returns
.Dv NULL
if it fails,
and an error message is logged.
The server is not registered with the
.Xr rpcbind 8
service.
.It Fn svc_tp_create
.Fn svc_tp_create
creates a server handle for the network
specified by
.Fa netconf ,
and registers itself with the rpcbind service.
.Fa dispatch
is called when there is a remote procedure call
for the given
.Fa prognum
and
.Fa versnum ;
this requires calling
.Fn svc_run .
.Fn svc_tp_create
returns the service handle if it succeeds,
otherwise a
.Dv NULL
is returned and an error message is logged.
.It Fn svc_vc_create
This routine creates a connection-oriented RPC
service and returns a pointer to it.
This routine returns
.Dv NULL
if it fails, and an error message is logged.
The users may specify the size of the send and receive buffers
with the parameters
.Fa sendsz
and
.Fa recvsz ;
values of 0 choose suitable defaults.
The file descriptor
.Fa fildes
should be open and bound.
The server is not registered with the
.Xr rpcbind 8
service.
.El
.Sh SEE ALSO
.Xr rpc 3 ,
.Xr rpc_svc_calls 3 ,
.Xr rpc_svc_err 3 ,
.Xr rpc_svc_reg 3 ,
.Xr rpcbind 8
OpenPOWER on IntegriCloud