r18572: Use the autogenerated client and server for the echo interface and implement
[samba.git] / source / rpc_server / srv_echo_nt.c
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.
10  *  
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.
15  *  
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.
19  */
20
21 /* This is the interface to the rpcecho pipe. */
22
23 #include "includes.h"
24 #include "nterr.h"
25
26 #ifdef DEVELOPER
27
28 #undef DBGC_CLASS
29 #define DBGC_CLASS DBGC_RPC_SRV
30
31 /* Add one to the input and return it */
32
33 void _echo_AddOne(pipes_struct *p, uint32_t in_data, uint32_t *out_data)
34 {
35         DEBUG(10, ("_echo_add_one\n"));
36
37         *out_data = in_data + 1;
38 }
39
40 /* Echo back an array of data */
41
42 void _echo_EchoData(pipes_struct *p, uint32_t len, uint8_t *in_data, uint8_t *out_data)
43 {
44         DEBUG(10, ("_echo_data\n"));
45
46         memcpy(out_data, in_data, len);
47 }
48
49 /* Sink an array of data */
50
51 void _echo_SinkData(pipes_struct *p, uint32_t len, uint8_t *data)
52 {
53         DEBUG(10, ("_sink_data\n"));
54
55         /* My that was some yummy data! */
56 }
57
58 /* Source an array of data */
59
60 void _echo_SourceData(pipes_struct *p, uint32_t len, uint8_t *data)
61 {
62         uint32 i;
63
64         DEBUG(10, ("_source_data\n"));
65
66         for (i = 0; i < len; i++)
67                 data[i] = i & 0xff;
68 }
69
70 void _echo_TestCall(pipes_struct *p, const char *s1, const char **s2)
71 {
72         *s2 = talloc_strdup(p->mem_ctx, s1);
73 }
74
75 NTSTATUS _echo_TestCall2(pipes_struct *p, uint16_t level, union echo_Info *info)
76 {
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;
104         }
105
106         return NT_STATUS_OK;
107 }
108
109 uint32 _echo_TestSleep(pipes_struct *p, uint32_t seconds)
110 {
111         sleep(seconds);
112         return seconds;
113 }
114
115 void _echo_TestEnum(pipes_struct *p, enum echo_Enum1 *foo1, struct echo_Enum2 *foo2, union echo_Enum3 *foo3)
116 {
117 }
118
119 void _echo_TestSurrounding(pipes_struct *p, struct echo_Surrounding *data)
120 {
121         data->x *= 2;
122         data->surrounding = talloc_zero_array(p->mem_ctx, uint16_t, data->x);
123 }
124
125 uint16 _echo_TestDoublePointer(pipes_struct *p, uint16_t ***data)
126 {
127         if (!*data) 
128                 return 0;
129         if (!**data)
130                 return 0;
131         return ***data;
132 }
133
134 #endif /* DEVELOPER */