17df0ccbaSfvdl.\" @(#)rpc_svc_create.3n 1.26 93/08/26 SMI; from SVr4 27df0ccbaSfvdl.\" Copyright 1989 AT&T 37df0ccbaSfvdl.\" @(#)rpc_svc_create 1.3 89/06/28 SMI; 47df0ccbaSfvdl.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. 5*1c3412faSjoerg.\" $NetBSD: rpc_svc_create.3,v 1.11 2010/03/22 19:30:54 joerg Exp $ 67df0ccbaSfvdl.Dd May 3, 1993 77df0ccbaSfvdl.Dt RPC_SVC_CREATE 3 8d23280d6Sjoerg.Os 97df0ccbaSfvdl.Sh NAME 107df0ccbaSfvdl.Nm rpc_svc_create , 117df0ccbaSfvdl.Nm svc_control , 127df0ccbaSfvdl.Nm svc_create , 137df0ccbaSfvdl.Nm svc_destroy , 147df0ccbaSfvdl.Nm svc_dg_create , 157df0ccbaSfvdl.Nm svc_fd_create , 167df0ccbaSfvdl.Nm svc_raw_create , 177df0ccbaSfvdl.Nm svc_tli_create , 187df0ccbaSfvdl.Nm svc_tp_create , 197df0ccbaSfvdl.Nm svc_vc_create 207df0ccbaSfvdl.Nd library routines for the creation of server handles 217df0ccbaSfvdl.Sh LIBRARY 227df0ccbaSfvdl.Lb libc 237df0ccbaSfvdl.Sh SYNOPSIS 24472351e1Swiz.In rpc/rpc.h 257df0ccbaSfvdl.Ft bool_t 267df0ccbaSfvdl.Fn svc_control "SVCXPRT *svc" "const u_int req" "void *info" 277df0ccbaSfvdl.Ft int 287df0ccbaSfvdl.Fn svc_create "const void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype" 297df0ccbaSfvdl.Ft SVCXPRT *" 307df0ccbaSfvdl.Fn svc_dg_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 317df0ccbaSfvdl.Ft void 327df0ccbaSfvdl.Fn svc_destroy "SVCXPRT *xprt" 337df0ccbaSfvdl.Ft "SVCXPRT *" 347df0ccbaSfvdl.Fn svc_fd_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 357df0ccbaSfvdl.Ft "SVCXPRT *" 367df0ccbaSfvdl.Fn svc_raw_create "void" 377df0ccbaSfvdl.Ft "SVCXPRT *" 387df0ccbaSfvdl.Fn svc_tli_create "const int fildes" "const struct netconfig *netconf" "const struct t_bind *bindaddr" "const u_int sendsz" "const u_int recvsz" 397df0ccbaSfvdl.Ft "SVCXPRT *" 407df0ccbaSfvdl.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" 417df0ccbaSfvdl.Ft "SVCXPRT *" 427df0ccbaSfvdl.Fn svc_vc_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 437df0ccbaSfvdl.Sh DESCRIPTION 447df0ccbaSfvdlThese routines are part of the RPC 457df0ccbaSfvdllibrary which allows C language programs to make procedure 467df0ccbaSfvdlcalls on servers across the network. 477df0ccbaSfvdlThese routines deal with the creation of service handles. 487df0ccbaSfvdlOnce the handle is created, the server can be invoked by calling 497df0ccbaSfvdl.Fn svc_run . 50723dbf64Swiz.Sh ROUTINES 517df0ccbaSfvdlSee 527df0ccbaSfvdl.Xr rpc 3 537df0ccbaSfvdlfor the definition of the 547df0ccbaSfvdl.Dv SVCXPRT 557df0ccbaSfvdldata structure. 567df0ccbaSfvdl.Pp 577df0ccbaSfvdl.Bl -tag -width XXXXX 587df0ccbaSfvdl.It Fn svc_control 597df0ccbaSfvdlA function to change or retrieve various information 607df0ccbaSfvdlabout a service object. 617df0ccbaSfvdl.Fa req 627df0ccbaSfvdlindicates the type of operation and 637df0ccbaSfvdl.Fa info 647df0ccbaSfvdlis a pointer to the information. 657df0ccbaSfvdlThe supported values of 667df0ccbaSfvdl.Fa req , 677df0ccbaSfvdltheir argument types, and what they do are: 687df0ccbaSfvdl.Bl -tag -width SVCGET_XID 697df0ccbaSfvdl.It Dv SVCGET_VERSQUIET 707df0ccbaSfvdlIf a request is received for a program number 717df0ccbaSfvdlserved by this server but the version number 727df0ccbaSfvdlis outside the range registered with the server, 737df0ccbaSfvdlan 747df0ccbaSfvdl.Dv RPC_PROGVERSMISMATCH 757df0ccbaSfvdlerror will normally 767df0ccbaSfvdlbe returned. 777df0ccbaSfvdl.Fa info 786569c5c5Swizshould be a pointer to an integer. 796569c5c5SwizUpon successful completion of the 807df0ccbaSfvdl.Dv SVCGET_VERSQUIET 817df0ccbaSfvdlrequest, 827df0ccbaSfvdl.Fa *info 837df0ccbaSfvdlcontains an 847df0ccbaSfvdlinteger which describes the server's current 857df0ccbaSfvdlbehavior: 0 indicates normal server behavior 867df0ccbaSfvdl(that is, an 877df0ccbaSfvdl.Dv RPC_PROGVERSMISMATCH 887df0ccbaSfvdlerror 897df0ccbaSfvdlwill be returned); 1 indicates that the out of 907df0ccbaSfvdlrange request will be silently ignored. 917df0ccbaSfvdl.Pp 927df0ccbaSfvdl.It Dv SVCSET_VERSQUIET 937df0ccbaSfvdlIf a request is received for a program number 947df0ccbaSfvdlserved by this server but the version number 957df0ccbaSfvdlis outside the range registered with the server, 967df0ccbaSfvdlan 9704d01455Swiz.Dv RPC_PROGVERSMISMATCH 986569c5c5Swizerror will normally be returned. 996569c5c5SwizIt is sometimes desirable to change this behavior. 1007df0ccbaSfvdl.Fa info 1017df0ccbaSfvdlshould be a 1027df0ccbaSfvdlpointer to an integer which is either 0 1037df0ccbaSfvdl(indicating normal server behavior - an 1047df0ccbaSfvdl.Dv RPC_PROGVERSMISMATCH 1057df0ccbaSfvdlerror will be returned), 1067df0ccbaSfvdlor 1 (indicating that the out of range request 1077df0ccbaSfvdlshould be silently ignored). 1087df0ccbaSfvdl.El 1097df0ccbaSfvdl.Pp 1107df0ccbaSfvdl.It Fn svc_create 1117df0ccbaSfvdl.Fn svc_create 1127df0ccbaSfvdlcreates server handles for all the transports 1137df0ccbaSfvdlbelonging to the class 1147df0ccbaSfvdl.Fa nettype . 1157df0ccbaSfvdl.Fa nettype 1167df0ccbaSfvdldefines a class of transports which can be used 1177df0ccbaSfvdlfor a particular application. 1187df0ccbaSfvdlThe transports are tried in left to right order in 1197df0ccbaSfvdl.Ev NETPATH 1207df0ccbaSfvdlvariable or in top to bottom order in the netconfig database. 1217df0ccbaSfvdlIf 1227df0ccbaSfvdl.Fa nettype 1237df0ccbaSfvdlis 1247df0ccbaSfvdl.Dv NULL , 1257df0ccbaSfvdlit defaults to 1267df0ccbaSfvdl.Dv netpath . 1277df0ccbaSfvdl.Pp 1287df0ccbaSfvdl.Fn svc_create 1297df0ccbaSfvdlregisters itself with the rpcbind 1307df0ccbaSfvdlservice (see 1317df0ccbaSfvdl.Xr rpcbind 8 ) . 1327df0ccbaSfvdl.Fa dispatch 1337df0ccbaSfvdlis called when there is a remote procedure call for the given 1347df0ccbaSfvdl.Fa prognum 1357df0ccbaSfvdland 1367df0ccbaSfvdl.Fa versnum ; 1377df0ccbaSfvdlthis requires calling 1387df0ccbaSfvdl.Fn svc_run 1397df0ccbaSfvdl(see 1407df0ccbaSfvdl.Fn svc_run 1417df0ccbaSfvdlin 1427df0ccbaSfvdl.Xr rpc_svc_reg 3 ) . 1437df0ccbaSfvdlIf 1447df0ccbaSfvdl.Fn svc_create 1457df0ccbaSfvdlsucceeds, it returns the number of server 1467df0ccbaSfvdlhandles it created, 1477df0ccbaSfvdlotherwise it returns 0 and an error message is logged. 1487df0ccbaSfvdl.Pp 1497df0ccbaSfvdl.It Fn svc_destroy 1507df0ccbaSfvdlA function macro that destroys the RPC 1517df0ccbaSfvdlservice handle 1527df0ccbaSfvdl.Fa xprt . 1537df0ccbaSfvdlDestruction usually involves deallocation 1547df0ccbaSfvdlof private data structures, 1557df0ccbaSfvdlincluding 1567df0ccbaSfvdl.Fa xprt 1576569c5c5Swizitself. 1586569c5c5SwizUse of 1597df0ccbaSfvdl.Fa xprt 1607df0ccbaSfvdlis undefined after calling this routine. 1617df0ccbaSfvdl.Pp 1627df0ccbaSfvdl.It Fn svc_dg_create 1637df0ccbaSfvdlThis routine creates a connectionless RPC 1647df0ccbaSfvdlservice handle, and returns a pointer to it. 1657df0ccbaSfvdlThis routine returns 1667df0ccbaSfvdl.Dv NULL 1677df0ccbaSfvdlif it fails, and an error message is logged. 1687df0ccbaSfvdl.Fa sendsz 1697df0ccbaSfvdland 1707df0ccbaSfvdl.Fa recvsz 1717df0ccbaSfvdlare parameters used to specify the size of the buffers. 1727df0ccbaSfvdlIf they are 0, suitable defaults are chosen. 1737df0ccbaSfvdlThe file descriptor 1747df0ccbaSfvdl.Fa fildes 1757df0ccbaSfvdlshould be open and bound. 1767df0ccbaSfvdlThe server is not registered with 1777df0ccbaSfvdl.Xr rpcbind 8 . 178d23280d6Sjoerg.Em Warning : 1797df0ccbaSfvdlsince connectionless-based RPC 1807df0ccbaSfvdlmessages can only hold limited amount of encoded data, 1817df0ccbaSfvdlthis transport cannot be used for procedures 1827df0ccbaSfvdlthat take large arguments or return huge results. 1837df0ccbaSfvdl.Pp 1847df0ccbaSfvdl.It Fn svc_fd_create 1857df0ccbaSfvdlThis routine creates a service on top of an open and bound file descriptor, 1867df0ccbaSfvdland returns the handle to it. 1877df0ccbaSfvdlTypically, this descriptor is a connected file descriptor for a 1887df0ccbaSfvdlconnection-oriented transport. 1897df0ccbaSfvdl.Fa sendsz 1907df0ccbaSfvdland 1917df0ccbaSfvdl.Fa recvsz 1927df0ccbaSfvdlindicate sizes for the send and receive buffers. 1937df0ccbaSfvdlIf they are 0, reasonable defaults are chosen. 1947df0ccbaSfvdlThis routine returns 1957df0ccbaSfvdl.Dv NULL 1967df0ccbaSfvdlif it fails, and an error message is logged. 1977df0ccbaSfvdl.Pp 1987df0ccbaSfvdl.It Fn svc_raw_create 1997df0ccbaSfvdlThis routine creates an RPC 2007df0ccbaSfvdlservice handle and returns a pointer to it. 2017df0ccbaSfvdlThe transport is really a buffer within the process's 2027df0ccbaSfvdladdress space, so the corresponding RPC 2037df0ccbaSfvdlclient should live in the same address space; 2047df0ccbaSfvdl(see 2057df0ccbaSfvdl.Fn clnt_raw_create 2067df0ccbaSfvdlin 2077df0ccbaSfvdl.Xr rpc_clnt_create 3 ) . 2087df0ccbaSfvdlThis routine allows simulation of RPC and acquisition of 2097df0ccbaSfvdlRPC overheads (such as round trip times), 2107df0ccbaSfvdlwithout any kernel and networking interference. 2117df0ccbaSfvdlThis routine returns 2127df0ccbaSfvdl.Dv NULL 2137df0ccbaSfvdlif it fails, and an error message is logged. 214d23280d6Sjoerg.Em Note : 2157df0ccbaSfvdl.Fn svc_run 2167df0ccbaSfvdlshould not be called when the raw interface is being used. 2177df0ccbaSfvdl.Pp 2187df0ccbaSfvdl.It Fn svc_tli_create 2197df0ccbaSfvdlThis routine creates an RPC 2207df0ccbaSfvdlserver handle, and returns a pointer to it. 2217df0ccbaSfvdl.Fa fildes 2227df0ccbaSfvdlis the file descriptor on which the service is listening. 2237df0ccbaSfvdlIf 2247df0ccbaSfvdl.Fa fildes 2257df0ccbaSfvdlis 2267df0ccbaSfvdl.Dv RPC_ANYFD , 2277df0ccbaSfvdlit opens a file descriptor on the transport specified by 2287df0ccbaSfvdl.Fa netconf . 2297df0ccbaSfvdlIf the file descriptor is unbound and 2307df0ccbaSfvdl.Fa bindaddr 2317df0ccbaSfvdlis non-null 2327df0ccbaSfvdl.Fa fildes 2337df0ccbaSfvdlis bound to the address specified by 2347df0ccbaSfvdl.Fa bindaddr , 2357df0ccbaSfvdlotherwise 2367df0ccbaSfvdl.Fa fildes 2377df0ccbaSfvdlis bound to a default address chosen by the transport. 2387df0ccbaSfvdl.Pp 2397df0ccbaSfvdlNote: the 2407df0ccbaSfvdl.Vt t_bind 241723dbf64Swizstructure comes from the TLI/XTI SysV interface, which 242723dbf64Swiz.Nx 243723dbf64Swizdoes not use. 2447df0ccbaSfvdlThe structure is defined in 245*1c3412faSjoerg.In rpc/types.h 2467df0ccbaSfvdlfor compatibility as: 2477df0ccbaSfvdl.Bd -literal 2487df0ccbaSfvdlstruct t_bind { 2497df0ccbaSfvdl struct netbuf addr; /* network address, see rpc(3) */ 2507df0ccbaSfvdl unsigned int qlen; /* queue length (for listen(2)) */ 2517df0ccbaSfvdl}; 2527df0ccbaSfvdl.Ed 2537df0ccbaSfvdl.Pp 2547df0ccbaSfvdlIn the case where the default address is chosen, 2557df0ccbaSfvdlthe number of outstanding connect requests is set to 8 2567df0ccbaSfvdlfor connection-oriented transports. 2577df0ccbaSfvdlThe user may specify the size of the send and receive buffers 2587df0ccbaSfvdlwith the parameters 2597df0ccbaSfvdl.Fa sendsz 2607df0ccbaSfvdland 2617df0ccbaSfvdl.Fa recvsz ; 2627df0ccbaSfvdlvalues of 0 choose suitable defaults. 2637df0ccbaSfvdlThis routine returns 2647df0ccbaSfvdl.Dv NULL 2657df0ccbaSfvdlif it fails, 2667df0ccbaSfvdland an error message is logged. 2677df0ccbaSfvdlThe server is not registered with the 2687df0ccbaSfvdl.Xr rpcbind 8 2697df0ccbaSfvdlservice. 2707df0ccbaSfvdl.Pp 2717df0ccbaSfvdl.It Fn svc_tp_create 2727df0ccbaSfvdl.Fn svc_tp_create 2737df0ccbaSfvdlcreates a server handle for the network 2747df0ccbaSfvdlspecified by 2757df0ccbaSfvdl.Fa netconf , 2767df0ccbaSfvdland registers itself with the rpcbind service. 2777df0ccbaSfvdl.Fa dispatch 2787df0ccbaSfvdlis called when there is a remote procedure call 2797df0ccbaSfvdlfor the given 2807df0ccbaSfvdl.Fa prognum 2817df0ccbaSfvdland 2827df0ccbaSfvdl.Fa versnum ; 2837df0ccbaSfvdlthis requires calling 2847df0ccbaSfvdl.Fn svc_run . 2857df0ccbaSfvdl.Fn svc_tp_create 2867df0ccbaSfvdlreturns the service handle if it succeeds, 2877df0ccbaSfvdlotherwise a 2887df0ccbaSfvdl.Dv NULL 2897df0ccbaSfvdlis returned and an error message is logged. 2907df0ccbaSfvdl.Pp 2917df0ccbaSfvdl.It Fn svc_vc_create 2927df0ccbaSfvdlThis routine creates a connection-oriented RPC 2937df0ccbaSfvdlservice and returns a pointer to it. 2947df0ccbaSfvdlThis routine returns 2957df0ccbaSfvdl.Dv NULL 2967df0ccbaSfvdlif it fails, and an error message is logged. 2977df0ccbaSfvdlThe users may specify the size of the send and receive buffers 2987df0ccbaSfvdlwith the parameters 2997df0ccbaSfvdl.Fa sendsz 3007df0ccbaSfvdland 3017df0ccbaSfvdl.Fa recvsz ; 3027df0ccbaSfvdlvalues of 0 choose suitable defaults. 3037df0ccbaSfvdlThe file descriptor 3047df0ccbaSfvdl.Fa fildes 3057df0ccbaSfvdlshould be open and bound. 3067df0ccbaSfvdlThe server is not registered with the 3077df0ccbaSfvdl.Xr rpcbind 8 3087df0ccbaSfvdlservice. 3097df0ccbaSfvdl.El 3107df0ccbaSfvdl.Sh SEE ALSO 3117df0ccbaSfvdl.Xr rpc 3 , 3127df0ccbaSfvdl.Xr rpc_svc_calls 3 , 3137df0ccbaSfvdl.Xr rpc_svc_err 3 , 314723dbf64Swiz.Xr rpc_svc_reg 3 , 315723dbf64Swiz.Xr rpcbind 8 316