s3: Lift the server_messaging_context from notify_job_status
[Samba/gbeck.git] / source3 / rpcclient / cmd_ntsvcs.c
blob95b905ab2ddf3330a8d5df0d0f38246a4b3e3703
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/cli_ntsvcs.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 NTSTATUS status;
31 WERROR werr;
32 uint16_t version;
34 status = rpccli_PNP_GetVersion(cli, mem_ctx,
35 &version, &werr);
36 if (!NT_STATUS_IS_OK(status)) {
37 return ntstatus_to_werror(status);
40 if (W_ERROR_IS_OK(werr)) {
41 printf("version: %d\n", version);
44 return werr;
47 static WERROR cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client *cli,
48 TALLOC_CTX *mem_ctx,
49 int argc,
50 const char **argv)
52 NTSTATUS status;
53 WERROR werr;
54 const char *devicepath = NULL;
55 uint32_t flags = 0;
57 if (argc < 2 || argc > 3) {
58 printf("usage: %s [devicepath] <flags>\n", argv[0]);
59 return WERR_OK;
62 devicepath = argv[1];
64 if (argc >= 3) {
65 flags = atoi(argv[2]);
68 status = rpccli_PNP_ValidateDeviceInstance(cli, mem_ctx,
69 devicepath,
70 flags,
71 &werr);
72 if (!NT_STATUS_IS_OK(status)) {
73 return ntstatus_to_werror(status);
76 return werr;
79 static WERROR cmd_ntsvcs_hw_prof_flags(struct rpc_pipe_client *cli,
80 TALLOC_CTX *mem_ctx,
81 int argc,
82 const char **argv)
84 NTSTATUS status;
85 WERROR werr;
86 const char *devicepath = NULL;
87 uint32_t profile_flags = 0;
88 uint16_t veto_type = 0;
89 const char *unk5 = NULL;
90 const char *unk5a = NULL;
92 if (argc < 2) {
93 printf("usage: %s [devicepath]\n", argv[0]);
94 return WERR_OK;
97 devicepath = argv[1];
99 status = rpccli_PNP_HwProfFlags(cli, mem_ctx,
101 devicepath,
103 &profile_flags,
104 &veto_type,
105 unk5,
106 &unk5a,
109 &werr);
110 if (!NT_STATUS_IS_OK(status)) {
111 return ntstatus_to_werror(status);
114 return werr;
117 static WERROR cmd_ntsvcs_get_hw_prof_info(struct rpc_pipe_client *cli,
118 TALLOC_CTX *mem_ctx,
119 int argc,
120 const char **argv)
122 NTSTATUS status;
123 WERROR werr;
124 uint32_t idx = 0;
125 struct PNP_HwProfInfo info;
126 uint32_t size = 0, flags = 0;
128 ZERO_STRUCT(info);
130 status = rpccli_PNP_GetHwProfInfo(cli, mem_ctx,
131 idx,
132 &info,
133 size,
134 flags,
135 &werr);
136 if (!NT_STATUS_IS_OK(status)) {
137 return ntstatus_to_werror(status);
140 return werr;
143 static WERROR cmd_ntsvcs_get_dev_reg_prop(struct rpc_pipe_client *cli,
144 TALLOC_CTX *mem_ctx,
145 int argc,
146 const char **argv)
148 NTSTATUS status;
149 WERROR werr;
150 const char *devicepath = NULL;
151 uint32_t property = DEV_REGPROP_DESC;
152 uint32_t reg_data_type = REG_NONE;
153 uint8_t *buffer;
154 uint32_t buffer_size = 0;
155 uint32_t needed = 0;
156 uint32_t flags = 0;
158 if (argc < 2) {
159 printf("usage: %s [devicepath] [buffersize]\n", argv[0]);
160 return WERR_OK;
163 devicepath = argv[1];
165 if (argc >= 3) {
166 buffer_size = atoi(argv[2]);
167 needed = buffer_size;
170 buffer = talloc_array(mem_ctx, uint8_t, buffer_size);
171 W_ERROR_HAVE_NO_MEMORY(buffer);
173 status = rpccli_PNP_GetDeviceRegProp(cli, mem_ctx,
174 devicepath,
175 property,
176 &reg_data_type,
177 buffer,
178 &buffer_size,
179 &needed,
180 flags,
181 &werr);
182 if (!NT_STATUS_IS_OK(status)) {
183 return ntstatus_to_werror(status);
186 return werr;
189 static WERROR cmd_ntsvcs_get_dev_list_size(struct rpc_pipe_client *cli,
190 TALLOC_CTX *mem_ctx,
191 int argc,
192 const char **argv)
194 NTSTATUS status;
195 WERROR werr;
196 uint32_t size = 0;
197 uint32_t flags = 0;
198 const char *filter = NULL;
200 if (argc > 3) {
201 printf("usage: %s [filter] [flags]\n", argv[0]);
202 return WERR_OK;
205 if (argc >= 2) {
206 filter = argv[1];
209 if (argc >= 3) {
210 flags = atoi(argv[2]);
213 status = rpccli_PNP_GetDeviceListSize(cli, mem_ctx,
214 filter,
215 &size,
216 flags,
217 &werr);
218 if (!NT_STATUS_IS_OK(status)) {
219 return ntstatus_to_werror(status);
222 printf("size: %d\n", size);
224 return werr;
227 static WERROR cmd_ntsvcs_get_dev_list(struct rpc_pipe_client *cli,
228 TALLOC_CTX *mem_ctx,
229 int argc,
230 const char **argv)
232 NTSTATUS status;
233 WERROR werr;
234 const char *filter = NULL;
235 uint16_t *buffer = NULL;
236 uint32_t length = 0;
237 uint32_t flags = 0;
239 if (argc > 4) {
240 printf("usage: %s [filter] [length] [flags]\n", argv[0]);
241 return WERR_OK;
244 if (argc >= 2) {
245 filter = argv[1];
248 if (argc >= 3) {
249 length = atoi(argv[2]);
252 if (argc >= 4) {
253 flags = atoi(argv[3]);
256 buffer = talloc(mem_ctx, uint16_t);
257 if (!buffer) {
258 return WERR_NOMEM;
261 status = rpccli_PNP_GetDeviceList(cli, mem_ctx,
262 filter,
263 buffer,
264 &length,
265 flags,
266 &werr);
267 if (!NT_STATUS_IS_OK(status)) {
268 return ntstatus_to_werror(status);
271 printf("devlist needs size: %d\n", length);
273 return werr;
276 struct cmd_set ntsvcs_commands[] = {
278 { "NTSVCS" },
279 { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS version", "" },
280 { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS device instance", "" },
281 { "ntsvcs_hwprofflags", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_hw_prof_flags, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS HW prof flags", "" },
282 { "ntsvcs_hwprofinfo", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_hw_prof_info, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS HW prof info", "" },
283 { "ntsvcs_getdevregprop", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_dev_reg_prop, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS device registry property", "" },
284 { "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_dev_list_size, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS device list size", "" },
285 { "ntsvcs_getdevlist", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_dev_list, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS device list", "" },
286 { NULL }