rpc_client/cli_echo.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003 
00004    RPC pipe client
00005 
00006    Copyright (C) Tim Potter 2003
00007    Copyright (C) Jeremy Allison 2005.
00008    
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; either version 2 of the License, or
00012    (at your option) any later version.
00013    
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018    
00019    You should have received a copy of the GNU General Public License
00020    along with this program; if not, write to the Free Software
00021    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00022 */
00023 
00024 #include "includes.h"
00025 
00026 NTSTATUS rpccli_echo_add_one(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00027                           uint32 request, uint32 *response)
00028 {
00029         prs_struct qbuf, rbuf;
00030         ECHO_Q_ADD_ONE q;
00031         ECHO_R_ADD_ONE r;
00032         BOOL result = False;
00033 
00034         ZERO_STRUCT(q);
00035         ZERO_STRUCT(r);
00036 
00037         /* Marshall data and send request */
00038 
00039         init_echo_q_add_one(&q, request);
00040 
00041         CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_ADD_ONE,
00042                         q, r,
00043                         qbuf, rbuf,
00044                         echo_io_q_add_one,
00045                         echo_io_r_add_one,
00046                         NT_STATUS_UNSUCCESSFUL);
00047 
00048         if (response)
00049                 *response = r.response;
00050 
00051         result = True;
00052 
00053         return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
00054 }
00055 
00056 NTSTATUS rpccli_echo_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00057                        uint32 size, char *in_data, char **out_data)
00058 {
00059         prs_struct qbuf, rbuf;
00060         ECHO_Q_ECHO_DATA q;
00061         ECHO_R_ECHO_DATA r;
00062         BOOL result = False;
00063 
00064         ZERO_STRUCT(q);
00065         ZERO_STRUCT(r);
00066 
00067         /* Marshall data and send request */
00068 
00069         init_echo_q_echo_data(&q, size, in_data);
00070 
00071         CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_DATA,
00072                         q, r,
00073                         qbuf, rbuf,
00074                         echo_io_q_echo_data,
00075                         echo_io_r_echo_data,
00076                         NT_STATUS_UNSUCCESSFUL);
00077 
00078         result = True;
00079 
00080         if (out_data) {
00081                 *out_data = TALLOC(mem_ctx, size);
00082                 if (!*out_data) {
00083                         return NT_STATUS_NO_MEMORY;
00084                 }
00085                 memcpy(*out_data, r.data, size);
00086         }
00087 
00088         return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
00089 }
00090 
00091 NTSTATUS rpccli_echo_sink_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00092                             uint32 size, char *in_data)
00093 {
00094         prs_struct qbuf, rbuf;
00095         ECHO_Q_SINK_DATA q;
00096         ECHO_R_SINK_DATA r;
00097         BOOL result = False;
00098 
00099         ZERO_STRUCT(q);
00100         ZERO_STRUCT(r);
00101 
00102         /* Marshall data and send request */
00103 
00104         init_echo_q_sink_data(&q, size, in_data);
00105 
00106         CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_SINK_DATA,
00107                         q, r,
00108                         qbuf, rbuf,
00109                         echo_io_q_sink_data,
00110                         echo_io_r_sink_data,
00111                         NT_STATUS_UNSUCCESSFUL);
00112 
00113         result = True;
00114 
00115         return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
00116 }
00117 
00118 NTSTATUS rpccli_echo_source_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00119                               uint32 size, char **out_data)
00120 {
00121         prs_struct qbuf, rbuf;
00122         ECHO_Q_SOURCE_DATA q;
00123         ECHO_R_SOURCE_DATA r;
00124         BOOL result = False;
00125 
00126         ZERO_STRUCT(q);
00127         ZERO_STRUCT(r);
00128 
00129         /* Marshall data and send request */
00130 
00131         init_echo_q_source_data(&q, size);
00132 
00133         CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_SOURCE_DATA,
00134                         q, r,
00135                         qbuf, rbuf,
00136                         echo_io_q_source_data,
00137                         echo_io_r_source_data,
00138                         NT_STATUS_UNSUCCESSFUL);
00139 
00140         result = True;
00141 
00142         return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
00143 }

Sambaに対してSat Aug 29 21:23:15 2009に生成されました。  doxygen 1.4.7