summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr/ndr_echo.c
blob: 7377f845c8930a7a4a8909c7b0a61043fa726c3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/* parser auto-generated by pidl */

#include "includes.h"

NTSTATUS ndr_push_echo_AddOne(struct ndr_push *ndr, struct echo_AddOne *r)
{
	NDR_CHECK(ndr_push_uint32(ndr, *r->in.v));

	return NT_STATUS_OK;
}

NTSTATUS ndr_push_echo_EchoData(struct ndr_push *ndr, struct echo_EchoData *r)
{
	NDR_CHECK(ndr_push_uint32(ndr, r->in.len));
	if (r->in.in_data) {
		NDR_CHECK(ndr_push_uint32(ndr, r->in.len));
		NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.in_data, r->in.len));
	}

	return NT_STATUS_OK;
}

NTSTATUS ndr_push_echo_SinkData(struct ndr_push *ndr, struct echo_SinkData *r)
{
	NDR_CHECK(ndr_push_uint32(ndr, r->in.len));
	if (r->in.data) {
		NDR_CHECK(ndr_push_uint32(ndr, r->in.len));
		NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.data, r->in.len));
	}

	return NT_STATUS_OK;
}

NTSTATUS ndr_push_echo_SourceData(struct ndr_push *ndr, struct echo_SourceData *r)
{
	NDR_CHECK(ndr_push_uint32(ndr, r->in.len));

	return NT_STATUS_OK;
}

NTSTATUS ndr_push_TestCall(struct ndr_push *ndr, struct TestCall *r)
{
	NDR_CHECK(ndr_push_uint16(ndr, r->in.level));

	return NT_STATUS_OK;
}

NTSTATUS ndr_pull_echo_AddOne(struct ndr_pull *ndr, struct echo_AddOne *r)
{
	NDR_CHECK(ndr_pull_uint32(ndr, r->out.v));

	return NT_STATUS_OK;
}

NTSTATUS ndr_pull_echo_EchoData(struct ndr_pull *ndr, struct echo_EchoData *r)
{
	if (r->out.out_data) {
	{
		uint32 _array_size;
		NDR_CHECK(ndr_pull_uint32(ndr, &_array_size));
		if (r->in.len > _array_size) {
			return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should be %u", _array_size, r->in.len);
		}
	}
		NDR_ALLOC_N_SIZE(ndr, r->out.out_data, r->in.len, sizeof(r->out.out_data[0]));
		NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.out_data, r->in.len));
	}

	return NT_STATUS_OK;
}

NTSTATUS ndr_pull_echo_SinkData(struct ndr_pull *ndr, struct echo_SinkData *r)
{

	return NT_STATUS_OK;
}

NTSTATUS ndr_pull_echo_SourceData(struct ndr_pull *ndr, struct echo_SourceData *r)
{
	if (r->out.data) {
	{
		uint32 _array_size;
		NDR_CHECK(ndr_pull_uint32(ndr, &_array_size));
		if (r->in.len > _array_size) {
			return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should be %u", _array_size, r->in.len);
		}
	}
		NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.data, r->in.len));
	}

	return NT_STATUS_OK;
}

NTSTATUS ndr_pull_echo_ServerRole(struct ndr_pull *ndr, int ndr_flags, struct echo_ServerRole *r)
{
	NDR_CHECK(ndr_pull_struct_start(ndr));
	if (!(ndr_flags & NDR_SCALARS)) goto buffers;
	NDR_CHECK(ndr_pull_align(ndr, 2));
	NDR_CHECK(ndr_pull_uint16(ndr, &r->role));
	ndr_pull_struct_end(ndr);
buffers:
	if (!(ndr_flags & NDR_BUFFERS)) goto done;
done:
	return NT_STATUS_OK;
}

NTSTATUS ndr_pull_echo_PolicyInformation(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union echo_PolicyInformation *r)
{
	if (!(ndr_flags & NDR_SCALARS)) goto buffers;
	NDR_CHECK(ndr_pull_struct_start(ndr));
	NDR_CHECK(ndr_pull_uint16(ndr, level));
	switch (*level) {
	case 6: {
	NDR_CHECK(ndr_pull_echo_ServerRole(ndr, NDR_SCALARS, &r->role));
	break; }

	default:
		return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level);
	}
	ndr_pull_struct_end(ndr);
buffers:
	if (!(ndr_flags & NDR_BUFFERS)) goto done;
	switch (*level) {
	case 6:
		NDR_CHECK(ndr_pull_echo_ServerRole(ndr, NDR_BUFFERS, &r->role));
	break;

	default:
		return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level);
	}
done:
	return NT_STATUS_OK;
}

NTSTATUS ndr_pull_TestCall(struct ndr_pull *ndr, struct TestCall *r)
{
	uint32 _ptr_info;
	NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_info));
	if (_ptr_info) {
		NDR_ALLOC(ndr, r->out.info);
	} else {
		r->out.info = NULL;
	}
	if (r->out.info) {
	{ uint16 _level = r->in.level;
	NDR_CHECK(ndr_pull_echo_PolicyInformation(ndr, NDR_SCALARS|NDR_BUFFERS, &_level, r->out.info));
	if (((NDR_SCALARS|NDR_BUFFERS) & NDR_SCALARS) && (_level != r->in.level)) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in info");
	}
	}

	return NT_STATUS_OK;
}

