tevent: expose tevent_context_init_ops
[Samba/gebeck_regimport.git] / source3 / rpcclient / cmd_ntsvcs.c
blobfaccbc8cf1b11c028a474531a2b230fa20a42b8e
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
5 Copyright (C) G√ľnther Deschner 2008
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "rpcclient.h"
23 #include "../librpc/gen_ndr/ndr_ntsvcs_c.h"
25 static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli,
26 TALLOC_CTX *mem_ctx,
27 int argc,
28 const char **argv)
30 struct dcerpc_binding_handle *b = cli->binding_handle;
31 NTSTATUS status;
32 WERROR werr;
33 uint16_t version;
35 status = dcerpc_PNP_GetVersion(b, mem_ctx,
36 &version, &werr);
37 if (!NT_STATUS_IS_OK(status)) {
38 return ntstatus_to_werror(status);
41 if (W_ERROR_IS_OK(werr)) {
42 printf("version: %d\n", version);
45 return werr;
48 static WERROR cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client *cli,
49 TALLOC_CTX *mem_ctx,
50 int argc,
51 const char **argv)
53 struct dcerpc_binding_handle *b = cli->binding_handle;
54 NTSTATUS status;
55 WERROR werr;
56 const char *devicepath = NULL;
57 uint32_t flags = 0;
59 if (argc < 2 || argc > 3) {
60 printf("usage: %s [devicepath] <flags>\n", argv[0]);
61 return WERR_OK;
64 devicepath = argv[1];
66 if (argc >= 3) {
67 flags = atoi(argv[2]);
70 status = dcerpc_PNP_ValidateDeviceInstance(b, mem_ctx,
71 devicepath,
72 flags,
73 &werr);
74 if (!NT_STATUS_IS_OK(status)) {
75 return ntstatus_to_werror(status);
78 return werr;
81 static WERROR cmd_ntsvcs_hw_prof_flags(struct rpc_pipe_client *cli,
82 TALLOC_CTX *mem_ctx,
83 int argc,
84 const char **argv)
86 struct dcerpc_binding_handle *b = cli->binding_handle;
87 NTSTATUS status;
88 WERROR werr;
89 const char *devicepath = NULL;
90 uint32_t profile_flags = 0;
91 uint16_t veto_type = 0;
92 const char *unk5 = NULL;
93 const char *unk5a = NULL;
95 if (argc < 2) {
96 printf("usage: %s [devicepath]\n", argv[0]);
97 return WERR_OK;
100 devicepath = argv[1];
102 status = dcerpc_PNP_HwProfFlags(b, mem_ctx,
104 devicepath,
106 &profile_flags,
107 &veto_type,
108 unk5,
109 &unk5a,
112 &werr);
113 if (!NT_STATUS_IS_OK(status)) {
114 return ntstatus_to_werror(status);
117 return werr;
120 static WERROR cmd_ntsvcs_get_hw_prof_info(struct rpc_pipe_client *cli,
121 TALLOC_CTX *mem_ctx,
122 int argc,
123 const char **argv)
125 struct dcerpc_binding_handle *b = cli->binding_handle;
126 NTSTATUS status;
127 WERROR werr;
128 uint32_t idx = 0;
129 struct PNP_HwProfInfo info;
130 uint32_t size = 0, flags = 0;
132 ZERO_STRUCT(info);
134 status = dcerpc_PNP_GetHwProfInfo(b, mem_ctx,
135 idx,
136 &info,
137 size,
138 flags,
139 &werr);
140 if (!NT_STATUS_IS_OK(status)) {
141 return ntstatus_to_werror(status);
144 return werr;
147 static WERROR cmd_ntsvcs_get_dev_reg_prop(struct rpc_pipe_client *cli,
148 TALLOC_CTX *mem_ctx,
149 int argc,
150 const char **argv)
152 struct dcerpc_binding_handle *b = cli->binding_handle;
153 NTSTATUS status;
154 WERROR werr;
155 const char *devicepath = NULL;
156 uint32_t property = DEV_REGPROP_DESC;
157 uint32_t reg_data_type = REG_NONE;
158 uint8_t *buffer;
159 uint32_t buffer_size = 0;
160 uint32_t needed = 0;
161 uint32_t flags = 0;
163 if (argc < 2) {
164 printf("usage: %s [devicepath] [buffersize]\n", argv[0]);
165 return WERR_OK;
168 devicepath = argv[1];
170 if (argc >= 3) {
171 buffer_size = atoi(argv[2]);
172 needed = buffer_size;
175 buffer = talloc_array(mem_ctx, uint8_t, buffer_size);
176 W_ERROR_HAVE_NO_MEMORY(buffer);
178 status = dcerpc_PNP_GetDeviceRegProp(b, mem_ctx,
179 devicepath,
180 property,
181 &reg_data_type,
182 buffer,
183 &buffer_size,
184 &needed,
185 flags,
186 &werr);
187 if (!NT_STATUS_IS_OK(status)) {
188 return ntstatus_to_werror(status);
191 return werr;
194 static WERROR cmd_ntsvcs_get_dev_list_size(struct rpc_pipe_client *cli,
195 TALLOC_CTX *mem_ctx,
196 int argc,
197 const char **argv)
199 struct dcerpc_binding_handle *b = cli->binding_handle;
200 NTSTATUS status;
201 WERROR werr;
202 uint32_t size = 0;
203 uint32_t flags = 0;
204 const char *filter = NULL;
206 if (argc > 3) {
207 printf("usage: %s [filter] [flags]\n", argv[0]);
208 return WERR_OK;
211 if (argc >= 2) {
212 filter = argv[1];
215 if (argc >= 3) {
216 flags = atoi(argv[2]);
219 status = dcerpc_PNP_GetDeviceListSize(b, mem_ctx,
220 filter,
221 &size,
222 flags,
223 &werr);
224 if (!NT_STATUS_IS_OK(status)) {
225 return ntstatus_to_werror(status);
228 printf("size: %d\n", size);
230 return werr;
233 static WERROR cmd_ntsvcs_get_dev_list(struct rpc_pipe_client *cli,
234 TALLOC_CTX *mem_ctx,
235 int argc,
236 const char **argv)
238 struct dcerpc_binding_handle *b = cli->binding_handle;
239 NTSTATUS status;
240 WERROR werr;
241 const char *filter = NULL;
242 uint16_t *buffer = NULL;
243 uint32_t length = 0;
244 uint32_t flags = 0;
246 if (argc > 4) {
247 printf("usage: %s [filter] [length] [flags]\n", argv[0]);
248 return WERR_OK;
251 if (argc >= 2) {
252 filter = argv[1];
255 if (argc >= 3) {
256 length = atoi(argv[2]);
259 if (argc >= 4) {
260 flags = atoi(argv[3]);
263 buffer = talloc(mem_ctx, uint16_t);
264 if (!buffer) {
265 return WERR_NOMEM;
268 status = dcerpc_PNP_GetDeviceList(b, mem_ctx,
269 filter,
270 buffer,
271 &length,
272 flags,
273 &werr);
274 if (!NT_STATUS_IS_OK(status)) {
275 return ntstatus_to_werror(status);
278 printf("devlist needs size: %d\n", length);
280 return werr;
283 struct cmd_set ntsvcs_commands[] = {
285 { "NTSVCS" },
286 { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, &ndr_table_ntsvcs, NULL, "Query NTSVCS version", "" },
287 { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, &ndr_table_ntsvcs, NULL, "Query NTSVCS device instance", "" },
288 { "ntsvcs_hwprofflags", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_hw_prof_flags, &ndr_table_ntsvcs, NULL, "Query NTSVCS HW prof flags", "" },
289 { "ntsvcs_hwprofinfo", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_hw_prof_info, &ndr_table_ntsvcs, NULL, "Query NTSVCS HW prof info", "" },
290 { "ntsvcs_getdevregprop", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_dev_reg_prop, &ndr_table_ntsvcs, NULL, "Query NTSVCS device registry property", "" },
291 { "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_dev_list_size, &ndr_table_ntsvcs, NULL, "Query NTSVCS device list size", "" },
292 { "ntsvcs_getdevlist", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_dev_list, &ndr_table_ntsvcs, NULL, "Query NTSVCS device list", "" },
293 { NULL }