Lines Matching defs:xdr
12 static void xdr_std_destroy(xdr_s_type *xdr)
17 static bool_t xdr_std_control(xdr_s_type *xdr, int request, void *info)
19 return r_control(xdr->fd, request, info);
22 static bool_t xdr_std_msg_done(xdr_s_type *xdr)
29 static bool_t xdr_std_msg_start(xdr_s_type *xdr,
58 if (rpc_msg_type == RPC_MSG_CALL) xdr->xid++;
65 xdr->out_next = (RPC_OFFSET+2)*sizeof(uint32);
68 ((uint32 *)xdr->out_msg)[RPC_OFFSET] = htonl(xdr->xid);
70 ((uint32 *)xdr->out_msg)[RPC_OFFSET+1] = htonl(rpc_msg_type);
75 static bool_t xdr_std_msg_abort(xdr_s_type *xdr)
83 extern bool_t xdr_recv_reply_header(xdr_s_type *xdr, rpc_reply_header *reply);
87 static bool_t xdr_std_msg_send(xdr_s_type *xdr)
90 if (r_write(xdr->fd, (void *)xdr->out_msg, xdr->out_next) !=
91 xdr->out_next)
97 static bool_t xdr_std_read(xdr_s_type *xdr)
99 xdr->in_len = r_read(xdr->fd, (void *)xdr->in_msg, RPCROUTER_MSGSIZE_MAX);
100 if (xdr->in_len < 0) return FALSE;
102 if (xdr->in_len < (RPC_OFFSET+2)*4) {
103 xdr->in_len = -1;
107 xdr->in_next = (RPC_OFFSET+2)*4;
112 static bool_t xdr_std_send_uint32(xdr_s_type *xdr, const uint32 *value)
114 if (xdr->out_next >= RPCROUTER_MSGSIZE_MAX - 3) return FALSE;
115 *(int32 *)(xdr->out_msg + xdr->out_next) = htonl(*value);
116 xdr->out_next += 4;
120 static bool_t xdr_std_send_int8(xdr_s_type *xdr, const int8 *value)
123 return xdr_std_send_uint32(xdr, &val);
126 static bool_t xdr_std_send_uint8(xdr_s_type *xdr, const uint8 *value)
129 return xdr_std_send_uint32(xdr, &val);
132 static bool_t xdr_std_send_int16(xdr_s_type *xdr, const int16 *value)
135 return xdr_std_send_uint32(xdr, &val);
138 static bool_t xdr_std_send_uint16(xdr_s_type *xdr, const uint16 *value)
141 return xdr_std_send_uint32(xdr, &val);
144 static bool_t xdr_std_send_int32(xdr_s_type *xdr, const int32 *value)
146 return xdr_std_send_uint32(xdr, (uint32_t *)value);
149 static bool_t xdr_std_send_bytes(xdr_s_type *xdr, const uint8 *buf,
152 if (xdr->out_next + len > RPCROUTER_MSGSIZE_MAX) return FALSE;
154 xdr->out_msg[xdr->out_next++] = *buf++;
155 while(xdr->out_next % 4)
156 xdr->out_msg[xdr->out_next++] = 0;
193 static bool_t xdr_std_recv_uint32(xdr_s_type *xdr, uint32 *value)
203 if (xdr->in_next + 4 > xdr->in_len) { return FALSE; }
204 if (value) *value = ntohl(*(uint32 *)(xdr->in_msg + xdr->in_next));
205 xdr->in_next += 4;
211 if (xdr_std_recv_uint32(xdr, &val)) { \
217 static bool_t xdr_std_recv_int8(xdr_s_type *xdr, int8 *value)
222 static bool_t xdr_std_recv_uint8(xdr_s_type *xdr, uint8 *value)
227 static bool_t xdr_std_recv_int16(xdr_s_type *xdr, int16 *value)
232 static bool_t xdr_std_recv_uint16(xdr_s_type *xdr, uint16 *value)
239 static bool_t xdr_std_recv_int32(xdr_s_type *xdr, int32 *value)
241 return xdr_std_recv_uint32(xdr, (uint32 * )value);
244 static bool_t xdr_std_recv_bytes(xdr_s_type *xdr, uint8 *buf, uint32 len)
246 if (xdr->in_next + (int)len > xdr->in_len) return FALSE;
247 if (buf) memcpy(buf, &xdr->in_msg[xdr->in_next], len);
248 xdr->in_next += len;
249 xdr->in_next = (xdr->in_next + 3) & ~3;
281 xdr_s_type *xdr = (xdr_s_type *)calloc(1, sizeof(xdr_s_type));
283 xdr->xops = &xdr_std_xops;
285 xdr->fd = r_open(router);
286 if (xdr->fd < 0) {
288 free(xdr);
291 xdr->is_client = is_client;
293 D("OPENED [%s] fd %d\n", router, xdr->fd);
294 return xdr;
299 xdr_s_type *xdr = (xdr_s_type *)calloc(1, sizeof(xdr_s_type));
301 xdr->xops = &xdr_std_xops;
303 xdr->fd = dup(other->fd);
304 if (xdr->fd < 0) {
306 free(xdr);
310 xdr->xid = xdr->xid;
311 xdr->x_prog = other->x_prog;
312 xdr->x_vers = other->x_vers;
313 xdr->is_client = other->is_client;
315 D("CLONED fd %d --> %d\n", other->fd, xdr->fd);
316 return xdr;
319 void xdr_destroy_common(xdr_s_type *xdr)
321 D("CLOSING fd %d\n", xdr->fd);
322 r_close(xdr->fd);
323 free(xdr);