ReactOS 0.4.15-dev-7788-g1ad9096
rpc_prot.c File Reference
#include <wintirpc.h>
#include <assert.h>
#include <rpc/rpc.h>
Include dependency graph for rpc_prot.c:

Go to the source code of this file.

Functions

static void accepted (enum accept_stat, struct rpc_err *)
 
static void rejected (enum reject_stat, struct rpc_err *)
 
bool_t xdr_opaque_auth (XDR *xdrs, struct opaque_auth *ap)
 
bool_t xdr_des_block (XDR *xdrs, des_block *blkp)
 
bool_t xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar)
 
bool_t xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr)
 
bool_t xdr_replymsg (XDR *xdrs, struct rpc_msg *rmsg)
 
bool_t xdr_getxiddir (XDR *xdrs, struct rpc_msg *rmsg)
 
bool_t xdr_getreplyunion (XDR *xdrs, struct rpc_msg *rmsg)
 
bool_t xdr_getcallbody (XDR *xdrs, struct rpc_msg *rmsg)
 
bool_t xdr_callhdr (XDR *xdrs, struct rpc_msg *cmsg)
 
void _seterr_reply (struct rpc_msg *msg, struct rpc_err *error)
 

Variables

struct opaque_auth _null_auth
 
static const struct xdr_discrim reply_dscrm [3]
 

Function Documentation

◆ _seterr_reply()

void _seterr_reply ( struct rpc_msg msg,
struct rpc_err error 
)

Definition at line 348 of file rpc_prot.c.

351{
352
353 assert(msg != NULL);
354 assert(error != NULL);
355
356 /* optimized for normal, SUCCESSful case */
357 switch (msg->rm_reply.rp_stat) {
358
359 case MSG_ACCEPTED:
360 if (msg->acpted_rply.ar_stat == SUCCESS) {
361 error->re_status = RPC_SUCCESS;
362 return;
363 }
364 accepted(msg->acpted_rply.ar_stat, error);
365 break;
366
367 case MSG_DENIED:
368 rejected(msg->rjcted_rply.rj_stat, error);
369 break;
370
371 default:
372 error->re_status = RPC_FAILED;
373 error->re_lb.s1 = (int32_t)(msg->rm_reply.rp_stat);
374 break;
375 }
376 switch (error->re_status) {
377
378 case RPC_VERSMISMATCH:
379 error->re_vers.low = msg->rjcted_rply.rj_vers.low;
380 error->re_vers.high = msg->rjcted_rply.rj_vers.high;
381 break;
382
383 case RPC_AUTHERROR:
384 error->re_why = msg->rjcted_rply.rj_why;
385 break;
386
388 error->re_vers.low = msg->acpted_rply.ar_vers.low;
389 error->re_vers.high = msg->acpted_rply.ar_vers.high;
390 break;
391
392 case RPC_FAILED:
393 case RPC_SUCCESS:
395 case RPC_PMAPFAILURE:
396 case RPC_UNKNOWNPROTO:
397 case RPC_UNKNOWNHOST:
398 case RPC_SYSTEMERROR:
400 case RPC_PROCUNAVAIL:
401 case RPC_PROGUNAVAIL:
402 case RPC_TIMEDOUT:
403 case RPC_CANTRECV:
404 case RPC_CANTSEND:
407 default:
408 break;
409 }
410}
#define msg(x)
Definition: auth_time.c:54
#define RPC_PMAPFAILURE
Definition: clnt_stat.h:57
@ RPC_SUCCESS
Definition: clnt_stat.h:22
@ RPC_CANTDECODERES
Definition: clnt_stat.h:27
@ RPC_TIMEDOUT
Definition: clnt_stat.h:31
@ RPC_PROGNOTREGISTERED
Definition: clnt_stat.h:58
@ RPC_AUTHERROR
Definition: clnt_stat.h:38
@ RPC_PROGUNAVAIL
Definition: clnt_stat.h:39
@ RPC_CANTSEND
Definition: clnt_stat.h:28
@ RPC_FAILED
Definition: clnt_stat.h:68
@ RPC_CANTDECODEARGS
Definition: clnt_stat.h:42
@ RPC_UNKNOWNHOST
Definition: clnt_stat.h:48
@ RPC_CANTRECV
Definition: clnt_stat.h:29
@ RPC_CANTENCODEARGS
Definition: clnt_stat.h:26
@ RPC_UNKNOWNPROTO
Definition: clnt_stat.h:49
@ RPC_PROGVERSMISMATCH
Definition: clnt_stat.h:40
@ RPC_SYSTEMERROR
Definition: clnt_stat.h:43
@ RPC_PROCUNAVAIL
Definition: clnt_stat.h:41
@ RPC_VERSMISMATCH
Definition: clnt_stat.h:37
#define NULL
Definition: types.h:112
#define assert(x)
Definition: debug.h:53
#define error(str)
Definition: mkdosfs.c:1605
#define int32_t
Definition: nsiface.idl:56
#define SUCCESS
Definition: regproc.h:26
@ MSG_DENIED
Definition: rpc_msg.h:84
@ MSG_ACCEPTED
Definition: rpc_msg.h:83
static void rejected(enum reject_stat, struct rpc_err *)
Definition: rpc_prot.c:321
static void accepted(enum accept_stat, struct rpc_err *)
Definition: rpc_prot.c:280

