r10656: BIG merge from trunk. Features not copied over
[Samba/nascimento.git] / source3 / rpc_client / cli_dfs.c
blob78df220ac2a3ecdbf7ac1ac3a8303cb49ea462c2
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
4 Copyright (C) Tim Potter 2000-2001,
5 Copyright (C) Jeremy Allison 2005.
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.
22 #include "includes.h"
24 /* Query DFS support */
26 NTSTATUS rpccli_dfs_exist(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
27 BOOL *dfs_exists)
29 prs_struct qbuf, rbuf;
30 DFS_Q_DFS_EXIST q;
31 DFS_R_DFS_EXIST r;
32 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
34 ZERO_STRUCT(q);
35 ZERO_STRUCT(r);
37 /* Marshall data and send request */
39 init_dfs_q_dfs_exist(&q);
41 CLI_DO_RPC( cli, mem_ctx, PI_NETDFS, DFS_EXIST,
42 q, r,
43 qbuf, rbuf,
44 dfs_io_q_dfs_exist,
45 dfs_io_r_dfs_exist,
46 NT_STATUS_UNSUCCESSFUL);
48 /* Return result */
50 *dfs_exists = (r.status != 0);
52 result = NT_STATUS_OK;
54 return result;
57 NTSTATUS rpccli_dfs_add(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
58 const char *entrypath, const char *servername,
59 const char *sharename, const char *comment, uint32 flags)
61 prs_struct qbuf, rbuf;
62 DFS_Q_DFS_ADD q;
63 DFS_R_DFS_ADD r;
64 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
66 ZERO_STRUCT(q);
67 ZERO_STRUCT(r);
69 /* Marshall data and send request */
71 init_dfs_q_dfs_add(&q, entrypath, servername, sharename, comment,
72 flags);
74 CLI_DO_RPC( cli, mem_ctx, PI_NETDFS, DFS_ADD,
75 q, r,
76 qbuf, rbuf,
77 dfs_io_q_dfs_add,
78 dfs_io_r_dfs_add,
79 NT_STATUS_UNSUCCESSFUL);
81 /* Return result */
83 result = werror_to_ntstatus(r.status);
85 return result;
88 NTSTATUS rpccli_dfs_remove(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
89 const char *entrypath, const char *servername,
90 const char *sharename)
92 prs_struct qbuf, rbuf;
93 DFS_Q_DFS_REMOVE q;
94 DFS_R_DFS_REMOVE r;
95 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
97 ZERO_STRUCT(q);
98 ZERO_STRUCT(r);
100 /* Marshall data and send request */
102 init_dfs_q_dfs_remove(&q, entrypath, servername, sharename);
104 CLI_DO_RPC( cli, mem_ctx, PI_NETDFS, DFS_REMOVE,
105 q, r,
106 qbuf, rbuf,
107 dfs_io_q_dfs_remove,
108 dfs_io_r_dfs_remove,
109 NT_STATUS_UNSUCCESSFUL);
111 /* Return result */
113 result = werror_to_ntstatus(r.status);
115 return result;
118 NTSTATUS rpccli_dfs_get_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
119 const char *entrypath, const char *servername,
120 const char *sharename, uint32 info_level,
121 DFS_INFO_CTR *ctr)
124 prs_struct qbuf, rbuf;
125 DFS_Q_DFS_GET_INFO q;
126 DFS_R_DFS_GET_INFO r;
127 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
129 ZERO_STRUCT(q);
130 ZERO_STRUCT(r);
132 /* Marshall data and send request */
134 init_dfs_q_dfs_get_info(&q, entrypath, servername, sharename,
135 info_level);
137 CLI_DO_RPC( cli, mem_ctx, PI_NETDFS, DFS_GET_INFO,
138 q, r,
139 qbuf, rbuf,
140 dfs_io_q_dfs_get_info,
141 dfs_io_r_dfs_get_info,
142 NT_STATUS_UNSUCCESSFUL);
144 /* Return result */
146 result = werror_to_ntstatus(r.status);
147 *ctr = r.ctr;
149 return result;
152 /* Enumerate dfs shares */
154 NTSTATUS rpccli_dfs_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
155 uint32 info_level, DFS_INFO_CTR *ctr)
157 prs_struct qbuf, rbuf;
158 DFS_Q_DFS_ENUM q;
159 DFS_R_DFS_ENUM r;
160 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
162 ZERO_STRUCT(q);
163 ZERO_STRUCT(r);
165 /* Marshall data and send request */
167 init_dfs_q_dfs_enum(&q, info_level, ctr);
169 r.ctr = ctr;
171 CLI_DO_RPC( cli, mem_ctx, PI_NETDFS, DFS_ENUM,
172 q, r,
173 qbuf, rbuf,
174 dfs_io_q_dfs_enum,
175 dfs_io_r_dfs_enum,
176 NT_STATUS_UNSUCCESSFUL);
178 /* Return result */
180 result = werror_to_ntstatus(r.status);
182 return result;