2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Gerald Carter 2005.
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 3 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, see <http://www.gnu.org/licenses/>.
23 #define DBGC_CLASS DBGC_RPC_SRV
25 /*******************************************************************
26 ********************************************************************/
28 static bool proxy_ntsvcs_call(pipes_struct *p, uint8_t opnum)
30 struct api_struct *fns;
33 ntsvcs_get_pipe_fns(&fns, &n_fns);
39 if (fns[opnum].opnum != opnum) {
40 smb_panic("NTSVCS function table not sorted");
43 return fns[opnum].fn(p);
46 /*******************************************************************
47 ********************************************************************/
49 static bool api_ntsvcs_get_version(pipes_struct *p)
51 return proxy_ntsvcs_call(p, NDR_PNP_GETVERSION);
54 /*******************************************************************
55 ********************************************************************/
57 static bool api_ntsvcs_get_device_list_size(pipes_struct *p)
59 NTSVCS_Q_GET_DEVICE_LIST_SIZE q_u;
60 NTSVCS_R_GET_DEVICE_LIST_SIZE r_u;
61 prs_struct *data = &p->in_data.data;
62 prs_struct *rdata = &p->out_data.rdata;
67 if(!ntsvcs_io_q_get_device_list_size("", &q_u, data, 0))
70 r_u.status = _ntsvcs_get_device_list_size(p, &q_u, &r_u);
72 if(!ntsvcs_io_r_get_device_list_size("", &r_u, rdata, 0))
78 /*******************************************************************
79 ********************************************************************/
81 static bool api_ntsvcs_get_device_list(pipes_struct *p)
83 NTSVCS_Q_GET_DEVICE_LIST q_u;
84 NTSVCS_R_GET_DEVICE_LIST r_u;
85 prs_struct *data = &p->in_data.data;
86 prs_struct *rdata = &p->out_data.rdata;
91 if(!ntsvcs_io_q_get_device_list("", &q_u, data, 0))
94 r_u.status = _ntsvcs_get_device_list(p, &q_u, &r_u);
96 if(!ntsvcs_io_r_get_device_list("", &r_u, rdata, 0))
102 /*******************************************************************
103 ********************************************************************/
105 static bool api_ntsvcs_validate_device_instance(pipes_struct *p)
107 NTSVCS_Q_VALIDATE_DEVICE_INSTANCE q_u;
108 NTSVCS_R_VALIDATE_DEVICE_INSTANCE r_u;
109 prs_struct *data = &p->in_data.data;
110 prs_struct *rdata = &p->out_data.rdata;
115 if(!ntsvcs_io_q_validate_device_instance("", &q_u, data, 0))
118 r_u.status = _ntsvcs_validate_device_instance(p, &q_u, &r_u);
120 if(!ntsvcs_io_r_validate_device_instance("", &r_u, rdata, 0))
126 /*******************************************************************
127 ********************************************************************/
129 static bool api_ntsvcs_get_device_reg_property(pipes_struct *p)
131 NTSVCS_Q_GET_DEVICE_REG_PROPERTY q_u;
132 NTSVCS_R_GET_DEVICE_REG_PROPERTY r_u;
133 prs_struct *data = &p->in_data.data;
134 prs_struct *rdata = &p->out_data.rdata;
139 if(!ntsvcs_io_q_get_device_reg_property("", &q_u, data, 0))
142 r_u.status = _ntsvcs_get_device_reg_property(p, &q_u, &r_u);
144 if(!ntsvcs_io_r_get_device_reg_property("", &r_u, rdata, 0))
150 /*******************************************************************
151 ********************************************************************/
153 static bool api_ntsvcs_get_hw_profile_info(pipes_struct *p)
155 NTSVCS_Q_GET_HW_PROFILE_INFO q_u;
156 NTSVCS_R_GET_HW_PROFILE_INFO r_u;
157 prs_struct *data = &p->in_data.data;
158 prs_struct *rdata = &p->out_data.rdata;
163 if(!ntsvcs_io_q_get_hw_profile_info("", &q_u, data, 0))
166 r_u.status = _ntsvcs_get_hw_profile_info(p, &q_u, &r_u);
168 if(!ntsvcs_io_r_get_hw_profile_info("", &r_u, rdata, 0))
174 /*******************************************************************
175 ********************************************************************/
177 static bool api_ntsvcs_hw_profile_flags(pipes_struct *p)
179 NTSVCS_Q_HW_PROFILE_FLAGS q_u;
180 NTSVCS_R_HW_PROFILE_FLAGS r_u;
181 prs_struct *data = &p->in_data.data;
182 prs_struct *rdata = &p->out_data.rdata;
187 if(!ntsvcs_io_q_hw_profile_flags("", &q_u, data, 0))
190 r_u.status = _ntsvcs_hw_profile_flags(p, &q_u, &r_u);
192 if(!ntsvcs_io_r_hw_profile_flags("", &r_u, rdata, 0))
198 /*******************************************************************
199 \PIPE\svcctl commands
200 ********************************************************************/
202 static struct api_struct api_ntsvcs_cmds[] =
204 { "NTSVCS_GET_VERSION" , NTSVCS_GET_VERSION , api_ntsvcs_get_version },
205 { "NTSVCS_GET_DEVICE_LIST_SIZE" , NTSVCS_GET_DEVICE_LIST_SIZE , api_ntsvcs_get_device_list_size },
206 { "NTSVCS_GET_DEVICE_LIST" , NTSVCS_GET_DEVICE_LIST , api_ntsvcs_get_device_list },
207 { "NTSVCS_VALIDATE_DEVICE_INSTANCE" , NTSVCS_VALIDATE_DEVICE_INSTANCE , api_ntsvcs_validate_device_instance },
208 { "NTSVCS_GET_DEVICE_REG_PROPERTY" , NTSVCS_GET_DEVICE_REG_PROPERTY , api_ntsvcs_get_device_reg_property },
209 { "NTSVCS_GET_HW_PROFILE_INFO" , NTSVCS_GET_HW_PROFILE_INFO , api_ntsvcs_get_hw_profile_info },
210 { "NTSVCS_HW_PROFILE_FLAGS" , NTSVCS_HW_PROFILE_FLAGS , api_ntsvcs_hw_profile_flags }
214 void ntsvcs2_get_pipe_fns( struct api_struct **fns, int *n_fns )
216 *fns = api_ntsvcs_cmds;
217 *n_fns = sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct);
220 NTSTATUS rpc_ntsvcs2_init(void)
222 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "ntsvcs", "ntsvcs", api_ntsvcs_cmds,
223 sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct));