Lines Matching +full:rpc +full:- +full:if

2 .\" Must use -- tbl and pic -- with this one
17 .IX "RPC Programming Guide"
22 the RPC mechanisms usually hidden by the
33 existing non-network application to run over the network, you may want to
39 section of that chapter contains the complete source for a working RPC
45 What are remote procedure calls? Simply put, they are the high-level
48 low-level networking mechanisms (such as TCP/IP and UDP/IP), and upon them
50 specifically for the support of network applications. With RPC, the client
56 \&Layers of RPC
57 .IX "layers of RPC"
58 .IX "RPC" "layers"
60 The RPC interface can be seen as being divided into three layers.\**
64 .I rpc(3N)
69 .IX RPC "The Highest Layer"
75 a \fIpart of\fP RPC proper. Programmers who write RPC routines
82 The user is not explicitly aware of using RPC \(em they simply
87 .IX RPC "The Middle Layer"
89 need to consider details about sockets, the UNIX system, or other low-level
92 It's this layer that allows RPC to pass the \*Qhello world\*U test \(em
93 simple things should be simple. The middle-layer routines are used
103 obtains a unique system-wide procedure-identification number, and
118 .IX RPC "The Lowest Layer"
122 real issue \(em since RPC clients and servers rarely generate
127 Even though this document discusses RPC
135 \&The RPC Paradigm
136 .IX RPC paradigm
138 Here is a diagram of the RPC paradigm:
140 \fBFigure 1-1\fI Network Communication with the Remote Reocedure Call\fR
167 \&Higher Layers of RPC
170 .IX "highest layer of RPC"
171 .IX RPC "highest layer"
175 You can do this by calling the RPC library routine
195 exit(-1);
204 are in the RPC services library
209 % cc \fIprogram.c -lrpcsvc\fP
212 like the other RPC library routines, is documented in section 3R
215 the same section which documents the standard Sun RPC services.
216 .IX "RPC Services"
220 for these services and their RPC protocols.
222 Here are some of the RPC service library routines available to the
225 \fBTable 3-3\fI RPC Service Library Routines\fR
235 havedisk&Determine if remote machine has disk
241 Other RPC services \(em for example
249 have RPC program numbers so they can be invoked with
267 .IX "intermediate layer of RPC"
268 .IX "RPC" "intermediate layer"
270 The simplest interface, which explicitly makes RPC calls, uses the
279 #include <rpc/rpc.h>
292 exit(-1);
305 Each RPC procedure is uniquely defined by a program number,
317 The simplest way of making remote procedure calls is with the RPC
328 results are handled by embedding them in structures. If
332 .IX "enum clnt_stat (in RPC programming)" "" "\fIenum clnt_stat\fP (in RPC programming)"
334 .I <rpc/clnt.h> .
338 needs both the type of the RPC argument, as well as
360 After trying several times to deliver a message, if
367 layer of the RPC library, discussed later in this document.
398 Normally, a server registers all of the RPC calls it plans
406 #include <rpc/rpc.h>
425 given RPC procedure number. The first three parameters,
455 the RPC library's remote procedure dispatcher. It is this
456 function that calls the remote procedures in response to RPC
470 0x0 - 0x1fffffff \fRDefined by Sun\fP
471 0x20000000 - 0x3fffffff \fRDefined by user\fP
472 0x40000000 - 0x5fffffff \fRTransient\fP
473 0x60000000 - 0x7fffffff \fRReserved\fP
474 0x80000000 - 0x9fffffff \fRReserved\fP
475 0xa0000000 - 0xbfffffff \fRReserved\fP
476 0xc0000000 - 0xdfffffff \fRReserved\fP
477 0xe0000000 - 0xffffffff \fRReserved\fP
481 should be identical for all Sun customers. If a customer
493 .I rpc@sun
505 .IX RPC administration
506 .IX administration "of RPC"
508 The RPC program numbers and protocol specifications
509 of standard Sun RPC services can be
517 \fBTable 3-2\fI RPC Registered Programs\fR
569 200000&PYRAMIDLOCKINGPROG&Pyramid-locking
570 200001&PYRAMIDSYS5&Pyramid-sys5
579 In the previous example, the RPC call passes a single
596 can be a built-in procedure like
599 XDR has these built-in type routines:
600 .IX RPC "built-in routines"
619 As an example of a user-defined type routine,
642 #include <rpc/rpc.h>
648 if (!xdr_int(xdrsp, &simplep->a))
650 if (!xdr_short(xdrsp, &simplep->b))
656 An XDR routine returns nonzero (true in the sense of C) if it
663 In addition to the built-in primitives,
680 and make an RPC call such as
696 return (xdr_array(xdrsp, &arrp->data, &arrp->arrlnth,
709 which serializes fixed-length arrays.
727 XDR always converts quantities to 4-byte multiples when serializing.
728 Thus, if either of the examples above involved characters
738 For null-terminated strings, there is also the
745 and on deserializing it creates a null-terminated string.
749 as well as the built-in functions
767 if (!xdr_string(xdrsp, &finalp->string, MAXSTRLEN))
769 if (!xdr_reference(xdrsp, &finalp->simplep,
780 \&Lowest Layer of RPC
781 .IX "lowest layer of RPC"
782 .IX "RPC" "lowest layer"
787 by using lower layers of the RPC library.
793 which restricts RPC calls to 8K bytes of data. Using TCP permits calls
812 .IX RPC "server side"
818 above, but is written using a lower layer of the RPC package:
823 #include <rpc/rpc.h>
834 fprintf(stderr, "can't create an RPC server\en");
853 switch (rqstp->rq_proc) {
855 if (!svc_sendreply(transp, xdr_void, 0))
856 fprintf(stderr, "can't reply to RPC call\en");
865 if (!svc_sendreply(transp, xdr_u_long, &nusers))
866 fprintf(stderr, "can't reply to RPC call\en");
876 for receiving and replying to RPC messages.
888 the RPC library creates a socket
889 on which to receive and reply to RPC calls. Otherwise,
897 (the low-level client routine) must match.
901 argument, the RPC library routines will open sockets.
906 will cause the RPC library routines to
908 their socket if it is not bound already.
912 a non-zero protocol number in
925 so that if the
965 for detecting if a remote program is running.
973 them to the RPC caller via
980 handles an RPC program that receives data.
1012 fprintf(stderr, "can't reply to RPC call\en");
1086 Then the RPC call might look like this:
1104 will not attempt to free any memory if the variable indicating it
1107 given earlier, if
1108 .I finalp->string
1110 .I finalp->simplep .
1132 .IX RPC "calling side"
1136 you have no control over the RPC delivery
1138 To illustrate the layer of RPC that lets you adjust these
1147 #include <rpc/rpc.h>
1168 exit(-1);
1172 exit(-1);
1176 bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr,
1177 hp->h_length);
1183 exit(-1);
1190 clnt_perror(client, "rpc");
1191 exit(-1);
1200 The low-level version of
1248 handle, however, only if the RPC library opened it. It the
1267 All RPC calls using that
1270 The server side of an RPC call using TCP has
1280 are send and receive sizes respectively. If `0' is specified for
1284 \&Other RPC Features
1285 .IX "RPC" "miscellaneous features"
1286 .IX "miscellaneous RPC features"
1288 This section discusses some other aspects of RPC
1292 .IX RPC select() RPC \fIselect()\fP
1295 Suppose a process is processing RPC requests
1300 But if the other activity
1321 case -1:
1322 if (errno == EINTR)
1347 that waits on both the RPC socket,
1350 is a bit mask of all the file descriptors that RPC is using for
1356 \&Broadcast RPC
1357 .IX "broadcast RPC"
1358 .IX RPC "broadcast"
1362 is a daemon that converts RPC program numbers
1365 man page. You can't do broadcast RPC without the portmapper.
1367 broadcast RPC and normal RPC calls:
1369 Normal RPC expects one answer, whereas
1370 broadcast RPC expects many answers
1373 Broadcast RPC can only be supported by packet-oriented (connectionless)
1376 The implementation of broadcast RPC
1378 Thus, if there is a version mismatch between the
1380 the user of broadcast RPC never knows.
1384 are accessible via the broadcast RPC mechanism.
1390 \&Broadcast RPC Synopsis
1391 .IX "broadcast RPC" synopsis
1392 .IX "RPC" "broadcast synopsis"
1396 #include <rpc/pmap_clnt.h>
1442 .IX RPC "batching"
1444 The RPC architecture is designed so that clients send a call message,
1448 This is inefficient if the client does not want or need
1452 using RPC batch facilities.
1457 1) each RPC call in the pipeline requires no response from the server,
1485 #include <rpc/rpc.h>
1496 fprintf(stderr, "can't create an RPC server\en");
1516 switch (rqstp->rq_proc) {
1518 if (!svc_sendreply(transp, xdr_void, 0))
1519 fprintf(stderr, "can't reply to RPC call\en");
1522 if (!svc_getargs(transp, xdr_wrapstring, &s)) {
1537 if (!svc_sendreply(transp, xdr_void, NULL))
1538 fprintf(stderr, "can't reply to RPC call\en");
1541 if (!svc_getargs(transp, xdr_wrapstring, &s)) {
1573 the client must perform RPC calls on a TCP-based transport
1577 and 2) the RPC call's timeout must be zero.
1588 #include <rpc/rpc.h>
1609 exit(-1);
1616 if (clnt_stat != RPC_SUCCESS) {
1617 clnt_perror(client, "batched rpc");
1618 exit(-1);
1628 clnt_perror(client, "rpc");
1629 exit(-1);
1646 1) machine to itself, regular RPC;
1647 2) machine to itself, batched RPC;
1648 3) machine to another, regular RPC; and
1649 4) machine to another, batched RPC.
1666 .IX "RPC" "authentication"
1674 In reality, every RPC call is authenticated by
1675 the RPC package on the server, and similarly,
1676 the RPC client package generates and sends authentication parameters.
1678 can be used when creating RPC clients and servers,
1679 different forms of authentication can be associated with RPC clients;
1683 The authentication subsystem of the RPC package is open ended.
1690 When a caller creates a new RPC client handle as in:
1700 clnt->cl_auth = authnone_create();
1702 The RPC client can choose to use
1705 .I clnt\->cl_auth
1706 after creating the RPC client handle:
1709 clnt->cl_auth = authunix_create_default();
1711 This causes each RPC call associated with
1733 Since the RPC user created this new style of authentication,
1737 auth_destroy(clnt->cl_auth);
1744 since the RPC package passes the service dispatch routine a request
1751 * An RPC Service request
1779 .IX RPC guarantees
1780 The RPC package guarantees the following
1790 if the style is not one of the styles supported by the RPC package.
1804 structure. If
1811 that the RPC package does not know about.
1832 if (rqstp->rq_proc == NULLPROC) {
1833 if (!svc_sendreply(transp, xdr_void, 0)) {
1834 fprintf(stderr, "can't reply to RPC call\en");
1844 switch (rqstp->rq_cred.oa_flavor) {
1847 (struct authunix_parms *)rqstp->rq_clntcred;
1848 uid = unix_cred->aup_uid;
1855 switch (rqstp->rq_proc) {
1862 if (uid == 16) {
1872 if (!svc_sendreply(transp, xdr_u_long, &nusers)) {
1873 fprintf(stderr, "can't reply to RPC call\en");
1889 Second, if the authentication parameter's type is not suitable
1899 the RPC authentication package and the services;
1908 .IX RPC DES
1909 .IX RPC authentication
1915 and then modify the RPC authentication handle it returns by filling in
1949 cl->cl_auth =
1966 to contain this root process's netname. If the
1988 seconds from now. If some mischievous user tries to reuse the
1989 credential, the server RPC subsystem will recognize that it has
1990 expired and not grant any requests. If the same mischievous user
1992 he will still be rejected because the server RPC subsystem
2010 timestamps and data. If this argument is
2029 #include <rpc/auth_des.h>
2047 if (rqstp->rq_proc == NULLPROC) {
2056 switch (rqstp->rq_cred.oa_flavor) {
2059 (struct authdes_cred *) rqstp->rq_clntcred;
2060 if (! netname2user(des_cred->adc_fullname.name,
2064 des_cred->adc_fullname.name);
2094 An RPC server can be started from
2119 Remember that if you want to exit
2128 for RPC services is in one of the following two forms:
2132 p_name/version dgram rpc/udp wait/nowait user server args
2133 p_name/version stream rpc/tcp wait/nowait user server args
2138 .I rpc(5) ,
2155 rstatd/1-2 dgram rpc/udp wait root /usr/etc/rpc.rstatd
2163 .IX "RPC" "versions"
2207 switch (rqstp->rq_proc) {
2209 if (!svc_sendreply(transp, xdr_void, 0)) {
2210 fprintf(stderr, "can't reply to RPC call\en");
2222 switch (rqstp->rq_vers) {
2224 if (!svc_sendreply(transp, xdr_u_long,
2226 fprintf(stderr,"can't reply to RPC call\en");
2230 if (!svc_sendreply(transp, xdr_u_short,
2232 fprintf(stderr,"can't reply to RPC call\en");
2250 The initiator of the RPC
2255 The RPC call uses TCP.
2269 #include <rpc/rpc.h>
2278 if (xdrs->x_op == XDR_FREE)/* nothing to free */
2281 if (xdrs->x_op == XDR_ENCODE) {
2282 if ((size = fread(buf, sizeof(char), BUFSIZ,
2289 if (!xdr_bytes(xdrs, &p, &size, BUFSIZ))
2291 if (size == 0)
2293 if (xdrs->x_op == XDR_DECODE) {
2294 if (fwrite(buf, sizeof(char), size,
2315 #include <rpc/rpc.h>
2328 exit(-1);
2333 fprintf(stderr, "can't make RPC call\en");
2353 return (-1);
2355 bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr,
2356 hp->h_length);
2362 return (-1);
2382 #include <rpc/rpc.h>
2408 switch (rqstp->rq_proc) {
2410 if (svc_sendreply(transp, xdr_void, 0) == 0) {
2416 if (!svc_getargs(transp, xdr_rcp, stdout)) {
2420 if (!svc_sendreply(transp, xdr_void, 0)) {
2434 .IX RPC "callback procedures"
2437 and make an RPC call back to the process which is its client.
2444 and then makes an RPC call to the server
2448 and the debugger wants to make an rpc call to the window program,
2451 In order to do an RPC callback,
2452 you need a program number to make the RPC call on.
2455 .I "0x40000000 - 0x5fffffff" .
2467 and if it has not, then reserves it. On return, the
2480 #include <rpc/rpc.h>
2502 if ((s = socket(AF_INET, socktype, 0)) < 0) {
2526 return (prognum-1);
2552 The client makes an RPC call to the server,
2558 so that it can receive the RPC call
2562 signal in this example), it sends a callback RPC call,
2573 #include <rpc/rpc.h>
2592 /* protocol is 0 - gettransient does registering
2611 switch (rqstp->rq_proc) {
2613 if (!svc_sendreply(transp, xdr_void, 0)) {
2619 if (!svc_getargs(transp, xdr_void, 0)) {
2624 if (!svc_sendreply(transp, xdr_void, 0)) {
2642 #include <rpc/rpc.h>