9d4c02500ff2d6a3a158079c9a30412bbf97c50e
[samba.git] / source3 / rpc_server / srv_ntsvcs.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Gerald Carter                   2005.
5  *  
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.
10  *  
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.
15  *  
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/>.
18  */
19
20 #include "includes.h"
21
22 #undef DBGC_CLASS
23 #define DBGC_CLASS DBGC_RPC_SRV
24
25 /*******************************************************************
26  ********************************************************************/
27
28 static BOOL api_ntsvcs_get_version(pipes_struct *p)
29 {
30         NTSVCS_Q_GET_VERSION q_u;
31         NTSVCS_R_GET_VERSION r_u;
32         prs_struct *data = &p->in_data.data;
33         prs_struct *rdata = &p->out_data.rdata;
34
35         ZERO_STRUCT(q_u);
36         ZERO_STRUCT(r_u);
37
38         if(!ntsvcs_io_q_get_version("", &q_u, data, 0))
39                 return False;
40
41         r_u.status = _ntsvcs_get_version(p, &q_u, &r_u);
42
43         if(!ntsvcs_io_r_get_version("", &r_u, rdata, 0))
44                 return False;
45
46         return True;
47 }
48
49 /*******************************************************************
50  ********************************************************************/
51
52 static BOOL api_ntsvcs_get_device_list_size(pipes_struct *p)
53 {
54         NTSVCS_Q_GET_DEVICE_LIST_SIZE q_u;
55         NTSVCS_R_GET_DEVICE_LIST_SIZE r_u;
56         prs_struct *data = &p->in_data.data;
57         prs_struct *rdata = &p->out_data.rdata;
58
59         ZERO_STRUCT(q_u);
60         ZERO_STRUCT(r_u);
61
62         if(!ntsvcs_io_q_get_device_list_size("", &q_u, data, 0))
63                 return False;
64
65         r_u.status = _ntsvcs_get_device_list_size(p, &q_u, &r_u);
66
67         if(!ntsvcs_io_r_get_device_list_size("", &r_u, rdata, 0))
68                 return False;
69
70         return True;
71 }
72
73 /*******************************************************************
74  ********************************************************************/
75
76 static BOOL api_ntsvcs_get_device_list(pipes_struct *p)
77 {
78         NTSVCS_Q_GET_DEVICE_LIST q_u;
79         NTSVCS_R_GET_DEVICE_LIST r_u;
80         prs_struct *data = &p->in_data.data;
81         prs_struct *rdata = &p->out_data.rdata;
82
83         ZERO_STRUCT(q_u);
84         ZERO_STRUCT(r_u);
85
86         if(!ntsvcs_io_q_get_device_list("", &q_u, data, 0))
87                 return False;
88
89         r_u.status = _ntsvcs_get_device_list(p, &q_u, &r_u);
90
91         if(!ntsvcs_io_r_get_device_list("", &r_u, rdata, 0))
92                 return False;
93
94         return True;
95 }
96
97 /*******************************************************************
98  ********************************************************************/
99
100 static BOOL api_ntsvcs_validate_device_instance(pipes_struct *p)
101 {
102         NTSVCS_Q_VALIDATE_DEVICE_INSTANCE q_u;
103         NTSVCS_R_VALIDATE_DEVICE_INSTANCE r_u;
104         prs_struct *data = &p->in_data.data;
105         prs_struct *rdata = &p->out_data.rdata;
106
107         ZERO_STRUCT(q_u);
108         ZERO_STRUCT(r_u);
109
110         if(!ntsvcs_io_q_validate_device_instance("", &q_u, data, 0))
111                 return False;
112
113         r_u.status = _ntsvcs_validate_device_instance(p, &q_u, &r_u);
114
115         if(!ntsvcs_io_r_validate_device_instance("", &r_u, rdata, 0))
116                 return False;
117
118         return True;
119 }
120
121 /*******************************************************************
122  ********************************************************************/
123
124 static BOOL api_ntsvcs_get_device_reg_property(pipes_struct *p)
125 {
126         NTSVCS_Q_GET_DEVICE_REG_PROPERTY q_u;
127         NTSVCS_R_GET_DEVICE_REG_PROPERTY r_u;
128         prs_struct *data = &p->in_data.data;
129         prs_struct *rdata = &p->out_data.rdata;
130
131         ZERO_STRUCT(q_u);
132         ZERO_STRUCT(r_u);
133
134         if(!ntsvcs_io_q_get_device_reg_property("", &q_u, data, 0))
135                 return False;
136
137         r_u.status = _ntsvcs_get_device_reg_property(p, &q_u, &r_u);
138
139         if(!ntsvcs_io_r_get_device_reg_property("", &r_u, rdata, 0))
140                 return False;
141
142         return True;
143 }
144
145 /*******************************************************************
146  ********************************************************************/
147
148 static BOOL api_ntsvcs_get_hw_profile_info(pipes_struct *p)
149 {
150         NTSVCS_Q_GET_HW_PROFILE_INFO q_u;
151         NTSVCS_R_GET_HW_PROFILE_INFO r_u;
152         prs_struct *data = &p->in_data.data;
153         prs_struct *rdata = &p->out_data.rdata;
154
155         ZERO_STRUCT(q_u);
156         ZERO_STRUCT(r_u);
157
158         if(!ntsvcs_io_q_get_hw_profile_info("", &q_u, data, 0))
159                 return False;
160
161         r_u.status = _ntsvcs_get_hw_profile_info(p, &q_u, &r_u);
162
163         if(!ntsvcs_io_r_get_hw_profile_info("", &r_u, rdata, 0))
164                 return False;
165
166         return True;
167 }
168
169 /*******************************************************************
170  ********************************************************************/
171
172 static BOOL api_ntsvcs_hw_profile_flags(pipes_struct *p)
173 {
174         NTSVCS_Q_HW_PROFILE_FLAGS q_u;
175         NTSVCS_R_HW_PROFILE_FLAGS r_u;
176         prs_struct *data = &p->in_data.data;
177         prs_struct *rdata = &p->out_data.rdata;
178
179         ZERO_STRUCT(q_u);
180         ZERO_STRUCT(r_u);
181
182         if(!ntsvcs_io_q_hw_profile_flags("", &q_u, data, 0))
183                 return False;
184
185         r_u.status = _ntsvcs_hw_profile_flags(p, &q_u, &r_u);
186
187         if(!ntsvcs_io_r_hw_profile_flags("", &r_u, rdata, 0))
188                 return False;
189
190         return True;
191 }
192
193 /*******************************************************************
194  \PIPE\svcctl commands
195  ********************************************************************/
196
197 static struct api_struct api_ntsvcs_cmds[] =
198 {
199       { "NTSVCS_GET_VERSION"              , NTSVCS_GET_VERSION              , api_ntsvcs_get_version },
200       { "NTSVCS_GET_DEVICE_LIST_SIZE"     , NTSVCS_GET_DEVICE_LIST_SIZE     , api_ntsvcs_get_device_list_size },
201       { "NTSVCS_GET_DEVICE_LIST"          , NTSVCS_GET_DEVICE_LIST          , api_ntsvcs_get_device_list },
202       { "NTSVCS_VALIDATE_DEVICE_INSTANCE" , NTSVCS_VALIDATE_DEVICE_INSTANCE , api_ntsvcs_validate_device_instance },
203       { "NTSVCS_GET_DEVICE_REG_PROPERTY"  , NTSVCS_GET_DEVICE_REG_PROPERTY  , api_ntsvcs_get_device_reg_property },
204       { "NTSVCS_GET_HW_PROFILE_INFO"      , NTSVCS_GET_HW_PROFILE_INFO      , api_ntsvcs_get_hw_profile_info },
205       { "NTSVCS_HW_PROFILE_FLAGS"         , NTSVCS_HW_PROFILE_FLAGS         , api_ntsvcs_hw_profile_flags }
206 };
207
208
209 void ntsvcs_get_pipe_fns( struct api_struct **fns, int *n_fns )
210 {
211         *fns = api_ntsvcs_cmds;
212         *n_fns = sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct);
213 }
214
215 NTSTATUS rpc_ntsvcs_init(void)
216 {
217   return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "ntsvcs", "ntsvcs", api_ntsvcs_cmds,
218                                     sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct));
219 }