[GLUE] Rsync SAMBA_3_0 SVN r25598 in order to create the v3-0-test branch.
[Samba.git] / source / rpc_server / srv_echo.c
blobc6cfde07c15e678b23070352ec8cdd19fe1aea48
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines for rpcecho
4 * Copyright (C) Tim Potter 2003.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 /* This is the interface to the rpcecho pipe. */
23 #include "includes.h"
24 #include "nterr.h"
26 #ifdef DEVELOPER
28 #undef DBGC_CLASS
29 #define DBGC_CLASS DBGC_RPC_SRV
31 static BOOL api_add_one(pipes_struct *p)
33 ECHO_Q_ADD_ONE q_u;
34 ECHO_R_ADD_ONE r_u;
36 prs_struct *data = &p->in_data.data;
37 prs_struct *rdata = &p->out_data.rdata;
39 ZERO_STRUCT(q_u);
40 ZERO_STRUCT(r_u);
42 if(!echo_io_q_add_one("", &q_u, data, 0))
43 return False;
45 _echo_add_one(p, &q_u, &r_u);
47 if(!echo_io_r_add_one("", &r_u, rdata, 0))
48 return False;
50 return True;
53 static BOOL api_echo_data(pipes_struct *p)
55 ECHO_Q_ECHO_DATA q_u;
56 ECHO_R_ECHO_DATA r_u;
58 prs_struct *data = &p->in_data.data;
59 prs_struct *rdata = &p->out_data.rdata;
61 ZERO_STRUCT(q_u);
62 ZERO_STRUCT(r_u);
64 if(!echo_io_q_echo_data("", &q_u, data, 0))
65 return False;
67 _echo_data(p, &q_u, &r_u);
69 if(!echo_io_r_echo_data("", &r_u, rdata, 0))
70 return False;
72 return True;
75 static BOOL api_source_data(pipes_struct *p)
77 ECHO_Q_SOURCE_DATA q_u;
78 ECHO_R_SOURCE_DATA r_u;
80 prs_struct *data = &p->in_data.data;
81 prs_struct *rdata = &p->out_data.rdata;
83 ZERO_STRUCT(q_u);
84 ZERO_STRUCT(r_u);
86 if(!echo_io_q_source_data("", &q_u, data, 0))
87 return False;
89 _source_data(p, &q_u, &r_u);
91 if(!echo_io_r_source_data("", &r_u, rdata, 0))
92 return False;
94 return True;
97 static BOOL api_sink_data(pipes_struct *p)
99 ECHO_Q_SINK_DATA q_u;
100 ECHO_R_SINK_DATA r_u;
102 prs_struct *data = &p->in_data.data;
103 prs_struct *rdata = &p->out_data.rdata;
105 ZERO_STRUCT(q_u);
106 ZERO_STRUCT(r_u);
108 if(!echo_io_q_sink_data("", &q_u, data, 0))
109 return False;
111 _sink_data(p, &q_u, &r_u);
113 if(!echo_io_r_sink_data("", &r_u, rdata, 0))
114 return False;
116 return True;
119 /*******************************************************************
120 \pipe\rpcecho commands
121 ********************************************************************/
123 struct api_struct api_echo_cmds[] = {
124 {"ADD_ONE", ECHO_ADD_ONE, api_add_one },
125 {"ECHO_DATA", ECHO_DATA, api_echo_data },
126 {"SOURCE_DATA", ECHO_SOURCE_DATA, api_source_data },
127 {"SINK_DATA", ECHO_SINK_DATA, api_sink_data },
131 void echo_get_pipe_fns( struct api_struct **fns, int *n_fns )
133 *fns = api_echo_cmds;
134 *n_fns = sizeof(api_echo_cmds) / sizeof(struct api_struct);
137 NTSTATUS rpc_echo_init(void)
139 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
140 "rpcecho", "rpcecho", api_echo_cmds,
141 sizeof(api_echo_cmds) / sizeof(struct api_struct));
144 #else /* DEVELOPER */
146 NTSTATUS rpc_echo_init(void)
148 return NT_STATUS_OK;
150 #endif /* DEVELOPER */