source: branches/samba-3.3.x/source/rpc_server/srv_ntsvcs.c

Last change on this file was 206, checked in by Herwig Bauernfeind, 16 years ago

Import Samba 3.3 branch at 3.0.0 level (psmedley's port)

File size: 5.1 KB
Line 
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
28static bool proxy_ntsvcs_call(pipes_struct *p, uint8_t opnum)
29{
30 struct api_struct *fns;
31 int n_fns;
32
33 ntsvcs_get_pipe_fns(&fns, &n_fns);
34
35 if (opnum >= n_fns) {
36 return false;
37 }
38
39 if (fns[opnum].opnum != opnum) {
40 smb_panic("NTSVCS function table not sorted");
41 }
42
43 return fns[opnum].fn(p);
44}
45
46/*******************************************************************
47 ********************************************************************/
48
49static bool api_ntsvcs_get_version(pipes_struct *p)
50{
51 return proxy_ntsvcs_call(p, NDR_PNP_GETVERSION);
52}
53
54/*******************************************************************
55 ********************************************************************/
56
57static bool api_ntsvcs_get_device_list_size(pipes_struct *p)
58{
59 return proxy_ntsvcs_call(p, NDR_PNP_GETDEVICELISTSIZE);
60}
61
62/*******************************************************************
63 ********************************************************************/
64
65static bool api_ntsvcs_get_device_list(pipes_struct *p)
66{
67 NTSVCS_Q_GET_DEVICE_LIST q_u;
68 NTSVCS_R_GET_DEVICE_LIST r_u;
69 prs_struct *data = &p->in_data.data;
70 prs_struct *rdata = &p->out_data.rdata;
71
72 ZERO_STRUCT(q_u);
73 ZERO_STRUCT(r_u);
74
75 if(!ntsvcs_io_q_get_device_list("", &q_u, data, 0))
76 return False;
77
78 r_u.status = _ntsvcs_get_device_list(p, &q_u, &r_u);
79
80 if(!ntsvcs_io_r_get_device_list("", &r_u, rdata, 0))
81 return False;
82
83 return True;
84}
85
86/*******************************************************************
87 ********************************************************************/
88
89static bool api_ntsvcs_validate_device_instance(pipes_struct *p)
90{
91 return proxy_ntsvcs_call(p, NDR_PNP_VALIDATEDEVICEINSTANCE);
92}
93
94/*******************************************************************
95 ********************************************************************/
96
97static bool api_ntsvcs_get_device_reg_property(pipes_struct *p)
98{
99 NTSVCS_Q_GET_DEVICE_REG_PROPERTY q_u;
100 NTSVCS_R_GET_DEVICE_REG_PROPERTY r_u;
101 prs_struct *data = &p->in_data.data;
102 prs_struct *rdata = &p->out_data.rdata;
103
104 ZERO_STRUCT(q_u);
105 ZERO_STRUCT(r_u);
106
107 if(!ntsvcs_io_q_get_device_reg_property("", &q_u, data, 0))
108 return False;
109
110 r_u.status = _ntsvcs_get_device_reg_property(p, &q_u, &r_u);
111
112 if(!ntsvcs_io_r_get_device_reg_property("", &r_u, rdata, 0))
113 return False;
114
115 return True;
116}
117
118/*******************************************************************
119 ********************************************************************/
120
121static bool api_ntsvcs_get_hw_profile_info(pipes_struct *p)
122{
123 return proxy_ntsvcs_call(p, NDR_PNP_GETHWPROFINFO);
124}
125
126/*******************************************************************
127 ********************************************************************/
128
129static bool api_ntsvcs_hw_profile_flags(pipes_struct *p)
130{
131 return proxy_ntsvcs_call(p, NDR_PNP_HWPROFFLAGS);
132}
133
134/*******************************************************************
135 \PIPE\svcctl commands
136 ********************************************************************/
137
138static struct api_struct api_ntsvcs_cmds[] =
139{
140 { "NTSVCS_GET_VERSION" , NTSVCS_GET_VERSION , api_ntsvcs_get_version },
141 { "NTSVCS_GET_DEVICE_LIST_SIZE" , NTSVCS_GET_DEVICE_LIST_SIZE , api_ntsvcs_get_device_list_size },
142 { "NTSVCS_GET_DEVICE_LIST" , NTSVCS_GET_DEVICE_LIST , api_ntsvcs_get_device_list },
143 { "NTSVCS_VALIDATE_DEVICE_INSTANCE" , NTSVCS_VALIDATE_DEVICE_INSTANCE , api_ntsvcs_validate_device_instance },
144 { "NTSVCS_GET_DEVICE_REG_PROPERTY" , NTSVCS_GET_DEVICE_REG_PROPERTY , api_ntsvcs_get_device_reg_property },
145 { "NTSVCS_GET_HW_PROFILE_INFO" , NTSVCS_GET_HW_PROFILE_INFO , api_ntsvcs_get_hw_profile_info },
146 { "NTSVCS_HW_PROFILE_FLAGS" , NTSVCS_HW_PROFILE_FLAGS , api_ntsvcs_hw_profile_flags }
147};
148
149
150void ntsvcs2_get_pipe_fns( struct api_struct **fns, int *n_fns )
151{
152 *fns = api_ntsvcs_cmds;
153 *n_fns = sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct);
154}
155
156NTSTATUS rpc_ntsvcs2_init(void)
157{
158 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
159 "ntsvcs", "ntsvcs",
160 &ndr_table_ntsvcs.syntax_id,
161 api_ntsvcs_cmds,
162 sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct));
163}
Note: See TracBrowser for help on using the repository browser.