18360efbdSAlfred Perlstein.\" Copyright 1989 AT&T 28360efbdSAlfred Perlstein.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. 38360efbdSAlfred Perlstein.Dd May 3, 1993 48360efbdSAlfred Perlstein.Dt RPC_SVC_CREATE 3 58360efbdSAlfred Perlstein.Os 68360efbdSAlfred Perlstein.Sh NAME 78360efbdSAlfred Perlstein.Nm rpc_svc_create , 88360efbdSAlfred Perlstein.Nm svc_control , 98360efbdSAlfred Perlstein.Nm svc_create , 108360efbdSAlfred Perlstein.Nm svc_destroy , 118360efbdSAlfred Perlstein.Nm svc_dg_create , 128360efbdSAlfred Perlstein.Nm svc_fd_create , 138360efbdSAlfred Perlstein.Nm svc_raw_create , 148360efbdSAlfred Perlstein.Nm svc_tli_create , 158360efbdSAlfred Perlstein.Nm svc_tp_create , 168360efbdSAlfred Perlstein.Nm svc_vc_create 178360efbdSAlfred Perlstein.Nd library routines for the creation of server handles 188360efbdSAlfred Perlstein.Sh LIBRARY 198360efbdSAlfred Perlstein.Lb libc 208360efbdSAlfred Perlstein.Sh SYNOPSIS 2132eef9aeSRuslan Ermilov.In rpc/rpc.h 228360efbdSAlfred Perlstein.Ft bool_t 238360efbdSAlfred Perlstein.Fn svc_control "SVCXPRT *svc" "const u_int req" "void *info" 248360efbdSAlfred Perlstein.Ft int 25db7534cfSBruce Evans.Fn svc_create "void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype" 26db7534cfSBruce Evans.Ft SVCXPRT * 278360efbdSAlfred Perlstein.Fn svc_dg_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 288360efbdSAlfred Perlstein.Ft void 298360efbdSAlfred Perlstein.Fn svc_destroy "SVCXPRT *xprt" 308360efbdSAlfred Perlstein.Ft "SVCXPRT *" 318360efbdSAlfred Perlstein.Fn svc_fd_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 328360efbdSAlfred Perlstein.Ft "SVCXPRT *" 338360efbdSAlfred Perlstein.Fn svc_raw_create "void" 348360efbdSAlfred Perlstein.Ft "SVCXPRT *" 358360efbdSAlfred Perlstein.Fn svc_tli_create "const int fildes" "const struct netconfig *netconf" "const struct t_bind *bindaddr" "const u_int sendsz" "const u_int recvsz" 368360efbdSAlfred Perlstein.Ft "SVCXPRT *" 37db7534cfSBruce Evans.Fn svc_tp_create "void (*dispatch)(struct svc_req *, SVCXPRT *)" "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf" 388360efbdSAlfred Perlstein.Ft "SVCXPRT *" 398360efbdSAlfred Perlstein.Fn svc_vc_create "const int fildes" "const u_int sendsz" "const u_int recvsz" 408360efbdSAlfred Perlstein.Sh DESCRIPTION 418360efbdSAlfred PerlsteinThese routines are part of the RPC 428360efbdSAlfred Perlsteinlibrary which allows C language programs to make procedure 438360efbdSAlfred Perlsteincalls on servers across the network. 448360efbdSAlfred PerlsteinThese routines deal with the creation of service handles. 458360efbdSAlfred PerlsteinOnce the handle is created, the server can be invoked by calling 468360efbdSAlfred Perlstein.Fn svc_run . 478360efbdSAlfred Perlstein.Sh Routines 488360efbdSAlfred PerlsteinSee 498360efbdSAlfred Perlstein.Xr rpc 3 508360efbdSAlfred Perlsteinfor the definition of the 518360efbdSAlfred Perlstein.Vt SVCXPRT 528360efbdSAlfred Perlsteindata structure. 538360efbdSAlfred Perlstein.Bl -tag -width XXXXX 548360efbdSAlfred Perlstein.It Fn svc_control 558360efbdSAlfred PerlsteinA function to change or retrieve various information 568360efbdSAlfred Perlsteinabout a service object. 572efeeba5SRuslan ErmilovThe 588360efbdSAlfred Perlstein.Fa req 592efeeba5SRuslan Ermilovargument 608360efbdSAlfred Perlsteinindicates the type of operation and 618360efbdSAlfred Perlstein.Fa info 628360efbdSAlfred Perlsteinis a pointer to the information. 638360efbdSAlfred PerlsteinThe supported values of 648360efbdSAlfred Perlstein.Fa req , 658360efbdSAlfred Perlsteintheir argument types, and what they do are: 668360efbdSAlfred Perlstein.Bl -tag -width SVCGET_XID 678360efbdSAlfred Perlstein.It Dv SVCGET_VERSQUIET 688360efbdSAlfred PerlsteinIf a request is received for a program number 698360efbdSAlfred Perlsteinserved by this server but the version number 708360efbdSAlfred Perlsteinis outside the range registered with the server, 718360efbdSAlfred Perlsteinan 728360efbdSAlfred Perlstein.Dv RPC_PROGVERSMISMATCH 738360efbdSAlfred Perlsteinerror will normally 748360efbdSAlfred Perlsteinbe returned. 752efeeba5SRuslan ErmilovThe 768360efbdSAlfred Perlstein.Fa info 772efeeba5SRuslan Ermilovargument 788360efbdSAlfred Perlsteinshould be a pointer to an 798360efbdSAlfred Perlsteininteger. 808360efbdSAlfred PerlsteinUpon successful completion of the 818360efbdSAlfred Perlstein.Dv SVCGET_VERSQUIET 828360efbdSAlfred Perlsteinrequest, 838360efbdSAlfred Perlstein.Fa *info 848360efbdSAlfred Perlsteincontains an 858360efbdSAlfred Perlsteininteger which describes the server's current 868360efbdSAlfred Perlsteinbehavior: 0 indicates normal server behavior 878360efbdSAlfred Perlstein(that is, an 888360efbdSAlfred Perlstein.Dv RPC_PROGVERSMISMATCH 898360efbdSAlfred Perlsteinerror 908360efbdSAlfred Perlsteinwill be returned); 1 indicates that the out of 918360efbdSAlfred Perlsteinrange request will be silently ignored. 928360efbdSAlfred Perlstein.It Dv SVCSET_VERSQUIET 938360efbdSAlfred PerlsteinIf a request is received for a program number 948360efbdSAlfred Perlsteinserved by this server but the version number 958360efbdSAlfred Perlsteinis outside the range registered with the server, 968360efbdSAlfred Perlsteinan 978360efbdSAlfred Perlstein.Dv RPC_PROGVERSMISMATCH 988360efbdSAlfred Perlsteinerror will normally 998360efbdSAlfred Perlsteinbe returned. 1008360efbdSAlfred PerlsteinIt is sometimes desirable to 1018360efbdSAlfred Perlsteinchange this behavior. 1022efeeba5SRuslan ErmilovThe 1038360efbdSAlfred Perlstein.Fa info 1042efeeba5SRuslan Ermilovargument 1058360efbdSAlfred Perlsteinshould be a 1068360efbdSAlfred Perlsteinpointer to an integer which is either 0 1078360efbdSAlfred Perlstein(indicating normal server behavior - an 1088360efbdSAlfred Perlstein.Dv RPC_PROGVERSMISMATCH 1098360efbdSAlfred Perlsteinerror will be returned), 1108360efbdSAlfred Perlsteinor 1 (indicating that the out of range request 1118360efbdSAlfred Perlsteinshould be silently ignored). 1128360efbdSAlfred Perlstein.El 1138360efbdSAlfred Perlstein.It Fn svc_create 1141fae73b1SRuslan ErmilovThe 1158360efbdSAlfred Perlstein.Fn svc_create 1161fae73b1SRuslan Ermilovfunction 1178360efbdSAlfred Perlsteincreates server handles for all the transports 1188360efbdSAlfred Perlsteinbelonging to the class 1198360efbdSAlfred Perlstein.Fa nettype . 1202efeeba5SRuslan ErmilovThe 1218360efbdSAlfred Perlstein.Fa nettype 1222efeeba5SRuslan Ermilovargument 1238360efbdSAlfred Perlsteindefines a class of transports which can be used 1248360efbdSAlfred Perlsteinfor a particular application. 1258360efbdSAlfred PerlsteinThe transports are tried in left to right order in 1268360efbdSAlfred Perlstein.Ev NETPATH 1278360efbdSAlfred Perlsteinvariable or in top to bottom order in the netconfig database. 1288360efbdSAlfred PerlsteinIf 1298360efbdSAlfred Perlstein.Fa nettype 1308360efbdSAlfred Perlsteinis 1318360efbdSAlfred Perlstein.Dv NULL , 1328360efbdSAlfred Perlsteinit defaults to 1338360efbdSAlfred Perlstein.Qq netpath . 1348360efbdSAlfred Perlstein.Pp 1351fae73b1SRuslan ErmilovThe 1368360efbdSAlfred Perlstein.Fn svc_create 1371fae73b1SRuslan Ermilovfunction 1388360efbdSAlfred Perlsteinregisters itself with the rpcbind 1398360efbdSAlfred Perlsteinservice (see 1408360efbdSAlfred Perlstein.Xr rpcbind 8 ) . 1412efeeba5SRuslan ErmilovThe 1428360efbdSAlfred Perlstein.Fa dispatch 1432efeeba5SRuslan Ermilovfunction 1448360efbdSAlfred Perlsteinis called when there is a remote procedure call for the given 1458360efbdSAlfred Perlstein.Fa prognum 1468360efbdSAlfred Perlsteinand 1478360efbdSAlfred Perlstein.Fa versnum ; 1488360efbdSAlfred Perlsteinthis requires calling 1498360efbdSAlfred Perlstein.Fn svc_run 1508360efbdSAlfred Perlstein(see 1518360efbdSAlfred Perlstein.Fn svc_run 1528360efbdSAlfred Perlsteinin 1538360efbdSAlfred Perlstein.Xr rpc_svc_reg 3 ) . 1548360efbdSAlfred PerlsteinIf 1558360efbdSAlfred Perlstein.Fn svc_create 1568360efbdSAlfred Perlsteinsucceeds, it returns the number of server 1578360efbdSAlfred Perlsteinhandles it created, 1588360efbdSAlfred Perlsteinotherwise it returns 0 and an error message is logged. 1598360efbdSAlfred Perlstein.It Fn svc_destroy 1608360efbdSAlfred PerlsteinA function macro that destroys the RPC 1618360efbdSAlfred Perlsteinservice handle 1628360efbdSAlfred Perlstein.Fa xprt . 1638360efbdSAlfred PerlsteinDestruction usually involves deallocation 1648360efbdSAlfred Perlsteinof private data structures, 1658360efbdSAlfred Perlsteinincluding 1668360efbdSAlfred Perlstein.Fa xprt 1678360efbdSAlfred Perlsteinitself. 1688360efbdSAlfred PerlsteinUse of 1698360efbdSAlfred Perlstein.Fa xprt 1708360efbdSAlfred Perlsteinis undefined after calling this routine. 1718360efbdSAlfred Perlstein.It Fn svc_dg_create 1728360efbdSAlfred PerlsteinThis routine creates a connectionless RPC 1738360efbdSAlfred Perlsteinservice handle, and returns a pointer to it. 1748360efbdSAlfred PerlsteinThis routine returns 1758360efbdSAlfred Perlstein.Dv NULL 1768360efbdSAlfred Perlsteinif it fails, and an error message is logged. 1772efeeba5SRuslan ErmilovThe 1788360efbdSAlfred Perlstein.Fa sendsz 1798360efbdSAlfred Perlsteinand 1808360efbdSAlfred Perlstein.Fa recvsz 1812efeeba5SRuslan Ermilovarguments 1822efeeba5SRuslan Ermilovare arguments used to specify the size of the buffers. 1838360efbdSAlfred PerlsteinIf they are 0, suitable defaults are chosen. 1848360efbdSAlfred PerlsteinThe file descriptor 1858360efbdSAlfred Perlstein.Fa fildes 1868360efbdSAlfred Perlsteinshould be open and bound. 1878360efbdSAlfred PerlsteinThe server is not registered with 1888360efbdSAlfred Perlstein.Xr rpcbind 8 . 1898360efbdSAlfred Perlstein.Pp 1908360efbdSAlfred PerlsteinWarning: 1918360efbdSAlfred Perlsteinsince connectionless-based RPC 1928360efbdSAlfred Perlsteinmessages can only hold limited amount of encoded data, 1938360efbdSAlfred Perlsteinthis transport cannot be used for procedures 1948360efbdSAlfred Perlsteinthat take large arguments or return huge results. 1958360efbdSAlfred Perlstein.It Fn svc_fd_create 1968360efbdSAlfred PerlsteinThis routine creates a service on top of an open and bound file descriptor, 1978360efbdSAlfred Perlsteinand returns the handle to it. 1988360efbdSAlfred PerlsteinTypically, this descriptor is a connected file descriptor for a 1998360efbdSAlfred Perlsteinconnection-oriented transport. 2002efeeba5SRuslan ErmilovThe 2018360efbdSAlfred Perlstein.Fa sendsz 2028360efbdSAlfred Perlsteinand 2038360efbdSAlfred Perlstein.Fa recvsz 2042efeeba5SRuslan Ermilovarguments 2058360efbdSAlfred Perlsteinindicate sizes for the send and receive buffers. 2068360efbdSAlfred PerlsteinIf they are 0, reasonable defaults are chosen. 2078360efbdSAlfred PerlsteinThis routine returns 2088360efbdSAlfred Perlstein.Dv NULL 2098360efbdSAlfred Perlsteinif it fails, and an error message is logged. 2108360efbdSAlfred Perlstein.It Fn svc_raw_create 2118360efbdSAlfred PerlsteinThis routine creates an RPC 2128360efbdSAlfred Perlsteinservice handle and returns a pointer to it. 2138360efbdSAlfred PerlsteinThe transport is really a buffer within the process's 2148360efbdSAlfred Perlsteinaddress space, so the corresponding RPC 2158360efbdSAlfred Perlsteinclient should live in the same address space; 2168360efbdSAlfred Perlstein(see 2178360efbdSAlfred Perlstein.Fn clnt_raw_create 2188360efbdSAlfred Perlsteinin 2198360efbdSAlfred Perlstein.Xr rpc_clnt_create 3 ) . 2208360efbdSAlfred PerlsteinThis routine allows simulation of RPC and acquisition of 2218360efbdSAlfred PerlsteinRPC overheads (such as round trip times), 2228360efbdSAlfred Perlsteinwithout any kernel and networking interference. 2238360efbdSAlfred PerlsteinThis routine returns 2248360efbdSAlfred Perlstein.Dv NULL 2258360efbdSAlfred Perlsteinif it fails, and an error message is logged. 2268360efbdSAlfred Perlstein.Pp 2278360efbdSAlfred PerlsteinNote: 2288360efbdSAlfred Perlstein.Fn svc_run 2298360efbdSAlfred Perlsteinshould not be called when the raw interface is being used. 2308360efbdSAlfred Perlstein.It Fn svc_tli_create 2318360efbdSAlfred PerlsteinThis routine creates an RPC 2328360efbdSAlfred Perlsteinserver handle, and returns a pointer to it. 2332efeeba5SRuslan ErmilovThe 2348360efbdSAlfred Perlstein.Fa fildes 2352efeeba5SRuslan Ermilovargument 2368360efbdSAlfred Perlsteinis the file descriptor on which the service is listening. 2378360efbdSAlfred PerlsteinIf 2388360efbdSAlfred Perlstein.Fa fildes 2398360efbdSAlfred Perlsteinis 2408360efbdSAlfred Perlstein.Dv RPC_ANYFD , 2418360efbdSAlfred Perlsteinit opens a file descriptor on the transport specified by 2428360efbdSAlfred Perlstein.Fa netconf . 2438360efbdSAlfred PerlsteinIf the file descriptor is unbound and 2448360efbdSAlfred Perlstein.Fa bindaddr 2458360efbdSAlfred Perlsteinis not 2468360efbdSAlfred Perlstein.Dv NULL , 2478360efbdSAlfred Perlstein.Fa fildes 2488360efbdSAlfred Perlsteinis bound to the address specified by 2498360efbdSAlfred Perlstein.Fa bindaddr , 2508360efbdSAlfred Perlsteinotherwise 2518360efbdSAlfred Perlstein.Fa fildes 2528360efbdSAlfred Perlsteinis bound to a default address chosen by the transport. 2538360efbdSAlfred Perlstein.Pp 2548360efbdSAlfred PerlsteinNote: the 2558360efbdSAlfred Perlstein.Vt t_bind 2568360efbdSAlfred Perlsteinstructure comes from the TLI/XTI SysV interface, which 2578360efbdSAlfred Perlstein.Nx 2588360efbdSAlfred Perlsteindoes not use. 2598360efbdSAlfred PerlsteinThe structure is defined in 260fe08efe6SRuslan Ermilov.In rpc/types.h 2618360efbdSAlfred Perlsteinfor compatibility as: 2628360efbdSAlfred Perlstein.Bd -literal 2638360efbdSAlfred Perlsteinstruct t_bind { 2648360efbdSAlfred Perlstein struct netbuf addr; /* network address, see rpc(3) */ 2658360efbdSAlfred Perlstein unsigned int qlen; /* queue length (for listen(2)) */ 2668360efbdSAlfred Perlstein}; 2678360efbdSAlfred Perlstein.Ed 2688360efbdSAlfred Perlstein.Pp 2698360efbdSAlfred PerlsteinIn the case where the default address is chosen, 2708360efbdSAlfred Perlsteinthe number of outstanding connect requests is set to 8 2718360efbdSAlfred Perlsteinfor connection-oriented transports. 2728360efbdSAlfred PerlsteinThe user may specify the size of the send and receive buffers 2732efeeba5SRuslan Ermilovwith the arguments 2748360efbdSAlfred Perlstein.Fa sendsz 2758360efbdSAlfred Perlsteinand 2768360efbdSAlfred Perlstein.Fa recvsz ; 2778360efbdSAlfred Perlsteinvalues of 0 choose suitable defaults. 2788360efbdSAlfred PerlsteinThis routine returns 2798360efbdSAlfred Perlstein.Dv NULL 2808360efbdSAlfred Perlsteinif it fails, 2818360efbdSAlfred Perlsteinand an error message is logged. 2828360efbdSAlfred PerlsteinThe server is not registered with the 2838360efbdSAlfred Perlstein.Xr rpcbind 8 2848360efbdSAlfred Perlsteinservice. 2858360efbdSAlfred Perlstein.It Fn svc_tp_create 2861fae73b1SRuslan ErmilovThe 2878360efbdSAlfred Perlstein.Fn svc_tp_create 2881fae73b1SRuslan Ermilovfunction 2898360efbdSAlfred Perlsteincreates a server handle for the network 2908360efbdSAlfred Perlsteinspecified by 2918360efbdSAlfred Perlstein.Fa netconf , 2928360efbdSAlfred Perlsteinand registers itself with the rpcbind service. 2932efeeba5SRuslan ErmilovThe 2948360efbdSAlfred Perlstein.Fa dispatch 2952efeeba5SRuslan Ermilovfunction 2968360efbdSAlfred Perlsteinis called when there is a remote procedure call 2978360efbdSAlfred Perlsteinfor the given 2988360efbdSAlfred Perlstein.Fa prognum 2998360efbdSAlfred Perlsteinand 3008360efbdSAlfred Perlstein.Fa versnum ; 3018360efbdSAlfred Perlsteinthis requires calling 3028360efbdSAlfred Perlstein.Fn svc_run . 3031fae73b1SRuslan ErmilovThe 3048360efbdSAlfred Perlstein.Fn svc_tp_create 3051fae73b1SRuslan Ermilovfunction 3068360efbdSAlfred Perlsteinreturns the service handle if it succeeds, 3078360efbdSAlfred Perlsteinotherwise a 3088360efbdSAlfred Perlstein.Dv NULL 3098360efbdSAlfred Perlsteinis returned and an error message is logged. 3108360efbdSAlfred Perlstein.It Fn svc_vc_create 3118360efbdSAlfred PerlsteinThis routine creates a connection-oriented RPC 3128360efbdSAlfred Perlsteinservice and returns a pointer to it. 3138360efbdSAlfred PerlsteinThis routine returns 3148360efbdSAlfred Perlstein.Dv NULL 3158360efbdSAlfred Perlsteinif it fails, and an error message is logged. 3168360efbdSAlfred PerlsteinThe users may specify the size of the send and receive buffers 3172efeeba5SRuslan Ermilovwith the arguments 3188360efbdSAlfred Perlstein.Fa sendsz 3198360efbdSAlfred Perlsteinand 3208360efbdSAlfred Perlstein.Fa recvsz ; 3218360efbdSAlfred Perlsteinvalues of 0 choose suitable defaults. 3228360efbdSAlfred PerlsteinThe file descriptor 3238360efbdSAlfred Perlstein.Fa fildes 3248360efbdSAlfred Perlsteinshould be open and bound. 3258360efbdSAlfred PerlsteinThe server is not registered with the 3268360efbdSAlfred Perlstein.Xr rpcbind 8 3278360efbdSAlfred Perlsteinservice. 3288360efbdSAlfred Perlstein.El 3298360efbdSAlfred Perlstein.Sh SEE ALSO 3308360efbdSAlfred Perlstein.Xr rpc 3 , 3318360efbdSAlfred Perlstein.Xr rpc_svc_calls 3 , 3328360efbdSAlfred Perlstein.Xr rpc_svc_err 3 , 3338360efbdSAlfred Perlstein.Xr rpc_svc_reg 3 , 3348360efbdSAlfred Perlstein.Xr rpcbind 8 335