ReactOS  0.4.14-dev-98-gb0d4763
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:
399  case RPC_CANTDECODEARGS:
400  case RPC_PROCUNAVAIL:
401  case RPC_PROGUNAVAIL:
402  case RPC_TIMEDOUT:
403  case RPC_CANTRECV:
404  case RPC_CANTSEND:
405  case RPC_CANTDECODERES:
406  case RPC_CANTENCODEARGS:
407  default:
408  break;
409  }
410 }
#define RPC_PMAPFAILURE
Definition: clnt_stat.h:57
#define int32_t
Definition: nsiface.idl:56
#define error(str)
Definition: mkdosfs.c:1605
#define assert(x)
Definition: debug.h:53
static void rejected(enum reject_stat, struct rpc_err *)
Definition: rpc_prot.c:321
smooth NULL
Definition: ftsmooth.c:416
#define msg(x)
Definition: auth_time.c:54
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 }
#define int32_t
Definition: nsiface.idl:56
#define error(str)
Definition: mkdosfs.c:1605
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416

Referenced by _seterr_reply(), and test_accept().

◆ 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 }
#define int32_t
Definition: nsiface.idl:56
#define error(str)
Definition: mkdosfs.c:1605
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416

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_opaque_auth(XDR *xdrs, struct opaque_auth *ap)
Definition: rpc_prot.c:82
#define TRUE
Definition: types.h:120
struct opaque_auth ar_verf
Definition: rpc_msg.h:111
#define assert(x)
Definition: debug.h:53
rpcvers_t high
Definition: rpc_msg.h:116
smooth NULL
Definition: ftsmooth.c:416
xdrproc_t proc
Definition: rpc_msg.h:120
bool_t xdr_enum(XDR *xdrs, enum_t *ep)
Definition: xdr.c:458
enum accept_stat ar_stat
Definition: rpc_msg.h:112
int32_t enum_t
Definition: types.h:102
caddr_t where
Definition: rpc_msg.h:119
rpcvers_t low
Definition: rpc_msg.h:115
bool_t xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
Definition: xdr.c:239

◆ 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 }
Definition: rpc_msg.h:78
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
bool_t xdr_enum(XDR *xdrs, enum_t *ep)
Definition: xdr.c:458
enum xdr_op x_op
Definition: xdr.h:104
int32_t enum_t
Definition: types.h:102
Definition: xdr.h:85
#define RPC_MSG_VERSION
Definition: rpc_msg.h:66
bool_t xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
Definition: xdr.c:239
enum msg_type rm_direction
Definition: rpc_msg.h:174
u_int32_t rm_xid
Definition: rpc_msg.h:173

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 }
#define assert(x)
Definition: debug.h:53
char * caddr_t
Definition: rosdhcp.h:36
smooth NULL
Definition: ftsmooth.c:416
bool_t xdr_opaque(XDR *xdrs, caddr_t cp, u_int cnt)
Definition: xdr.c:484

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 }
bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap)
Definition: rpc_prot.c:82
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
bool_t xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
Definition: xdr.c:239

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,
230  NULL_xdrproc_t));
231 }
bool_t xdr_union(XDR *xdrs, enum_t *dscmp, char *unp, const struct xdr_discrim *choices, xdrproc_t dfault)
Definition: xdr.c:629
#define assert(x)
Definition: debug.h:53
char * caddr_t
Definition: rosdhcp.h:36
smooth NULL
Definition: ftsmooth.c:416
union rpc_msg::@191 ru
#define NULL_xdrproc_t
Definition: xdr.h:246
int32_t enum_t
Definition: types.h:102
static const struct xdr_discrim reply_dscrm[3]
Definition: rpc_prot.c:179

◆ 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 }
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
bool_t xdr_enum(XDR *xdrs, enum_t *ep)
Definition: xdr.c:458
int32_t enum_t
Definition: types.h:102
bool_t xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
Definition: xdr.c:239
enum msg_type rm_direction
Definition: rpc_msg.h:174
u_int32_t rm_xid
Definition: rpc_msg.h:173

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 }
#define MAX_AUTH_BYTES
Definition: auth.h:77
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
bool_t xdr_enum(XDR *xdrs, enum_t *ep)
Definition: xdr.c:458
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
bool_t xdr_bytes(XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
Definition: xdr.c:536

Referenced by xdr_accepted_reply(), and xdr_getcallbody().

◆ 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 low
Definition: rpc_msg.h:135
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
bool_t xdr_enum(XDR *xdrs, enum_t *ep)
Definition: xdr.c:458
int32_t enum_t
Definition: types.h:102
rpcvers_t high
Definition: rpc_msg.h:136
enum reject_stat rj_stat
Definition: rpc_msg.h:132
bool_t xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
Definition: xdr.c:239

◆ 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,
201  NULL_xdrproc_t));
202  return (FALSE);
203 }
bool_t xdr_union(XDR *xdrs, enum_t *dscmp, char *unp, const struct xdr_discrim *choices, xdrproc_t dfault)
Definition: xdr.c:629
#define assert(x)
Definition: debug.h:53
char * caddr_t
Definition: rosdhcp.h:36
smooth NULL
Definition: ftsmooth.c:416
union rpc_msg::@191 ru
bool_t xdr_enum(XDR *xdrs, enum_t *ep)
Definition: xdr.c:458
#define NULL_xdrproc_t
Definition: xdr.h:246
int32_t enum_t
Definition: types.h:102
bool_t xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
Definition: xdr.c:239
Definition: rpc_msg.h:79
enum msg_type rm_direction
Definition: rpc_msg.h:174
u_int32_t rm_xid
Definition: rpc_msg.h:173
static const struct xdr_discrim reply_dscrm[3]
Definition: rpc_prot.c:179

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

Definition at line 37 of file rpc_commondata.c.

◆ reply_dscrm

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

Definition at line 179 of file rpc_prot.c.

Referenced by xdr_getreplyunion(), and xdr_replymsg().