ReactOS 0.4.15-dev-5875-g7c755d9
rpc_msg.h File Reference
#include <rpc/auth.h>
Include dependency graph for rpc_msg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  accepted_reply
 
struct  rejected_reply
 
struct  reply_body
 
struct  call_body
 
struct  rpc_msg
 

Macros

#define RPC_MSG_VERSION   ((u_int32_t) 2)
 
#define RPC_SERVICE_PORT   ((u_short) 2048)
 
#define ar_results   ru.AR_results
 
#define ar_vers   ru.AR_versions
 
#define rj_vers   ru.RJ_versions
 
#define rj_why   ru.RJ_why
 
#define rp_acpt   ru.RP_ar
 
#define rp_rjct   ru.RP_dr
 
#define rm_call   ru.RM_cmb
 
#define rm_reply   ru.RM_rmb
 
#define acpted_rply   ru.RM_rmb.ru.RP_ar
 
#define rjcted_rply   ru.RM_rmb.ru.RP_dr
 

Enumerations

enum  msg_type { CALL =0 , REPLY =1 }
 
enum  reply_stat { MSG_ACCEPTED =0 , MSG_DENIED =1 }
 
enum  accept_stat {
  SUCCESS =0 , PROG_UNAVAIL =1 , PROG_MISMATCH =2 , PROC_UNAVAIL =3 ,
  GARBAGE_ARGS =4 , SYSTEM_ERR =5
}
 
enum  reject_stat { RPC_MISMATCH =0 , AUTH_ERROR =1 }
 

Functions

__BEGIN_DECLS bool_t xdr_callmsg (XDR *, struct rpc_msg *)
 
bool_t xdr_callhdr (XDR *, struct rpc_msg *)
 
bool_t xdr_replymsg (XDR *, struct rpc_msg *)
 
bool_t xdr_getxiddir (XDR *, struct rpc_msg *)
 
bool_t xdr_getreplyunion (XDR *, struct rpc_msg *)
 
bool_t xdr_getcallbody (XDR *, struct rpc_msg *)
 
bool_t xdr_accepted_reply (XDR *, struct accepted_reply *)
 
bool_t xdr_rejected_reply (XDR *, struct rejected_reply *)
 
void _seterr_reply (struct rpc_msg *, struct rpc_err *)
 

Macro Definition Documentation

◆ acpted_rply

#define acpted_rply   ru.RM_rmb.ru.RP_ar

Definition at line 182 of file rpc_msg.h.

◆ ar_results

#define ar_results   ru.AR_results

Definition at line 124 of file rpc_msg.h.

◆ ar_vers

#define ar_vers   ru.AR_versions

Definition at line 125 of file rpc_msg.h.

◆ rj_vers

#define rj_vers   ru.RJ_versions

Definition at line 140 of file rpc_msg.h.

◆ rj_why

#define rj_why   ru.RJ_why

Definition at line 141 of file rpc_msg.h.

◆ rjcted_rply

#define rjcted_rply   ru.RM_rmb.ru.RP_dr

Definition at line 183 of file rpc_msg.h.

◆ rm_call

#define rm_call   ru.RM_cmb

Definition at line 179 of file rpc_msg.h.

◆ rm_reply

#define rm_reply   ru.RM_rmb

Definition at line 180 of file rpc_msg.h.

◆ rp_acpt

#define rp_acpt   ru.RP_ar

Definition at line 153 of file rpc_msg.h.

◆ rp_rjct

#define rp_rjct   ru.RP_dr

Definition at line 154 of file rpc_msg.h.

◆ RPC_MSG_VERSION

#define RPC_MSG_VERSION   ((u_int32_t) 2)

Definition at line 66 of file rpc_msg.h.

◆ RPC_SERVICE_PORT

#define RPC_SERVICE_PORT   ((u_short) 2048)

Definition at line 67 of file rpc_msg.h.

Enumeration Type Documentation

◆ accept_stat

