| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 |
|
|---|
| 4 | RPC pipe client
|
|---|
| 5 |
|
|---|
| 6 | Copyright (C) Tim Potter 2003
|
|---|
| 7 | Copyright (C) Jeremy Allison 2005.
|
|---|
| 8 |
|
|---|
| 9 | This program is free software; you can redistribute it and/or modify
|
|---|
| 10 | it under the terms of the GNU General Public License as published by
|
|---|
| 11 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 12 | (at your option) any later version.
|
|---|
| 13 |
|
|---|
| 14 | This program is distributed in the hope that it will be useful,
|
|---|
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 17 | GNU General Public License for more details.
|
|---|
| 18 |
|
|---|
| 19 | You should have received a copy of the GNU General Public License
|
|---|
| 20 | along with this program; if not, write to the Free Software
|
|---|
| 21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|---|
| 22 | */
|
|---|
| 23 |
|
|---|
| 24 | #include "includes.h"
|
|---|
| 25 |
|
|---|
| 26 | NTSTATUS rpccli_echo_add_one(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 27 | uint32 request, uint32 *response)
|
|---|
| 28 | {
|
|---|
| 29 | prs_struct qbuf, rbuf;
|
|---|
| 30 | ECHO_Q_ADD_ONE q;
|
|---|
| 31 | ECHO_R_ADD_ONE r;
|
|---|
| 32 | BOOL result = False;
|
|---|
| 33 |
|
|---|
| 34 | ZERO_STRUCT(q);
|
|---|
| 35 | ZERO_STRUCT(r);
|
|---|
| 36 |
|
|---|
| 37 | /* Marshall data and send request */
|
|---|
| 38 |
|
|---|
| 39 | init_echo_q_add_one(&q, request);
|
|---|
| 40 |
|
|---|
| 41 | CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_ADD_ONE,
|
|---|
| 42 | q, r,
|
|---|
| 43 | qbuf, rbuf,
|
|---|
| 44 | echo_io_q_add_one,
|
|---|
| 45 | echo_io_r_add_one,
|
|---|
| 46 | NT_STATUS_UNSUCCESSFUL);
|
|---|
| 47 |
|
|---|
| 48 | if (response)
|
|---|
| 49 | *response = r.response;
|
|---|
| 50 |
|
|---|
| 51 | result = True;
|
|---|
| 52 |
|
|---|
| 53 | return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | NTSTATUS rpccli_echo_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 57 | uint32 size, char *in_data, char **out_data)
|
|---|
| 58 | {
|
|---|
| 59 | prs_struct qbuf, rbuf;
|
|---|
| 60 | ECHO_Q_ECHO_DATA q;
|
|---|
| 61 | ECHO_R_ECHO_DATA r;
|
|---|
| 62 | BOOL result = False;
|
|---|
| 63 |
|
|---|
| 64 | ZERO_STRUCT(q);
|
|---|
| 65 | ZERO_STRUCT(r);
|
|---|
| 66 |
|
|---|
| 67 | /* Marshall data and send request */
|
|---|
| 68 |
|
|---|
| 69 | init_echo_q_echo_data(&q, size, in_data);
|
|---|
| 70 |
|
|---|
| 71 | CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_DATA,
|
|---|
| 72 | q, r,
|
|---|
| 73 | qbuf, rbuf,
|
|---|
| 74 | echo_io_q_echo_data,
|
|---|
| 75 | echo_io_r_echo_data,
|
|---|
| 76 | NT_STATUS_UNSUCCESSFUL);
|
|---|
| 77 |
|
|---|
| 78 | result = True;
|
|---|
| 79 |
|
|---|
| 80 | if (out_data) {
|
|---|
| 81 | *out_data = TALLOC(mem_ctx, size);
|
|---|
| 82 | if (!*out_data) {
|
|---|
| 83 | return NT_STATUS_NO_MEMORY;
|
|---|
| 84 | }
|
|---|
| 85 | memcpy(*out_data, r.data, size);
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | NTSTATUS rpccli_echo_sink_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 92 | uint32 size, char *in_data)
|
|---|
| 93 | {
|
|---|
| 94 | prs_struct qbuf, rbuf;
|
|---|
| 95 | ECHO_Q_SINK_DATA q;
|
|---|
| 96 | ECHO_R_SINK_DATA r;
|
|---|
| 97 | BOOL result = False;
|
|---|
| 98 |
|
|---|
| 99 | ZERO_STRUCT(q);
|
|---|
| 100 | ZERO_STRUCT(r);
|
|---|
| 101 |
|
|---|
| 102 | /* Marshall data and send request */
|
|---|
| 103 |
|
|---|
| 104 | init_echo_q_sink_data(&q, size, in_data);
|
|---|
| 105 |
|
|---|
| 106 | CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_SINK_DATA,
|
|---|
| 107 | q, r,
|
|---|
| 108 | qbuf, rbuf,
|
|---|
| 109 | echo_io_q_sink_data,
|
|---|
| 110 | echo_io_r_sink_data,
|
|---|
| 111 | NT_STATUS_UNSUCCESSFUL);
|
|---|
| 112 |
|
|---|
| 113 | result = True;
|
|---|
| 114 |
|
|---|
| 115 | return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | NTSTATUS rpccli_echo_source_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 119 | uint32 size, char **out_data)
|
|---|
| 120 | {
|
|---|
| 121 | prs_struct qbuf, rbuf;
|
|---|
| 122 | ECHO_Q_SOURCE_DATA q;
|
|---|
| 123 | ECHO_R_SOURCE_DATA r;
|
|---|
| 124 | BOOL result = False;
|
|---|
| 125 |
|
|---|
| 126 | ZERO_STRUCT(q);
|
|---|
| 127 | ZERO_STRUCT(r);
|
|---|
| 128 |
|
|---|
| 129 | /* Marshall data and send request */
|
|---|
| 130 |
|
|---|
| 131 | init_echo_q_source_data(&q, size);
|
|---|
| 132 |
|
|---|
| 133 | CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_SOURCE_DATA,
|
|---|
| 134 | q, r,
|
|---|
| 135 | qbuf, rbuf,
|
|---|
| 136 | echo_io_q_source_data,
|
|---|
| 137 | echo_io_r_source_data,
|
|---|
| 138 | NT_STATUS_UNSUCCESSFUL);
|
|---|
| 139 |
|
|---|
| 140 | result = True;
|
|---|
| 141 |
|
|---|
| 142 | return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
|
|---|
| 143 | }
|
|---|