Initial import
[samba] / source / rpc_client / cli_dfs.c
1 /* 
2    Unix SMB/CIFS implementation.
3    RPC pipe client
4    Copyright (C) Tim Potter                        2000-2001,
5    Copyright (C) Jeremy Allison                         2005.
6    
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.
11    
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.
16    
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.
20 */
21
22 #include "includes.h"
23
24 /* Query DFS support */
25
26 NTSTATUS rpccli_dfs_exist(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
27                        BOOL *dfs_exists)
28 {
29         prs_struct qbuf, rbuf;
30         DFS_Q_DFS_EXIST q;
31         DFS_R_DFS_EXIST r;
32         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
33
34         ZERO_STRUCT(q);
35         ZERO_STRUCT(r);
36
37         /* Marshall data and send request */
38
39         init_dfs_q_dfs_exist(&q);
40
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);
47
48         /* Return result */
49
50         *dfs_exists = (r.status != 0);
51
52         result = NT_STATUS_OK;
53
54         return result;
55 }
56
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)
60 {
61         prs_struct qbuf, rbuf;
62         DFS_Q_DFS_ADD q;
63         DFS_R_DFS_ADD r;
64         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
65
66         ZERO_STRUCT(q);
67         ZERO_STRUCT(r);
68
69         /* Marshall data and send request */
70
71         init_dfs_q_dfs_add(&q, entrypath, servername, sharename, comment,
72                            flags);
73
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);
80
81         /* Return result */
82
83         result = werror_to_ntstatus(r.status);
84
85         return result;
86 }
87
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)
91 {
92         prs_struct qbuf, rbuf;
93         DFS_Q_DFS_REMOVE q;
94         DFS_R_DFS_REMOVE r;
95         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
96
97         ZERO_STRUCT(q);
98         ZERO_STRUCT(r);
99
100         /* Marshall data and send request */
101
102         init_dfs_q_dfs_remove(&q, entrypath, servername, sharename);
103
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);
110
111         /* Return result */
112
113         result = werror_to_ntstatus(r.status);
114
115         return result;
116 }
117
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)
122
123 {
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;
128
129         ZERO_STRUCT(q);
130         ZERO_STRUCT(r);
131
132         /* Marshall data and send request */
133
134         init_dfs_q_dfs_get_info(&q, entrypath, servername, sharename,
135                                 info_level);
136
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);
143
144         /* Return result */
145
146         result = werror_to_ntstatus(r.status);
147         *ctr = r.ctr;
148         
149         return result;
150 }
151
152 /* Enumerate dfs shares */
153
154 NTSTATUS rpccli_dfs_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
155                       uint32 info_level, DFS_INFO_CTR *ctr)
156 {
157         prs_struct qbuf, rbuf;
158         DFS_Q_DFS_ENUM q;
159         DFS_R_DFS_ENUM r;
160         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
161
162         ZERO_STRUCT(q);
163         ZERO_STRUCT(r);
164
165         /* Marshall data and send request */
166
167         init_dfs_q_dfs_enum(&q, info_level, ctr);
168
169         r.ctr = ctr;
170
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);
177
178         /* Return result */
179
180         result = werror_to_ntstatus(r.status);
181
182         return result;
183 }