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.\" $FreeBSD$ 6.Dd May 3, 1993 7.Dt RPC_SVC_CREATE 3 8.Os 9.Sh NAME 10.Nm rpc_svc_create , 11.Nm svc_control , 12.Nm svc_create , 13.Nm svc_destroy , 14.Nm svc_dg_create , 15.Nm svc_fd_create , 16.Nm svc_raw_create , 17.Nm svc_tli_create , 18.Nm svc_tp_create , 19.Nm svc_vc_create 20.Nd library routines for the creation of server handles 21.Sh LIBRARY 22.Lb libc 23.Sh SYNOPSIS 24.Fd #include <rpc/rpc.h> 25.Ft bool_t 26.Fn svc_control "SVCXPRT *svc" "const u_int req" "void *info" 27.Ft int 28.Fn svc_create "const void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype" 29.Ft SVCXPRT *" 30.Fn svc_dg_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 31.Ft void 32.Fn svc_destroy "SVCXPRT *xprt" 33.Ft "SVCXPRT *" 34.Fn svc_fd_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 35.Ft "SVCXPRT *" 36.Fn svc_raw_create "void" 37.Ft "SVCXPRT *" 38.Fn svc_tli_create "const int fildes" "const struct netconfig *netconf" "const struct t_bind *bindaddr" "const u_int sendsz" "const u_int recvsz" 39.Ft "SVCXPRT *" 40.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" 41.Ft "SVCXPRT *" 42.Fn svc_vc_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 43.Sh DESCRIPTION 44These routines are part of the RPC 45library which allows C language programs to make procedure 46calls on servers across the network. 47These routines deal with the creation of service handles. 48Once the handle is created, the server can be invoked by calling 49.Fn svc_run . 50.Sh Routines 51See 52.Xr rpc 3 53for the definition of the 54.Vt SVCXPRT 55data structure. 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. 79Upon successful completion of the 80.Dv SVCGET_VERSQUIET 81request, 82.Fa *info 83contains an 84integer which describes the server's current 85behavior: 0 indicates normal server behavior 86(that is, an 87.Dv RPC_PROGVERSMISMATCH 88error 89will be returned); 1 indicates that the out of 90range request will be silently ignored. 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. 99It is sometimes desirable to 100change this behavior. 101.Fa info 102should be a 103pointer to an integer which is either 0 104(indicating normal server behavior - an 105.Dv RPC_PROGVERSMISMATCH 106error will be returned), 107or 1 (indicating that the out of range request 108should be silently ignored). 109.El 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.Qq 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.It Fn svc_destroy 149A function macro that destroys the RPC 150service handle 151.Fa xprt . 152Destruction usually involves deallocation 153of private data structures, 154including 155.Fa xprt 156itself. 157Use of 158.Fa xprt 159is undefined after calling this routine. 160.It Fn svc_dg_create 161This routine creates a connectionless RPC 162service handle, and returns a pointer to it. 163This routine returns 164.Dv NULL 165if it fails, and an error message is logged. 166.Fa sendsz 167and 168.Fa recvsz 169are parameters used to specify the size of the buffers. 170If they are 0, suitable defaults are chosen. 171The file descriptor 172.Fa fildes 173should be open and bound. 174The server is not registered with 175.Xr rpcbind 8 . 176.Pp 177Warning: 178since connectionless-based RPC 179messages can only hold limited amount of encoded data, 180this transport cannot be used for procedures 181that take large arguments or return huge results. 182.It Fn svc_fd_create 183This routine creates a service on top of an open and bound file descriptor, 184and returns the handle to it. 185Typically, this descriptor is a connected file descriptor for a 186connection-oriented transport. 187.Fa sendsz 188and 189.Fa recvsz 190indicate sizes for the send and receive buffers. 191If they are 0, reasonable defaults are chosen. 192This routine returns 193.Dv NULL 194if it fails, and an error message is logged. 195.It Fn svc_raw_create 196This routine creates an RPC 197service handle and returns a pointer to it. 198The transport is really a buffer within the process's 199address space, so the corresponding RPC 200client should live in the same address space; 201(see 202.Fn clnt_raw_create 203in 204.Xr rpc_clnt_create 3 ) . 205This routine allows simulation of RPC and acquisition of 206RPC overheads (such as round trip times), 207without any kernel and networking interference. 208This routine returns 209.Dv NULL 210if it fails, and an error message is logged. 211.Pp 212Note: 213.Fn svc_run 214should not be called when the raw interface is being used. 215.It Fn svc_tli_create 216This routine creates an RPC 217server handle, and returns a pointer to it. 218.Fa fildes 219is the file descriptor on which the service is listening. 220If 221.Fa fildes 222is 223.Dv RPC_ANYFD , 224it opens a file descriptor on the transport specified by 225.Fa netconf . 226If the file descriptor is unbound and 227.Fa bindaddr 228is not 229.Dv NULL , 230.Fa fildes 231is bound to the address specified by 232.Fa bindaddr , 233otherwise 234.Fa fildes 235is bound to a default address chosen by the transport. 236.Pp 237Note: the 238.Vt t_bind 239structure comes from the TLI/XTI SysV interface, which 240.Nx 241does not use. 242The structure is defined in 243.Aq Pa rpc/types.h 244for compatibility as: 245.Bd -literal 246struct t_bind { 247 struct netbuf addr; /* network address, see rpc(3) */ 248 unsigned int qlen; /* queue length (for listen(2)) */ 249}; 250.Ed 251.Pp 252In the case where the default address is chosen, 253the number of outstanding connect requests is set to 8 254for connection-oriented transports. 255The user may specify the size of the send and receive buffers 256with the parameters 257.Fa sendsz 258and 259.Fa recvsz ; 260values of 0 choose suitable defaults. 261This routine returns 262.Dv NULL 263if it fails, 264and an error message is logged. 265The server is not registered with the 266.Xr rpcbind 8 267service. 268.It Fn svc_tp_create 269.Fn svc_tp_create 270creates a server handle for the network 271specified by 272.Fa netconf , 273and registers itself with the rpcbind service. 274.Fa dispatch 275is called when there is a remote procedure call 276for the given 277.Fa prognum 278and 279.Fa versnum ; 280this requires calling 281.Fn svc_run . 282.Fn svc_tp_create 283returns the service handle if it succeeds, 284otherwise a 285.Dv NULL 286is returned and an error message is logged. 287.It Fn svc_vc_create 288This routine creates a connection-oriented RPC 289service and returns a pointer to it. 290This routine returns 291.Dv NULL 292if it fails, and an error message is logged. 293The users may specify the size of the send and receive buffers 294with the parameters 295.Fa sendsz 296and 297.Fa recvsz ; 298values of 0 choose suitable defaults. 299The file descriptor 300.Fa fildes 301should be open and bound. 302The server is not registered with the 303.Xr rpcbind 8 304service. 305.El 306.Sh SEE ALSO 307.Xr rpc 3 , 308.Xr rpc_svc_calls 3 , 309.Xr rpc_svc_err 3 , 310.Xr rpc_svc_reg 3 , 311.Xr rpcbind 8 312