r18572: Use the autogenerated client and server for the echo interface and implement
[Samba.git] / source / rpc_server / srv_echo_nt.c
blob221f4bc8b24c417f297c3f4b477b2d80a1d24809
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines for rpcecho
4 * Copyright (C) Tim Potter 2003.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 /* This is the interface to the rpcecho pipe. */
23 #include "includes.h"
24 #include "nterr.h"
26 #ifdef DEVELOPER
28 #undef DBGC_CLASS
29 #define DBGC_CLASS DBGC_RPC_SRV
31 /* Add one to the input and return it */
33 void _echo_AddOne(pipes_struct *p, uint32_t in_data, uint32_t *out_data)
35 DEBUG(10, ("_echo_add_one\n"));
37 *out_data = in_data + 1;
40 /* Echo back an array of data */
42 void _echo_EchoData(pipes_struct *p, uint32_t len, uint8_t *in_data, uint8_t *out_data)
44 DEBUG(10, ("_echo_data\n"));
46 memcpy(out_data, in_data, len);
49 /* Sink an array of data */
51 void _echo_SinkData(pipes_struct *p, uint32_t len, uint8_t *data)
53 DEBUG(10, ("_sink_data\n"));
55 /* My that was some yummy data! */
58 /* Source an array of data */
60 void _echo_SourceData(pipes_struct *p, uint32_t len, uint8_t *data)
62 uint32 i;
64 DEBUG(10, ("_source_data\n"));
66 for (i = 0; i < len; i++)
67 data[i] = i & 0xff;
70 void _echo_TestCall(pipes_struct *p, const char *s1, const char **s2)
72 *s2 = talloc_strdup(p->mem_ctx, s1);
75 NTSTATUS _echo_TestCall2(pipes_struct *p, uint16_t level, union echo_Info *info)
77 switch (level) {
78 case 1:
79 info->info1.v = 10;
80 break;
81 case 2:
82 info->info2.v = 20;
83 break;
84 case 3:
85 info->info3.v = 30;
86 break;
87 case 4:
88 info->info4.v = 40;
89 break;
90 case 5:
91 info->info5.v1 = 50;
92 info->info5.v2 = 60;
93 break;
94 case 6:
95 info->info6.v1 = 70;
96 info->info6.info1.v= 80;
97 break;
98 case 7:
99 info->info7.v1 = 80;
100 info->info7.info4.v = 90;
101 break;
102 default:
103 return NT_STATUS_INVALID_LEVEL;
106 return NT_STATUS_OK;
109 uint32 _echo_TestSleep(pipes_struct *p, uint32_t seconds)
111 sleep(seconds);
112 return seconds;
115 void _echo_TestEnum(pipes_struct *p, enum echo_Enum1 *foo1, struct echo_Enum2 *foo2, union echo_Enum3 *foo3)
119 void _echo_TestSurrounding(pipes_struct *p, struct echo_Surrounding *data)
121 data->x *= 2;
122 data->surrounding = talloc_zero_array(p->mem_ctx, uint16_t, data->x);
125 uint16 _echo_TestDoublePointer(pipes_struct *p, uint16_t ***data)
127 if (!*data)
128 return 0;
129 if (!**data)
130 return 0;
131 return ***data;
134 #endif /* DEVELOPER */