r7573: you can't make an omlette without break a few eggs....start reworking the...
[samba.git] / source3 / include / rpc_svcctl.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB parameters and setup
4    Copyright (C) Andrew Tridgell              1992-1997,
5    Copyright (C) Gerald (Jerry) Carter        2005
6    
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 2 of the License, or
10    (at your option) any later version.
11    
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.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #ifndef _RPC_SVCCTL_H /* _RPC_SVCCTL_H */
23 #define _RPC_SVCCTL_H 
24
25
26 /* svcctl pipe */
27
28 #define SVCCTL_CLOSE_SERVICE                    0x00
29 #define SVCCTL_CONTROL_SERVICE                  0x01
30 #define SVCCTL_QUERY_STATUS                     0x06
31 #define SVCCTL_ENUM_DEPENDENT_SERVICES_W        0x0d
32 #define SVCCTL_ENUM_SERVICES_STATUS_W           0x0e
33 #define SVCCTL_OPEN_SCMANAGER_W                 0x0f
34 #define SVCCTL_OPEN_SERVICE_W                   0x10
35 #define SVCCTL_QUERY_SERVICE_CONFIG_W           0x11
36 #define SVCCTL_START_SERVICE_W                  0x13
37 #define SVCCTL_GET_DISPLAY_NAME                 0x14
38 #define SVCCTL_QUERY_SERVICE_CONFIG2_W          0x27
39 #define SVCCTL_QUERY_SERVICE_STATUSEX_W         0x28
40
41 /* ANSI versions not implemented currently 
42 #define SVCCTL_ENUM_SERVICES_STATUS_A           0x0e
43 #define SVCCTL_OPEN_SCMANAGER_A                 0x1b
44 */
45
46 /* SERVER_STATUS - type */
47
48 #define SVCCTL_TYPE_WIN32               0x00000030
49 #define SVCCTL_TYPE_DRIVER              0x0000000f
50
51 /* SERVER_STATUS - state */
52 #define SVCCTL_STATE_ACTIVE             0x00000001
53 #define SVCCTL_STATE_INACTIVE           0x00000002
54 #define SVCCTL_STATE_ALL                ( SVCCTL_STATE_ACTIVE | SVCCTL_STATE_INACTIVE )
55
56 /* SERVER_STATUS - CurrentState */
57
58 #define SVCCTL_STOPPED                  0x00000001
59 #define SVCCTL_START_PENDING            0x00000002
60 #define SVCCTL_STOP_PENDING             0x00000003
61 #define SVCCTL_RUNNING                  0x00000004
62 #define SVCCTL_CONTINUE_PENDING         0x00000005
63 #define SVCCTL_PAUSE_PENDING            0x00000006
64 #define SVCCTL_PAUSED                   0x00000007
65
66 /* SERVER_STATUS - ControlAccepted */
67
68 #define SVCCTL_ACCEPT_STOP                      0x00000001
69 #define SVCCTL_ACCEPT_PAUSE_CONTINUE            0x00000002
70 #define SVCCTL_ACCEPT_SHUTDOWN                  0x00000004
71 #define SVCCTL_ACCEPT_PARAMCHANGE               0x00000008
72 #define SVCCTL_ACCEPT_NETBINDCHANGE             0x00000010
73 #define SVCCTL_ACCEPT_HARDWAREPROFILECHANGE     0x00000020
74 #define SVCCTL_ACCEPT_POWEREVENT                0x00000040
75
76 /* SERVER_STATUS - ControlAccepted */
77 #define SVCCTL_SVC_ERROR_IGNORE                 0x00000000
78 #define SVCCTL_SVC_ERROR_NORMAL                 0x00000001
79 #define SVCCTL_SVC_ERROR_CRITICAL               0x00000002
80 #define SVCCTL_SVC_ERROR_SEVERE                 0x00000003
81
82 /* QueryServiceConfig2 options */
83 #define SERVICE_CONFIG_DESCRIPTION              0x00000001
84 #define SERVICE_CONFIG_FAILURE_ACTIONS          0x00000002
85
86
87 /* Service Config - values for ServiceType field*/
88
89 #define SVCCTL_KERNEL_DRVR                         0x00000001  /* doubtful we'll have these */
90 #define SVCCTL_FILE_SYSTEM_DRVR                    0x00000002  
91 #define SVCCTL_WIN32_OWN_PROC                      0x00000010
92 #define SVCCTL_WIN32_SHARED_PROC                   0x00000020
93 #define SVCCTL_WIN32_INTERACTIVE                   0x00000100 
94
95 /* Service Config - values for StartType field */
96 #define SVCCTL_BOOT_START                          0x00000000
97 #define SVCCTL_SYSTEM_START                        0x00000001
98 #define SVCCTL_AUTO_START                          0x00000002
99 #define SVCCTL_DEMAND_START                        0x00000003
100 #define SVCCTL_DISABLED                            0x00000004
101
102 /* Service Controls */
103
104 #define SVCCTL_CONTROL_STOP                     0x00000001
105 #define SVCCTL_CONTROL_PAUSE                    0x00000002
106 #define SVCCTL_CONTROL_CONTINUE                 0x00000003
107 #define SVCCTL_CONTROL_SHUTDOWN                 0x00000004
108
109 #define SVC_HANDLE_IS_SCM                       0x0000001
110 #define SVC_HANDLE_IS_SERVICE                   0x0000002
111
112 #define SVC_STATUS_PROCESS_INFO                 0x00000001
113
114 /* utility structures for RPCs */
115
116 typedef struct {
117         uint32 type;
118         uint32 state;
119         uint32 controls_accepted;
120         uint32 win32_exit_code;
121         uint32 service_exit_code;
122         uint32 check_point;
123         uint32 wait_hint;
124 } SERVICE_STATUS;
125
126 typedef struct {
127         uint32 type;
128         uint32 state;
129         uint32 controls_accepted;
130         uint32 win32_exit_code;
131         uint32 service_exit_code;
132         uint32 check_point;
133         uint32 wait_hint;
134         uint32 process_id;
135         uint32 service_flags;
136 } SERVICE_STATUS_PROCESS;
137
138
139 typedef struct {
140         UNISTR servicename;
141         UNISTR displayname;
142         SERVICE_STATUS status;
143 } ENUM_SERVICES_STATUS;
144
145 typedef struct {
146         uint32 service_type;
147         uint32 start_type;
148         uint32 error_control;
149         UNISTR2 *executablepath;
150         UNISTR2 *loadordergroup;
151         uint32 tag_id;
152         UNISTR2 *dependencies;
153         UNISTR2 *startname;
154         UNISTR2 *displayname;
155 } SERVICE_CONFIG;
156
157 typedef struct {
158         UNISTR2 *description;
159 } SERVICE_DESCRIPTION;
160
161 typedef struct {
162         uint32 type;
163         uint32 delay;
164 } SC_ACTION;
165
166 typedef struct {
167         uint32 reset_period;
168         UNISTR2 *rebootmsg;
169         UNISTR2 *command;
170         uint32  nActions;
171         SC_ACTION *saActions;
172         UNISTR2 *description;
173 } SERVICE_FAILURE_ACTIONS;
174
175
176 typedef struct SCM_info_struct {
177         uint32  type;                    /* should be SVC_HANDLE_IS_SCM */
178         pstring target_server_name;      /* name of the server on which the operation is taking place */
179         pstring target_db_name;          /* name of the database that we're opening */
180 } SCM_info;
181
182 typedef struct Service_info_struct {
183         uint32  type;           /* should be SVC_HANDLE_IS_SERVICE */
184         pstring servicename;    /* the name of the service */
185         pstring servicetype;    /* internal or external */
186         pstring filename;       /* what file name we can find this in, 
187                                    as well as the "index" for what the 
188                                    service name is */
189         pstring provides;
190         pstring dependencies;
191         pstring shouldstart;
192         pstring shouldstop;
193         pstring requiredstart;
194         pstring requiredstop;
195         pstring shortdescription;
196         pstring description;
197 } Service_info;
198
199 /* 
200  * dispatch table of functions to handle the =ServiceControl API
201  */ 
202  
203 typedef struct {
204         /* functions for enumerating subkeys and values */      
205         WERROR  (*stop_service)( void );
206         WERROR  (*start_service) ( void );
207         BOOL    (*service_status)( SERVICE_STATUS *status );
208 } SERVICE_CONTROL_OPS;
209
210 /* structure to store the service handle information  */
211
212 typedef struct _ServiceInfo {
213         uint8                   type;
214         char                    *name;
215         uint32                  access_granted;
216         SERVICE_CONTROL_OPS     *ops;
217 } SERVICE_INFO;
218
219
220 /* rpc structures */
221
222 /**************************/
223
224 typedef struct {
225         POLICY_HND handle;
226 } SVCCTL_Q_CLOSE_SERVICE;
227
228 typedef struct {
229         POLICY_HND handle;
230         WERROR status;
231 } SVCCTL_R_CLOSE_SERVICE;
232
233 /**************************/
234
235 typedef struct {
236         UNISTR2 *servername;
237         UNISTR2 *database; 
238         uint32 access;
239 } SVCCTL_Q_OPEN_SCMANAGER;
240
241 typedef struct {
242         POLICY_HND handle;
243         WERROR status;
244 } SVCCTL_R_OPEN_SCMANAGER;
245
246 /**************************/
247
248 typedef struct {
249         POLICY_HND handle;
250         UNISTR2 servicename;
251         uint32  display_name_len;
252 } SVCCTL_Q_GET_DISPLAY_NAME;
253
254 typedef struct {
255         UNISTR2 displayname;
256         uint32 display_name_len;
257         WERROR status;
258 } SVCCTL_R_GET_DISPLAY_NAME;
259
260 /**************************/
261
262 typedef struct {
263         POLICY_HND handle;
264         UNISTR2 servicename;
265         uint32 access;
266 } SVCCTL_Q_OPEN_SERVICE;
267
268 typedef struct {
269         POLICY_HND handle;
270         WERROR status;
271 } SVCCTL_R_OPEN_SERVICE;
272
273 /**************************/
274
275 typedef struct {
276         POLICY_HND handle;
277         uint32 parmcount;
278         UNISTR4_ARRAY *parameters;
279 } SVCCTL_Q_START_SERVICE;
280
281 typedef struct {
282         WERROR status;
283 } SVCCTL_R_START_SERVICE;
284
285 /**************************/
286
287 typedef struct {
288         POLICY_HND handle;
289         uint32 control;
290 } SVCCTL_Q_CONTROL_SERVICE;
291
292 typedef struct {
293         SERVICE_STATUS svc_status;
294         WERROR status;
295 } SVCCTL_R_CONTROL_SERVICE;
296
297 /**************************/
298
299 typedef struct {
300         POLICY_HND handle;
301 } SVCCTL_Q_QUERY_STATUS;
302
303 typedef struct {
304         SERVICE_STATUS svc_status;
305         WERROR status;
306 } SVCCTL_R_QUERY_STATUS;
307
308 /**************************/
309
310 typedef struct {
311         POLICY_HND handle;
312         uint32 type;
313         uint32 state;
314         uint32 buffer_size;
315         uint32 *resume;
316 } SVCCTL_Q_ENUM_SERVICES_STATUS;
317
318 typedef struct {
319         RPC_BUFFER buffer;
320         uint32 needed;
321         uint32 returned;
322         uint32 *resume;
323         WERROR status;
324 } SVCCTL_R_ENUM_SERVICES_STATUS;
325
326 /**************************/
327
328 typedef struct {
329         POLICY_HND handle;
330         uint32 state;
331         uint32 buffer_size;
332 } SVCCTL_Q_ENUM_DEPENDENT_SERVICES;
333
334 typedef struct {
335         RPC_BUFFER buffer;
336         uint32 needed;
337         uint32 returned;
338         WERROR status;
339 } SVCCTL_R_ENUM_DEPENDENT_SERVICES;
340
341 /**************************/
342
343 typedef struct {
344         POLICY_HND handle;
345         uint32 buffer_size;
346 } SVCCTL_Q_QUERY_SERVICE_CONFIG;
347
348 typedef struct {
349         SERVICE_CONFIG config;
350         uint32 needed;
351         WERROR status;
352 } SVCCTL_R_QUERY_SERVICE_CONFIG;
353
354 typedef struct {
355         POLICY_HND handle;
356         uint32 info_level;
357         uint32 buffer_size;
358 } SVCCTL_Q_QUERY_SERVICE_CONFIG2;
359
360 typedef struct {
361         UNISTR2 *description;
362         uint32 returned;
363         uint32 needed;
364         uint32 offset;
365         WERROR status;
366 } SVCCTL_R_QUERY_SERVICE_CONFIG2;
367
368 typedef struct {
369         POLICY_HND handle;
370         uint32 info_level;
371         uint32 buffer_size;
372 } SVCCTL_Q_QUERY_SERVICE_STATUSEX;
373
374 typedef struct {
375         RPC_BUFFER buffer;
376         uint32 returned;
377         uint32 needed;
378         WERROR status;
379 } SVCCTL_R_QUERY_SERVICE_STATUSEX;
380
381 #endif /* _RPC_SVCCTL_H */
382