rpc(3N)rpc(3N)NAMErpc - library routines for remote procedure calls
SYNOPSIS
[ flag ]... file... [ library ]...
DESCRIPTION
These routines allow C language programs to make procedure calls on
other machines across a network. First, the client sends a request to
the server. On receipt of the request, the server calls a dispatch
routine to perform the requested service, and then sends back a reply.
All RPC routines require the header Routines that take a structure also
require that be included. Applications using RPC and XDR routines
should be linked with the library.
The HP-UX implementation of RPC only supports the X/Open Transport
Interface (XTI). Applications that are written using the Transport
Layer Interface (TLI) and wish to use RPC, must convert their applica‐
tion to XTI.
Multithread Considerations
In the case of multithreaded applications, the flag must be defined on
the command line at compilation time Defining this flag enables a
thread-specific version of (see rpc_clnt_create(3N)).
When used in multithreaded applications, client-side routines are
thread-safe. CLIENT handles (see rpc_clnt_create(3N)) can be shared
between threads; however, in this implementation requests by different
threads are serialized (that is, the first request will receive its
results before the second request is sent).
When used in multithreaded applications, server-side routines are usu‐
ally not thread-safe. In this implementation the service transport
handle, (see rpc_svc_create(3N)), contains a single data area for
decoding arguments and encoding results. Therefore, this structure
cannot be freely shared between threads that call functions that do
this. Routines that are affected by this restriction are marked as
unsafe for multithreaded applications (see rpc_svc_calls(3N)).
See the section of the routines' respective manual pages.
Nettype
Some of the high-level RPC interface routines take a nettype string as
one of the parameters (for example, This string defines a class of
transports which can be used for a particular application.
nettype can be one of the following:
Choose from the transports which have been
indicated by their token names in the environment vari‐
able. If is unset or NULL, it defaults to is the
default nettype.
Choose the transports which have the visible flag
set in the file.
This is same as
except that it chooses only the connection oriented
transports (semantics or from the entries in the file.
This is same as
except that it chooses only the connectionless datagram
transports (semantics from the entries in the file.
This is same as
except that it chooses only the connection oriented
datagram transports (semantics or
This is same as
except that it chooses only the connectionless datagram
transports (semantics
This refers to Internet UDP.
This refers to Internet TCP.
If nettype is NULL, it defaults to The transports are tried in left to
right order in the variable or in top to down order in the file.
Derived Types
In a 64-bit environment, the derived types are defined as follows:
typedef unsigned long rpcprog_t;
typedef unsigned long rpcvers_t;
typedef unsigned long rpcproc_t;
typedef unsigned long rpcprot_t;
typedef unsigned long rpcport_t;
typedef int32_t rpc_inline_t;
In a 32-bit environment, the derived types are defined as follows:
typedef unsigned long rpcprog_t;
typedef unsigned long rpcvers_t;
typedef unsigned long rpcproc_t;
typedef unsigned long rpcprot_t;
typedef unsigned long rpcport_t;
typedef long rpc_inline_t;
Data Structures
Some of the data structures used by the RPC package are shown below.
union des_block {
struct {
u_int32 high;
u_int32 low;
} key;
char c[8];
};
typedef union des_block des_block;
extern bool_t xdr_des_block();
/*
* Authentication info. Opaque to client.
*/
struct opaque_auth {
enum_t oa_flavor; /* flavor of auth */
caddr_t oa_base; /* address of more auth stuff */
u_int oa_length; /* not to exceed MAX_AUTH_BYTES */
};
/*
* Auth handle, interface to client side authenticators.
*/
typedef struct {
struct opaque_auth ah_cred;
struct opaque_auth ah_verf;
union des_block ah_key;
struct auth_ops {
void (*ah_nextverf)();
int (*ah_marshal)(); /* nextverf & serialize */
int (*ah_validate)(); /* validate verifier */
int (*ah_refresh)(); /* refresh credentials */
void (*ah_destroy)(); /* destroy this structure */
} *ah_ops;
caddr_t ah_private;
} AUTH;
/*
* Client rpc handle.
* Created by individual implementations.
* Client is responsible for initializing auth.
*/
typedef struct {
AUTH *cl_auth; /* authenticator */
struct clnt_ops {
enum clnt_stat (*cl_call)(); /* call remote procedure */
void (*cl_abort)(); /* abort a call */
void (*cl_geterr)(); /* get specific error code */
bool_t (*cl_freeres)(); /* frees results */
void (*cl_destroy)(); /* destroy this structure */
bool_t (*cl_control)(); /* the ioctl() of rpc */
int (*cl_settimers)(); /* set rpc level timers */
} *cl_ops;
caddr_t cl_private; /* private stuff */
char *cl_netid; /* network identifier */
char *cl_tp; /* device name */
} CLIENT;
enum xprt_stat {
XPRT_DIED,
XPRT_MOREREQS,
XPRT_IDLE
};
/*
* Server side transport handle
*/
typedef struct {
int xp_fd; /* file descriptor for the
server handle */
u_short xp_port; /* obsolete */
struct xp_ops {
bool_t (*xp_recv)(); /* receive incoming requests */
enum xprt_stat (*xp_stat)(); /* get transport status */
bool_t (*xp_getargs)(); /* get arguments */
bool_t (*xp_reply)(); /* send reply */
bool_t (*xp_freeargs)(); /* free mem allocated
for args */
void (*xp_destroy)(); /* destroy this struct */
} *xp_ops;
int xp_addrlen; /* length of remote addr.
Obsolete */
char *xp_tp; /* transport provider device
name */
char *xp_netid; /* network identifier */
struct netbuf xp_ltaddr; /* local transport address */
struct netbuf xp_rtaddr; /* remote transport address */
char xp_raddr[16]; /* remote address. Obsolete */
struct opaque_auth xp_verf; /* raw response verifier */
caddr_t xp_p1; /* private: for use
by svc ops */
caddr_t xp_p2; /* private: for use
by svc ops */
caddr_t xp_p3; /* private: for use
by svc lib */
int xp_type /* transport type */
} SVCXPRT;
struct svc_req {
rpcprog_t rq_prog; /* service program number */
rpcvers_t rq_vers; /* service protocol version */
rpcproc_t rq_proc; /* the desired procedure */
struct opaque_auth rq_cred; /* raw creds from the wire */
caddr_t rq_clntcred; /* read only cooked cred */
SVCXPRT *rq_xprt; /* associated transport */
};
/*
* XDR operations.
* XDR_ENCODE causes the type to be encoded into the stream.
* XDR_DECODE causes the type to be extracted from the stream.
* XDR_FREE can be used to release the space allocated by an XDR_DECODE
* request.
*/
enum xdr_op {
XDR_ENCODE=0,
XDR_DECODE=1,
XDR_FREE=2
};
/*
* This is the number of bytes per unit of external data.
*/
#define BYTES_PER_XDR_UNIT (4)
#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) /
BYTES_PER_XDR_UNIT) * BYTES_PER_XDR_UNIT)
/*
* A xdrproc_t exists for each data type which is to be encoded or
* decoded. The second argument to the xdrproc_t is a pointer to
* an opaque pointer. The opaque pointer generally points to a
* structure of the data type to be decoded. If this points to 0,
* then the type routines should allocate dynamic storage of the
* appropriate size and return it.
* bool_t (*xdrproc_t)(XDR *, caddr_t *);
*/
typedef bool_t (*xdrproc_t)();
/*
* The XDR handle.
* Contains operation which is being applied to the stream,
* an operations vector for the particular implementation
*/
typedef struct {
enum xdr_op x_op; /* operation; fast additional param */
struct xdr_ops {
bool_t (*x_getlong)(); /* get a long from underlying stream */
bool_t (*x_putlong)(); /* put a long to underlying stream */
bool_t (*x_getbytes)(); /* get bytes from underlying stream */
bool_t (*x_putbytes)(); /* put bytes to underlying stream */
u_int (*x_getpostn)(); /* returns bytes off from beginning */
bool_t (*x_setpostn)(); /* lets you reposition the stream */
rpc_inline_t *(*x_inline)(); /* buf quick ptr to buffered data */
void (*x_destroy)(); /* free privates of this xdr_stream */
bool_t (*x_control)(); /* change/retrieve client object info */
bool_t (*x_getint32)(); /* get an int from underlying stream */
bool_t (*x_putint32)(); /* put an int to underlying stream */
} *x_ops;
caddr_t x_public; /* users' data */
caddr_t x_private; /* pointer to private data */
caddr_t x_base; /* private used for position info */
int x_handy; /* extra private word */
} XDR;
Index to Routines
The following table lists RPC routines and the manual reference pages
on which they are described:
RPC Routine Manual Reference Page
rpc_clnt_auth(3N)rpc_soc(3N)secure_rpc(3N)secure_rpc(3N)rpc_clnt_auth(3N)rpc_clnt_auth(3N)rpc_clnt_auth(3N)rpc_soc(3N)rpc_soc(3N)rpc_soc(3N)rpc_soc(3N)rpc_clnt_calls(3N)rpc_clnt_create(3N)rpc_clnt_create(3N)rpc_clnt_create(3N)rpc_clnt_create(3N)rpc_clnt_create(3N)rpc_clnt_create(3N)rpc_clnt_create(3N)rpc_clnt_calls(3N)rpc_clnt_calls(3N)rpc_clnt_create(3N)rpc_clnt_calls(3N)rpc_clnt_calls(3N)rpc_clnt_create(3N)rpc_clnt_create(3N)rpc_clnt_calls(3N)rpc_clnt_calls(3N)rpc_clnt_create(3N)rpc_clnt_create(3N)rpc_clnt_create(3N)rpc_soc(3N)rpc_clnt_create(3N)rpc_soc(3N)rpc_soc(3N)rpc_soc(3N)rpc_soc(3N)secure_rpc(3N)secure_rpc(3N)secure_rpc(3N)secure_rpc(3N)secure_rpc(3N)secure_rpc(3N)secure_rpc(3N)secure_rpc(3N)rpc_soc(3N)rpc_soc(3N)rpc_soc(3N)rpc_soc(3N)rpc_soc(3N)rpc_soc(3N)rpc_clnt_calls(3N)rpc_clnt_calls(3N)rpc_clnt_calls(3N)rpc_svc_calls(3N)rpc_svc_create(3N)rpc_svc_create(3N)rpc_svc_create(3N)rpc_svc_calls(3N)rpc_svc_create(3N)rpc_soc(3N)rpc_svc_reg(3N)rpc_svc_reg(3N)rpc_soc(3N)rpc_soc(3N)rpc_svc_calls(3N)rpc_svc_calls(3N)rpc_svc_create(3N)rpc_svc_calls(3N)rpc_soc(3N)rpc_svc_reg(3N)rpc_svc_reg(3N)rpc_svc_create(3N)rpc_svc_create(3N)rpc_svc_calls(3N)rpc_soc(3N)rpc_svc_create(3N)rpc_svc_err(3N)rpc_svc_err(3N)rpc_svc_err(3N)rpc_svc_err(3N)rpc_svc_err(3N)rpc_svc_err(3N)rpc_svc_err(3N)rpc_soc(3N)rpc_soc(3N)rpc_soc(3N)rpc_soc(3N)rpc_soc(3N)secure_rpc(3N)rpc_xdr(3N)rpc_xdr(3N)rpc_soc(3N)rpc_xdr(3N)rpc_xdr(3N)rpc_xdr(3N)rpc_xdr(3N)rpc_xdr(3N)rpc_svc_calls(3N)rpc_svc_calls(3N)FILESSEE ALSOgetnetconfig(3N), getnetpath(3N), rpc_clnt_auth(3N),
rpc_clnt_calls(3N), rpc_clnt_create(3N), rpc_svc_calls(3N),
rpc_svc_create(3N), rpc_svc_err(3N), rpc_svc_reg(3N), rpc_xdr(3N),
rpcbind(3N), secure_rpc(3N), xdr(3N), netconfig(4), rpc(4), environ(5).
rpc(3N)