/* * XDR unsigned integers */ bool_t xdr_u_int (XDR *xdrs, unsigned int *up) { xdr_uint32_t l; switch (xdrs->x_op) { case XDR_ENCODE: l = (xdr_uint32_t) (*up); return xdr_putuint32 (xdrs, &l); case XDR_DECODE: if (!xdr_getuint32 (xdrs, &l)) { return FALSE; } *up = (unsigned int) l; case XDR_FREE: return TRUE; } return FALSE; }
/* * XDR unsigned short integers */ bool_t xdr_u_short (XDR *xdrs, unsigned short *usp) { xdr_uint32_t l; switch (xdrs->x_op) { case XDR_ENCODE: l = (xdr_uint32_t) *usp; return xdr_putuint32 (xdrs, &l); case XDR_DECODE: if (!xdr_getuint32 (xdrs, &l)) { return FALSE; } *usp = (unsigned short) l; return TRUE; case XDR_FREE: return TRUE; } return FALSE; }
/* * decode a reply message * * param[IN] buf 3 more inline */ bool xdr_reply_decode(XDR *xdrs, struct rpc_msg *dmsg, int32_t *buf) { if (buf != NULL) { __warnx(TIRPC_DEBUG_FLAG_RPC_MSG, "%s:%u INLINE", __func__, __LINE__); dmsg->rm_reply.rp_stat = IXDR_GET_ENUM(buf, enum_t); } else { __warnx(TIRPC_DEBUG_FLAG_RPC_MSG, "%s:%u non-INLINE", __func__, __LINE__); if (!xdr_getenum(xdrs, (enum_t *)&(dmsg->rm_reply.rp_stat))) { __warnx(TIRPC_DEBUG_FLAG_ERROR, "%s:%u ERROR rm_reply.rp_stat", __func__, __LINE__); return (false); } } switch (dmsg->rm_reply.rp_stat) { case MSG_ACCEPTED: { struct accepted_reply *ar = (struct accepted_reply *) &(dmsg->rm_reply.ru); if (!inline_auth_decode(xdrs, &ar->ar_verf, buf)) { __warnx(TIRPC_DEBUG_FLAG_ERROR, "%s:%u ERROR (return)", __func__, __LINE__); return (false); } if (!xdr_getenum(xdrs, (enum_t *)&(ar->ar_stat))) { __warnx(TIRPC_DEBUG_FLAG_ERROR, "%s:%u ERROR ar_stat", __func__, __LINE__); return (false); } switch (ar->ar_stat) { case SUCCESS: __warnx(TIRPC_DEBUG_FLAG_RPC_MSG, "%s:%u SUCCESS", __func__, __LINE__); return ((*(ar->ar_results.proc))(xdrs, &(ar->ar_results.where))); case PROG_MISMATCH: __warnx(TIRPC_DEBUG_FLAG_RPC_MSG, "%s:%u MISMATCH", __func__, __LINE__); if (!xdr_getuint32(xdrs, &(ar->ar_vers.low))) { __warnx(TIRPC_DEBUG_FLAG_ERROR, "%s:%u ERROR ar_vers.low", __func__, __LINE__); return (false); } if (!xdr_getuint32(xdrs, &(ar->ar_vers.high))) { __warnx(TIRPC_DEBUG_FLAG_ERROR, "%s:%u ERROR ar_vers.high", __func__, __LINE__); return (false); } case GARBAGE_ARGS: case SYSTEM_ERR: case PROC_UNAVAIL: case PROG_UNAVAIL: /* true */ break; default: break; }; /* ar_stat */ return (true); } /* MSG_ACCEPTED */ case MSG_DENIED: { /* XXX branch not verified */ struct rejected_reply *rr = (struct rejected_reply *) &(dmsg->rm_reply.ru); __warnx(TIRPC_DEBUG_FLAG_RPC_MSG, "%s:%u MSG_DENIED not verified", __func__, __LINE__); if (buf != NULL) { rr->rj_stat = IXDR_GET_ENUM(buf, enum_t); } else if (!xdr_getenum(xdrs, (enum_t *)&(rr->rj_stat))) { __warnx(TIRPC_DEBUG_FLAG_ERROR, "%s:%u ERROR rj_stat", __func__, __LINE__); return (false); } switch (rr->rj_stat) { case RPC_MISMATCH: __warnx(TIRPC_DEBUG_FLAG_RPC_MSG, "%s:%u DENIED MISMATCH", __func__, __LINE__); if (buf != NULL) { rr->rj_vers.low = IXDR_GET_U_INT32(buf); } else if (!xdr_getuint32(xdrs, &(rr->rj_vers.low))) { __warnx(TIRPC_DEBUG_FLAG_ERROR, "%s:%u ERROR rj_vers.low", __func__, __LINE__); return (false); } if (!xdr_getuint32(xdrs, &(rr->rj_vers.high))) { __warnx(TIRPC_DEBUG_FLAG_ERROR, "%s:%u ERROR rj_vers.high", __func__, __LINE__); return (false); } break; case AUTH_ERROR: __warnx(TIRPC_DEBUG_FLAG_RPC_MSG, "%s:%u DENIED AUTH", __func__, __LINE__); if (buf != NULL) { rr->rj_why = IXDR_GET_ENUM(buf, enum_t); } else if (!xdr_getenum(xdrs, (enum_t *)&(rr->rj_why))) { __warnx(TIRPC_DEBUG_FLAG_ERROR, "%s:%u ERROR rj_why", __func__, __LINE__); return (false); } break; }; return (true); } /* MSG_DENIED */ default: __warnx(TIRPC_DEBUG_FLAG_ERROR, "%s:%u ERROR dmsg->rm_reply.rp_stat %u", __func__, __LINE__, dmsg->rm_reply.rp_stat); break; }; /* rm_reply.rp_stat */ return (false); }