r20830: merge mgmt work
[nivanova/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 2 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, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "rpc_server/dcerpc_server.h"
25 #include "librpc/gen_ndr/ndr_mgmt.h"
26 #include "rpc_server/common/common.h"
27
28 /* 
29   mgmt_inq_if_ids 
30 */
31 static WERROR mgmt_inq_if_ids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
32                        struct mgmt_inq_if_ids *r)
33 {
34         const struct dcesrv_endpoint *ep = dce_call->conn->endpoint;
35         struct dcesrv_if_list *l;
36         struct rpc_if_id_vector_t *vector;
37
38         vector = *r->out.if_id_vector = talloc(mem_ctx, struct rpc_if_id_vector_t);
39         vector->count = 0;
40         vector->if_id = NULL;
41         for (l = ep->interface_list; l; l = l->next) {
42                 vector->count++;
43                 vector->if_id = talloc_realloc(mem_ctx, vector->if_id, struct dcerpc_syntax_id_p, vector->count);
44                 vector->if_id[vector->count-1].id = &l->iface.syntax_id;
45         }
46         return WERR_OK;
47 }
48
49
50 /* 
51   mgmt_inq_stats 
52 */
53 static WERROR mgmt_inq_stats(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
54                        struct mgmt_inq_stats *r)
55 {
56         if (r->in.max_count != MGMT_STATS_ARRAY_MAX_SIZE)
57                 return WERR_NOT_SUPPORTED;
58
59         r->out.statistics->count = r->in.max_count;
60         r->out.statistics->statistics = talloc_array(mem_ctx, uint32_t, r->in.max_count);
61         /* FIXME */
62         r->out.statistics->statistics[MGMT_STATS_CALLS_IN] = 0;
63         r->out.statistics->statistics[MGMT_STATS_CALLS_OUT] = 0;
64         r->out.statistics->statistics[MGMT_STATS_PKTS_IN] = 0;
65         r->out.statistics->statistics[MGMT_STATS_PKTS_OUT] = 0;
66
67         return WERR_OK;
68 }
69
70
71 /* 
72   mgmt_is_server_listening 
73 */
74 static uint32_t mgmt_is_server_listening(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
75                        struct mgmt_is_server_listening *r)
76 {
77         *r->out.status = 0;
78         return 1;
79 }
80
81
82 /* 
83   mgmt_stop_server_listening 
84 */
85 static WERROR mgmt_stop_server_listening(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
86                        struct mgmt_stop_server_listening *r)
87 {
88         return WERR_ACCESS_DENIED;
89 }
90
91
92 /* 
93   mgmt_inq_princ_name 
94 */
95 static WERROR mgmt_inq_princ_name(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
96                        struct mgmt_inq_princ_name *r)
97 {
98         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
99 }
100
101
102 /* include the generated boilerplate */
103 #include "librpc/gen_ndr/ndr_mgmt_s.c"