ReactOS 0.4.15-dev-8422-g6219a1a
clnt_raw.c File Reference
#include <wintirpc.h>
#include <reentrant.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <rpc/rpc.h>
#include <rpc/raw.h>
Include dependency graph for clnt_raw.c:

Go to the source code of this file.

Classes

struct  clntraw_private
 

Macros

#define MCALL_MSG_SIZE   24
 

Functions

static enum clnt_stat clnt_raw_call (CLIENT *, rpcproc_t, xdrproc_t, void *, xdrproc_t, void *, struct timeval)
 
static void clnt_raw_geterr (CLIENT *, struct rpc_err *)
 
static bool_t clnt_raw_freeres (CLIENT *, xdrproc_t, void *)
 
static void clnt_raw_abort (CLIENT *)
 
static bool_t clnt_raw_control (CLIENT *, u_int, void *)
 
static void clnt_raw_destroy (CLIENT *)
 
static struct clnt_ops * clnt_raw_ops (void)
 
CLIENTclnt_raw_create (rpcprog_t prog, rpcvers_t vers)
 

Variables

mutex_t clntraw_lock
 
static struct clntraw_privateclntraw_private
 

Macro Definition Documentation

◆ MCALL_MSG_SIZE

#define MCALL_MSG_SIZE   24

Definition at line 52 of file clnt_raw.c.

Function Documentation

◆ clnt_raw_abort()

static void clnt_raw_abort ( CLIENT cl)
static

Definition at line 265 of file clnt_raw.c.

267{
268}

Referenced by clnt_raw_ops().

◆ clnt_raw_call()

static enum clnt_stat clnt_raw_call ( CLIENT h,
rpcproc_t  proc,
xdrproc_t  xargs,
void argsp,
xdrproc_t  xresults,
void resultsp,
struct timeval  timeout 
)
static

Definition at line 136 of file clnt_raw.c.

144{
145 struct clntraw_private *clp = clntraw_private;
146 XDR *xdrs = &clp->xdr_stream;
147 struct rpc_msg msg;
148 enum clnt_stat status;
149 struct rpc_err error;
150
151 assert(h != NULL);
152
154 if (clp == NULL) {
156 return (RPC_FAILED);
157 }
159
160call_again:
161 /*
162 * send request
163 */
164 xdrs->x_op = XDR_ENCODE;
165 XDR_SETPOS(xdrs, 0);
166 clp->u.mashl_rpcmsg.rm_xid ++ ;
167 if ((! XDR_PUTBYTES(xdrs, clp->u.mashl_callmsg, clp->mcnt)) ||
168 (! XDR_PUTINT32(xdrs, (int32_t *)&proc)) ||
169 (! AUTH_MARSHALL(h->cl_auth, xdrs, NULL)) ||
170 (! (*xargs)(xdrs, argsp))) {
171 return (RPC_CANTENCODEARGS);
172 }
173 (void)XDR_GETPOS(xdrs); /* called just to cause overhead */
174
175 /*
176 * We have to call server input routine here because this is
177 * all going on in one process. Yuk.
178 */
180
181 /*
182 * get results
183 */
184 xdrs->x_op = XDR_DECODE;
185 XDR_SETPOS(xdrs, 0);
186 msg.acpted_rply.ar_verf = _null_auth;
187 msg.acpted_rply.ar_results.where = resultsp;
188 msg.acpted_rply.ar_results.proc = xresults;
189 if (! xdr_replymsg(xdrs, &msg)) {
190 /*
191 * It's possible for xdr_replymsg() to fail partway
192 * through its attempt to decode the result from the
193 * server. If this happens, it will leave the reply
194 * structure partially populated with dynamically
195 * allocated memory. (This can happen if someone uses
196 * clntudp_bufcreate() to create a CLIENT handle and
197 * specifies a receive buffer size that is too small.)
198 * This memory must be free()ed to avoid a leak.
199 */
200 int op = xdrs->x_op;
201 xdrs->x_op = XDR_FREE;
202 xdr_replymsg(xdrs, &msg);
203 xdrs->x_op = op;
204 return (RPC_CANTDECODERES);
205 }
207 status = error.re_status;
208
209 if (status == RPC_SUCCESS) {
210 if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf, 0)) {
212 }
213 } /* end successful completion */
214 else {
215 if (AUTH_REFRESH(h->cl_auth, &msg))
216 goto call_again;
217 } /* end of unsuccessful completion */
218
219 if (status == RPC_SUCCESS) {
220 if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf, 0)) {
222 }
223 if (msg.acpted_rply.ar_verf.oa_base != NULL) {
224 xdrs->x_op = XDR_FREE;
225 (void)xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf));
226 }
227 }
228
229 return (status);
230}
bool_t xdr_opaque_auth()
#define msg(x)
Definition: auth_time.c:54
mutex_t clntraw_lock
Definition: mt_misc.c:53
clnt_stat
Definition: clnt_stat.h:21
@ RPC_SUCCESS
Definition: clnt_stat.h:22
@ RPC_CANTDECODERES
Definition: clnt_stat.h:27
@ RPC_AUTHERROR
Definition: clnt_stat.h:38
@ RPC_FAILED
Definition: clnt_stat.h:68
@ RPC_CANTENCODEARGS
Definition: clnt_stat.h:26
#define AUTH_MARSHALL(auth, xdrs, seq)
Definition: auth.h:242
#define AUTH_VALIDATE(auth, verfp, seq)
Definition: auth.h:247
#define AUTH_REFRESH(auth, msg)
Definition: auth.h:252
#define NULL
Definition: types.h:112
INT32 int32_t
Definition: types.h:71
UINT op
Definition: effect.c:236
#define assert(x)
Definition: debug.h:53
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define error(str)
Definition: mkdosfs.c:1605
static HANDLE proc()
Definition: pdb.c:34
#define mutex_lock(m)
Definition: reentrant.h:128
#define mutex_unlock(m)
Definition: reentrant.h:129
struct opaque_auth _null_auth
bool_t xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg)
Definition: rpc_prot.c:188
void _seterr_reply(struct rpc_msg *msg, struct rpc_err *error)
Definition: rpc_prot.c:348
Definition: xdr.h:103
enum xdr_op x_op
Definition: xdr.h:104
char mashl_callmsg[MCALL_MSG_SIZE]
Definition: clnt_raw.c:63
struct rpc_msg mashl_rpcmsg
Definition: clnt_raw.c:62
union clntraw_private::@183 u
Definition: clnt.h:95
Definition: ps.c:97
void svc_getreq_common(SOCKET fd)
Definition: svc.c:641
#define FD_SETSIZE
Definition: winsock.h:50
#define XDR_PUTINT32(xdrs, int32p)
Definition: xdr.h:187
@ XDR_DECODE
Definition: xdr.h:86
@ XDR_FREE
Definition: xdr.h:87
@ XDR_ENCODE
Definition: xdr.h:85
#define XDR_PUTBYTES(xdrs, addr, len)
Definition: xdr.h:194
#define XDR_SETPOS(xdrs, pos)
Definition: xdr.h:204
#define XDR_GETPOS(xdrs)
Definition: xdr.h:199

Referenced by clnt_raw_ops().

◆ clnt_raw_control()

static bool_t clnt_raw_control ( CLIENT cl,
u_int  ui,
void str 
)
static

Definition at line 272 of file clnt_raw.c.

276{
277 return (FALSE);
278}
#define FALSE
Definition: types.h:117

Referenced by clnt_raw_ops().

◆ clnt_raw_create()

CLIENT * clnt_raw_create ( rpcprog_t  prog,
rpcvers_t  vers 
)

Definition at line 81 of file clnt_raw.c.

