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 prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
);
39 prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
);
41 /* Marshall data and send request */
43 init_echo_q_add_one(&q
, request
);
45 if (!echo_io_q_add_one("", &q
, &qbuf
, 0) ||
46 !rpc_api_pipe_req(cli
, ECHO_ADD_ONE
, &qbuf
, &rbuf
))
49 /* Unmarshall response */
51 if (!echo_io_r_add_one("", &r
, &rbuf
, 0))
55 *response
= r
.response
;
63 return result
? NT_STATUS_OK
: NT_STATUS_UNSUCCESSFUL
;
66 NTSTATUS
cli_echo_data(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
67 uint32 size
, char *in_data
, char **out_data
)
69 prs_struct qbuf
, rbuf
;
77 /* Initialise parse structures */
79 prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
);
80 prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
);
82 /* Marshall data and send request */
84 init_echo_q_echo_data(&q
, size
, in_data
);
86 if (!echo_io_q_echo_data("", &q
, &qbuf
, 0) ||
87 !rpc_api_pipe_req(cli
, ECHO_DATA
, &qbuf
, &rbuf
))
90 /* Unmarshall response */
92 if (!echo_io_r_echo_data("", &r
, &rbuf
, 0))
98 *out_data
= talloc(mem_ctx
, size
);
99 memcpy(*out_data
, r
.data
, size
);
106 return result
? NT_STATUS_OK
: NT_STATUS_UNSUCCESSFUL
;
109 NTSTATUS
cli_echo_sink_data(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
110 uint32 size
, char *in_data
)
112 prs_struct qbuf
, rbuf
;
120 /* Initialise parse structures */
122 prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
);
123 prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
);
125 /* Marshall data and send request */
127 init_echo_q_sink_data(&q
, size
, in_data
);
129 if (!echo_io_q_sink_data("", &q
, &qbuf
, 0) ||
130 !rpc_api_pipe_req(cli
, ECHO_SINK_DATA
, &qbuf
, &rbuf
)) {
134 /* Unmarshall response */
136 if (!echo_io_r_sink_data("", &r
, &rbuf
, 0)) {
146 return result
? NT_STATUS_OK
: NT_STATUS_UNSUCCESSFUL
;
149 NTSTATUS
cli_echo_source_data(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
150 uint32 size
, char **out_data
)
152 prs_struct qbuf
, rbuf
;
153 ECHO_Q_SOURCE_DATA q
;
154 ECHO_R_SOURCE_DATA r
;
160 /* Initialise parse structures */
162 prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
);
163 prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
);
165 /* Marshall data and send request */
167 init_echo_q_source_data(&q
, size
);
169 if (!echo_io_q_source_data("", &q
, &qbuf
, 0) ||
170 !rpc_api_pipe_req(cli
, ECHO_SOURCE_DATA
, &qbuf
, &rbuf
)) {
174 /* Unmarshall response */
176 if (!echo_io_r_source_data("", &r
, &rbuf
, 0)) {
186 return result
? NT_STATUS_OK
: NT_STATUS_UNSUCCESSFUL
;