◆ accepted()

static void accepted ( enum accept_stat  acpt_stat,
struct rpc_err error 
)
static

Definition at line 280 of file rpc_prot.c.

283{
284
285 assert(error != NULL);
286
287 switch (acpt_stat) {
288
289 case PROG_UNAVAIL:
290 error->re_status = RPC_PROGUNAVAIL;
291 return;
292
293 case PROG_MISMATCH:
294 error->re_status = RPC_PROGVERSMISMATCH;
295 return;
296
297 case PROC_UNAVAIL:
298 error->re_status = RPC_PROCUNAVAIL;
299 return;
300
301 case GARBAGE_ARGS:
302 error->re_status = RPC_CANTDECODEARGS;
303 return;
304
305 case SYSTEM_ERR:
306 error->re_status = RPC_SYSTEMERROR;
307 return;
308
309 case SUCCESS:
310 error->re_status = RPC_SUCCESS;
311 return;
312 }
313 /* NOTREACHED */
314 /* something's wrong, but we don't know what ... */
315 error->re_status = RPC_FAILED;
316 error->re_lb.s1 = (int32_t)MSG_ACCEPTED;
317 error->re_lb.s2 = (int32_t)acpt_stat;
318}
@ PROG_MISMATCH
Definition: rpc_msg.h:90
@ GARBAGE_ARGS
Definition: rpc_msg.h:92
@ SYSTEM_ERR
Definition: rpc_msg.h:93
@ PROC_UNAVAIL
Definition: rpc_msg.h:91
@ PROG_UNAVAIL
Definition: rpc_msg.h:89

Referenced by _seterr_reply(), and request_set_option().

◆ rejected()

static void rejected ( enum reject_stat  rjct_stat,
struct rpc_err error 
)
static

Definition at line 321 of file rpc_prot.c.

324{
325
326 assert(error != NULL);
327
328 switch (rjct_stat) {
329 case RPC_MISMATCH:
330 error->re_status = RPC_VERSMISMATCH;
331 return;
332
333 case AUTH_ERROR:
334 error->re_status = RPC_AUTHERROR;
335 return;
336 }
337 /* something's wrong, but we don't know what ... */
338 /* NOTREACHED */
339 error->re_status = RPC_FAILED;
340 error->re_lb.s1 = (int32_t)MSG_DENIED;
341 error->re_lb.s2 = (int32_t)rjct_stat;
342}
@ RPC_MISMATCH
Definition: rpc_msg.h:97
@ AUTH_ERROR
Definition: rpc_msg.h:98

Referenced by _seterr_reply().

◆ xdr_accepted_reply()

bool_t xdr_accepted_reply ( XDR xdrs,
struct accepted_reply ar 
)

Definition at line 117 of file rpc_prot.c.

