2 Unix SMB/CIFS implementation.
5 Copyright (C) Günther Deschner 2015
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "rpcclient.h"
23 #include "../librpc/gen_ndr/ndr_clusapi_c.h"
25 static WERROR
cmd_clusapi_open_cluster(struct rpc_pipe_client
*cli
,
30 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
33 struct policy_handle Cluster
;
35 status
= dcerpc_clusapi_OpenCluster(b
, mem_ctx
,
38 if (!NT_STATUS_IS_OK(status
)) {
39 return ntstatus_to_werror(status
);
42 if (!W_ERROR_IS_OK(error
)) {
43 printf("error: %s\n", win_errstr(error
));
47 printf("successfully opened cluster\n");
49 status
= dcerpc_clusapi_CloseCluster(b
, mem_ctx
,
52 if (!NT_STATUS_IS_OK(status
)) {
53 return ntstatus_to_werror(status
);
56 if (!W_ERROR_IS_OK(error
)) {
57 printf("error: %s\n", win_errstr(error
));
61 printf("successfully closed cluster\n");
66 static WERROR
cmd_clusapi_get_cluster_name(struct rpc_pipe_client
*cli
,
71 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
74 const char *ClusterName
;
77 status
= dcerpc_clusapi_GetClusterName(b
, mem_ctx
,
81 if (!NT_STATUS_IS_OK(status
)) {
82 return ntstatus_to_werror(status
);
85 if (!W_ERROR_IS_OK(error
)) {
86 printf("error: %s\n", win_errstr(error
));
90 printf("ClusterName: %s\n", ClusterName
);
91 printf("NodeName: %s\n", NodeName
);
96 static WERROR
cmd_clusapi_get_cluster_version(struct rpc_pipe_client
*cli
,
101 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
104 uint16_t lpwMajorVersion
;
105 uint16_t lpwMinorVersion
;
106 uint16_t lpwBuildNumber
;
107 const char *lpszVendorId
;
108 const char *lpszCSDVersion
;
110 status
= dcerpc_clusapi_GetClusterVersion(b
, mem_ctx
,
117 if (!NT_STATUS_IS_OK(status
)) {
118 return ntstatus_to_werror(status
);
121 if (!W_ERROR_IS_OK(error
)) {
122 printf("error: %s\n", win_errstr(error
));
126 printf("lpwMajorVersion: %d\n", lpwMajorVersion
);
127 printf("lpwMinorVersion: %d\n", lpwMinorVersion
);
128 printf("lpwBuildNumber: %d\n", lpwBuildNumber
);
129 printf("lpszVendorId: %s\n", lpszVendorId
);
130 printf("lpszCSDVersion: %s\n", lpszCSDVersion
);
135 static WERROR
cmd_clusapi_get_quorum_resource(struct rpc_pipe_client
*cli
,
140 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
143 const char *lpszResourceName
;
144 const char *lpszDeviceName
;
145 uint32_t pdwMaxQuorumLogSize
;
148 status
= dcerpc_clusapi_GetQuorumResource(b
, mem_ctx
,
151 &pdwMaxQuorumLogSize
,
154 if (!NT_STATUS_IS_OK(status
)) {
155 return ntstatus_to_werror(status
);
158 if (!W_ERROR_IS_OK(error
)) {
159 printf("error: %s\n", win_errstr(error
));
163 printf("lpszResourceName: %s\n", lpszResourceName
);
164 printf("lpszDeviceName: %s\n", lpszDeviceName
);
165 printf("pdwMaxQuorumLogSize: %d\n", pdwMaxQuorumLogSize
);
166 printf("rpc_status: %s\n", win_errstr(rpc_status
));
171 static WERROR
cmd_clusapi_create_enum(struct rpc_pipe_client
*cli
,
176 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
180 struct ENUM_LIST
*ReturnEnum
;
184 sscanf(argv
[1],"%x",&dwType
);
187 status
= dcerpc_clusapi_CreateEnum(b
, mem_ctx
,
192 if (!NT_STATUS_IS_OK(status
)) {
193 return ntstatus_to_werror(status
);
196 if (!W_ERROR_IS_OK(error
)) {
197 printf("error: %s\n", win_errstr(error
));
201 printf("rpc_status: %s\n", win_errstr(rpc_status
));
206 static WERROR
cmd_clusapi_open_resource(struct rpc_pipe_client
*cli
,
211 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
213 const char *lpszResourceName
= "Cluster Name";
215 struct policy_handle hResource
;
219 lpszResourceName
= argv
[1];
222 status
= dcerpc_clusapi_OpenResource(b
, mem_ctx
,
227 if (!NT_STATUS_IS_OK(status
)) {
228 return ntstatus_to_werror(status
);
231 if (!W_ERROR_IS_OK(Status
)) {
232 printf("Status: %s\n", win_errstr(Status
));
236 printf("rpc_status: %s\n", win_errstr(rpc_status
));
241 struct cmd_set clusapi_commands
[] = {
244 { "clusapi_open_cluster", RPC_RTYPE_WERROR
, NULL
, cmd_clusapi_open_cluster
, &ndr_table_clusapi
, NULL
, "bla", "" },
245 { "clusapi_get_cluster_name", RPC_RTYPE_WERROR
, NULL
, cmd_clusapi_get_cluster_name
, &ndr_table_clusapi
, NULL
, "bla", "" },
246 { "clusapi_get_cluster_version", RPC_RTYPE_WERROR
, NULL
, cmd_clusapi_get_cluster_version
, &ndr_table_clusapi
, NULL
, "bla", "" },
247 { "clusapi_get_quorum_resource", RPC_RTYPE_WERROR
, NULL
, cmd_clusapi_get_quorum_resource
, &ndr_table_clusapi
, NULL
, "bla", "" },
248 { "clusapi_create_enum", RPC_RTYPE_WERROR
, NULL
, cmd_clusapi_create_enum
, &ndr_table_clusapi
, NULL
, "bla", "" },
249 { "clusapi_open_resource", RPC_RTYPE_WERROR
, NULL
, cmd_clusapi_open_resource
, &ndr_table_clusapi
, NULL
, "bla", "" },