Second part of the fix for bug 6828 - infinite timeout occurs when byte lock held...
[Samba.git] / source / rpc_server / srv_ntsvcs.c
blob100d577010fa7cfc7b62691d2ef66f98e2555881
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.
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.
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/>.
20 #include "includes.h"
22 #undef DBGC_CLASS
23 #define DBGC_CLASS DBGC_RPC_SRV
25 /*******************************************************************
26 ********************************************************************/
28 static bool proxy_ntsvcs_call(pipes_struct *p, uint8_t opnum)
30 struct api_struct *fns;
31 int n_fns;
33 ntsvcs_get_pipe_fns(&fns, &n_fns);
35 if (opnum >= n_fns) {
36 return false;
39 if (fns[opnum].opnum != opnum) {
40 smb_panic("NTSVCS function table not sorted");
43 return fns[opnum].fn(p);
46 /*******************************************************************
47 ********************************************************************/
49 static bool api_ntsvcs_get_version(pipes_struct *p)
51 return proxy_ntsvcs_call(p, NDR_PNP_GETVERSION);
54 /*******************************************************************
55 ********************************************************************/
57 static bool api_ntsvcs_get_device_list_size(pipes_struct *p)
59 return proxy_ntsvcs_call(p, NDR_PNP_GETDEVICELISTSIZE);
62 /*******************************************************************
63 ********************************************************************/
65 static bool api_ntsvcs_get_device_list(pipes_struct *p)
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;
72 ZERO_STRUCT(q_u);
73 ZERO_STRUCT(r_u);
75 if(!ntsvcs_io_q_get_device_list("", &q_u, data, 0))
76 return False;
78 r_u.status = _ntsvcs_get_device_list(p, &q_u, &r_u);
80 if(!ntsvcs_io_r_get_device_list("", &r_u, rdata, 0))
81 return False;
83 return True;
86 /*******************************************************************
87 ********************************************************************/
89 static bool api_ntsvcs_validate_device_instance(pipes_struct *p)
91 return proxy_ntsvcs_call(p, NDR_PNP_VALIDATEDEVICEINSTANCE);
94 /*******************************************************************
95 ********************************************************************/
97 static bool api_ntsvcs_get_device_reg_property(pipes_struct *p)
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;
104 ZERO_STRUCT(q_u);
105 ZERO_STRUCT(r_u);
107 if(!ntsvcs_io_q_get_device_reg_property("", &q_u, data, 0))
108 return False;
110 r_u.status = _ntsvcs_get_device_reg_property(p, &q_u, &r_u);
112 if(!ntsvcs_io_r_get_device_reg_property("", &r_u, rdata, 0))
113 return False;
115 return True;
118 /*******************************************************************
119 ********************************************************************/
121 static bool api_ntsvcs_get_hw_profile_info(pipes_struct *p)
123 return proxy_ntsvcs_call(p, NDR_PNP_GETHWPROFINFO);
126 /*******************************************************************
127 ********************************************************************/
129 static bool api_ntsvcs_hw_profile_flags(pipes_struct *p)
131 return proxy_ntsvcs_call(p, NDR_PNP_HWPROFFLAGS);
134 /*******************************************************************
135 \PIPE\svcctl commands
136 ********************************************************************/
138 static struct api_struct api_ntsvcs_cmds[] =
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 }
150 void ntsvcs2_get_pipe_fns( struct api_struct **fns, int *n_fns )
152 *fns = api_ntsvcs_cmds;
153 *n_fns = sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct);
156 NTSTATUS rpc_ntsvcs2_init(void)
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));