120{
121
122 assert(xdrs != NULL);
123 assert(ar != NULL);
124
125 /* personalized union, rather than calling xdr_union */
126 if (! xdr_opaque_auth(xdrs, &(ar->ar_verf)))
127 return (FALSE);
128 if (! xdr_enum(xdrs, (enum_t *)&(ar->ar_stat)))
129 return (FALSE);
130 switch (ar->ar_stat) {
131
132 case SUCCESS:
133 return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where));
134
135 case PROG_MISMATCH:
136 if (! xdr_u_int32_t(xdrs, &(ar->ar_vers.low)))
137 return (FALSE);
138 return (xdr_u_int32_t(xdrs, &(ar->ar_vers.high)));
139
140 case GARBAGE_ARGS:
141 case SYSTEM_ERR:
142 case PROC_UNAVAIL:
143 case PROG_UNAVAIL:
144 break;
145 }
146 return (TRUE); /* TRUE => open ended set of problems */
147}
bool_t xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
Definition: xdr.c:239
bool_t xdr_enum(XDR *xdrs, enum_t *ep)
Definition: xdr.c:458
bool_t xdr_opaque_auth()
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
int32_t enum_t
Definition: types.h:102
caddr_t where
Definition: rpc_msg.h:119
struct opaque_auth ar_verf
Definition: rpc_msg.h:111
xdrproc_t proc
Definition: rpc_msg.h:120
rpcvers_t low
Definition: rpc_msg.h:115
enum accept_stat ar_stat
Definition: rpc_msg.h:112
rpcvers_t high
Definition: rpc_msg.h:116

◆ xdr_callhdr()

bool_t xdr_callhdr ( XDR xdrs,
struct rpc_msg cmsg 
)

Definition at line 257 of file rpc_prot.c.

260{
261
262 assert(xdrs != NULL);
263 assert(cmsg != NULL);
264
265 cmsg->rm_direction = CALL;
266 cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION;
267 if (
268 (xdrs->x_op == XDR_ENCODE) &&
269 xdr_u_int32_t(xdrs, &(cmsg->rm_xid)) &&
270 xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
271 xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
272 xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_prog)) )
273 return (xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers)));
274 return (FALSE);
275}
#define RPC_MSG_VERSION
Definition: rpc_msg.h:66
@ CALL
Definition: rpc_msg.h:78
enum xdr_op x_op
Definition: xdr.h:104
enum msg_type rm_direction
Definition: rpc_msg.h:174
u_int32_t rm_xid
Definition: rpc_msg.h:173
@ XDR_ENCODE
Definition: xdr.h:85

Referenced by clnt_dg_create(), clnt_raw_create(), and clnt_vc_create().

◆ xdr_des_block()

bool_t xdr_des_block ( XDR xdrs,
des_block blkp 
)

Definition at line 100 of file rpc_prot.c.

103{
104
105 assert(xdrs != NULL);
106 assert(blkp != NULL);
107
108 return (xdr_opaque(xdrs, (caddr_t)(void *)blkp, sizeof(des_block)));
109}
bool_t xdr_opaque(XDR *xdrs, caddr_t cp, u_int cnt)
Definition: xdr.c:484
char * caddr_t
Definition: rosdhcp.h:36

Referenced by key_gendes(), xdr_cryptkeyarg(), xdr_cryptkeyarg2(), and xdr_cryptkeyres().

◆ xdr_getcallbody()

bool_t xdr_getcallbody ( XDR xdrs,
struct rpc_msg rmsg 
)

Definition at line 234 of file rpc_prot.c.

237{
238 assert(xdrs != NULL);
239 assert(rmsg != NULL);
240
241 if (
242 xdr_u_int32_t(xdrs, &(rmsg->rm_call.cb_rpcvers)) &&
243 xdr_u_int32_t(xdrs, &(rmsg->rm_call.cb_prog)) &&
244 xdr_u_int32_t(xdrs, &(rmsg->rm_call.cb_vers)) &&
245 xdr_u_int32_t(xdrs, &(rmsg->rm_call.cb_proc)) &&
246 xdr_opaque_auth(xdrs, &(rmsg->rm_call.cb_cred)) )
247 return (xdr_opaque_auth(xdrs, &(rmsg->rm_call.cb_verf)));
248 return FALSE;
249}

Referenced by clnt_cb_thread().

◆ xdr_getreplyunion()

bool_t xdr_getreplyunion ( XDR xdrs,
struct rpc_msg rmsg 
)

Definition at line 221 of file rpc_prot.c.

