2 Unix SMB/CIFS implementation.
4 Copyright (C) Tim Potter 2000-2001,
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 2 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, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 /* Opens a SMB connection to the netdfs pipe */
25 struct cli_state
*cli_dfs_initialise(struct cli_state
*cli
, char *system_name
,
26 struct ntuser_creds
*creds
)
28 return cli_pipe_initialise(cli
, system_name
, PIPE_NETDFS
, creds
);
31 /* Query DFS support */
33 NTSTATUS
cli_dfs_exist(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
36 prs_struct qbuf
, rbuf
;
39 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
44 /* Initialise parse structures */
46 prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
);
47 prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
);
49 /* Marshall data and send request */
51 init_dfs_q_dfs_exist(&q
);
53 if (!dfs_io_q_dfs_exist("", &q
, &qbuf
, 0) ||
54 !rpc_api_pipe_req(cli
, DFS_EXIST
, &qbuf
, &rbuf
)) {
58 /* Unmarshall response */
60 if (!dfs_io_r_dfs_exist("", &r
, &rbuf
, 0)) {
66 *dfs_exists
= (r
.status
!= 0);
68 result
= NT_STATUS_OK
;
77 NTSTATUS
cli_dfs_add(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
78 char *entrypath
, char *servername
, char *sharename
,
79 char *comment
, uint32 flags
)
81 prs_struct qbuf
, rbuf
;
84 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
89 /* Initialise parse structures */
91 prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
);
92 prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
);
94 /* Marshall data and send request */
96 init_dfs_q_dfs_add(&q
, entrypath
, servername
, sharename
, comment
,
99 if (!dfs_io_q_dfs_add("", &q
, &qbuf
, 0) ||
100 !rpc_api_pipe_req(cli
, DFS_ADD
, &qbuf
, &rbuf
)) {
104 /* Unmarshall response */
106 if (!dfs_io_r_dfs_add("", &r
, &rbuf
, 0)) {
112 result
= werror_to_ntstatus(r
.status
);
121 NTSTATUS
cli_dfs_remove(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
122 char *entrypath
, char *servername
, char *sharename
)
124 prs_struct qbuf
, rbuf
;
127 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
132 /* Initialise parse structures */
134 prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
);
135 prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
);
137 /* Marshall data and send request */
139 init_dfs_q_dfs_remove(&q
, entrypath
, servername
, sharename
);
141 if (!dfs_io_q_dfs_remove("", &q
, &qbuf
, 0) ||
142 !rpc_api_pipe_req(cli
, DFS_REMOVE
, &qbuf
, &rbuf
)) {
146 /* Unmarshall response */
148 if (!dfs_io_r_dfs_remove("", &r
, &rbuf
, 0)) {
154 result
= werror_to_ntstatus(r
.status
);
163 NTSTATUS
cli_dfs_get_info(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
164 char *entrypath
, char *servername
, char *sharename
,
165 uint32 info_level
, DFS_INFO_CTR
*ctr
)
168 prs_struct qbuf
, rbuf
;
169 DFS_Q_DFS_GET_INFO q
;
170 DFS_R_DFS_GET_INFO r
;
171 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
176 /* Initialise parse structures */
178 prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
);
179 prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
);
181 /* Marshall data and send request */
183 init_dfs_q_dfs_get_info(&q
, entrypath
, servername
, sharename
,
186 if (!dfs_io_q_dfs_get_info("", &q
, &qbuf
, 0) ||
187 !rpc_api_pipe_req(cli
, DFS_GET_INFO
, &qbuf
, &rbuf
)) {
191 /* Unmarshall response */
193 if (!dfs_io_r_dfs_get_info("", &r
, &rbuf
, 0)) {
199 result
= werror_to_ntstatus(r
.status
);
209 /* Enumerate dfs shares */
211 NTSTATUS
cli_dfs_enum(struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
212 uint32 info_level
, DFS_INFO_CTR
*ctr
)
214 prs_struct qbuf
, rbuf
;
217 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
222 /* Initialise parse structures */
224 prs_init(&qbuf
, MAX_PDU_FRAG_LEN
, mem_ctx
, MARSHALL
);
225 prs_init(&rbuf
, 0, mem_ctx
, UNMARSHALL
);
227 /* Marshall data and send request */
229 init_dfs_q_dfs_enum(&q
, info_level
, ctr
);
231 if (!dfs_io_q_dfs_enum("", &q
, &qbuf
, 0) ||
232 !rpc_api_pipe_req(cli
, DFS_ENUM
, &qbuf
, &rbuf
)) {
236 /* Unmarshall response */
240 if (!dfs_io_r_dfs_enum("", &r
, &rbuf
, 0)) {
246 result
= werror_to_ntstatus(r
.status
);