4d3428d13cff7ecc13b0c29478b0bee04b3af58d
[sfrench/samba-autobuild/.git] / source4 / rpc_server / dcesrv_mgmt.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    endpoint server for the mgmt pipe
5
6    Copyright (C) Jelmer Vernooij 2006
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "includes.h"
23 #include "rpc_server/dcerpc_server.h"
24 #include "librpc/gen_ndr/ndr_mgmt.h"
25
26 #define DCESRV_INTERFACE_MGMT_BIND(call, iface) \
27        dcesrv_interface_mgmt_bind(call, iface)
28 static NTSTATUS dcesrv_interface_mgmt_bind(struct dcesrv_call_state *dce_call,
29                                              const struct dcesrv_interface *iface)
30 {
31         return dcesrv_interface_bind_allow_connect(dce_call, iface);
32 }
33
34 /* 
35   mgmt_inq_if_ids 
36 */
37 static WERROR dcesrv_mgmt_inq_if_ids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
38                        struct mgmt_inq_if_ids *r)
39 {
40         const struct dcesrv_endpoint *ep = dce_call->conn->endpoint;
41         struct dcesrv_if_list *l;
42         struct rpc_if_id_vector_t *vector;
43
44         vector = *r->out.if_id_vector = talloc(mem_ctx, struct rpc_if_id_vector_t);
45         vector->count = 0;
46         vector->if_id = NULL;
47         for (l = ep->interface_list; l; l = l->next) {
48                 vector->count++;
49                 vector->if_id = talloc_realloc(mem_ctx, vector->if_id, struct ndr_syntax_id_p, vector->count);
50                 vector->if_id[vector->count-1].id = &l->iface.syntax_id;
51         }
52         return WERR_OK;
53 }
54
55
56 /* 
57   mgmt_inq_stats 
58 */
59 static WERROR dcesrv_mgmt_inq_stats(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
60                        struct mgmt_inq_stats *r)
61 {
62         if (r->in.max_count != MGMT_STATS_ARRAY_MAX_SIZE)
63                 return WERR_NOT_SUPPORTED;
64
65         r->out.statistics->count = r->in.max_count;
66         r->out.statistics->statistics = talloc_array(mem_ctx, uint32_t, r->in.max_count);
67         /* FIXME */
68         r->out.statistics->statistics[MGMT_STATS_CALLS_IN] = 0;
69         r->out.statistics->statistics[MGMT_STATS_CALLS_OUT] = 0;
70         r->out.statistics->statistics[MGMT_STATS_PKTS_IN] = 0;
71         r->out.statistics->statistics[MGMT_STATS_PKTS_OUT] = 0;
72
73         return WERR_OK;
74 }
75
76
77 /* 
78   mgmt_is_server_listening 
79 */
80 static uint32_t dcesrv_mgmt_is_server_listening(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
81                        struct mgmt_is_server_listening *r)
82 {
83         *r->out.status = 0;
84         return 1;
85 }
86
87
88 /* 
89   mgmt_stop_server_listening 
90 */
91 static WERROR dcesrv_mgmt_stop_server_listening(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
92                        struct mgmt_stop_server_listening *r)
93 {
94         return WERR_ACCESS_DENIED;
95 }
96
97
98 /* 
99   mgmt_inq_princ_name 
100 */
101 static WERROR dcesrv_mgmt_inq_princ_name(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
102                        struct mgmt_inq_princ_name *r)
103 {
104         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
105 }
106
107
108 /* include the generated boilerplate */
109 #include "librpc/gen_ndr/ndr_mgmt_s.c"