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