Enumerator
SUCCESS 
PROG_UNAVAIL 
PROG_MISMATCH 
PROC_UNAVAIL 
GARBAGE_ARGS 
SYSTEM_ERR 

Definition at line 87 of file rpc_msg.h.

87 {
88 SUCCESS=0,
94};
@ PROG_MISMATCH
Definition: rpc_msg.h:90
@ GARBAGE_ARGS
Definition: rpc_msg.h:92
@ SUCCESS
Definition: rpc_msg.h:88
@ SYSTEM_ERR
Definition: rpc_msg.h:93
@ PROC_UNAVAIL
Definition: rpc_msg.h:91
@ PROG_UNAVAIL
Definition: rpc_msg.h:89

◆ msg_type

Enumerator
CALL 
REPLY 

Definition at line 77 of file rpc_msg.h.

77 {
78 CALL=0,
79 REPLY=1
80};
@ REPLY
Definition: rpc_msg.h:79
@ CALL
Definition: rpc_msg.h:78

◆ reject_stat

Enumerator
RPC_MISMATCH 
AUTH_ERROR 

Definition at line 96 of file rpc_msg.h.

96 {
99};
@ RPC_MISMATCH
Definition: rpc_msg.h:97
@ AUTH_ERROR
Definition: rpc_msg.h:98

◆ reply_stat

Enumerator
MSG_ACCEPTED 
MSG_DENIED 

Definition at line 82 of file rpc_msg.h.

82 {
85};
@ MSG_DENIED
Definition: rpc_msg.h:84
@ MSG_ACCEPTED
Definition: rpc_msg.h:83

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
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

◆ 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
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_callmsg()

__BEGIN_DECLS bool_t xdr_callmsg ( XDR xdrs,
struct rpc_msg cmsg 
)

Definition at line 50 of file rpc_callmsg.c.