224{
225 assert(xdrs != NULL);
226 assert(rmsg != NULL);
227
228 return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat),
229 (caddr_t)(void *)&(rmsg->rm_reply.ru), reply_dscrm,
231}
bool_t xdr_union(XDR *xdrs, enum_t *dscmp, char *unp, const struct xdr_discrim *choices, xdrproc_t dfault)
Definition: xdr.c:629
static const struct xdr_discrim reply_dscrm[3]
Definition: rpc_prot.c:179
union rpc_msg::@206 ru
#define NULL_xdrproc_t
Definition: xdr.h:246

◆ xdr_getxiddir()

bool_t xdr_getxiddir ( XDR xdrs,
struct rpc_msg rmsg 
)

Definition at line 209 of file rpc_prot.c.

212{
213 assert(xdrs != NULL);
214 assert(rmsg != NULL);
215
216 return (xdr_u_int32_t(xdrs, &(rmsg->rm_xid)) &&
217 xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)));
218}

Referenced by clnt_cb_thread().

◆ xdr_opaque_auth()

bool_t xdr_opaque_auth ( XDR xdrs,
struct opaque_auth ap 
)

Definition at line 82 of file rpc_prot.c.

85{
86
87 assert(xdrs != NULL);
88 assert(ap != NULL);
89
90 if (xdr_enum(xdrs, &(ap->oa_flavor)))
91 return (xdr_bytes(xdrs, &ap->oa_base,
92 &ap->oa_length, MAX_AUTH_BYTES));
93 return (FALSE);
94}
bool_t xdr_bytes(XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
Definition: xdr.c:536
#define MAX_AUTH_BYTES
Definition: auth.h:77
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

◆ xdr_rejected_reply()

bool_t xdr_rejected_reply ( XDR xdrs,
struct rejected_reply rr 
)

Definition at line 153 of file rpc_prot.c.

156{
157
158 assert(xdrs != NULL);
159 assert(rr != NULL);
160
161 /* personalized union, rather than calling xdr_union */
162 if (! xdr_enum(xdrs, (enum_t *)&(rr->rj_stat)))
163 return (FALSE);
164 switch (rr->rj_stat) {
165
166 case RPC_MISMATCH:
167 if (! xdr_u_int32_t(xdrs, &(rr->rj_vers.low)))
168 return (FALSE);
169 return (xdr_u_int32_t(xdrs, &(rr->rj_vers.high)));
170
171 case AUTH_ERROR:
172 return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why)));
173 }
174 /* NOTREACHED */
175 assert(0);
176 return (FALSE);
177}
rpcvers_t high
Definition: rpc_msg.h:136
rpcvers_t low
Definition: rpc_msg.h:135
enum reject_stat rj_stat
Definition: rpc_msg.h:132

◆ xdr_replymsg()

bool_t xdr_replymsg ( XDR xdrs,
struct rpc_msg rmsg 
)

Definition at line 188 of file rpc_prot.c.

191{
192 assert(xdrs != NULL);
193 assert(rmsg != NULL);
194
195 if (
196 xdr_u_int32_t(xdrs, &(rmsg->rm_xid)) &&
197 xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)) &&
198 (rmsg->rm_direction == REPLY) )
199 return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat),
200 (caddr_t)(void *)&(rmsg->rm_reply.ru), reply_dscrm,
202 return (FALSE);
203}
#define REPLY
Definition: port.c:108

Referenced by clnt_cb_thread(), rpc_broadcast_exp(), svc_dg_reply(), svc_raw_reply(), and svc_vc_reply().

Variable Documentation

◆ _null_auth

struct opaque_auth _null_auth
extern

Definition at line 37 of file rpc_commondata.c.

◆ reply_dscrm

const struct xdr_discrim reply_dscrm[3]
static
Initial value:
= {
#define __dontcare__
Definition: types.h:114
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
bool_t xdr_rejected_reply(XDR *xdrs, struct rejected_reply *rr)
Definition: rpc_prot.c:153
bool_t xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar)
Definition: rpc_prot.c:117
bool_t(* xdrproc_t)(XDR *,...)
Definition: xdr.h:144

Definition at line 179 of file rpc_prot.c.

Referenced by xdr_getreplyunion(), and xdr_replymsg().