1/*
2 *  Unix SMB/CIFS implementation.
3 *
4 *  RPC Pipe client / server routines
5 *
6 *  Copyright (C) Tim Potter 2003
7 *
8 *  This program is free software; you can redistribute it and/or modify
9 *  it under the terms of the GNU General Public License as published by
10 *  the Free Software Foundation; either version 2 of the License, or
11 *  (at your option) any later version.
12 *
13 *  This program is distributed in the hope that it will be useful,
14 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *  GNU General Public License for more details.
17 *
18 *  You should have received a copy of the GNU General Public License
19 *  along with this program; if not, write to the Free Software
20 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "includes.h"
24#include "nterr.h"
25#include "rpc_parse.h"
26
27#undef DBGC_CLASS
28#define DBGC_CLASS DBGC_RPC_PARSE
29
30void init_echo_q_add_one(ECHO_Q_ADD_ONE *q_d, uint32 request)
31{
32	q_d->request = request;
33}
34
35BOOL echo_io_q_add_one(const char *desc, ECHO_Q_ADD_ONE *q_d,
36		       prs_struct *ps, int depth)
37{
38	if (!prs_uint32("request", ps, 0, &q_d->request))
39		return False;
40
41	return True;
42}
43
44BOOL echo_io_r_add_one(const char *desc, ECHO_R_ADD_ONE *q_d,
45		       prs_struct *ps, int depth)
46{
47	if (!prs_uint32("response", ps, 0, &q_d->response))
48		return False;
49
50	return True;
51}
52
53
54void init_echo_q_echo_data(ECHO_Q_ECHO_DATA *q_d, uint32 size, char *data)
55{
56	q_d->size = size;
57	q_d->data = data;
58}
59
60BOOL echo_io_q_echo_data(const char *desc, ECHO_Q_ECHO_DATA *q_d,
61			  prs_struct *ps, int depth)
62{
63	if (!prs_uint32("size", ps, depth, &q_d->size))
64		return False;
65
66	if (!prs_uint32("size", ps, depth, &q_d->size))
67		return False;
68
69	if (UNMARSHALLING(ps)) {
70		q_d->data = PRS_ALLOC_MEM(ps, char, q_d->size);
71
72		if (!q_d->data)
73			return False;
74	}
75
76	if (!prs_uint8s(False, "data", ps, depth, (unsigned char *)q_d->data, q_d->size))
77		return False;
78
79	return True;
80}
81
82BOOL echo_io_r_echo_data(const char *desc, ECHO_R_ECHO_DATA *q_d,
83			  prs_struct *ps, int depth)
84{
85	if (!prs_uint32("size", ps, 0, &q_d->size))
86		return False;
87
88	if (UNMARSHALLING(ps)) {
89		q_d->data = PRS_ALLOC_MEM(ps, char, q_d->size);
90
91		if (!q_d->data)
92			return False;
93	}
94
95	if (!prs_uint8s(False, "data", ps, depth, (unsigned char *)q_d->data, q_d->size))
96		return False;
97
98	return True;
99}
100
101void init_echo_q_sink_data(ECHO_Q_SINK_DATA *q_d, uint32 size, char *data)
102{
103	q_d->size = size;
104	q_d->data = data;
105}
106
107BOOL echo_io_q_sink_data(const char *desc, ECHO_Q_SINK_DATA *q_d,
108			 prs_struct *ps, int depth)
109{
110	if (!prs_uint32("size", ps, depth, &q_d->size))
111		return False;
112
113	if (!prs_uint32("size", ps, depth, &q_d->size))
114		return False;
115
116	if (UNMARSHALLING(ps)) {
117		q_d->data = PRS_ALLOC_MEM(ps, char, q_d->size);
118
119		if (!q_d->data)
120			return False;
121	}
122
123	if (!prs_uint8s(False, "data", ps, depth, (unsigned char *)q_d->data, q_d->size))
124		return False;
125
126	return True;
127}
128
129BOOL echo_io_r_sink_data(const char *desc, ECHO_R_SINK_DATA *q_d,
130			 prs_struct *ps, int depth)
131{
132	return True;
133}
134
135void init_echo_q_source_data(ECHO_Q_SOURCE_DATA *q_d, uint32 size)
136{
137	q_d->size = size;
138}
139
140BOOL echo_io_q_source_data(const char *desc, ECHO_Q_SOURCE_DATA *q_d,
141			 prs_struct *ps, int depth)
142{
143	if (!prs_uint32("size", ps, depth, &q_d->size))
144		return False;
145
146	return True;
147}
148
149BOOL echo_io_r_source_data(const char *desc, ECHO_R_SOURCE_DATA *q_d,
150			   prs_struct *ps, int depth)
151{
152	if (!prs_uint32("size", ps, 0, &q_d->size))
153		return False;
154
155	if (UNMARSHALLING(ps)) {
156		q_d->data = PRS_ALLOC_MEM(ps, char, q_d->size);
157
158		if (!q_d->data)
159			return False;
160	}
161
162	if (!prs_uint8s(False, "data", ps, depth, (unsigned char *)q_d->data, q_d->size))
163		return False;
164
165	return True;
166}
167