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.Dd May 3, 1993 6.Dt RPC_SVC_CREATE 3 7.Sh NAME 8.Nm rpc_svc_create, 9.Nm svc_control, 10.Nm svc_create, 11.Nm svc_destroy, 12.Nm svc_dg_create, 13.Nm svc_fd_create, 14.Nm svc_raw_create, 15.Nm svc_tli_create, 16.Nm svc_tp_create, 17.Nm svc_vc_create 18.Nd library routines for the creation of server handles 19.Sh LIBRARY 20.Lb libc 21.Sh SYNOPSIS 22.Fd #include <rpc/rpc.h> 23.Ft bool_t 24.Fn svc_control "SVCXPRT *svc" "const u_int req" "void *info" 25.Ft int 26.Fn svc_create "const void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype" 27.Ft SVCXPRT *" 28.Fn svc_dg_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 29.Ft void 30.Fn svc_destroy "SVCXPRT *xprt" 31.Ft "SVCXPRT *" 32.Fn svc_fd_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 33.Ft "SVCXPRT *" 34.Fn svc_raw_create "void" 35.Ft "SVCXPRT *" 36.Fn svc_tli_create "const int fildes" "const struct netconfig *netconf" "const struct t_bind *bindaddr" "const u_int sendsz" "const u_int recvsz" 37.Ft "SVCXPRT *" 38.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" 39.Ft "SVCXPRT *" 40.Fn svc_vc_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 41.Sh DESCRIPTION 42These routines are part of the RPC 43library which allows C language programs to make procedure 44calls on servers across the network. 45These routines deal with the creation of service handles. 46Once the handle is created, the server can be invoked by calling 47.Fn svc_run . 48.Sh Routines 49See 50.Xr rpc 3 51for the definition of the 52.Dv SVCXPRT 53data structure. 54.Pp 55.Bl -tag -width XXXXX 56.It Fn svc_control 57A function to change or retrieve various information 58about a service object. 59.Fa req 60indicates the type of operation and 61.Fa info 62is a pointer to the information. 63The supported values of 64.Fa req , 65their argument types, and what they do are: 66.Bl -tag -width SVCGET_XID 67.It Dv SVCGET_VERSQUIET 68If a request is received for a program number 69served by this server but the version number 70is outside the range registered with the server, 71an 72.Dv RPC_PROGVERSMISMATCH 73error will normally 74be returned. 75.Fa info 76should be a pointer to an 77integer. Upon successful completion of the 78.Dv SVCGET_VERSQUIET 79request, 80.Fa *info 81contains an 82integer which describes the server's current 83behavior: 0 indicates normal server behavior 84(that is, an 85.Dv RPC_PROGVERSMISMATCH 86error 87will be returned); 1 indicates that the out of 88range request will be silently ignored. 89.Pp 90.It Dv SVCSET_VERSQUIET 91If a request is received for a program number 92served by this server but the version number 93is outside the range registered with the server, 94an 95.Dv RPC_PROGVERSMISMATCH. 96error will normally 97be returned. It is sometimes desirable to 98change this behavior. 99.Fa info 100should be a 101pointer to an integer which is either 0 102(indicating normal server behavior - an 103.Dv RPC_PROGVERSMISMATCH 104error will be returned), 105or 1 (indicating that the out of range request 106should be silently ignored). 107.El 108.Pp 109.It Fn svc_create 110.Fn svc_create 111creates server handles for all the transports 112belonging to the class 113.Fa nettype . 114.Fa nettype 115defines a class of transports which can be used 116for a particular application. 117The transports are tried in left to right order in 118.Ev NETPATH 119variable or in top to bottom order in the netconfig database. 120If 121.Fa nettype 122is 123.Dv NULL , 124it defaults to 125.Dv netpath . 126.Pp 127.Fn svc_create 128registers itself with the rpcbind 129service (see 130.Xr rpcbind 8 ). 131.Fa dispatch 132is called when there is a remote procedure call for the given 133.Fa prognum 134and 135.Fa versnum ; 136this requires calling 137.Fn svc_run 138(see 139.Fn svc_run 140in 141.Xr rpc_svc_reg 3 ). 142If 143.Fn svc_create 144succeeds, it returns the number of server 145handles it created, 146otherwise it returns 0 and an error message is logged. 147.Pp 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. Use of 157.Fa xprt 158is undefined after calling this routine. 159.Pp 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.IP 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.Pp 183.It Fn svc_fd_create 184This routine creates a service on top of an open and bound file descriptor, 185and returns the handle to it. 186Typically, this descriptor is a connected file descriptor for a 187connection-oriented transport. 188.Fa sendsz 189and 190.Fa recvsz 191indicate sizes for the send and receive buffers. 192If they are 0, reasonable defaults are chosen. 193This routine returns 194.Dv NULL 195if it fails, and an error message is logged. 196.Pp 197.It Fn svc_raw_create 198This routine creates an RPC 199service handle and returns a pointer to it. 200The transport is really a buffer within the process's 201address space, so the corresponding RPC 202client should live in the same address space; 203(see 204.Fn clnt_raw_create 205in 206.Xr rpc_clnt_create 3 ). 207This routine allows simulation of RPC and acquisition of 208RPC overheads (such as round trip times), 209without any kernel and networking interference. 210This routine returns 211.Dv NULL 212if it fails, and an error message is logged. 213.IP 214Note: 215.Fn svc_run 216should not be called when the raw interface is being used. 217.Pp 218.It Fn svc_tli_create 219This routine creates an RPC 220server handle, and returns a pointer to it. 221.Fa fildes 222is the file descriptor on which the service is listening. 223If 224.Fa fildes 225is 226.Dv RPC_ANYFD , 227it opens a file descriptor on the transport specified by 228.Fa netconf . 229If the file descriptor is unbound and 230.Fa bindaddr 231is non-null 232.Fa fildes 233is bound to the address specified by 234.Fa bindaddr , 235otherwise 236.Fa fildes 237is bound to a default address chosen by the transport. 238.Pp 239Note: the 240.Vt t_bind 241structure comes from the TLI/XTI SysV interface, which NetBSD does not use. 242The structure is defined in 243.Fd <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.Pp 269.It Fn svc_tp_create 270.Fn svc_tp_create 271creates a server handle for the network 272specified by 273.Fa netconf , 274and registers itself with the rpcbind service. 275.Fa dispatch 276is called when there is a remote procedure call 277for the given 278.Fa prognum 279and 280.Fa versnum ; 281this requires calling 282.Fn svc_run . 283.Fn svc_tp_create 284returns the service handle if it succeeds, 285otherwise a 286.Dv NULL 287is returned and an error message is logged. 288.Pp 289.It Fn svc_vc_create 290This routine creates a connection-oriented RPC 291service and returns a pointer to it. 292This routine returns 293.Dv NULL 294if it fails, and an error message is logged. 295The users may specify the size of the send and receive buffers 296with the parameters 297.Fa sendsz 298and 299.Fa recvsz ; 300values of 0 choose suitable defaults. 301The file descriptor 302.Fa fildes 303should be open and bound. 304The server is not registered with the 305.Xr rpcbind 8 306service. 307.El 308.Sh SEE ALSO 309.Xr rpcbind 8 , 310.Xr rpc 3 , 311.Xr rpc_svc_calls 3 , 312.Xr rpc_svc_err 3 , 313.Xr rpc_svc_reg 3 314