void ndr_print_echo_AddOne(struct ndr_print *ndr, const char *name, int flags, struct echo_AddOne *r)
{
	ndr_print_struct(ndr, name, "echo_AddOne");
	ndr->depth++;
	if (flags & NDR_IN) {
		ndr_print_struct(ndr, "in", "echo_AddOne");
	ndr->depth++;
	ndr_print_ptr(ndr, "v", r->in.v);
	ndr->depth++;
		ndr_print_uint32(ndr, "v", *r->in.v);
	ndr->depth--;
	ndr->depth--;
	}
	if (flags & NDR_OUT) {
		ndr_print_struct(ndr, "out", "echo_AddOne");
	ndr->depth++;
	ndr_print_ptr(ndr, "v", r->out.v);
	ndr->depth++;
		ndr_print_uint32(ndr, "v", *r->out.v);
	ndr->depth--;
	ndr->depth--;
	}
	ndr->depth--;
}

void ndr_print_echo_EchoData(struct ndr_print *ndr, const char *name, int flags, struct echo_EchoData *r)
{
	ndr_print_struct(ndr, name, "echo_EchoData");
	ndr->depth++;
	if (flags & NDR_IN) {
		ndr_print_struct(ndr, "in", "echo_EchoData");
	ndr->depth++;
	ndr_print_uint32(ndr, "len", r->in.len);
	ndr_print_ptr(ndr, "in_data", r->in.in_data);
	ndr->depth++;
		ndr_print_array_uint8(ndr, "in_data", r->in.in_data, r->in.len);
	ndr->depth--;
	ndr->depth--;
	}
	if (flags & NDR_OUT) {
		ndr_print_struct(ndr, "out", "echo_EchoData");
	ndr->depth++;
	ndr_print_ptr(ndr, "out_data", r->out.out_data);
	ndr->depth++;
		ndr_print_array_uint8(ndr, "out_data", r->out.out_data, r->in.len);
	ndr->depth--;
	ndr->depth--;
	}
	ndr->depth--;
}

void ndr_print_echo_SinkData(struct ndr_print *ndr, const char *name, int flags, struct echo_SinkData *r)
{
	ndr_print_struct(ndr, name, "echo_SinkData");
	ndr->depth++;
	if (flags & NDR_IN) {
		ndr_print_struct(ndr, "in", "echo_SinkData");
	ndr->depth++;
	ndr_print_uint32(ndr, "len", r->in.len);
	ndr_print_ptr(ndr, "data", r->in.data);
	ndr->depth++;
		ndr_print_array_uint8(ndr, "data", r->in.data, r->in.len);
	ndr->depth--;
	ndr->depth--;
	}
	if (flags & NDR_OUT) {
		ndr_print_struct(ndr, "out", "echo_SinkData");
	ndr->depth++;
	ndr->depth--;
	}
	ndr->depth--;
}

void ndr_print_echo_SourceData(struct ndr_print *ndr, const char *name, int flags, struct echo_SourceData *r)
{
	ndr_print_struct(ndr, name, "echo_SourceData");
	ndr->depth++;
	if (flags & NDR_IN) {
		ndr_print_struct(ndr, "in", "echo_SourceData");
	ndr->depth++;
	ndr_print_uint32(ndr, "len", r->in.len);
	ndr->depth--;
	}
	if (flags & NDR_OUT) {
		ndr_print_struct(ndr, "out", "echo_SourceData");
	ndr->depth++;
	ndr_print_ptr(ndr, "data", r->out.data);
	ndr->depth++;
		ndr_print_array_uint8(ndr, "data", r->out.data, r->in.len);
	ndr->depth--;
	ndr->depth--;
	}
	ndr->depth--;
}

void ndr_print_echo_ServerRole(struct ndr_print *ndr, const char *name, struct echo_ServerRole *r)
{
	ndr_print_struct(ndr, name, "echo_ServerRole");
	ndr->depth++;
	ndr_print_uint16(ndr, "role", r->role);
	ndr->depth--;
}

void ndr_print_echo_PolicyInformation(struct ndr_print *ndr, const char *name, uint16 level, union echo_PolicyInformation *r)
{
	ndr_print_union(ndr, name, level, "echo_PolicyInformation");
	switch (level) {
	case 6:
	ndr_print_echo_ServerRole(ndr, "role", &r->role);
	break;

	default:
		ndr_print_bad_level(ndr, name, level);
	}
}

void ndr_print_TestCall(struct ndr_print *ndr, const char *name, int flags, struct TestCall *r)
{
	ndr_print_struct(ndr, name, "TestCall");
	ndr->depth++;
	if (flags & NDR_IN) {
		ndr_print_struct(ndr, "in", "TestCall");
	ndr->depth++;
	ndr_print_uint16(ndr, "level", r->in.level);
	ndr->depth--;
	}
	if (flags & NDR_OUT) {
		ndr_print_struct(ndr, "out", "TestCall");
	ndr->depth++;
	ndr_print_ptr(ndr, "info", r->out.info);
	ndr->depth++;
	if (r->out.info) {
	ndr_print_echo_PolicyInformation(ndr, "info", r->in.level, r->out.info);
	}
	ndr->depth--;
	ndr->depth--;
	}
	ndr->depth--;
}