1RPC(3) Linux Programmer's Manual RPC(3)
2
3
4
6 rpc - library routines for remote procedure calls
7
9 These routines allow C programs to make procedure calls on other ma‐
10 chines across the network. First, the client calls a procedure to send
11 a data packet to the server. Upon receipt of the packet, the server
12 calls a dispatch routine to perform the requested service, and then
13 sends back a reply. Finally, the procedure call returns to the client.
14
15 To take use of these routines, include the header file <rpc/rpc.h>.
16
17 The prototypes below make use of the following types:
18
19 typedef int bool_t;
20
21 typedef bool_t (*xdrproc_t)(XDR *, void *, ...);
22
23 typedef bool_t (*resultproc_t)(caddr_t resp,
24 struct sockaddr_in *raddr);
25
26 See the header files for the declarations of the AUTH, CLIENT, SVCXPRT,
27 and XDR types.
28
29 void auth_destroy(AUTH *auth);
30
31 A macro that destroys the authentication information associated
32 with auth. Destruction usually involves deallocation of private
33 data structures. The use of auth is undefined after calling
34 auth_destroy().
35
36 AUTH *authnone_create(void);
37
38 Create and return an RPC authentication handle that passes
39 nonusable authentication information with each remote procedure
40 call. This is the default authentication used by RPC.
41
42 AUTH *authunix_create(char *host, uid_t uid, gid_t gid,
43 int len, gid_t *aup_gids);
44
45 Create and return an RPC authentication handle that contains au‐
46 thentication information. The parameter host is the name of the
47 machine on which the information was created; uid is the user's
48 user ID; gid is the user's current group ID; len and aup_gids
49 refer to a counted array of groups to which the user belongs.
50 It is easy to impersonate a user.
51
52 AUTH *authunix_create_default(void);
53
54 Calls authunix_create() with the appropriate parameters.
55
56 int callrpc(char *host, unsigned long prognum,
57 unsigned long versnum, unsigned long procnum,
58 xdrproc_t inproc, const char *in,
59 xdrproc_t outproc, char *out);
60
61 Call the remote procedure associated with prognum, versnum, and
62 procnum on the machine, host. The parameter in is the address
63 of the procedure's argument(s), and out is the address of where
64 to place the result(s); inproc is used to encode the procedure's
65 parameters, and outproc is used to decode the procedure's re‐
66 sults. This routine returns zero if it succeeds, or the value
67 of enum clnt_stat cast to an integer if it fails. Th