Path: blob/main/crypto/krb5/src/include/gssrpc/clnt.h
34907 views
/* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/1/*2* Copyright (c) 2010, Oracle America, Inc.3*4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions are met:8*9* * Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11*12* * Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in14* the documentation and/or other materials provided with the15* distribution.16*17* * Neither the name of the "Oracle America, Inc." nor the names of18* its contributors may be used to endorse or promote products19* derived from this software without specific prior written permission.20*21* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS22* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED23* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A24* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT25* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,26* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED27* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR28* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF29* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING30* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS31* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.32*/3334/*35* clnt.h - Client side remote procedure call interface.36*/3738#ifndef GSSRPC_CLNT_H39#define GSSRPC_CLNT_H4041GSSRPC__BEGIN_DECLS42/*43* Rpc calls return an enum clnt_stat. This should be looked at more,44* since each implementation is required to live with this (implementation45* independent) list of errors.46*/47enum clnt_stat {48RPC_SUCCESS=0, /* call succeeded */49/*50* local errors51*/52RPC_CANTENCODEARGS=1, /* can't encode arguments */53RPC_CANTDECODERES=2, /* can't decode results */54RPC_CANTSEND=3, /* failure in sending call */55RPC_CANTRECV=4, /* failure in receiving result */56RPC_TIMEDOUT=5, /* call timed out */57/*58* remote errors59*/60RPC_VERSMISMATCH=6, /* rpc versions not compatible */61RPC_AUTHERROR=7, /* authentication error */62RPC_PROGUNAVAIL=8, /* program not available */63RPC_PROGVERSMISMATCH=9, /* program version mismatched */64RPC_PROCUNAVAIL=10, /* procedure unavailable */65RPC_CANTDECODEARGS=11, /* decode arguments error */66RPC_SYSTEMERROR=12, /* generic "other problem" */6768/*69* callrpc & clnt_create errors70*/71RPC_UNKNOWNHOST=13, /* unknown host name */72RPC_UNKNOWNPROTO=17, /* unknown protocol */7374/*75* _ create errors76*/77RPC_PMAPFAILURE=14, /* the pmapper failed in its call */78RPC_PROGNOTREGISTERED=15, /* remote program is not registered */79/*80* unspecified error81*/82RPC_FAILED=1683};848586/*87* Error info.88*/89struct rpc_err {90enum clnt_stat re_status;91union {92int RE_errno; /* realated system error */93enum auth_stat RE_why; /* why the auth error occurred */94struct {95rpcvers_t low; /* lowest version supported */96rpcvers_t high; /* highest version supported */97} RE_vers;98struct { /* maybe meaningful if RPC_FAILED */99int32_t s1;100int32_t s2;101} RE_lb; /* life boot & debugging only */102} ru;103#define re_errno ru.RE_errno104#define re_why ru.RE_why105#define re_vers ru.RE_vers106#define re_lb ru.RE_lb107};108109110/*111* Client rpc handle.112* Created by individual implementations, see e.g. rpc_udp.c.113* Client is responsible for initializing auth, see e.g. auth_none.c.114*/115typedef struct CLIENT {116AUTH *cl_auth; /* authenticator */117struct clnt_ops {118/* call remote procedure */119enum clnt_stat (*cl_call)(struct CLIENT *,120rpcproc_t, xdrproc_t, void *,121xdrproc_t, void *,122struct timeval);123/* abort a call */124void (*cl_abort)(struct CLIENT *);125/* get specific error code */126void (*cl_geterr)(struct CLIENT *,127struct rpc_err *);128/* frees results */129bool_t (*cl_freeres)(struct CLIENT *,130xdrproc_t, void *);131/* destroy this structure */132void (*cl_destroy)(struct CLIENT *);133/* the ioctl() of rpc */134/* XXX CITI makes 2nd arg take u_int */135bool_t (*cl_control)(struct CLIENT *, int,136void *);137} *cl_ops;138void *cl_private; /* private stuff */139} CLIENT;140141142/*143* client side rpc interface ops144*145* Parameter types are:146*147*/148149/*150* enum clnt_stat151* CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)152* CLIENT *rh;153* rpcproc_t proc;154* xdrproc_t xargs;155* caddr_t argsp;156* xdrproc_t xres;157* caddr_t resp;158* struct timeval timeout;159*/160#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \161((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))162#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \163((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))164165/*166* void167* CLNT_ABORT(rh);168* CLIENT *rh;169*/170#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh))171#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh))172173/*174* struct rpc_err175* CLNT_GETERR(rh);176* CLIENT *rh;177*/178#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))179#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))180181182/*183* bool_t184* CLNT_FREERES(rh, xres, resp);185* CLIENT *rh;186* xdrproc_t xres;187* caddr_t resp;188*/189#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))190#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))191192/*193* bool_t194* CLNT_CONTROL(cl, request, info)195* CLIENT *cl;196* u_int request;197* char *info;198*/199#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))200#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))201202/*203* control operations that apply to both udp and tcp transports204*/205#define CLSET_TIMEOUT 1 /* set timeout (timeval) */206#define CLGET_TIMEOUT 2 /* get timeout (timeval) */207#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */208/*209* udp only control operations210*/211#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */212#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */213/*214* new control operations215*/216#define CLGET_LOCAL_ADDR 6 /* get local address (sockaddr, getsockname)*/217218/*219* void220* CLNT_DESTROY(rh);221* CLIENT *rh;222*/223#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh))224#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh))225226227/*228* RPCTEST is a test program which is accessible on every rpc229* transport/port. It is used for testing, performance evaluation,230* and network administration.231*/232233#define RPCTEST_PROGRAM ((rpcprog_t)1)234#define RPCTEST_VERSION ((rpcvers_t)1)235#define RPCTEST_NULL_PROC ((rpcproc_t)2)236#define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3)237238/*239* By convention, procedure 0 takes null arguments and returns them240*/241242#define NULLPROC ((rpcproc_t)0)243244/*245* Below are the client handle creation routines for the various246* implementations of client side rpc. They can return NULL if a247* creation failure occurs.248*/249250/*251* Memory based rpc (for speed check and testing)252* CLIENT *253* clntraw_create(prog, vers)254* rpcprog_t prog;255* rpcvers_t vers;256*/257extern CLIENT *clntraw_create(rpcprog_t, rpcvers_t);258259/*260* Generic client creation routine. Supported protocols are "udp" and "tcp"261*/262extern CLIENT *clnt_create(char *, rpcprog_t, rpcvers_t, char *);263264265/*266* TCP based rpc267* CLIENT *268* clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)269* struct sockaddr_in *raddr;270* rpcprog_t prog;271* rpcvers_t version;272* int *sockp;273* u_int sendsz;274* u_int recvsz;275*/276extern CLIENT *clnttcp_create(struct sockaddr_in *, rpcprog_t, rpcvers_t,277int *, u_int, u_int);278279/*280* UDP based rpc.281* CLIENT *282* clntudp_create(raddr, program, version, wait, sockp)283* struct sockaddr_in *raddr;284* rpcprog_t program;285* rpcvers_t version;286* struct timeval wait;287* int *sockp;288*289* Same as above, but you specify max packet sizes.290* CLIENT *291* clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)292* struct sockaddr_in *raddr;293* rpcprog_t program;294* rpcvers_t version;295* struct timeval wait;296* int *sockp;297* u_int sendsz;298* u_int recvsz;299*/300extern CLIENT *clntudp_create(struct sockaddr_in *, rpcprog_t,301rpcvers_t, struct timeval, int *);302extern CLIENT *clntudp_bufcreate(struct sockaddr_in *, rpcprog_t,303rpcvers_t, struct timeval, int *,304u_int, u_int);305306/*307* Print why creation failed308*/309void clnt_pcreateerror(char *); /* stderr */310char *clnt_spcreateerror(char *); /* string */311312/*313* Like clnt_perror(), but is more verbose in its output314*/315void clnt_perrno(enum clnt_stat); /* stderr */316317/*318* Print an English error message, given the client error code319*/320void clnt_perror(CLIENT *, char *); /* stderr */321char *clnt_sperror(CLIENT *, char *); /* string */322323/*324* If a creation fails, the following allows the user to figure out why.325*/326struct rpc_createerr {327enum clnt_stat cf_stat;328struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */329};330331extern struct rpc_createerr rpc_createerr;332333334335/*336* Copy error message to buffer.337*/338char *clnt_sperrno(enum clnt_stat num); /* string */339340#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */341#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */342343GSSRPC__END_DECLS344345#endif /* !defined(GSSRPC_CLNT_H) */346347348