clnt.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley
* 4.3 BSD under license from the Regents of the University of
* California.
*/
/*
* clnt.h - Client side remote procedure call interface.
*/
#ifndef _RPC_CLNT_H
#define _RPC_CLNT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <rpc/clnt_stat.h>
/*
* rpc calls return an enum clnt_stat. This should be looked at more,
* since each implementation is required to live with this (implementation
* independent) list of errors.
*/
#include <sys/netconfig.h>
#ifdef _KERNEL
#endif /* _KERNEL */
#ifdef __cplusplus
extern "C" {
#endif
/*
* Following defines the multicast group address used by IPV6 enabled
* client to do the broadcast. IPv6 doesn't have any broadcast support
* as IPv4 provides, thus it used this reserved address which is joined
* by all rpc clients.
*/
#define RPCB_MULTICAST_ADDR "FF02::202"
/*
* the following errors are in general unrecoverable. The caller
* should give up rather than retry.
*/
#define IS_UNRECOVERABLE_RPC(s) (((s) == RPC_AUTHERROR) || \
((s) == RPC_CANTENCODEARGS) || \
((s) == RPC_CANTDECODERES) || \
((s) == RPC_VERSMISMATCH) || \
((s) == RPC_PROCUNAVAIL) || \
((s) == RPC_PROGUNAVAIL) || \
((s) == RPC_PROGVERSMISMATCH) || \
((s) == RPC_CANTDECODEARGS))
/* Maximum rpc backoff time */
#define RPC_MAX_BACKOFF 30
/*
* Error info.
*/
struct rpc_err {
union {
struct {
int RE_errno; /* related system error */
int RE_t_errno; /* related tli error number */
} RE_err;
struct {
} RE_vers;
struct { /* maybe meaningful if RPC_FAILED */
} RE_lb; /* life boot & debugging only */
} ru;
};
/*
* Timers used for the pseudo-transport protocol when using datagrams
*/
struct rpc_timers {
};
/*
* PSARC 2003/523 Contract Private Interface
* CLIENT
* Changes must be reviewed by Solaris File Sharing
* Changes must be communicated to contract-2003-523@sun.com
*
* Client rpc handle.
* Created by individual implementations
* Client is responsible for initializing auth, see e.g. auth_none.c.
*/
typedef struct __client {
struct clnt_ops {
#ifdef __STDC__
/* call remote procedure */
/* abort a call */
void (*cl_abort)(/* various */);
/* get specific error code */
struct rpc_err *);
/* frees results */
caddr_t);
/* destroy this structure */
void (*cl_destroy)(struct __client *);
/* the ioctl() of rpc */
/* set rpc level timers */
int (*cl_settimers)(struct __client *,
struct rpc_timers *, struct rpc_timers *,
#ifndef _KERNEL
/* send a one-way asynchronous call to remote procedure */
#endif /* !_KERNEL */
#else
void (*cl_abort)(); /* abort a call */
void (*cl_geterr)(); /* get specific error code */
void (*cl_destroy)(); /* destroy this structure */
int (*cl_settimers)(); /* set rpc level timers */
#ifndef _KERNEL
#endif /* !_KERNEL */
#endif
} *cl_ops;
#ifndef _KERNEL
char *cl_netid; /* network token */
char *cl_tp; /* device name */
#else
#endif
} CLIENT;
/*
* Feedback values used for possible congestion and rate control
*/
/*
* The following defines the control routines
* for rpcbind.
*/
#define CLCR_GET_RPCB_TIMEOUT 1
#define CLCR_SET_RPCB_TIMEOUT 2
#define CLCR_SET_LOWVERS 3
#define CLCR_GET_LOWVERS 4
#define CLCR_SET_RPCB_RMTTIME 5
#define CLCR_GET_RPCB_RMTTIME 6
#define CLCR_SET_CRED_CACHE_SZ 7
#define CLCR_GET_CRED_CACHE_SZ 8
/*
* PSARC 2003/523 Contract Private Interface
* knetconfig
* Changes must be reviewed by Solaris File Sharing
* Changes must be communicated to contract-2003-523@sun.com
*
* Note that the knetconfig strings can either be dynamically allocated, or
* they can be string literals. The code that sets up the knetconfig is
* responsible for keeping track of this and freeing the strings if
* necessary when the knetconfig is destroyed.
*/
struct knetconfig {
unsigned int knc_semantics; /* token name */
unsigned int knc_unused[8];
};
#ifdef _SYSCALL32
struct knetconfig32 {
};
#endif /* _SYSCALL32 */
#ifdef _KERNEL
/*
* Bucket defined for the call table. Padded out to 64 bytes so that
* false sharing won't be induced.
*/
typedef union call_table {
struct {
struct calllist_s *uct_call_next;
struct calllist_s *uct_call_prev;
} ct_s;
char uct_pad[64];
} call_table_t;
/*
* Define some macros for easy access into the call table structure
*/
/*
* List of outstanding calls awaiting replies, for COTS, CLTS
*/
typedef struct calllist_s {
struct calllist_s *call_prev;
} calllist_t;
/*
* Define macros for call table hashing
*/
/*
* A simple hash function. Due to the way XID's get allocated, this may be
* sufficient. This hash function provides round robin bucket selection so
* that the next time a particular bucket gets picked is when there have
* been N-1 calls. N is the number of buckets.
*/
#define call_table_enter(e) \
{ \
ctp->ct_call_next = e; \
}
#define call_table_remove(e) \
{ \
}
{ \
calllist_t *cp; \
} \
}
#define DEFAULT_MIN_HASH_SIZE 32
#define DEFAULT_HASH_SIZE 1024
/*
* Alloc_xid presents an interface which kernel RPC clients
* should use to allocate their XIDs. Its implementation
* may change over time (for example, to allow sharing of
* XIDs between the kernel and user-level applications, so
* all XID allocation should be done by calling alloc_xid().
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
struct knetconfig **knconf);
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
extern call_table_t *call_table_init(int);
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
extern void clnt_init(void);
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
extern void clnt_fini(void);
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
extern void clnt_clts_init(void);
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
extern void clnt_clts_fini(void);
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
extern void clnt_cots_init(void);
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
extern void clnt_cots_fini(void);
/*
* kRPC internal function. Not for general use. Subject to rapid change.
*/
extern void rpc_poptimod(struct vnode *);
extern boolean_t connmgr_cpr_reset(void *, int);
extern void put_loopback_port(struct netbuf *, char *);
/*
* Kstat stuff
*/
extern zone_key_t rpcstat_zone_key;
struct rpc_clts_client; /* unix:0:rpc_clts_client */
struct rpc_clts_server; /* unix:0:rpc_clts_server */
struct rpc_cots_client; /* unix:0:rpc_cots_client */
struct rpc_cots_server; /* unix:0:rpc_cots_server */
struct rpcstat {
struct rpc_clts_client *rpc_clts_client;
struct rpc_clts_server *rpc_clts_server;
struct rpc_cots_client *rpc_cots_client;
struct rpc_cots_server *rpc_cots_server;
};
const char *, const kstat_named_t *, size_t);
extern void rpcstat_zone_fini_common(zoneid_t, const char *, const char *);
#endif /* _KERNEL */
/*
* client side rpc interface ops
*/
/*
* enum clnt_stat
* CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
* CLIENT *rh;
* rpcproc_t proc;
* xdrproc_t xargs;
* caddr_t argsp;
* xdrproc_t xres;
* caddr_t resp;
* struct timeval timeout;
*
* PSARC 2003/523 Contract Private Interface
* CLNT_CALL
* Changes must be reviewed by Solaris File Sharing
* Changes must be communicated to contract-2003-523@sun.com
*/
#ifndef _KERNEL
/*
* enum clnt_stat
* CLNT_SEND(rh, proc, xargs, argsp)
* CLIENT *rh;
* rpcproc_t proc;
* xdrproc_t xargs;
* caddr_t argsp;
*
* PSARC 2000/428 Contract Private Interface
*/
#endif /* !_KERNEL */
/*
* void
* CLNT_ABORT(rh);
* CLIENT *rh;
*/
/*
* struct rpc_err
* CLNT_GETERR(rh);
* CLIENT *rh;
*/
/*
* bool_t
* CLNT_FREERES(rh, xres, resp);
* CLIENT *rh;
* xdrproc_t xres;
* caddr_t resp;
*/
/*
* bool_t
* CLNT_CONTROL(cl, request, info)
* CLIENT *cl;
* uint_t request;
* char *info;
*
* PSARC 2003/523 Contract Private Interface
* CLNT_CONTROL
* Changes must be reviewed by Solaris File Sharing
* Changes must be communicated to contract-2003-523@sun.com
*/
/*
* control operations that apply to all transports
*/
#ifndef _KERNEL
/* 00-08-17 - NON STANDARD CONTROL PARAMETER */
typedef enum {
/* without blocking */
RPC_CL_BLOCKING_FLUSH, /* flush the buffer completely */
/* (possibly blocking) */
RPC_CL_DEFAULT_FLUSH /* flush according to the currently */
/* defined policy. */
typedef enum {
} rpciomode_t;
#endif /* !_KERNEL */
/*
* Connectionless only control operations
*/
#ifdef _KERNEL
/*
* Connection oriented only control operation.
*/
/* has been sent but no reply */
/* received yet. */
/* connection setup error */
/* connection setup error */
#endif
/*
* void
* CLNT_SETTIMERS(rh);
* CLIENT *rh;
* struct rpc_timers *t;
* struct rpc_timers *all;
* unsigned int min;
* void (*fdbck)();
* caddr_t arg;
* uint_t xid;
*/
/*
* void
* CLNT_DESTROY(rh);
* CLIENT *rh;
*
* PSARC 2003/523 Contract Private Interface
* CLNT_DESTROY
* Changes must be reviewed by Solaris File Sharing
* Changes must be communicated to contract-2003-523@sun.com
*/
/*
* RPCTEST is a test program which is accessable on every rpc
* and network administration.
*/
/*
* By convention, procedure 0 takes null arguments and returns them
*/
/*
* Below are the client handle creation routines for the various
* implementations of client side rpc. They can return NULL if a
* creation failure occurs.
*/
#ifndef _KERNEL
/*
* Generic client creation routine. Supported protocols are which belong
* to the nettype name space
*/
#ifdef __STDC__
const char *);
/*
*
* const char *hostname; -- hostname
* const rpcprog_t prog; -- program number
* const rpcvers_t vers; -- version number
* const char *nettype; -- network type
*/
#else
extern CLIENT * clnt_create();
#endif
/*
* Generic client creation routine. Just like clnt_create(), except
* it takes an additional timeout parameter.
*/
#ifdef __STDC__
/*
*
* const char *hostname; -- hostname
* const rpcprog_t prog; -- program number
* const rpcvers_t vers; -- version number
* const char *nettype; -- network type
* const struct timeval *tp; -- timeout
*/
#else
extern CLIENT * clnt_create_timed();
#endif
/*
* Generic client creation routine. Supported protocols are which belong
* to the nettype name space.
*/
#ifdef __STDC__
/*
* const char *host; -- hostname
* const rpcprog_t prog; -- program number
* rpcvers_t *vers_out; -- servers highest available version number
* const rpcvers_t vers_low; -- low version number
* const rpcvers_t vers_high; -- high version number
* const char *nettype; -- network type
*/
#else
extern CLIENT * clnt_create_vers();
#endif
/*
* Generic client creation routine. Supported protocols are which belong
* to the nettype name space.
*/
#ifdef __STDC__
const struct timeval *);
/*
* const char *host; -- hostname
* const rpcprog_t prog; -- program number
* rpcvers_t *vers_out; -- servers highest available version number
* const rpcvers_t vers_low; -- low version number
* const prcvers_t vers_high; -- high version number
* const char *nettype; -- network type
* const struct timeval *tp -- timeout
*/
#else
extern CLIENT * clnt_create_vers_timed();
#endif
/*
* Generic client creation routine. It takes a netconfig structure
* instead of nettype
*/
#ifdef __STDC__
const struct netconfig *);
/*
* const char *hostname; -- hostname
* const rpcprog_t prog; -- program number
* const rpcvers_t vers; -- version number
* const struct netconfig *netconf; -- network config structure
*/
#else
extern CLIENT * clnt_tp_create();
#endif
/*
* Generic client creation routine. Just like clnt_tp_create(), except
* it takes an additional timeout parameter.
*/
#ifdef __STDC__
/*
* const char *hostname; -- hostname
* const rpcprog_t prog; -- program number
* const rpcvers_t vers; -- version number
* const struct netconfig *netconf; -- network config structure
* const struct timeval *tp; -- timeout
*/
#else
extern CLIENT * clnt_tp_create_timed();
#endif
/*
* Generic TLI create routine
*/
#ifdef __STDC__
const uint_t);
/*
* const int fd; -- fd
* const struct netconfig *nconf; -- netconfig structure
* struct netbuf *svcaddr; -- servers address
* const rpcprog_t prog; -- program number
* const rpcvers_t vers; -- version number
* const uint_t sendsz; -- send size
* const uint_t recvsz; -- recv size
*/
#else
extern CLIENT * clnt_tli_create();
#endif
/*
* Low level clnt create routine for connectionful transports, e.g. tcp.
*/
#ifdef __STDC__
/*
* const int fd; -- open file descriptor
* const struct netbuf *svcaddr; -- servers address
* const rpcprog_t prog; -- program number
* const rpcvers_t vers; -- version number
* const uint_t sendsz; -- buffer recv size
* const uint_t recvsz; -- buffer send size
*/
#else
extern CLIENT * clnt_vc_create();
#endif
/*
* Low level clnt create routine for connectionless transports, e.g. udp.
*/
#ifdef __STDC__
/*
* const int fd; -- open file descriptor
* const struct netbuf *svcaddr; -- servers address
* const rpcprog_t program; -- program number
* const rpcvers_t version; -- version number
* const uint_t sendsz; -- buffer recv size
* const uint_t recvsz; -- buffer send size
*/
#else
extern CLIENT * clnt_dg_create();
#endif
/*
* Memory based rpc (for speed check and testing)
* CLIENT *
* clnt_raw_create(prog, vers)
* const rpcprog_t prog; -- program number
* const rpcvers_t vers; -- version number
*/
#ifdef __STDC__
#else
extern CLIENT *clnt_raw_create();
#endif
/*
* Client creation routine over doors transport.
*/
#ifdef __STDC__
const uint_t);
/*
* const rpcprog_t prog; -- program number
* const rpcvers_t vers; -- version number
* const uint_t sendsz; -- max send size
*/
#else
extern CLIENT * clnt_door_create();
#endif
/*
* internal function. Not for general use. Subject to rapid change.
*/
#ifdef __STDC__
extern CLIENT *clnt_create_service_timed(const char *,
const char *,
const rpcprog_t,
const rpcvers_t,
const ushort_t,
const char *,
const struct timeval *);
#else
extern CLIENT *clnt_create_service_timed();
#endif
/*
* Print why creation failed
*/
#ifdef __STDC__
void clnt_pcreateerror(const char *); /* stderr */
char *clnt_spcreateerror(const char *); /* string */
#else
void clnt_pcreateerror();
char *clnt_spcreateerror();
#endif
/*
* Like clnt_perror(), but is more verbose in its output
*/
#ifdef __STDC__
#else
void clnt_perrno();
#endif
/*
* Print an error message, given the client error code
*/
#ifdef __STDC__
void clnt_perror(const CLIENT *, const char *);
#else
void clnt_perror();
#endif
/*
* If a creation fails, the following allows the user to figure out why.
*/
struct rpc_createerr {
};
#ifdef _REENTRANT
extern struct rpc_createerr *__rpc_createerr();
#define rpc_createerr (*(__rpc_createerr()))
#else
extern struct rpc_createerr rpc_createerr;
#endif /* _REENTRANT */
/*
* The simplified interface:
* enum clnt_stat
* rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype)
* const char *host;
* const rpcprog_t prognum;
* const rpcvers_t versnum;
* const rpcproc_t procnum;
* const xdrproc_t inproc, outproc;
* const char *in;
* char *out;
* const char *nettype;
*/
#ifdef __STDC__
char *, const char *);
#else
#endif
#ifdef _REENTRANT
extern struct rpc_err *__rpc_callerr();
#define rpc_callerr (*(__rpc_callerr()))
#else
extern struct rpc_err rpc_callerr;
#endif /* _REENTRANT */
/*
* RPC broadcast interface
* The call is broadcasted to all locally connected nets.
*
* extern enum clnt_stat
* rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp,
* eachresult, nettype)
* const rpcprog_t prog; -- program number
* const rpcvers_t vers; -- version number
* const rpcproc_t proc; -- procedure number
* const xdrproc_t xargs; -- xdr routine for args
* caddr_t argsp; -- pointer to args
* const xdrproc_t xresults; -- xdr routine for results
* caddr_t resultsp; -- pointer to results
* const resultproc_t eachresult; -- call with each result
* const char *nettype; -- Transport type
*
* For each valid response received, the procedure eachresult is called.
* Its form is:
* done = eachresult(resp, raddr, nconf)
* bool_t done;
* caddr_t resp;
* struct netbuf *raddr;
* struct netconfig *nconf;
* where resp points to the results of the call and raddr is the
* address if the responder to the broadcast. nconf is the transport
* on which the response was received.
*
* extern enum clnt_stat
* rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
* eachresult, inittime, waittime, nettype)
* const rpcprog_t prog; -- program number
* const rpcvers_t vers; -- version number
* const rpcproc_t proc; -- procedure number
* const xdrproc_t xargs; -- xdr routine for args
* caddr_t argsp; -- pointer to args
* const xdrproc_t xresults; -- xdr routine for results
* caddr_t resultsp; -- pointer to results
* const resultproc_t eachresult; -- call with each result
* const int inittime; -- how long to wait initially
* const int waittime; -- maximum time to wait
* const char *nettype; -- Transport type
*/
typedef bool_t(*resultproc_t)(
#ifdef __STDC__
... /* for backward compatibility */
#endif /* __STDC__ */
);
#ifdef __STDC__
caddr_t, const resultproc_t, const char *);
const resultproc_t, const int, const int, const char *);
#else
extern enum clnt_stat rpc_broadcast();
extern enum clnt_stat rpc_broadcast_exp();
#endif
#endif /* !_KERNEL */
/*
* Copy error message to buffer.
*/
#ifdef __STDC__
const char *clnt_sperrno(const enum clnt_stat);
#else
char *clnt_sperrno(); /* string */
#endif
/*
* Print an error message, given the client error code
*/
#ifdef __STDC__
char *clnt_sperror(const CLIENT *, const char *);
#else
char *clnt_sperror();
#endif
/*
* Client side rpc control routine for rpcbind.
*/
#ifdef __STDC__
bool_t __rpc_control(int, void *);
#else
#endif
#ifdef __cplusplus
}
#endif
#ifdef PORTMAP
/* For backward compatibility */
#include <rpc/clnt_soc.h>
#endif
#endif /* !_RPC_CLNT_H */