2 * Unix SMB/Netbios implementation.
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.
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. */
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
;
45 /* grab the net server get info */
46 if (!srv_io_q_net_srv_get_info("", &q_u
, data
, 0))
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))
58 /*******************************************************************
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
;
72 /* grab the net file enum */
73 if (!srv_io_q_net_file_enum("", &q_u
, data
, 0))
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))
85 /*******************************************************************
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
;
99 /* grab the net server get enum */
100 if (!srv_io_q_net_conn_enum("", &q_u
, data
, 0))
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))
112 /*******************************************************************
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
;
126 /* grab the net server get enum */
127 if (!srv_io_q_net_sess_enum("", &q_u
, data
, 0))
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))
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
;
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"));
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"));
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
;
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"));
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"));
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
;
214 /* grab the net server get enum */
215 if(!srv_io_q_net_remote_tod("", &q_u
, data
, 0))
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))
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
},
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
);