Line data Source code
1 : /* server functions auto-generated by pidl */
2 : #include "bin/default/librpc/gen_ndr/ndr_mgmt.h"
3 : #include <util/debug.h>
4 :
5 : NTSTATUS dcerpc_server_mgmt_init(TALLOC_CTX *);
6 :
7 : /* mgmt - dcerpc server boilerplate generated by pidl */
8 :
9 :
10 625 : static NTSTATUS mgmt__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
11 : {
12 : #ifdef DCESRV_INTERFACE_MGMT_BIND
13 625 : return DCESRV_INTERFACE_MGMT_BIND(context,iface);
14 : #else
15 : return NT_STATUS_OK;
16 : #endif
17 : }
18 :
19 625 : static void mgmt__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
20 : {
21 : #ifdef DCESRV_INTERFACE_MGMT_UNBIND
22 : DCESRV_INTERFACE_MGMT_UNBIND(context, iface);
23 : #else
24 625 : return;
25 : #endif
26 : }
27 :
28 37512 : static NTSTATUS mgmt__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
29 : {
30 0 : enum ndr_err_code ndr_err;
31 37512 : uint16_t opnum = dce_call->pkt.u.request.opnum;
32 :
33 37512 : dce_call->fault_code = 0;
34 :
35 37512 : if (opnum >= ndr_table_mgmt.num_calls) {
36 54 : dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
37 54 : return NT_STATUS_NET_WRITE_FAULT;
38 : }
39 :
40 74916 : *r = talloc_named(mem_ctx,
41 37458 : ndr_table_mgmt.calls[opnum].struct_size,
42 : "struct %s",
43 37458 : ndr_table_mgmt.calls[opnum].name);
44 37458 : NT_STATUS_HAVE_NO_MEMORY(*r);
45 :
46 : /* unravel the NDR for the packet */
47 37458 : ndr_err = ndr_table_mgmt.calls[opnum].ndr_pull(pull, NDR_IN, *r);
48 37458 : if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
49 0 : dce_call->fault_code = DCERPC_FAULT_NDR;
50 0 : return NT_STATUS_NET_WRITE_FAULT;
51 : }
52 :
53 37458 : return NT_STATUS_OK;
54 : }
55 :
56 37458 : static NTSTATUS mgmt__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
57 : {
58 37458 : uint16_t opnum = dce_call->pkt.u.request.opnum;
59 :
60 37458 : switch (opnum) {
61 459 : case 0: {
62 459 : struct mgmt_inq_if_ids *r2 = (struct mgmt_inq_if_ids *)r;
63 459 : if (DEBUGLEVEL >= 10) {
64 0 : NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_if_ids, NDR_IN, r2);
65 : }
66 459 : r2->out.result = dcesrv_mgmt_inq_if_ids(dce_call, mem_ctx, r2);
67 459 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
68 0 : DEBUG(5,("function mgmt_inq_if_ids will reply async\n"));
69 : }
70 459 : break;
71 : }
72 179 : case 1: {
73 179 : struct mgmt_inq_stats *r2 = (struct mgmt_inq_stats *)r;
74 179 : if (DEBUGLEVEL >= 10) {
75 0 : NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_stats, NDR_IN, r2);
76 : }
77 179 : r2->out.result = dcesrv_mgmt_inq_stats(dce_call, mem_ctx, r2);
78 179 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
79 0 : DEBUG(5,("function mgmt_inq_stats will reply async\n"));
80 : }
81 179 : break;
82 : }
83 161 : case 2: {
84 161 : struct mgmt_is_server_listening *r2 = (struct mgmt_is_server_listening *)r;
85 161 : if (DEBUGLEVEL >= 10) {
86 0 : NDR_PRINT_FUNCTION_DEBUG(mgmt_is_server_listening, NDR_IN, r2);
87 : }
88 161 : r2->out.result = dcesrv_mgmt_is_server_listening(dce_call, mem_ctx, r2);
89 161 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
90 0 : DEBUG(5,("function mgmt_is_server_listening will reply async\n"));
91 : }
92 161 : break;
93 : }
94 173 : case 3: {
95 173 : struct mgmt_stop_server_listening *r2 = (struct mgmt_stop_server_listening *)r;
96 173 : if (DEBUGLEVEL >= 10) {
97 0 : NDR_PRINT_FUNCTION_DEBUG(mgmt_stop_server_listening, NDR_IN, r2);
98 : }
99 173 : r2->out.result = dcesrv_mgmt_stop_server_listening(dce_call, mem_ctx, r2);
100 173 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
101 0 : DEBUG(5,("function mgmt_stop_server_listening will reply async\n"));
102 : }
103 173 : break;
104 : }
105 36486 : case 4: {
106 36486 : struct mgmt_inq_princ_name *r2 = (struct mgmt_inq_princ_name *)r;
107 36486 : if (DEBUGLEVEL >= 10) {
108 0 : NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_princ_name, NDR_IN, r2);
109 : }
110 36486 : r2->out.result = dcesrv_mgmt_inq_princ_name(dce_call, mem_ctx, r2);
111 36486 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
112 0 : DEBUG(5,("function mgmt_inq_princ_name will reply async\n"));
113 : }
114 36486 : break;
115 : }
116 :
117 0 : default:
118 0 : dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
119 0 : break;
120 : }
121 :
122 37458 : if (dce_call->fault_code != 0) {
123 98 : return NT_STATUS_NET_WRITE_FAULT;
124 : }
125 :
126 37360 : return NT_STATUS_OK;
127 : }
128 :
129 37360 : static NTSTATUS mgmt__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
130 : {
131 37360 : uint16_t opnum = dce_call->pkt.u.request.opnum;
132 :
133 37360 : switch (opnum) {
134 459 : case 0: {
135 459 : struct mgmt_inq_if_ids *r2 = (struct mgmt_inq_if_ids *)r;
136 459 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
137 0 : DEBUG(5,("function mgmt_inq_if_ids replied async\n"));
138 : }
139 459 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
140 0 : NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_if_ids, NDR_OUT | NDR_SET_VALUES, r2);
141 : }
142 459 : if (dce_call->fault_code != 0) {
143 0 : DEBUG(2,("dcerpc_fault %s in mgmt_inq_if_ids\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
144 : }
145 459 : break;
146 : }
147 179 : case 1: {
148 179 : struct mgmt_inq_stats *r2 = (struct mgmt_inq_stats *)r;
149 179 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
150 0 : DEBUG(5,("function mgmt_inq_stats replied async\n"));
151 : }
152 179 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
153 0 : NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_stats, NDR_OUT | NDR_SET_VALUES, r2);
154 : }
155 179 : if (dce_call->fault_code != 0) {
156 0 : DEBUG(2,("dcerpc_fault %s in mgmt_inq_stats\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
157 : }
158 179 : break;
159 : }
160 161 : case 2: {
161 161 : struct mgmt_is_server_listening *r2 = (struct mgmt_is_server_listening *)r;
162 161 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
163 0 : DEBUG(5,("function mgmt_is_server_listening replied async\n"));
164 : }
165 161 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
166 0 : NDR_PRINT_FUNCTION_DEBUG(mgmt_is_server_listening, NDR_OUT | NDR_SET_VALUES, r2);
167 : }
168 161 : if (dce_call->fault_code != 0) {
169 0 : DEBUG(2,("dcerpc_fault %s in mgmt_is_server_listening\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
170 : }
171 161 : break;
172 : }
173 173 : case 3: {
174 173 : struct mgmt_stop_server_listening *r2 = (struct mgmt_stop_server_listening *)r;
175 173 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
176 0 : DEBUG(5,("function mgmt_stop_server_listening replied async\n"));
177 : }
178 173 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
179 0 : NDR_PRINT_FUNCTION_DEBUG(mgmt_stop_server_listening, NDR_OUT | NDR_SET_VALUES, r2);
180 : }
181 173 : if (dce_call->fault_code != 0) {
182 0 : DEBUG(2,("dcerpc_fault %s in mgmt_stop_server_listening\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
183 : }
184 173 : break;
185 : }
186 36388 : case 4: {
187 36388 : struct mgmt_inq_princ_name *r2 = (struct mgmt_inq_princ_name *)r;
188 36388 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
189 0 : DEBUG(5,("function mgmt_inq_princ_name replied async\n"));
190 : }
191 36388 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
192 0 : NDR_PRINT_FUNCTION_DEBUG(mgmt_inq_princ_name, NDR_OUT | NDR_SET_VALUES, r2);
193 : }
194 36388 : if (dce_call->fault_code != 0) {
195 0 : DEBUG(2,("dcerpc_fault %s in mgmt_inq_princ_name\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
196 : }
197 36388 : break;
198 : }
199 :
200 0 : default:
201 0 : dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
202 0 : break;
203 : }
204 :
205 37360 : if (dce_call->fault_code != 0) {
206 0 : return NT_STATUS_NET_WRITE_FAULT;
207 : }
208 :
209 37360 : return NT_STATUS_OK;
210 : }
211 :
212 37360 : static NTSTATUS mgmt__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
213 : {
214 0 : enum ndr_err_code ndr_err;
215 37360 : uint16_t opnum = dce_call->pkt.u.request.opnum;
216 :
217 37360 : ndr_err = ndr_table_mgmt.calls[opnum].ndr_push(push, NDR_OUT, r);
218 37360 : if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
219 0 : dce_call->fault_code = DCERPC_FAULT_NDR;
220 0 : return NT_STATUS_NET_WRITE_FAULT;
221 : }
222 :
223 37360 : return NT_STATUS_OK;
224 : }
225 :
226 : static const struct dcesrv_interface dcesrv_mgmt_interface = {
227 : .name = "mgmt",
228 : .syntax_id = {{0xafa8bd80,0x7d8a,0x11c9,{0xbe,0xf4},{0x08,0x00,0x2b,0x10,0x29,0x89}},1.0},
229 : .bind = mgmt__op_bind,
230 : .unbind = mgmt__op_unbind,
231 : .ndr_pull = mgmt__op_ndr_pull,
232 : .dispatch = mgmt__op_dispatch,
233 : .reply = mgmt__op_reply,
234 : .ndr_push = mgmt__op_ndr_push,
235 : .local = NULL,
236 : #ifdef DCESRV_INTERFACE_MGMT_FLAGS
237 : .flags = DCESRV_INTERFACE_MGMT_FLAGS
238 : #else
239 : .flags = 0
240 : #endif
241 : };
242 :
243 :
244 0 : static NTSTATUS mgmt__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
245 : {
246 0 : int i;
247 : #ifdef DCESRV_INTERFACE_MGMT_NCACN_NP_SECONDARY_ENDPOINT
248 : const char *ncacn_np_secondary_endpoint =
249 : DCESRV_INTERFACE_MGMT_NCACN_NP_SECONDARY_ENDPOINT;
250 : #else
251 0 : const char *ncacn_np_secondary_endpoint = NULL;
252 : #endif
253 :
254 0 : for (i=0;i<ndr_table_mgmt.endpoints->count;i++) {
255 0 : NTSTATUS ret;
256 0 : const char *name = ndr_table_mgmt.endpoints->names[i];
257 :
258 0 : ret = dcesrv_interface_register(dce_ctx,
259 : name,
260 : ncacn_np_secondary_endpoint,
261 : &dcesrv_mgmt_interface,
262 : NULL);
263 0 : if (!NT_STATUS_IS_OK(ret)) {
264 0 : DEBUG(1,("mgmt_op_init_server: failed to register endpoint '%s'\n",name));
265 0 : return ret;
266 : }
267 : }
268 :
269 0 : return NT_STATUS_OK;
270 : }
271 :
272 0 : static NTSTATUS mgmt__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
273 : {
274 0 : return NT_STATUS_OK;
275 : }
276 :
277 0 : static bool mgmt__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
278 : {
279 0 : if (dcesrv_mgmt_interface.syntax_id.if_version == if_version &&
280 0 : GUID_equal(&dcesrv_mgmt_interface.syntax_id.uuid, uuid)) {
281 0 : memcpy(iface,&dcesrv_mgmt_interface, sizeof(*iface));
282 0 : return true;
283 : }
284 :
285 0 : return false;
286 : }
287 :
288 0 : static bool mgmt__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
289 : {
290 0 : if (strcmp(dcesrv_mgmt_interface.name, name)==0) {
291 0 : memcpy(iface, &dcesrv_mgmt_interface, sizeof(*iface));
292 0 : return true;
293 : }
294 :
295 0 : return false;
296 : }
297 :
298 0 : NTSTATUS dcerpc_server_mgmt_init(TALLOC_CTX *ctx)
299 : {
300 0 : NTSTATUS ret;
301 0 : static const struct dcesrv_endpoint_server ep_server = {
302 : /* fill in our name */
303 : .name = "mgmt",
304 :
305 : /* Initialization flag */
306 : .initialized = false,
307 :
308 : /* fill in all the operations */
309 : #ifdef DCESRV_INTERFACE_MGMT_INIT_SERVER
310 : .init_server = DCESRV_INTERFACE_MGMT_INIT_SERVER,
311 : #else
312 : .init_server = mgmt__op_init_server,
313 : #endif
314 : #ifdef DCESRV_INTERFACE_MGMT_SHUTDOWN_SERVER
315 : .shutdown_server = DCESRV_INTERFACE_MGMT_SHUTDOWN_SERVER,
316 : #else
317 : .shutdown_server = mgmt__op_shutdown_server,
318 : #endif
319 : .interface_by_uuid = mgmt__op_interface_by_uuid,
320 : .interface_by_name = mgmt__op_interface_by_name
321 : };
322 : /* register ourselves with the DCERPC subsystem. */
323 0 : ret = dcerpc_register_ep_server(&ep_server);
324 :
325 0 : if (!NT_STATUS_IS_OK(ret)) {
326 0 : DEBUG(0,("Failed to register 'mgmt' endpoint server!\n"));
327 0 : return ret;
328 : }
329 :
330 0 : return ret;
331 : }
332 :
|