84{
85 struct clntraw_private *clp;
86 struct rpc_msg call_msg;
87 XDR *xdrs;
89
91 clp = clntraw_private;
92 if (clp == NULL) {
93 clp = (struct clntraw_private *)calloc(1, sizeof (*clp));
94 if (clp == NULL) {
96 return NULL;
97 }
98 if (__rpc_rawcombuf == NULL)
100 (char *)calloc(UDPMSGSIZE, sizeof (char));
102 clntraw_private = clp;
103 }
104 xdrs = &clp->xdr_stream;
105 client = &clp->client_object;
106 /*
107 * pre-serialize the static part of the call msg and stash it away
108 */
109 call_msg.rm_direction = CALL;
110 call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
111 /* XXX: prog and vers have been long historically :-( */
112 call_msg.rm_call.cb_prog = (u_int32_t)prog;
113 call_msg.rm_call.cb_vers = (u_int32_t)vers;
115 if (! xdr_callhdr(xdrs, &call_msg))
116 //warnx("clntraw_create - Fatal header serialization error.");
117 clp->mcnt = XDR_GETPOS(xdrs);
118 XDR_DESTROY(xdrs);
119
120 /*
121 * Set xdrmem for client/server shared buffer
122 */
124
125 /*
126 * create client handle
127 */
128 client->cl_ops = clnt_raw_ops();
129 client->cl_auth = authnone_create();
131 return (client);
132}
AUTH * authnone_create()
Definition: auth_none.c:100
static struct clnt_ops * clnt_raw_ops(void)
Definition: clnt_raw.c:288
#define MCALL_MSG_SIZE
Definition: clnt_raw.c:52
char * prog
Definition: isohybrid.c:47
unsigned int u_int32_t
Definition: rosdhcp.h:35
#define calloc
Definition: rosglue.h:14
#define RPC_MSG_VERSION
Definition: rpc_msg.h:66
@ CALL
Definition: rpc_msg.h:78
bool_t xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg)
Definition: rpc_prot.c:257
static FILE * client
Definition: client.c:41
CLIENT client_object
Definition: clnt_raw.c:58
char * _raw_buf
Definition: clnt_raw.c:60
char * __rpc_rawcombuf
Definition: svc_raw.c:73
#define UDPMSGSIZE
Definition: svc_raw.c:49
#define XDR_DESTROY(xdrs)
Definition: xdr.h:214
void xdrmem_create(XDR *xdrs, char *addr, u_int size, enum xdr_op op)
Definition: xdr_mem.c:94

◆ clnt_raw_destroy()

static void clnt_raw_destroy ( CLIENT cl)
static

Definition at line 282 of file clnt_raw.c.

284{
285}

Referenced by clnt_raw_ops().

◆ clnt_raw_freeres()

static bool_t clnt_raw_freeres ( CLIENT cl,
xdrproc_t  xdr_res,
void res_ptr 
)
static

Definition at line 243 of file clnt_raw.c.

247{
248 struct clntraw_private *clp = clntraw_private;
249 XDR *xdrs = &clp->xdr_stream;
250 bool_t rval;
251
253 if (clp == NULL) {
256 return (rval);
257 }
259 xdrs->x_op = XDR_FREE;
260 return ((*xdr_res)(xdrs, res_ptr));
261}
float rval
Definition: cylfrac.c:48
int32_t bool_t
Definition: types.h:101

Referenced by clnt_raw_ops().

◆ clnt_raw_geterr()

static void clnt_raw_geterr ( CLIENT cl,
struct rpc_err err 
)
static

Definition at line 234 of file clnt_raw.c.

237{
238}

Referenced by clnt_raw_ops().

◆ clnt_raw_ops()

static struct clnt_ops * clnt_raw_ops ( void  )
static

Definition at line 288 of file clnt_raw.c.

289{
290 static struct clnt_ops ops;
291 extern mutex_t ops_lock;
292
293 /* VARIABLES PROTECTED BY ops_lock: ops */
294
296 if (ops.cl_call == NULL) {
297 ops.cl_call = clnt_raw_call;
298 ops.cl_abort = clnt_raw_abort;
299 ops.cl_geterr = clnt_raw_geterr;
300 ops.cl_freeres = clnt_raw_freeres;
301 ops.cl_destroy = clnt_raw_destroy;
302 ops.cl_control = clnt_raw_control;
303 }
305 return (&ops);
306}
static bool_t clnt_raw_freeres(CLIENT *, xdrproc_t, void *)
Definition: clnt_raw.c:243
static void clnt_raw_abort(CLIENT *)
Definition: clnt_raw.c:265
static enum clnt_stat clnt_raw_call(CLIENT *, rpcproc_t, xdrproc_t, void *, xdrproc_t, void *, struct timeval)
Definition: clnt_raw.c:136
static bool_t clnt_raw_control(CLIENT *, u_int, void *)
Definition: clnt_raw.c:272
static void clnt_raw_geterr(CLIENT *, struct rpc_err *)
Definition: clnt_raw.c:234
static void clnt_raw_destroy(CLIENT *)
Definition: clnt_raw.c:282
mutex_t ops_lock
Definition: mt_misc.c:71
Definition: module.h:456

Referenced by clnt_raw_create().

Variable Documentation

◆ clntraw_lock

mutex_t clntraw_lock
extern

Definition at line 53 of file mt_misc.c.

Referenced by clnt_raw_create(), and clnt_raw_freeres().

◆ clntraw_private