r18572: Use the autogenerated client and server for the echo interface and implement
[kai/samba.git] / source3 / librpc / gen_ndr / srv_echo.c
1 /*
2  * Unix SMB/CIFS implementation.
3  * server auto-generated by pidl. DO NOT MODIFY!
4  */
5
6 #include "includes.h"
7 #include "librpc/gen_ndr/srv_echo.h"
8
9 static BOOL api_echo_AddOne(pipes_struct *p)
10 {
11         struct ndr_pull *pull;
12         struct ndr_push *push;
13         NTSTATUS status;
14         DATA_BLOB blob;
15         struct echo_AddOne r;
16         TALLOC_CTX *mem_ctx = talloc_init("api_echo_AddOne");
17         
18         if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
19                 talloc_free(mem_ctx);
20                 return False;
21         }
22         
23         pull = ndr_pull_init_blob(&blob, mem_ctx);
24         if (pull == NULL)
25                 return False;
26         
27         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
28         status = ndr_pull_echo_AddOne(pull, NDR_IN, &r);
29         if (NT_STATUS_IS_ERR(status)) {
30                 talloc_free(mem_ctx);
31                 return False;
32         }
33         
34         r.out.out_data = talloc_size(mem_ctx, sizeof(*r.out.out_data));
35         if (r.out.out_data == NULL) {
36                 talloc_free(mem_ctx);
37                 return False;
38         }
39         
40         _echo_AddOne(p, r.in.in_data, r.out.out_data);
41         
42         push = ndr_push_init_ctx(mem_ctx);
43         if (push == NULL) {
44                 talloc_free(mem_ctx);
45                 return False;
46         }
47         
48         status = ndr_push_echo_AddOne(push, NDR_OUT, &r);
49         if (NT_STATUS_IS_ERR(status)) {
50                 talloc_free(mem_ctx);
51                 return False;
52         }
53         
54         blob = ndr_push_blob(push);
55         if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
56                 talloc_free(mem_ctx);
57                 return False;
58         }
59         
60         talloc_free(mem_ctx);
61         
62         return True;
63 }
64
65 static BOOL api_echo_EchoData(pipes_struct *p)
66 {
67         struct ndr_pull *pull;
68         struct ndr_push *push;
69         NTSTATUS status;
70         DATA_BLOB blob;
71         struct echo_EchoData r;
72         TALLOC_CTX *mem_ctx = talloc_init("api_echo_EchoData");
73         
74         if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
75                 talloc_free(mem_ctx);
76                 return False;
77         }
78         
79         pull = ndr_pull_init_blob(&blob, mem_ctx);
80         if (pull == NULL)
81                 return False;
82         
83         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
84         status = ndr_pull_echo_EchoData(pull, NDR_IN, &r);
85         if (NT_STATUS_IS_ERR(status)) {
86                 talloc_free(mem_ctx);
87                 return False;
88         }
89         
90         r.out.out_data = talloc_array_size(mem_ctx, sizeof(*r.out.out_data), r.in.len);
91         if (r.out.out_data == NULL) {
92                 talloc_free(mem_ctx);
93                 return False;
94         }
95         
96         _echo_EchoData(p, r.in.len, r.in.in_data, r.out.out_data);
97         
98         push = ndr_push_init_ctx(mem_ctx);
99         if (push == NULL) {
100                 talloc_free(mem_ctx);
101                 return False;
102         }
103         
104         status = ndr_push_echo_EchoData(push, NDR_OUT, &r);
105         if (NT_STATUS_IS_ERR(status)) {
106                 talloc_free(mem_ctx);
107                 return False;
108         }
109         
110         blob = ndr_push_blob(push);
111         if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
112                 talloc_free(mem_ctx);
113                 return False;
114         }
115         
116         talloc_free(mem_ctx);
117         
118         return True;
119 }
120
121 static BOOL api_echo_SinkData(pipes_struct *p)
122 {
123         struct ndr_pull *pull;
124         struct ndr_push *push;
125         NTSTATUS status;
126         DATA_BLOB blob;
127         struct echo_SinkData r;
128         TALLOC_CTX *mem_ctx = talloc_init("api_echo_SinkData");
129         
130         if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
131                 talloc_free(mem_ctx);
132                 return False;
133         }
134         
135         pull = ndr_pull_init_blob(&blob, mem_ctx);
136         if (pull == NULL)
137                 return False;
138         
139         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
140         status = ndr_pull_echo_SinkData(pull, NDR_IN, &r);
141         if (NT_STATUS_IS_ERR(status)) {
142                 talloc_free(mem_ctx);
143                 return False;
144         }
145         
146         _echo_SinkData(p, r.in.len, r.in.data);
147         
148         push = ndr_push_init_ctx(mem_ctx);
149         if (push == NULL) {
150                 talloc_free(mem_ctx);
151                 return False;
152         }
153         
154         status = ndr_push_echo_SinkData(push, NDR_OUT, &r);
155         if (NT_STATUS_IS_ERR(status)) {
156                 talloc_free(mem_ctx);
157                 return False;
158         }
159         
160         blob = ndr_push_blob(push);
161         if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
162                 talloc_free(mem_ctx);
163                 return False;
164         }
165         
166         talloc_free(mem_ctx);
167         
168         return True;
169 }
170
171 static BOOL api_echo_SourceData(pipes_struct *p)
172 {
173         struct ndr_pull *pull;
174         struct ndr_push *push;
175         NTSTATUS status;
176         DATA_BLOB blob;
177         struct echo_SourceData r;
178         TALLOC_CTX *mem_ctx = talloc_init("api_echo_SourceData");
179         
180         if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
181                 talloc_free(mem_ctx);
182                 return False;
183         }
184         
185         pull = ndr_pull_init_blob(&blob, mem_ctx);
186         if (pull == NULL)
187                 return False;
188         
189         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
190         status = ndr_pull_echo_SourceData(pull, NDR_IN, &r);
191         if (NT_STATUS_IS_ERR(status)) {
192                 talloc_free(mem_ctx);
193                 return False;
194         }
195         
196         r.out.data = talloc_array_size(mem_ctx, sizeof(*r.out.data), r.in.len);
197         if (r.out.data == NULL) {
198                 talloc_free(mem_ctx);
199                 return False;
200         }
201         
202         _echo_SourceData(p, r.in.len, r.out.data);
203         
204         push = ndr_push_init_ctx(mem_ctx);
205         if (push == NULL) {
206                 talloc_free(mem_ctx);
207                 return False;
208         }
209         
210         status = ndr_push_echo_SourceData(push, NDR_OUT, &r);
211         if (NT_STATUS_IS_ERR(status)) {
212                 talloc_free(mem_ctx);
213                 return False;
214         }
215         
216         blob = ndr_push_blob(push);
217         if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
218                 talloc_free(mem_ctx);
219                 return False;
220         }
221         
222         talloc_free(mem_ctx);
223         
224         return True;
225 }
226
227 static BOOL api_echo_TestCall(pipes_struct *p)
228 {
229         struct ndr_pull *pull;
230         struct ndr_push *push;
231         NTSTATUS status;
232         DATA_BLOB blob;
233         struct echo_TestCall r;
234         TALLOC_CTX *mem_ctx = talloc_init("api_echo_TestCall");
235         
236         if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
237                 talloc_free(mem_ctx);
238                 return False;
239         }
240         
241         pull = ndr_pull_init_blob(&blob, mem_ctx);
242         if (pull == NULL)
243                 return False;
244         
245         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
246         status = ndr_pull_echo_TestCall(pull, NDR_IN, &r);
247         if (NT_STATUS_IS_ERR(status)) {
248                 talloc_free(mem_ctx);
249                 return False;
250         }
251         
252         r.out.s2 = talloc_size(mem_ctx, sizeof(*r.out.s2));
253         if (r.out.s2 == NULL) {
254                 talloc_free(mem_ctx);
255                 return False;
256         }
257         
258         _echo_TestCall(p, r.in.s1, r.out.s2);
259         
260         push = ndr_push_init_ctx(mem_ctx);
261         if (push == NULL) {
262                 talloc_free(mem_ctx);
263                 return False;
264         }
265         
266         status = ndr_push_echo_TestCall(push, NDR_OUT, &r);
267         if (NT_STATUS_IS_ERR(status)) {
268                 talloc_free(mem_ctx);
269                 return False;
270         }
271         
272         blob = ndr_push_blob(push);
273         if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
274                 talloc_free(mem_ctx);
275                 return False;
276         }
277         
278         talloc_free(mem_ctx);
279         
280         return True;
281 }
282
283 static BOOL api_echo_TestCall2(pipes_struct *p)
284 {
285         struct ndr_pull *pull;
286         struct ndr_push *push;
287         NTSTATUS status;
288         DATA_BLOB blob;
289         struct echo_TestCall2 r;
290         TALLOC_CTX *mem_ctx = talloc_init("api_echo_TestCall2");
291         
292         if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
293                 talloc_free(mem_ctx);
294                 return False;
295         }
296         
297         pull = ndr_pull_init_blob(&blob, mem_ctx);
298         if (pull == NULL)
299                 return False;
300         
301         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
302         status = ndr_pull_echo_TestCall2(pull, NDR_IN, &r);
303         if (NT_STATUS_IS_ERR(status)) {
304                 talloc_free(mem_ctx);
305                 return False;
306         }
307         
308         r.out.info = talloc_size(mem_ctx, sizeof(*r.out.info));
309         if (r.out.info == NULL) {
310                 talloc_free(mem_ctx);
311                 return False;
312         }
313         
314         r.out.result = _echo_TestCall2(p, r.in.level, r.out.info);
315         
316         push = ndr_push_init_ctx(mem_ctx);
317         if (push == NULL) {
318                 talloc_free(mem_ctx);
319                 return False;
320         }
321         
322         status = ndr_push_echo_TestCall2(push, NDR_OUT, &r);
323         if (NT_STATUS_IS_ERR(status)) {
324                 talloc_free(mem_ctx);
325                 return False;
326         }
327         
328         blob = ndr_push_blob(push);
329         if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
330                 talloc_free(mem_ctx);
331                 return False;
332         }
333         
334         talloc_free(mem_ctx);
335         
336         return True;
337 }
338
339 static BOOL api_echo_TestSleep(pipes_struct *p)
340 {
341         struct ndr_pull *pull;
342         struct ndr_push *push;
343         NTSTATUS status;
344         DATA_BLOB blob;
345         struct echo_TestSleep r;
346         TALLOC_CTX *mem_ctx = talloc_init("api_echo_TestSleep");
347         
348         if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
349                 talloc_free(mem_ctx);
350                 return False;
351         }
352         
353         pull = ndr_pull_init_blob(&blob, mem_ctx);
354         if (pull == NULL)
355                 return False;
356         
357         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
358         status = ndr_pull_echo_TestSleep(pull, NDR_IN, &r);
359         if (NT_STATUS_IS_ERR(status)) {
360                 talloc_free(mem_ctx);
361                 return False;
362         }
363         
364         r.out.result = _echo_TestSleep(p, r.in.seconds);
365         
366         push = ndr_push_init_ctx(mem_ctx);
367         if (push == NULL) {
368                 talloc_free(mem_ctx);
369                 return False;
370         }
371         
372         status = ndr_push_echo_TestSleep(push, NDR_OUT, &r);
373         if (NT_STATUS_IS_ERR(status)) {
374                 talloc_free(mem_ctx);
375                 return False;
376         }
377         
378         blob = ndr_push_blob(push);
379         if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
380                 talloc_free(mem_ctx);
381                 return False;
382         }
383         
384         talloc_free(mem_ctx);
385         
386         return True;
387 }
388
389 static BOOL api_echo_TestEnum(pipes_struct *p)
390 {
391         struct ndr_pull *pull;
392         struct ndr_push *push;
393         NTSTATUS status;
394         DATA_BLOB blob;
395         struct echo_TestEnum r;
396         TALLOC_CTX *mem_ctx = talloc_init("api_echo_TestEnum");
397         
398         if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
399                 talloc_free(mem_ctx);
400                 return False;
401         }
402         
403         pull = ndr_pull_init_blob(&blob, mem_ctx);
404         if (pull == NULL)
405                 return False;
406         
407         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
408         status = ndr_pull_echo_TestEnum(pull, NDR_IN, &r);
409         if (NT_STATUS_IS_ERR(status)) {
410                 talloc_free(mem_ctx);
411                 return False;
412         }
413         
414         r.out.foo1 = r.in.foo1;
415         r.out.foo2 = r.in.foo2;
416         r.out.foo3 = r.in.foo3;
417         _echo_TestEnum(p, r.in.foo1, r.in.foo2, r.in.foo3);
418         
419         push = ndr_push_init_ctx(mem_ctx);
420         if (push == NULL) {
421                 talloc_free(mem_ctx);
422                 return False;
423         }
424         
425         status = ndr_push_echo_TestEnum(push, NDR_OUT, &r);
426         if (NT_STATUS_IS_ERR(status)) {
427                 talloc_free(mem_ctx);
428                 return False;
429         }
430         
431         blob = ndr_push_blob(push);
432         if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
433                 talloc_free(mem_ctx);
434                 return False;
435         }
436         
437         talloc_free(mem_ctx);
438         
439         return True;
440 }
441
442 static BOOL api_echo_TestSurrounding(pipes_struct *p)
443 {
444         struct ndr_pull *pull;
445         struct ndr_push *push;
446         NTSTATUS status;
447         DATA_BLOB blob;
448         struct echo_TestSurrounding r;
449         TALLOC_CTX *mem_ctx = talloc_init("api_echo_TestSurrounding");
450         
451         if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
452                 talloc_free(mem_ctx);
453                 return False;
454         }
455         
456         pull = ndr_pull_init_blob(&blob, mem_ctx);
457         if (pull == NULL)
458                 return False;
459         
460         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
461         status = ndr_pull_echo_TestSurrounding(pull, NDR_IN, &r);
462         if (NT_STATUS_IS_ERR(status)) {
463                 talloc_free(mem_ctx);
464                 return False;
465         }
466         
467         r.out.data = r.in.data;
468         _echo_TestSurrounding(p, r.in.data);
469         
470         push = ndr_push_init_ctx(mem_ctx);
471         if (push == NULL) {
472                 talloc_free(mem_ctx);
473                 return False;
474         }
475         
476         status = ndr_push_echo_TestSurrounding(push, NDR_OUT, &r);
477         if (NT_STATUS_IS_ERR(status)) {
478                 talloc_free(mem_ctx);
479                 return False;
480         }
481         
482         blob = ndr_push_blob(push);
483         if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
484                 talloc_free(mem_ctx);
485                 return False;
486         }
487         
488         talloc_free(mem_ctx);
489         
490         return True;
491 }
492
493 static BOOL api_echo_TestDoublePointer(pipes_struct *p)
494 {
495         struct ndr_pull *pull;
496         struct ndr_push *push;
497         NTSTATUS status;
498         DATA_BLOB blob;
499         struct echo_TestDoublePointer r;
500         TALLOC_CTX *mem_ctx = talloc_init("api_echo_TestDoublePointer");
501         
502         if (!prs_data_blob(&p->in_data.data, &blob, mem_ctx)) {
503                 talloc_free(mem_ctx);
504                 return False;
505         }
506         
507         pull = ndr_pull_init_blob(&blob, mem_ctx);
508         if (pull == NULL)
509                 return False;
510         
511         pull->flags |= LIBNDR_FLAG_REF_ALLOC;
512         status = ndr_pull_echo_TestDoublePointer(pull, NDR_IN, &r);
513         if (NT_STATUS_IS_ERR(status)) {
514                 talloc_free(mem_ctx);
515                 return False;
516         }
517         
518         r.out.result = _echo_TestDoublePointer(p, r.in.data);
519         
520         push = ndr_push_init_ctx(mem_ctx);
521         if (push == NULL) {
522                 talloc_free(mem_ctx);
523                 return False;
524         }
525         
526         status = ndr_push_echo_TestDoublePointer(push, NDR_OUT, &r);
527         if (NT_STATUS_IS_ERR(status)) {
528                 talloc_free(mem_ctx);
529                 return False;
530         }
531         
532         blob = ndr_push_blob(push);
533         if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
534                 talloc_free(mem_ctx);
535                 return False;
536         }
537         
538         talloc_free(mem_ctx);
539         
540         return True;
541 }
542
543
544 /* Tables */
545 static struct api_struct api_rpcecho_cmds[] = 
546 {
547         {"ECHO_ADDONE", DCERPC_ECHO_ADDONE, api_echo_AddOne},
548         {"ECHO_ECHODATA", DCERPC_ECHO_ECHODATA, api_echo_EchoData},
549         {"ECHO_SINKDATA", DCERPC_ECHO_SINKDATA, api_echo_SinkData},
550         {"ECHO_SOURCEDATA", DCERPC_ECHO_SOURCEDATA, api_echo_SourceData},
551         {"ECHO_TESTCALL", DCERPC_ECHO_TESTCALL, api_echo_TestCall},
552         {"ECHO_TESTCALL2", DCERPC_ECHO_TESTCALL2, api_echo_TestCall2},
553         {"ECHO_TESTSLEEP", DCERPC_ECHO_TESTSLEEP, api_echo_TestSleep},
554         {"ECHO_TESTENUM", DCERPC_ECHO_TESTENUM, api_echo_TestEnum},
555         {"ECHO_TESTSURROUNDING", DCERPC_ECHO_TESTSURROUNDING, api_echo_TestSurrounding},
556         {"ECHO_TESTDOUBLEPOINTER", DCERPC_ECHO_TESTDOUBLEPOINTER, api_echo_TestDoublePointer},
557 };
558
559 void rpcecho_get_pipe_fns(struct api_struct **fns, int *n_fns)
560 {
561         *fns = api_rpcecho_cmds;
562         *n_fns = sizeof(api_rpcecho_cmds) / sizeof(struct api_struct);
563 }
564
565 NTSTATUS rpc_rpcecho_init(void)
566 {
567         return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "rpcecho", "rpcecho", api_rpcecho_cmds, sizeof(api_rpcecho_cmds) / sizeof(struct api_struct));
568 }