Line data Source code
1 : /* server functions auto-generated by pidl */
2 : #include "bin/default/librpc/gen_ndr/ndr_echo.h"
3 : #include <util/debug.h>
4 :
5 : NTSTATUS dcerpc_server_rpcecho_init(TALLOC_CTX *);
6 :
7 : /* rpcecho - dcerpc server boilerplate generated by pidl */
8 :
9 :
10 327 : static NTSTATUS rpcecho__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
11 : {
12 : #ifdef DCESRV_INTERFACE_RPCECHO_BIND
13 327 : return DCESRV_INTERFACE_RPCECHO_BIND(context,iface);
14 : #else
15 : return NT_STATUS_OK;
16 : #endif
17 : }
18 :
19 327 : static void rpcecho__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
20 : {
21 : #ifdef DCESRV_INTERFACE_RPCECHO_UNBIND
22 : DCESRV_INTERFACE_RPCECHO_UNBIND(context, iface);
23 : #else
24 327 : return;
25 : #endif
26 : }
27 :
28 7515 : static NTSTATUS rpcecho__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
29 : {
30 56 : enum ndr_err_code ndr_err;
31 7515 : uint16_t opnum = dce_call->pkt.u.request.opnum;
32 :
33 7515 : dce_call->fault_code = 0;
34 :
35 7515 : if (opnum >= ndr_table_rpcecho.num_calls) {
36 0 : dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
37 0 : return NT_STATUS_NET_WRITE_FAULT;
38 : }
39 :
40 15030 : *r = talloc_named(mem_ctx,
41 7515 : ndr_table_rpcecho.calls[opnum].struct_size,
42 : "struct %s",
43 7515 : ndr_table_rpcecho.calls[opnum].name);
44 7515 : NT_STATUS_HAVE_NO_MEMORY(*r);
45 :
46 : /* unravel the NDR for the packet */
47 7515 : ndr_err = ndr_table_rpcecho.calls[opnum].ndr_pull(pull, NDR_IN, *r);
48 7515 : if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
49 0 : dce_call->fault_code = DCERPC_FAULT_NDR;
50 0 : return NT_STATUS_NET_WRITE_FAULT;
51 : }
52 :
53 7515 : return NT_STATUS_OK;
54 : }
55 :
56 7515 : static NTSTATUS rpcecho__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
57 : {
58 7515 : uint16_t opnum = dce_call->pkt.u.request.opnum;
59 :
60 7515 : switch (opnum) {
61 3689 : case 0: {
62 3689 : struct echo_AddOne *r2 = (struct echo_AddOne *)r;
63 3689 : if (DEBUGLEVEL >= 10) {
64 0 : NDR_PRINT_FUNCTION_DEBUG(echo_AddOne, NDR_IN, r2);
65 : }
66 3689 : dcesrv_echo_AddOne(dce_call, mem_ctx, r2);
67 3689 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
68 0 : DEBUG(5,("function echo_AddOne will reply async\n"));
69 : }
70 3661 : break;
71 : }
72 270 : case 1: {
73 270 : struct echo_EchoData *r2 = (struct echo_EchoData *)r;
74 270 : if (DEBUGLEVEL >= 10) {
75 0 : NDR_PRINT_FUNCTION_DEBUG(echo_EchoData, NDR_IN, r2);
76 : }
77 270 : dcesrv_echo_EchoData(dce_call, mem_ctx, r2);
78 270 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
79 0 : DEBUG(5,("function echo_EchoData will reply async\n"));
80 : }
81 268 : break;
82 : }
83 263 : case 2: {
84 263 : struct echo_SinkData *r2 = (struct echo_SinkData *)r;
85 263 : if (DEBUGLEVEL >= 10) {
86 0 : NDR_PRINT_FUNCTION_DEBUG(echo_SinkData, NDR_IN, r2);
87 : }
88 263 : dcesrv_echo_SinkData(dce_call, mem_ctx, r2);
89 263 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
90 0 : DEBUG(5,("function echo_SinkData will reply async\n"));
91 : }
92 261 : break;
93 : }
94 263 : case 3: {
95 263 : struct echo_SourceData *r2 = (struct echo_SourceData *)r;
96 263 : if (DEBUGLEVEL >= 10) {
97 0 : NDR_PRINT_FUNCTION_DEBUG(echo_SourceData, NDR_IN, r2);
98 : }
99 263 : dcesrv_echo_SourceData(dce_call, mem_ctx, r2);
100 263 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
101 0 : DEBUG(5,("function echo_SourceData will reply async\n"));
102 : }
103 261 : break;
104 : }
105 264 : case 4: {
106 264 : struct echo_TestCall *r2 = (struct echo_TestCall *)r;
107 264 : if (DEBUGLEVEL >= 10) {
108 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestCall, NDR_IN, r2);
109 : }
110 264 : dcesrv_echo_TestCall(dce_call, mem_ctx, r2);
111 264 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
112 0 : DEBUG(5,("function echo_TestCall will reply async\n"));
113 : }
114 262 : break;
115 : }
116 1841 : case 5: {
117 1841 : struct echo_TestCall2 *r2 = (struct echo_TestCall2 *)r;
118 1841 : if (DEBUGLEVEL >= 10) {
119 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestCall2, NDR_IN, r2);
120 : }
121 1841 : r2->out.result = dcesrv_echo_TestCall2(dce_call, mem_ctx, r2);
122 1841 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
123 0 : DEBUG(5,("function echo_TestCall2 will reply async\n"));
124 : }
125 1827 : break;
126 : }
127 135 : case 6: {
128 135 : struct echo_TestSleep *r2 = (struct echo_TestSleep *)r;
129 135 : if (DEBUGLEVEL >= 10) {
130 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestSleep, NDR_IN, r2);
131 : }
132 135 : r2->out.result = dcesrv_echo_TestSleep(dce_call, mem_ctx, r2);
133 135 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
134 135 : DEBUG(5,("function echo_TestSleep will reply async\n"));
135 : }
136 135 : break;
137 : }
138 263 : case 7: {
139 263 : struct echo_TestEnum *r2 = (struct echo_TestEnum *)r;
140 263 : if (DEBUGLEVEL >= 10) {
141 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestEnum, NDR_IN, r2);
142 : }
143 263 : dcesrv_echo_TestEnum(dce_call, mem_ctx, r2);
144 263 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
145 0 : DEBUG(5,("function echo_TestEnum will reply async\n"));
146 : }
147 261 : break;
148 : }
149 264 : case 8: {
150 264 : struct echo_TestSurrounding *r2 = (struct echo_TestSurrounding *)r;
151 264 : if (DEBUGLEVEL >= 10) {
152 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestSurrounding, NDR_IN, r2);
153 : }
154 264 : dcesrv_echo_TestSurrounding(dce_call, mem_ctx, r2);
155 264 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
156 0 : DEBUG(5,("function echo_TestSurrounding will reply async\n"));
157 : }
158 262 : break;
159 : }
160 263 : case 9: {
161 263 : struct echo_TestDoublePointer *r2 = (struct echo_TestDoublePointer *)r;
162 263 : if (DEBUGLEVEL >= 10) {
163 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestDoublePointer, NDR_IN, r2);
164 : }
165 263 : r2->out.result = dcesrv_echo_TestDoublePointer(dce_call, mem_ctx, r2);
166 263 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
167 0 : DEBUG(5,("function echo_TestDoublePointer will reply async\n"));
168 : }
169 261 : break;
170 : }
171 :
172 0 : default:
173 0 : dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
174 0 : break;
175 : }
176 :
177 7515 : if (dce_call->fault_code != 0) {
178 0 : return NT_STATUS_NET_WRITE_FAULT;
179 : }
180 :
181 7515 : return NT_STATUS_OK;
182 : }
183 :
184 7515 : static NTSTATUS rpcecho__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
185 : {
186 7515 : uint16_t opnum = dce_call->pkt.u.request.opnum;
187 :
188 7515 : switch (opnum) {
189 3689 : case 0: {
190 3689 : struct echo_AddOne *r2 = (struct echo_AddOne *)r;
191 3689 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
192 0 : DEBUG(5,("function echo_AddOne replied async\n"));
193 : }
194 3689 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
195 0 : NDR_PRINT_FUNCTION_DEBUG(echo_AddOne, NDR_OUT | NDR_SET_VALUES, r2);
196 : }
197 3689 : if (dce_call->fault_code != 0) {
198 0 : DEBUG(2,("dcerpc_fault %s in echo_AddOne\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
199 : }
200 3661 : break;
201 : }
202 270 : case 1: {
203 270 : struct echo_EchoData *r2 = (struct echo_EchoData *)r;
204 270 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
205 0 : DEBUG(5,("function echo_EchoData replied async\n"));
206 : }
207 270 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
208 0 : NDR_PRINT_FUNCTION_DEBUG(echo_EchoData, NDR_OUT | NDR_SET_VALUES, r2);
209 : }
210 270 : if (dce_call->fault_code != 0) {
211 0 : DEBUG(2,("dcerpc_fault %s in echo_EchoData\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
212 : }
213 268 : break;
214 : }
215 263 : case 2: {
216 263 : struct echo_SinkData *r2 = (struct echo_SinkData *)r;
217 263 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
218 0 : DEBUG(5,("function echo_SinkData replied async\n"));
219 : }
220 263 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
221 0 : NDR_PRINT_FUNCTION_DEBUG(echo_SinkData, NDR_OUT | NDR_SET_VALUES, r2);
222 : }
223 263 : if (dce_call->fault_code != 0) {
224 0 : DEBUG(2,("dcerpc_fault %s in echo_SinkData\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
225 : }
226 261 : break;
227 : }
228 263 : case 3: {
229 263 : struct echo_SourceData *r2 = (struct echo_SourceData *)r;
230 263 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
231 0 : DEBUG(5,("function echo_SourceData replied async\n"));
232 : }
233 263 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
234 0 : NDR_PRINT_FUNCTION_DEBUG(echo_SourceData, NDR_OUT | NDR_SET_VALUES, r2);
235 : }
236 263 : if (dce_call->fault_code != 0) {
237 0 : DEBUG(2,("dcerpc_fault %s in echo_SourceData\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
238 : }
239 261 : break;
240 : }
241 264 : case 4: {
242 264 : struct echo_TestCall *r2 = (struct echo_TestCall *)r;
243 264 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
244 0 : DEBUG(5,("function echo_TestCall replied async\n"));
245 : }
246 264 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
247 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestCall, NDR_OUT | NDR_SET_VALUES, r2);
248 : }
249 264 : if (dce_call->fault_code != 0) {
250 0 : DEBUG(2,("dcerpc_fault %s in echo_TestCall\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
251 : }
252 262 : break;
253 : }
254 1841 : case 5: {
255 1841 : struct echo_TestCall2 *r2 = (struct echo_TestCall2 *)r;
256 1841 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
257 0 : DEBUG(5,("function echo_TestCall2 replied async\n"));
258 : }
259 1841 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
260 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestCall2, NDR_OUT | NDR_SET_VALUES, r2);
261 : }
262 1841 : if (dce_call->fault_code != 0) {
263 0 : DEBUG(2,("dcerpc_fault %s in echo_TestCall2\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
264 : }
265 1827 : break;
266 : }
267 135 : case 6: {
268 135 : struct echo_TestSleep *r2 = (struct echo_TestSleep *)r;
269 135 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
270 135 : DEBUG(5,("function echo_TestSleep replied async\n"));
271 : }
272 135 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
273 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestSleep, NDR_OUT | NDR_SET_VALUES, r2);
274 : }
275 135 : if (dce_call->fault_code != 0) {
276 0 : DEBUG(2,("dcerpc_fault %s in echo_TestSleep\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
277 : }
278 135 : break;
279 : }
280 263 : case 7: {
281 263 : struct echo_TestEnum *r2 = (struct echo_TestEnum *)r;
282 263 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
283 0 : DEBUG(5,("function echo_TestEnum replied async\n"));
284 : }
285 263 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
286 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestEnum, NDR_OUT | NDR_SET_VALUES, r2);
287 : }
288 263 : if (dce_call->fault_code != 0) {
289 0 : DEBUG(2,("dcerpc_fault %s in echo_TestEnum\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
290 : }
291 261 : break;
292 : }
293 264 : case 8: {
294 264 : struct echo_TestSurrounding *r2 = (struct echo_TestSurrounding *)r;
295 264 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
296 0 : DEBUG(5,("function echo_TestSurrounding replied async\n"));
297 : }
298 264 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
299 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestSurrounding, NDR_OUT | NDR_SET_VALUES, r2);
300 : }
301 264 : if (dce_call->fault_code != 0) {
302 0 : DEBUG(2,("dcerpc_fault %s in echo_TestSurrounding\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
303 : }
304 262 : break;
305 : }
306 263 : case 9: {
307 263 : struct echo_TestDoublePointer *r2 = (struct echo_TestDoublePointer *)r;
308 263 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
309 0 : DEBUG(5,("function echo_TestDoublePointer replied async\n"));
310 : }
311 263 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
312 0 : NDR_PRINT_FUNCTION_DEBUG(echo_TestDoublePointer, NDR_OUT | NDR_SET_VALUES, r2);
313 : }
314 263 : if (dce_call->fault_code != 0) {
315 0 : DEBUG(2,("dcerpc_fault %s in echo_TestDoublePointer\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
316 : }
317 261 : break;
318 : }
319 :
320 0 : default:
321 0 : dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
322 0 : break;
323 : }
324 :
325 7515 : if (dce_call->fault_code != 0) {
326 0 : return NT_STATUS_NET_WRITE_FAULT;
327 : }
328 :
329 7515 : return NT_STATUS_OK;
330 : }
331 :
332 7515 : static NTSTATUS rpcecho__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
333 : {
334 56 : enum ndr_err_code ndr_err;
335 7515 : uint16_t opnum = dce_call->pkt.u.request.opnum;
336 :
337 7515 : ndr_err = ndr_table_rpcecho.calls[opnum].ndr_push(push, NDR_OUT, r);
338 7515 : if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
339 0 : dce_call->fault_code = DCERPC_FAULT_NDR;
340 0 : return NT_STATUS_NET_WRITE_FAULT;
341 : }
342 :
343 7515 : return NT_STATUS_OK;
344 : }
345 :
346 : static const struct dcesrv_interface dcesrv_rpcecho_interface = {
347 : .name = "rpcecho",
348 : .syntax_id = {{0x60a15ec5,0x4de8,0x11d7,{0xa6,0x37},{0x00,0x50,0x56,0xa2,0x01,0x82}},1.0},
349 : .bind = rpcecho__op_bind,
350 : .unbind = rpcecho__op_unbind,
351 : .ndr_pull = rpcecho__op_ndr_pull,
352 : .dispatch = rpcecho__op_dispatch,
353 : .reply = rpcecho__op_reply,
354 : .ndr_push = rpcecho__op_ndr_push,
355 : .local = NULL,
356 : #ifdef DCESRV_INTERFACE_RPCECHO_FLAGS
357 : .flags = DCESRV_INTERFACE_RPCECHO_FLAGS
358 : #else
359 : .flags = 0
360 : #endif
361 : };
362 :
363 :
364 64 : static NTSTATUS rpcecho__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
365 : {
366 2 : int i;
367 : #ifdef DCESRV_INTERFACE_RPCECHO_NCACN_NP_SECONDARY_ENDPOINT
368 : const char *ncacn_np_secondary_endpoint =
369 : DCESRV_INTERFACE_RPCECHO_NCACN_NP_SECONDARY_ENDPOINT;
370 : #else
371 64 : const char *ncacn_np_secondary_endpoint = NULL;
372 : #endif
373 :
374 256 : for (i=0;i<ndr_table_rpcecho.endpoints->count;i++) {
375 6 : NTSTATUS ret;
376 192 : const char *name = ndr_table_rpcecho.endpoints->names[i];
377 :
378 192 : ret = dcesrv_interface_register(dce_ctx,
379 : name,
380 : ncacn_np_secondary_endpoint,
381 : &dcesrv_rpcecho_interface,
382 : NULL);
383 192 : if (!NT_STATUS_IS_OK(ret)) {
384 0 : DEBUG(1,("rpcecho_op_init_server: failed to register endpoint '%s'\n",name));
385 0 : return ret;
386 : }
387 : }
388 :
389 64 : return NT_STATUS_OK;
390 : }
391 :
392 0 : static NTSTATUS rpcecho__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
393 : {
394 0 : return NT_STATUS_OK;
395 : }
396 :
397 0 : static bool rpcecho__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
398 : {
399 0 : if (dcesrv_rpcecho_interface.syntax_id.if_version == if_version &&
400 0 : GUID_equal(&dcesrv_rpcecho_interface.syntax_id.uuid, uuid)) {
401 0 : memcpy(iface,&dcesrv_rpcecho_interface, sizeof(*iface));
402 0 : return true;
403 : }
404 :
405 0 : return false;
406 : }
407 :
408 0 : static bool rpcecho__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
409 : {
410 0 : if (strcmp(dcesrv_rpcecho_interface.name, name)==0) {
411 0 : memcpy(iface, &dcesrv_rpcecho_interface, sizeof(*iface));
412 0 : return true;
413 : }
414 :
415 0 : return false;
416 : }
417 :
418 66 : NTSTATUS dcerpc_server_rpcecho_init(TALLOC_CTX *ctx)
419 : {
420 2 : NTSTATUS ret;
421 2 : static const struct dcesrv_endpoint_server ep_server = {
422 : /* fill in our name */
423 : .name = "rpcecho",
424 :
425 : /* Initialization flag */
426 : .initialized = false,
427 :
428 : /* fill in all the operations */
429 : #ifdef DCESRV_INTERFACE_RPCECHO_INIT_SERVER
430 : .init_server = DCESRV_INTERFACE_RPCECHO_INIT_SERVER,
431 : #else
432 : .init_server = rpcecho__op_init_server,
433 : #endif
434 : #ifdef DCESRV_INTERFACE_RPCECHO_SHUTDOWN_SERVER
435 : .shutdown_server = DCESRV_INTERFACE_RPCECHO_SHUTDOWN_SERVER,
436 : #else
437 : .shutdown_server = rpcecho__op_shutdown_server,
438 : #endif
439 : .interface_by_uuid = rpcecho__op_interface_by_uuid,
440 : .interface_by_name = rpcecho__op_interface_by_name
441 : };
442 : /* register ourselves with the DCERPC subsystem. */
443 66 : ret = dcerpc_register_ep_server(&ep_server);
444 :
445 66 : if (!NT_STATUS_IS_OK(ret)) {
446 0 : DEBUG(0,("Failed to register 'rpcecho' endpoint server!\n"));
447 0 : return ret;
448 : }
449 :
450 66 : return ret;
451 : }
452 :
|