1 /* 2 * Copyright (c) 2013 Linux Test Project. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License as 6 * published by the Free Software Foundation; either version 2 of 7 * the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it would be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19 #include <rpc/xdr.h> 20 #include "librpc01.h" 21 22 bool_t xdr_receive_data(XDR *xdrs, struct data **buffer) 23 { 24 struct data *bp; 25 int i, rc; 26 char *p; 27 28 bp = *buffer = malloc(sizeof(struct data)); 29 rc = xdr_long(xdrs, &(bp->address)); 30 rc = rc && xdr_long(xdrs, &bp->request_id); 31 rc = rc && xdr_long(xdrs, &bp->data_length); 32 p = (*buffer)->data = malloc(bp->data_length); 33 for (i = 0; rc && i < bp->data_length; p++, i++) 34 rc = xdr_char(xdrs, p); 35 return rc; 36 } 37 38 bool_t xdr_send_data(XDR *xdrs, struct data *buffer) 39 { 40 int i, rc; 41 char *p; 42 43 rc = xdr_long(xdrs, &buffer->address); 44 rc = rc && xdr_long(xdrs, &buffer->request_id); 45 rc = rc && xdr_long(xdrs, &buffer->data_length); 46 for (i = 0, p = buffer->data; rc && i < buffer->data_length; i++, p++) 47 rc = xdr_char(xdrs, p); 48 return rc; 49 } 50