53{
54 int32_t *buf;
55 struct opaque_auth *oa;
56
57 assert(xdrs != NULL);
58 assert(cmsg != NULL);
59
60 if (xdrs->x_op == XDR_ENCODE) {
61 if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) {
62 return (FALSE);
63 }
64 if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) {
65 return (FALSE);
66 }
68 + RNDUP(cmsg->rm_call.cb_cred.oa_length)
70 + RNDUP(cmsg->rm_call.cb_verf.oa_length));
71 if (buf != NULL) {
74 if (cmsg->rm_direction != CALL) {
75 return (FALSE);
76 }
77 IXDR_PUT_INT32(buf, cmsg->rm_call.cb_rpcvers);
78 if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
79 return (FALSE);
80 }
81 IXDR_PUT_INT32(buf, cmsg->rm_call.cb_prog);
82 IXDR_PUT_INT32(buf, cmsg->rm_call.cb_vers);
83 IXDR_PUT_INT32(buf, cmsg->rm_call.cb_proc);
84 oa = &cmsg->rm_call.cb_cred;
87 if (oa->oa_length) {
88 memmove(buf, oa->oa_base, oa->oa_length);
89 buf += RNDUP(oa->oa_length) / sizeof (int32_t);
90 }
91 oa = &cmsg->rm_call.cb_verf;
94 if (oa->oa_length) {
95 memmove(buf, oa->oa_base, oa->oa_length);
96 /* no real need....
97 buf += RNDUP(oa->oa_length) / sizeof (int32_t);
98 */
99 }
100 return (TRUE);
101 }
102 }
103 if (xdrs->x_op == XDR_DECODE) {
104 buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT);
105 if (buf != NULL) {
106 cmsg->rm_xid = IXDR_GET_U_INT32(buf);
107 cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type);
108 if (cmsg->rm_direction != CALL) {
109 return (FALSE);
110 }
111 cmsg->rm_call.cb_rpcvers = IXDR_GET_U_INT32(buf);
112 if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
113 return (FALSE);
114 }
115 cmsg->rm_call.cb_prog = IXDR_GET_U_INT32(buf);
116 cmsg->rm_call.cb_vers = IXDR_GET_U_INT32(buf);
117 cmsg->rm_call.cb_proc = IXDR_GET_U_INT32(buf);
118 oa = &cmsg->rm_call.cb_cred;
121 if (oa->oa_length) {
122 if (oa->oa_length > MAX_AUTH_BYTES) {
123 return (FALSE);
124 }
125 if (oa->oa_base == NULL) {
126 oa->oa_base = (caddr_t)
127 mem_alloc(oa->oa_length);
128 if (oa->oa_base == NULL)
129 return (FALSE);
130 }
131 buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
132 if (buf == NULL) {
133 if (xdr_opaque(xdrs, oa->oa_base,
134 oa->oa_length) == FALSE) {
135 return (FALSE);
136 }
137 } else {
138 memmove(oa->oa_base, buf,
139 oa->oa_length);
140 /* no real need....
141 buf += RNDUP(oa->oa_length) /
142 sizeof (int32_t);
143 */
144 }
145 }
146 oa = &cmsg->rm_call.cb_verf;
147 buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
148 if (buf == NULL) {
149 if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE ||
150 xdr_u_int(xdrs, &oa->oa_length) == FALSE) {
151 return (FALSE);
152 }
153 } else {
156 }
157 if (oa->oa_length) {
158 if (oa->oa_length > MAX_AUTH_BYTES) {
159 return (FALSE);
160 }
161 if (oa->oa_base == NULL) {
162 oa->oa_base = (caddr_t)
163 mem_alloc(oa->oa_length);
164 if (oa->oa_base == NULL)
165 return (FALSE);
166 }
167 buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
168 if (buf == NULL) {
169 if (xdr_opaque(xdrs, oa->oa_base,
170 oa->oa_length) == FALSE) {
171 return (FALSE);
172 }
173 } else {
174 memmove(oa->oa_base, buf,
175 oa->oa_length);
176 /* no real need...
177 buf += RNDUP(oa->oa_length) /
178 sizeof (int32_t);
179 */
180 }
181 }
182 return (TRUE);
183 }
184 }
185 if (
186 xdr_u_int32_t(xdrs, &(cmsg->rm_xid)) &&
187 xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
188 (cmsg->rm_direction == CALL) &&
189 xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
190 (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) &&
191 xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_prog)) &&
192 xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers)) &&
193 xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_proc)) &&
194 xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) )
195 return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));
196 return (FALSE);
197}
bool_t xdr_u_int(XDR *xdrs, u_int *up)
Definition: xdr.c:133
bool_t xdr_opaque(XDR *xdrs, caddr_t cp, u_int cnt)
Definition: xdr.c:484
#define caddr_t
Definition: ftp.c:24
#define MAX_AUTH_BYTES
Definition: auth.h:77
UINT32 u_int
Definition: types.h:82
#define mem_alloc(bsize)
Definition: types.h:123
INT32 int32_t
Definition: types.h:71
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
msg_type
Definition: rpc_msg.h:77
#define IXDR_PUT_INT32(buf, v)
Definition: rpcb_prot.h:15
#define IXDR_GET_U_INT32(buf)
Definition: rpcb_prot.h:18
u_int oa_length
Definition: auth.h:198
caddr_t oa_base
Definition: auth.h:197
enum_t oa_flavor
Definition: auth.h:196
#define IXDR_PUT_ENUM(buf, v)
Definition: xdr.h:282
#define XDR_INLINE(xdrs, len)
Definition: xdr.h:209
@ XDR_DECODE
Definition: xdr.h:86
#define IXDR_GET_ENUM(buf, t)
Definition: xdr.h:276
#define BYTES_PER_XDR_UNIT
Definition: xdr.h:93
#define RNDUP(x)
Definition: xdr.h:94

Referenced by rpc_broadcast_exp(), svc_dg_recv(), svc_raw_recv(), and svc_vc_recv().

◆ 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
char * caddr_t
Definition: rosdhcp.h:36
static const struct xdr_discrim reply_dscrm[3]
Definition: rpc_prot.c:179
union rpc_msg::@196 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_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().