make proto
[Samba/gbeck.git] / source / rpc_server / srv_srvsvc.c
bloba3176bfd739c667746ec08abb91f0fb79b86d924
1 /*
2 * Unix SMB/Netbios implementation.
3 * Version 1.9.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1997,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7 * Copyright (C) Paul Ashton 1997.
8 * Copyright (C) Jeremy Allison 2001.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /* This is the interface to the srvsvc pipe. */
27 #include "includes.h"
29 extern int DEBUGLEVEL;
31 /*******************************************************************
32 api_srv_net_srv_get_info
33 ********************************************************************/
35 static BOOL api_srv_net_srv_get_info(pipes_struct *p)
37 SRV_Q_NET_SRV_GET_INFO q_u;
38 SRV_R_NET_SRV_GET_INFO r_u;
39 prs_struct *data = &p->in_data.data;
40 prs_struct *rdata = &p->out_data.rdata;
42 ZERO_STRUCT(q_u);
43 ZERO_STRUCT(r_u);
45 /* grab the net server get info */
46 if (!srv_io_q_net_srv_get_info("", &q_u, data, 0))
47 return False;
49 r_u.status = _srv_net_srv_get_info(p, &q_u, &r_u);
51 /* store the response in the SMB stream */
52 if (!srv_io_r_net_srv_get_info("", &r_u, rdata, 0))
53 return False;
55 return True;
58 /*******************************************************************
59 api_srv_net_file_enum
60 ********************************************************************/
62 static BOOL api_srv_net_file_enum(pipes_struct *p)
64 SRV_Q_NET_FILE_ENUM q_u;
65 SRV_R_NET_FILE_ENUM r_u;
66 prs_struct *data = &p->in_data.data;
67 prs_struct *rdata = &p->out_data.rdata;
69 ZERO_STRUCT(q_u);
70 ZERO_STRUCT(r_u);
72 /* grab the net file enum */
73 if (!srv_io_q_net_file_enum("", &q_u, data, 0))
74 return False;
76 r_u.status = _srv_net_file_enum(p, &q_u, &r_u);
78 /* store the response in the SMB stream */
79 if(!srv_io_r_net_file_enum("", &r_u, rdata, 0))
80 return False;
82 return True;
85 /*******************************************************************
86 api_srv_net_conn_enum
87 ********************************************************************/
89 static BOOL api_srv_net_conn_enum(pipes_struct *p)
91 SRV_Q_NET_CONN_ENUM q_u;
92 SRV_R_NET_CONN_ENUM r_u;
93 prs_struct *data = &p->in_data.data;
94 prs_struct *rdata = &p->out_data.rdata;
96 ZERO_STRUCT(q_u);
97 ZERO_STRUCT(r_u);
99 /* grab the net server get enum */
100 if (!srv_io_q_net_conn_enum("", &q_u, data, 0))
101 return False;
103 r_u.status = _srv_net_conn_enum(p, &q_u, &r_u);
105 /* store the response in the SMB stream */
106 if (!srv_io_r_net_conn_enum("", &r_u, rdata, 0))
107 return False;
109 return True;
112 /*******************************************************************
113 Enumerate sessions.
114 ********************************************************************/
116 static BOOL api_srv_net_sess_enum(pipes_struct *p)
118 SRV_Q_NET_SESS_ENUM q_u;
119 SRV_R_NET_SESS_ENUM r_u;
120 prs_struct *data = &p->in_data.data;
121 prs_struct *rdata = &p->out_data.rdata;
123 ZERO_STRUCT(q_u);
124 ZERO_STRUCT(r_u);
126 /* grab the net server get enum */
127 if (!srv_io_q_net_sess_enum("", &q_u, data, 0))
128 return False;
130 /* construct reply. always indicate success */
131 r_u.status = _srv_net_sess_enum(p, &q_u, &r_u);
133 /* store the response in the SMB stream */
134 if (!srv_io_r_net_sess_enum("", &r_u, rdata, 0))
135 return False;
137 return True;
140 /*******************************************************************
141 RPC to enumerate shares.
142 ********************************************************************/
144 static BOOL api_srv_net_share_enum(pipes_struct *p)
146 SRV_Q_NET_SHARE_ENUM q_u;
147 SRV_R_NET_SHARE_ENUM r_u;
148 prs_struct *data = &p->in_data.data;
149 prs_struct *rdata = &p->out_data.rdata;
151 ZERO_STRUCT(q_u);
152 ZERO_STRUCT(r_u);
154 /* Unmarshall the net server get enum. */
155 if(!srv_io_q_net_share_enum("", &q_u, data, 0)) {
156 DEBUG(0,("api_srv_net_share_enum: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n"));
157 return False;
160 r_u.status = _srv_net_share_enum(p, &q_u, &r_u);
162 if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) {
163 DEBUG(0,("api_srv_net_share_enum: Failed to marshall SRV_R_NET_SHARE_ENUM.\n"));
164 return False;
167 return True;
170 /*******************************************************************
171 RPC to return share information.
172 ********************************************************************/
174 static BOOL api_srv_net_share_get_info(pipes_struct *p)
176 SRV_Q_NET_SHARE_GET_INFO q_u;
177 SRV_R_NET_SHARE_GET_INFO r_u;
178 prs_struct *data = &p->in_data.data;
179 prs_struct *rdata = &p->out_data.rdata;
181 ZERO_STRUCT(q_u);
182 ZERO_STRUCT(r_u);
184 /* Unmarshall the net server get info. */
185 if(!srv_io_q_net_share_get_info("", &q_u, data, 0)) {
186 DEBUG(0,("api_srv_net_share_get_info: Failed to unmarshall SRV_Q_NET_SHARE_GET_INFO.\n"));
187 return False;
190 r_u.status = _srv_net_share_get_info(p, &q_u, &r_u);
192 if(!srv_io_r_net_share_get_info("", &r_u, rdata, 0)) {
193 DEBUG(0,("api_srv_net_share_get_info: Failed to marshall SRV_R_NET_SHARE_GET_INFO.\n"));
194 return False;
197 return True;
200 /*******************************************************************
201 api_srv_net_remote_tod
202 ********************************************************************/
204 static BOOL api_srv_net_remote_tod(pipes_struct *p)
206 SRV_Q_NET_REMOTE_TOD q_u;
207 SRV_R_NET_REMOTE_TOD r_u;
208 prs_struct *data = &p->in_data.data;
209 prs_struct *rdata = &p->out_data.rdata;
211 ZERO_STRUCT(q_u);
212 ZERO_STRUCT(r_u);
214 /* grab the net server get enum */
215 if(!srv_io_q_net_remote_tod("", &q_u, data, 0))
216 return False;
218 r_u.status = _srv_net_remote_tod(p, &q_u, &r_u);
220 /* store the response in the SMB stream */
221 if(!srv_io_r_net_remote_tod("", &r_u, rdata, 0))
222 return False;
224 return True;
227 /*******************************************************************
228 \PIPE\srvsvc commands
229 ********************************************************************/
231 struct api_struct api_srv_cmds[] =
233 { "SRV_NETCONNENUM" , SRV_NETCONNENUM , api_srv_net_conn_enum },
234 { "SRV_NETSESSENUM" , SRV_NETSESSENUM , api_srv_net_sess_enum },
235 { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum },
236 { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info },
237 { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum },
238 { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info },
239 { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod },
240 { NULL , 0 , NULL }
243 /*******************************************************************
244 receives a srvsvc pipe and responds.
245 ********************************************************************/
246 BOOL api_srvsvc_rpc(pipes_struct *p)
248 return api_rpcTNP(p, "api_srvsvc_rpc", api_srv_cmds);