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.
21 #define _WIN32_WINNT 0x0500
29 #define RPC_MIN_CALLS 1
30 #define RPC_MAX_CALLS 20
31 #define RPC_ENDPOINT "\\pipe\\rpcecho"
33 void AddOne(int in_data, __RPC_FAR int *out_data)
35 printf("AddOne: got in_data = %d\n", in_data);
36 *out_data = in_data + 1;
39 void EchoData(int len, unsigned char __RPC_FAR in_data[],
40 unsigned char __RPC_FAR out_data[])
42 printf("EchoData: got len = %d\n", len);
44 memcpy(out_data, in_data, len);
47 void SinkData(int len, unsigned char __RPC_FAR in_data[ ])
49 printf("SinkData: got len = %d\n", len);
52 void SourceData(int len, unsigned char __RPC_FAR out_data[ ])
56 printf("SourceData: got len = %d\n", len);
58 for (i = 0; i < len; i++)
59 out_data[i] = i & 0xff;
62 void TestCall(wchar_t **s1, wchar_t **s2)
65 printf("s1='%S'\n", *s1);
72 long TestCall2(short level, echo_Info **info)
76 printf("TestCall2 level %d\n", level);
103 i.info7.info4.v = 71;
112 void TestSleep(PRPC_ASYNC_STATE pAsync, long seconds)
115 printf("async Sleeping for %d seconds\n", seconds);
116 Sleep(1000 * seconds);
118 RpcAsyncCompleteCall(pAsync, &ret);
121 long TestSleep(long seconds)
123 printf("non-async Sleeping for %d seconds\n", seconds);
124 Sleep(1000 * seconds);
135 printf("TestEnum ...\n");
138 void TestSurrounding(Surrounding *data)
140 printf("TestSurrounding ...\n");
143 short TestDoublePointer(short ***data)
145 printf("TestDoublePointer ...\n");
150 PRPC_ASYNC_STATE TestBytePipeIn_AsyncHandle,
153 ASYNC_BYTE_PIPE *in_pipe)
156 byte in_bytes[0x80000];
160 printf("TestBytePipeIn: Start\n");
163 in_bytes_count = sizeof(in_bytes);
164 for (i=0; in_bytes_count > 0; i++) {
165 in_bytes_count = sizeof(in_bytes);
166 in_pipe->pull(in_pipe->state, in_bytes, sizeof(byte), &in_bytes_count);
167 printf("pull[%u] bytes_count[%u]\n", i, in_bytes_count);
171 printf("TestBytePipeIn: End\n");
174 RpcAsyncCompleteCall(TestBytePipeIn_AsyncHandle, &ret);
177 void TestBytePipeOut(
178 PRPC_ASYNC_STATE TestBytePipeOut_AsyncHandle,
181 ASYNC_BYTE_PIPE *out_pipe)
184 byte *out_bytes = NULL;
185 unsigned long out_alloc_size = 0;
186 unsigned long out_bytes_count = 0;
189 printf("TestBytePipeOut: Start\n");
192 out_alloc_size = chunk_size * sizeof(byte);
193 out_pipe->alloc(out_pipe->state, out_alloc_size, &out_bytes, &out_bytes_count);
194 memset(out_bytes, 0xCC, out_bytes_count * sizeof(byte));
196 for (i = 0; i <= num_chunks; i++) {
197 if (i == num_chunks) {
200 printf("[%u] push outb_len[%u]\n", i, out_bytes_count);
202 out_pipe->push(out_pipe->state, out_bytes, out_bytes_count);
205 printf("TestBytePipeOut: End\n");
208 RpcAsyncCompleteCall(TestBytePipeOut_AsyncHandle, &ret);
211 void main(int argc, char **argv)
215 RPC_BINDING_VECTOR *pBindingVector;
216 #define SERVER_PRINC_LEN 1024
217 unsigned server_princ_len = SERVER_PRINC_LEN;
218 char server_princ[SERVER_PRINC_LEN];
221 printf("Usage: rpcechosrv\n");
225 status = RpcServerUseProtseqEp("ncacn_np", RPC_MAX_CALLS, "\\pipe\\rpcecho", NULL);
227 printf("Failed to register ncacn_np endpoint\n");
231 status = RpcServerUseProtseqEp("ncacn_ip_tcp", RPC_MAX_CALLS, "1234", NULL);
233 printf("Failed to register ncacn_ip_tcp endpoint\n");
237 status = RpcServerInqBindings(&pBindingVector);
239 printf("Failed RpcServerInqBindings\n");
243 status = RpcEpRegister(rpcecho_v1_0_s_ifspec, pBindingVector, NULL, "rpcecho server");
245 printf("Failed RpcEpRegister\n");
249 status = RpcServerRegisterIf(rpcecho_v1_0_s_ifspec, NULL, NULL);
252 printf("Failed to register interface\n");
256 dwStatus = DsMakeSpn("host",
263 printf("server_princ: %s\n", server_princ);
265 #ifdef RPC_C_AUTHN_GSS_NEGOTIATE
266 status = RpcServerRegisterAuthInfo(server_princ, RPC_C_AUTHN_GSS_NEGOTIATE, NULL, NULL);
268 printf("Failed to setup auth info: RPC_C_AUTHN_GSS_NEGOTIATE\n");
271 printf("Sorry auth info RPC_C_AUTHN_GSS_NEGOTIATE not compiled in\n");
274 status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_WINNT, NULL, NULL);
276 printf("Failed to setup auth info: RPC_C_AUTHN_WINNT\n");
279 #ifdef RPC_C_AUTHN_GSS_KERBEROS
280 status = RpcServerRegisterAuthInfo(server_princ, RPC_C_AUTHN_GSS_KERBEROS, NULL, NULL);
282 printf("Failed to setup auth info: RPC_C_AUTHN_GSS_KERBEROS\n");
285 printf("Sorry auth info RPC_C_AUTHN_GSS_KERBEROS not compiled in\n");
288 status = RpcServerListen(RPC_MIN_CALLS, RPC_MAX_CALLS, FALSE);
291 printf("RpcServerListen returned error %d\n", status);