2 Unix SMB/Netbios implementation.
5 Copyright (C) Tim Potter 2000-2001,
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 2 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, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /* Opens a SMB connection to the netdfs pipe */
26 struct cli_state *cli_dfs_initialise(struct cli_state *cli, char *system_name,
27 struct ntuser_creds *creds)
29 return cli_pipe_initialise(cli, system_name, PIPE_NETDFS, creds);
32 /* Query DFS support */
34 NTSTATUS cli_dfs_exist(struct cli_state *cli, TALLOC_CTX *mem_ctx,
37 prs_struct qbuf, rbuf;
40 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
45 /* Initialise parse structures */
47 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
48 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
50 /* Marshall data and send request */
52 init_dfs_q_dfs_exist(&q);
54 if (!dfs_io_q_dfs_exist("", &q, &qbuf, 0) ||
55 !rpc_api_pipe_req(cli, DFS_EXIST, &qbuf, &rbuf)) {
59 /* Unmarshall response */
61 if (!dfs_io_r_dfs_exist("", &r, &rbuf, 0)) {
67 *dfs_exists = (r.status != 0);
69 result = NT_STATUS_OK;
78 NTSTATUS cli_dfs_add(struct cli_state *cli, TALLOC_CTX *mem_ctx,
79 char *entrypath, char *servername, char *sharename,
80 char *comment, uint32 flags)
82 prs_struct qbuf, rbuf;
85 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
90 /* Initialise parse structures */
92 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
93 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
95 /* Marshall data and send request */
97 init_dfs_q_dfs_add(&q, entrypath, servername, sharename, comment,
100 if (!dfs_io_q_dfs_add("", &q, &qbuf, 0) ||
101 !rpc_api_pipe_req(cli, DFS_ADD, &qbuf, &rbuf)) {
105 /* Unmarshall response */
107 if (!dfs_io_r_dfs_add("", &r, &rbuf, 0)) {
113 result = werror_to_ntstatus(r.status);
122 NTSTATUS cli_dfs_remove(struct cli_state *cli, TALLOC_CTX *mem_ctx,
123 char *entrypath, char *servername, char *sharename)
125 prs_struct qbuf, rbuf;
128 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
133 /* Initialise parse structures */
135 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
136 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
138 /* Marshall data and send request */
140 init_dfs_q_dfs_remove(&q, entrypath, servername, sharename);
142 if (!dfs_io_q_dfs_remove("", &q, &qbuf, 0) ||
143 !rpc_api_pipe_req(cli, DFS_REMOVE, &qbuf, &rbuf)) {
147 /* Unmarshall response */
149 if (!dfs_io_r_dfs_remove("", &r, &rbuf, 0)) {
155 result = werror_to_ntstatus(r.status);
164 NTSTATUS cli_dfs_get_info(struct cli_state *cli, TALLOC_CTX *mem_ctx,
165 char *entrypath, char *servername, char *sharename,
166 uint32 info_level, DFS_INFO_CTR *ctr)
169 prs_struct qbuf, rbuf;
170 DFS_Q_DFS_GET_INFO q;
171 DFS_R_DFS_GET_INFO r;
172 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
177 /* Initialise parse structures */
179 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
180 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
182 /* Marshall data and send request */
184 init_dfs_q_dfs_get_info(&q, entrypath, servername, sharename,
187 if (!dfs_io_q_dfs_get_info("", &q, &qbuf, 0) ||
188 !rpc_api_pipe_req(cli, DFS_GET_INFO, &qbuf, &rbuf)) {
192 /* Unmarshall response */
194 if (!dfs_io_r_dfs_get_info("", &r, &rbuf, 0)) {
200 result = werror_to_ntstatus(r.status);
210 /* Enumerate dfs shares */
212 NTSTATUS cli_dfs_enum(struct cli_state *cli, TALLOC_CTX *mem_ctx,
213 uint32 info_level, DFS_INFO_CTR *ctr)
215 prs_struct qbuf, rbuf;
218 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
223 /* Initialise parse structures */
225 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
226 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
228 /* Marshall data and send request */
230 init_dfs_q_dfs_enum(&q, info_level, ctr);
232 if (!dfs_io_q_dfs_enum("", &q, &qbuf, 0) ||
233 !rpc_api_pipe_req(cli, DFS_ENUM, &qbuf, &rbuf)) {
237 /* Unmarshall response */
241 if (!dfs_io_r_dfs_enum("", &r, &rbuf, 0)) {
247 result = werror_to_ntstatus(r.status);