2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines for rpcecho
4 * Copyright (C) Tim Potter 2003
5 * Copyright (C) Jelmer Vernooij 2006
6 * Copyright (C) Gerald (Jerry) Carter 2007
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 /* This is the interface to the rpcecho pipe. */
25 #include "../librpc/gen_ndr/srv_echo.h"
28 #define DBGC_CLASS DBGC_RPC_SRV
30 /* Add one to the input and return it */
32 void _echo_AddOne(struct pipes_struct *p, struct echo_AddOne *r )
34 DEBUG(10, ("_echo_AddOne\n"));
36 *r->out.out_data = r->in.in_data + 1;
39 /* Echo back an array of data */
41 void _echo_EchoData(struct pipes_struct *p, struct echo_EchoData *r)
43 DEBUG(10, ("_echo_EchoData\n"));
45 if ( r->in.len == 0 ) {
46 r->out.out_data = NULL;
50 r->out.out_data = TALLOC_ARRAY(p->mem_ctx, uint8, r->in.len);
51 memcpy( r->out.out_data, r->in.in_data, r->in.len );
55 /* Sink an array of data */
57 void _echo_SinkData(struct pipes_struct *p, struct echo_SinkData *r)
59 DEBUG(10, ("_echo_SinkData\n"));
61 /* My that was some yummy data! */
65 /* Source an array of data */
67 void _echo_SourceData(struct pipes_struct *p, struct echo_SourceData *r)
71 DEBUG(10, ("_echo_SourceData\n"));
73 if ( r->in.len == 0 ) {
78 r->out.data = TALLOC_ARRAY(p->mem_ctx, uint8, r->in.len );
80 for (i = 0; i < r->in.len; i++ ) {
81 r->out.data[i] = i & 0xff;
87 void _echo_TestCall(struct pipes_struct *p, struct echo_TestCall *r)
89 p->rng_fault_state = True;
93 NTSTATUS _echo_TestCall2(struct pipes_struct *p, struct echo_TestCall2 *r)
95 p->rng_fault_state = True;
99 uint32 _echo_TestSleep(struct pipes_struct *p, struct echo_TestSleep *r)
101 smb_msleep(r->in.seconds * 1000);
105 void _echo_TestEnum(struct pipes_struct *p, struct echo_TestEnum *r)
107 p->rng_fault_state = True;
111 void _echo_TestSurrounding(struct pipes_struct *p, struct echo_TestSurrounding *r)
113 p->rng_fault_state = True;
117 uint16 _echo_TestDoublePointer(struct pipes_struct *p, struct echo_TestDoublePointer *r)
119 p->rng_fault_state = True;