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. */
26 #include "../librpc/gen_ndr/srv_echo.h"
29 #define DBGC_CLASS DBGC_RPC_SRV
31 /* Add one to the input and return it */
33 void _echo_AddOne(struct pipes_struct
*p
, struct echo_AddOne
*r
)
35 DEBUG(10, ("_echo_AddOne\n"));
37 *r
->out
.out_data
= r
->in
.in_data
+ 1;
40 /* Echo back an array of data */
42 void _echo_EchoData(struct pipes_struct
*p
, struct echo_EchoData
*r
)
44 DEBUG(10, ("_echo_EchoData\n"));
46 if ( r
->in
.len
== 0 ) {
47 r
->out
.out_data
= NULL
;
51 r
->out
.out_data
= talloc_array(p
->mem_ctx
, uint8
, r
->in
.len
);
52 memcpy( r
->out
.out_data
, r
->in
.in_data
, r
->in
.len
);
56 /* Sink an array of data */
58 void _echo_SinkData(struct pipes_struct
*p
, struct echo_SinkData
*r
)
60 DEBUG(10, ("_echo_SinkData\n"));
62 /* My that was some yummy data! */
66 /* Source an array of data */
68 void _echo_SourceData(struct pipes_struct
*p
, struct echo_SourceData
*r
)
72 DEBUG(10, ("_echo_SourceData\n"));
74 if ( r
->in
.len
== 0 ) {
79 r
->out
.data
= talloc_array(p
->mem_ctx
, uint8
, r
->in
.len
);
81 for (i
= 0; i
< r
->in
.len
; i
++ ) {
82 r
->out
.data
[i
] = i
& 0xff;
88 void _echo_TestCall(struct pipes_struct
*p
, struct echo_TestCall
*r
)
90 p
->fault_state
= DCERPC_FAULT_OP_RNG_ERROR
;
94 NTSTATUS
_echo_TestCall2(struct pipes_struct
*p
, struct echo_TestCall2
*r
)
96 p
->fault_state
= DCERPC_FAULT_OP_RNG_ERROR
;
100 uint32
_echo_TestSleep(struct pipes_struct
*p
, struct echo_TestSleep
*r
)
102 smb_msleep(r
->in
.seconds
* 1000);
106 void _echo_TestEnum(struct pipes_struct
*p
, struct echo_TestEnum
*r
)
108 p
->fault_state
= DCERPC_FAULT_OP_RNG_ERROR
;
112 void _echo_TestSurrounding(struct pipes_struct
*p
, struct echo_TestSurrounding
*r
)
114 p
->fault_state
= DCERPC_FAULT_OP_RNG_ERROR
;
118 uint16
_echo_TestDoublePointer(struct pipes_struct
*p
, struct echo_TestDoublePointer
*r
)
120 p
->fault_state
= DCERPC_FAULT_OP_RNG_ERROR
;