4 Copyright (C) Tim Potter 2003
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.
28 #error "please run 'vcvarsall.bat amd64' -midltests_tcp needs 64-bit support!"
31 #define RPC_MIN_CALLS 1
32 #define RPC_MAX_CALLS 20
33 #define RPC_ENDPOINT "\\pipe\\rpcecho"
35 void AddOne(int in_data, __RPC_FAR int *out_data)
37 printf("AddOne: got in_data = %d\n", in_data);
38 *out_data = in_data + 1;
41 void EchoData(int len, unsigned char __RPC_FAR in_data[],
42 unsigned char __RPC_FAR out_data[])
44 printf("EchoData: got len = %d\n", len);
46 memcpy(out_data, in_data, len);
49 void SinkData(int len, unsigned char __RPC_FAR in_data[ ])
51 printf("SinkData: got len = %d\n", len);
54 void SourceData(int len, unsigned char __RPC_FAR out_data[ ])
58 printf("SourceData: got len = %d\n", len);
60 for (i = 0; i < len; i++)
61 out_data[i] = i & 0xff;
64 void TestCall(wchar_t **s1, wchar_t **s2)
67 printf("s1='%S'\n", *s1);
74 long TestCall2(short level, echo_Info **info)
78 printf("TestCall2 level %d\n", level);
101 i.info6.info1.v = 61;
105 i.info7.info4.v = 71;
114 void TestSleep(PRPC_ASYNC_STATE pAsync, long seconds)
117 printf("async Sleeping for %d seconds\n", seconds);
118 Sleep(1000 * seconds);
120 RpcAsyncCompleteCall(pAsync, &ret);
123 long TestSleep(long seconds)
125 printf("non-async Sleeping for %d seconds\n", seconds);
126 Sleep(1000 * seconds);
137 printf("TestEnum ...\n");
140 void TestSurrounding(Surrounding *data)
142 printf("TestSurrounding ...\n");
145 short TestDoublePointer(short ***data)
147 printf("TestDoublePointer ...\n");
152 PRPC_ASYNC_STATE TestBytePipeIn_AsyncHandle,
155 ASYNC_BYTE_PIPE *in_pipe)
163 printf("TestBytePipeIn: Start\n");
166 in_alloc_size = 5840 * sizeof(byte);
167 in_bytes = malloc(in_alloc_size);
169 in_bytes_count = chunk_size;
170 for (i=0; in_bytes_count > 0; i++) {
172 in_pipe->pull(in_pipe->state, in_bytes, in_alloc_size, &in_bytes_count);
173 printf("pull[%u] bytes_count[%u]\n", i, in_bytes_count);
177 printf("TestBytePipeIn: End\n");
180 RpcAsyncCompleteCall(TestBytePipeIn_AsyncHandle, &ret);
183 void TestBytePipeOut(
184 PRPC_ASYNC_STATE TestBytePipeOut_AsyncHandle,
187 ASYNC_BYTE_PIPE *out_pipe)
190 byte *out_bytes = NULL;
191 unsigned long out_alloc_size = 0;
192 unsigned long out_bytes_count = 0;
195 printf("TestBytePipeOut: Start\n");
198 out_alloc_size = chunk_size * sizeof(byte);
199 out_pipe->alloc(out_pipe->state, out_alloc_size, &out_bytes, &out_bytes_count);
200 memset(out_bytes, 0xCC, out_bytes_count * sizeof(byte));
202 for (i = 0; i <= num_chunks; i++) {
203 if (i == num_chunks) {
206 printf("[%u] push outb_len[%u]\n", i, out_bytes_count);
208 out_pipe->push(out_pipe->state, out_bytes, out_bytes_count);
211 printf("TestBytePipeOut: End\n");
214 RpcAsyncCompleteCall(TestBytePipeOut_AsyncHandle, &ret);
217 void main(int argc, char **argv)
221 RPC_BINDING_VECTOR *pBindingVector;
222 #define SERVER_PRINC_LEN 1024
223 unsigned server_princ_len = SERVER_PRINC_LEN;
224 char server_princ[SERVER_PRINC_LEN];
227 printf("Usage: rpcechosrv\n");
231 status = RpcServerUseProtseqEp("ncacn_np", RPC_MAX_CALLS, "\\pipe\\rpcecho", NULL);
233 printf("Failed to register ncacn_np endpoint\n");
237 status = RpcServerUseProtseqEp("ncacn_ip_tcp", RPC_MAX_CALLS, "1234", NULL);
239 printf("Failed to register ncacn_ip_tcp endpoint\n");
243 status = RpcServerInqBindings(&pBindingVector);
245 printf("Failed RpcServerInqBindings\n");
249 status = RpcEpRegister(rpcecho_v1_0_s_ifspec, pBindingVector, NULL, "rpcecho server");
251 printf("Failed RpcEpRegister\n");
255 status = RpcServerRegisterIf(rpcecho_v1_0_s_ifspec, NULL, NULL);
258 printf("Failed to register interface\n");
262 dwStatus = DsMakeSpn("host",
269 printf("server_princ: %s\n", server_princ);
271 #ifdef RPC_C_AUTHN_GSS_NEGOTIATE
272 status = RpcServerRegisterAuthInfo(server_princ, RPC_C_AUTHN_GSS_NEGOTIATE, NULL, NULL);
274 printf("Failed to setup auth info: RPC_C_AUTHN_GSS_NEGOTIATE\n");
277 printf("Sorry auth info RPC_C_AUTHN_GSS_NEGOTIATE not compiled in\n");
280 status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_WINNT, NULL, NULL);
282 printf("Failed to setup auth info: RPC_C_AUTHN_WINNT\n");
285 #ifdef RPC_C_AUTHN_GSS_KERBEROS
286 status = RpcServerRegisterAuthInfo(server_princ, RPC_C_AUTHN_GSS_KERBEROS, NULL, NULL);
288 printf("Failed to setup auth info: RPC_C_AUTHN_GSS_KERBEROS\n");
291 printf("Sorry auth info RPC_C_AUTHN_GSS_KERBEROS not compiled in\n");
294 status = RpcServerListen(RPC_MIN_CALLS, RPC_MAX_CALLS, FALSE);
297 printf("RpcServerListen returned error %d\n", status);