2 Unix SMB/CIFS implementation.
5 Copyright (C) Tim Potter 2003
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "rpcclient.h"
25 static NTSTATUS
cmd_echo_add_one(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
26 int argc
, const char **argv
)
28 uint32 request
= 1, response
;
32 printf("Usage: %s [num]\n", argv
[0]);
37 request
= atoi(argv
[1]);
39 result
= rpccli_echo_AddOne(cli
, mem_ctx
, request
, &response
);
41 if (!NT_STATUS_IS_OK(result
))
44 printf("%d + 1 = %d\n", request
, response
);
50 static NTSTATUS
cmd_echo_data(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
51 int argc
, const char **argv
)
55 uint8
*in_data
= NULL
, *out_data
= NULL
;
58 printf("Usage: %s num\n", argv
[0]);
63 in_data
= (uint8
*)SMB_MALLOC(size
);
64 out_data
= (uint8
*)SMB_MALLOC(size
);
66 for (i
= 0; i
< size
; i
++)
67 in_data
[i
] = i
& 0xff;
69 result
= rpccli_echo_EchoData(cli
, mem_ctx
, size
, in_data
, out_data
);
71 if (!NT_STATUS_IS_OK(result
))
74 for (i
= 0; i
< size
; i
++) {
75 if (in_data
[i
] != out_data
[i
]) {
76 printf("mismatch at offset %d, %d != %d\n",
77 i
, in_data
[i
], out_data
[i
]);
78 result
= NT_STATUS_UNSUCCESSFUL
;
89 static NTSTATUS
cmd_echo_source_data(struct rpc_pipe_client
*cli
,
90 TALLOC_CTX
*mem_ctx
, int argc
,
98 printf("Usage: %s num\n", argv
[0]);
102 size
= atoi(argv
[1]);
103 if (!(out_data
= (uint8
*)SMB_MALLOC(size
))) {
104 return NT_STATUS_NO_MEMORY
;
107 result
= rpccli_echo_SourceData(cli
, mem_ctx
, size
, out_data
);
109 if (!NT_STATUS_IS_OK(result
))
112 for (i
= 0; i
< size
; i
++) {
113 if (out_data
[i
] != (i
& 0xff)) {
114 printf("mismatch at offset %d, %d != %d\n",
115 i
, out_data
[i
], i
& 0xff);
116 result
= NT_STATUS_UNSUCCESSFUL
;
126 static NTSTATUS
cmd_echo_sink_data(struct rpc_pipe_client
*cli
, TALLOC_CTX
*mem_ctx
,
127 int argc
, const char **argv
)
131 uint8
*in_data
= NULL
;
134 printf("Usage: %s num\n", argv
[0]);
138 size
= atoi(argv
[1]);
139 in_data
= (uint8
*)SMB_MALLOC(size
);
141 for (i
= 0; i
< size
; i
++)
142 in_data
[i
] = i
& 0xff;
144 result
= rpccli_echo_SinkData(cli
, mem_ctx
, size
, in_data
);
146 if (!NT_STATUS_IS_OK(result
))
155 /* List of commands exported by this module */
157 struct cmd_set echo_commands
[] = {
161 { "echoaddone", RPC_RTYPE_NTSTATUS
, cmd_echo_add_one
, NULL
, PI_RPCECHO
, NULL
, "Add one to a number", "" },
162 { "echodata", RPC_RTYPE_NTSTATUS
, cmd_echo_data
, NULL
, PI_RPCECHO
, NULL
, "Echo data", "" },
163 { "sinkdata", RPC_RTYPE_NTSTATUS
, cmd_echo_sink_data
, NULL
, PI_RPCECHO
, NULL
, "Sink data", "" },
164 { "sourcedata", RPC_RTYPE_NTSTATUS
, cmd_echo_source_data
, NULL
, PI_RPCECHO
, NULL
, "Source data", "" },