2 Unix SMB/CIFS implementation.
6 Copyright (C) Tim Potter 2003
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 2 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, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 NTSTATUS
cli_echo_add_one(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
26 uint32 request
, uint32
*response
)
28 prs_struct qbuf
, rbuf
;
36 /* Initialise parse structures */
38 if (!prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
)) {
39 return NT_STATUS_NO_MEMORY
;
41 if (!prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
)) {
43 return NT_STATUS_NO_MEMORY
;
46 /* Marshall data and send request */
48 init_echo_q_add_one(&q
, request
);
50 if (!echo_io_q_add_one("", &q
, &qbuf
, 0) ||
51 !rpc_api_pipe_req(cli
, PI_ECHO
, ECHO_ADD_ONE
, &qbuf
, &rbuf
))
54 /* Unmarshall response */
56 if (!echo_io_r_add_one("", &r
, &rbuf
, 0))
60 *response
= r
.response
;
68 return result
? NT_STATUS_OK
: NT_STATUS_UNSUCCESSFUL
;
71 NTSTATUS
cli_echo_data(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
72 uint32 size
, char *in_data
, char **out_data
)
74 prs_struct qbuf
, rbuf
;
82 /* Initialise parse structures */
84 if (!prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
)) {
85 return NT_STATUS_NO_MEMORY
;
87 if (!prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
)) {
89 return NT_STATUS_NO_MEMORY
;
92 /* Marshall data and send request */
94 init_echo_q_echo_data(&q
, size
, in_data
);
96 if (!echo_io_q_echo_data("", &q
, &qbuf
, 0) ||
97 !rpc_api_pipe_req(cli
, PI_ECHO
, ECHO_DATA
, &qbuf
, &rbuf
))
100 /* Unmarshall response */
102 if (!echo_io_r_echo_data("", &r
, &rbuf
, 0))
108 *out_data
= TALLOC(mem_ctx
, size
);
109 memcpy(*out_data
, r
.data
, size
);
116 return result
? NT_STATUS_OK
: NT_STATUS_UNSUCCESSFUL
;
119 NTSTATUS
cli_echo_sink_data(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
120 uint32 size
, char *in_data
)
122 prs_struct qbuf
, rbuf
;
130 /* Initialise parse structures */
132 if (!prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
)) {
133 return NT_STATUS_NO_MEMORY
;
135 if (!prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
)) {
137 return NT_STATUS_NO_MEMORY
;
140 /* Marshall data and send request */
142 init_echo_q_sink_data(&q
, size
, in_data
);
144 if (!echo_io_q_sink_data("", &q
, &qbuf
, 0) ||
145 !rpc_api_pipe_req(cli
, PI_ECHO
, ECHO_SINK_DATA
, &qbuf
, &rbuf
)) {
149 /* Unmarshall response */
151 if (!echo_io_r_sink_data("", &r
, &rbuf
, 0)) {
161 return result
? NT_STATUS_OK
: NT_STATUS_UNSUCCESSFUL
;
164 NTSTATUS
cli_echo_source_data(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
165 uint32 size
, char **out_data
)
167 prs_struct qbuf
, rbuf
;
168 ECHO_Q_SOURCE_DATA q
;
169 ECHO_R_SOURCE_DATA r
;
175 /* Initialise parse structures */
177 if (!prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
)) {
178 return NT_STATUS_NO_MEMORY
;
180 if (!prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
)) {
182 return NT_STATUS_NO_MEMORY
;
185 /* Marshall data and send request */
187 init_echo_q_source_data(&q
, size
);
189 if (!echo_io_q_source_data("", &q
, &qbuf
, 0) ||
190 !rpc_api_pipe_req(cli
, PI_ECHO
, ECHO_SOURCE_DATA
, &qbuf
, &rbuf
)) {
194 /* Unmarshall response */
196 if (!echo_io_r_source_data("", &r
, &rbuf
, 0)) {
206 return result
? NT_STATUS_OK
: NT_STATUS_UNSUCCESSFUL
;