source: vendor/current/source4/libcli/libcli.h

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 15.4 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 SMB parameters and setup
4 Copyright (C) Andrew Tridgell 2004
5 Copyright (C) James Myers 2003 <myersjj@samba.org>
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 3 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, see <http://www.gnu.org/licenses/>.
19*/
20
21#ifndef __LIBCLI_H__
22#define __LIBCLI_H__
23
24#include "librpc/gen_ndr/nbt.h"
25#include "libcli/raw/libcliraw.h"
26
27struct substitute_context;
28
29/*
30 smbcli_state: internal state used in libcli library for single-threaded callers,
31 i.e. a single session on a single socket.
32 */
33struct smbcli_state {
34 struct smbcli_options options;
35 struct smbcli_socket *sock; /* NULL if connected */
36 struct smbcli_transport *transport;
37 struct smbcli_session *session;
38 struct smbcli_tree *tree;
39 struct substitute_context *substitute;
40 struct smblsa_state *lsa;
41};
42
43struct clilist_file_info {
44 uint64_t size;
45 uint16_t attrib;
46 time_t mtime;
47 const char *name;
48 const char *short_name;
49};
50
51struct nbt_dc_name {
52 const char *address;
53 const char *name;
54};
55
56struct cli_credentials;
57struct tevent_context;
58
59/* passed to br lock code. */
60enum brl_type {
61 READ_LOCK,
62 WRITE_LOCK,
63 PENDING_READ_LOCK,
64 PENDING_WRITE_LOCK
65};
66
67#include "libcli/raw/libcliraw.h"
68struct gensec_settings;
69
70ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, void *_buf, off_t offset, size_t size);
71
72/****************************************************************************
73 write to a file
74 write_mode: 0x0001 disallow write cacheing
75 0x0002 return bytes remaining
76 0x0004 use raw named pipe protocol
77 0x0008 start of message mode named pipe protocol
78****************************************************************************/
79ssize_t smbcli_write(struct smbcli_tree *tree,
80 int fnum, uint16_t write_mode,
81 const void *_buf, off_t offset, size_t size);
82
83/****************************************************************************
84 write to a file using a SMBwrite and not bypassing 0 byte writes
85****************************************************************************/
86ssize_t smbcli_smbwrite(struct smbcli_tree *tree,
87 int fnum, const void *_buf, off_t offset, size_t size1);
88
89bool smbcli_socket_connect(struct smbcli_state *cli, const char *server,
90 const char **ports,
91 struct tevent_context *ev_ctx,
92 struct resolve_context *resolve_ctx,
93 struct smbcli_options *options,
94 const char *socket_options,
95 struct nbt_name *calling,
96 struct nbt_name *called);
97NTSTATUS smbcli_negprot(struct smbcli_state *cli, bool unicode, int maxprotocol);
98NTSTATUS smbcli_session_setup(struct smbcli_state *cli,
99 struct cli_credentials *credentials,
100 const char *workgroup,
101 struct smbcli_session_options options,
102 struct gensec_settings *gensec_settings);
103NTSTATUS smbcli_tconX(struct smbcli_state *cli, const char *sharename,
104 const char *devtype, const char *password);
105NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
106 struct smbcli_state **ret_cli,
107 const char *host,
108 const char **ports,
109 const char *sharename,
110 const char *devtype,
111 const char *socket_options,
112 struct cli_credentials *credentials,
113 struct resolve_context *resolve_ctx,
114 struct tevent_context *ev,
115 struct smbcli_options *options,
116 struct smbcli_session_options *session_options,
117 struct gensec_settings *gensec_settings);
118NTSTATUS smbcli_tdis(struct smbcli_state *cli);
119
120/****************************************************************************
121 Initialise a client state structure.
122****************************************************************************/
123struct smbcli_state *smbcli_state_init(TALLOC_CTX *mem_ctx);
124bool smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
125 char **hostname, char **sharename);
126
127/****************************************************************************
128 Symlink a file (UNIX extensions).
129****************************************************************************/
130NTSTATUS smbcli_unix_symlink(struct smbcli_tree *tree, const char *fname_src,
131 const char *fname_dst);
132
133/****************************************************************************
134 Hard a file (UNIX extensions).
135****************************************************************************/
136NTSTATUS smbcli_unix_hardlink(struct smbcli_tree *tree, const char *fname_src,
137 const char *fname_dst);
138
139/****************************************************************************
140 chmod a file (UNIX extensions).
141****************************************************************************/
142NTSTATUS smbcli_unix_chmod(struct smbcli_tree *tree, const char *fname, mode_t mode);
143
144/****************************************************************************
145 chown a file (UNIX extensions).
146****************************************************************************/
147NTSTATUS smbcli_unix_chown(struct smbcli_tree *tree, const char *fname, uid_t uid,
148 gid_t gid);
149
150/****************************************************************************
151 Rename a file.
152****************************************************************************/
153NTSTATUS smbcli_rename(struct smbcli_tree *tree, const char *fname_src,
154 const char *fname_dst);
155
156/****************************************************************************
157 Delete a file.
158****************************************************************************/
159NTSTATUS smbcli_unlink(struct smbcli_tree *tree, const char *fname);
160
161/****************************************************************************
162 Create a directory.
163****************************************************************************/
164NTSTATUS smbcli_mkdir(struct smbcli_tree *tree, const char *dname);
165
166/****************************************************************************
167 Remove a directory.
168****************************************************************************/
169NTSTATUS smbcli_rmdir(struct smbcli_tree *tree, const char *dname);
170
171/****************************************************************************
172 Set or clear the delete on close flag.
173****************************************************************************/
174NTSTATUS smbcli_nt_delete_on_close(struct smbcli_tree *tree, int fnum,
175 bool flag);
176
177/****************************************************************************
178 Create/open a file - exposing the full horror of the NT API :-).
179 Used in CIFS-on-CIFS NTVFS.
180****************************************************************************/
181int smbcli_nt_create_full(struct smbcli_tree *tree, const char *fname,
182 uint32_t CreatFlags, uint32_t DesiredAccess,
183 uint32_t FileAttributes, uint32_t ShareAccess,
184 uint32_t CreateDisposition, uint32_t CreateOptions,
185 uint8_t SecurityFlags);
186
187/****************************************************************************
188 Open a file (using SMBopenx)
189 WARNING: if you open with O_WRONLY then getattrE won't work!
190****************************************************************************/
191int smbcli_open(struct smbcli_tree *tree, const char *fname, int flags,
192 int share_mode);
193
194/****************************************************************************
195 Close a file.
196****************************************************************************/
197NTSTATUS smbcli_close(struct smbcli_tree *tree, int fnum);
198
199/****************************************************************************
200 send a lock with a specified locktype
201 this is used for testing LOCKING_ANDX_CANCEL_LOCK
202****************************************************************************/
203NTSTATUS smbcli_locktype(struct smbcli_tree *tree, int fnum,
204 uint32_t offset, uint32_t len, int timeout,
205 uint8_t locktype);
206
207/****************************************************************************
208 Lock a file.
209****************************************************************************/
210NTSTATUS smbcli_lock(struct smbcli_tree *tree, int fnum,
211 uint32_t offset, uint32_t len, int timeout,
212 enum brl_type lock_type);
213
214/****************************************************************************
215 Unlock a file.
216****************************************************************************/
217NTSTATUS smbcli_unlock(struct smbcli_tree *tree, int fnum, uint32_t offset, uint32_t len);
218
219/****************************************************************************
220 Lock a file with 64 bit offsets.
221****************************************************************************/
222NTSTATUS smbcli_lock64(struct smbcli_tree *tree, int fnum,
223 off_t offset, off_t len, int timeout,
224 enum brl_type lock_type);
225
226/****************************************************************************
227 Unlock a file with 64 bit offsets.
228****************************************************************************/
229NTSTATUS smbcli_unlock64(struct smbcli_tree *tree, int fnum, off_t offset,
230 off_t len);
231
232/****************************************************************************
233 Do a SMBgetattrE call.
234****************************************************************************/
235NTSTATUS smbcli_getattrE(struct smbcli_tree *tree, int fnum,
236 uint16_t *attr, size_t *size,
237 time_t *c_time, time_t *a_time, time_t *m_time);
238
239/****************************************************************************
240 Do a SMBgetatr call
241****************************************************************************/
242NTSTATUS smbcli_getatr(struct smbcli_tree *tree, const char *fname,
243 uint16_t *attr, size_t *size, time_t *t);
244
245/****************************************************************************
246 Do a SMBsetatr call.
247****************************************************************************/
248NTSTATUS smbcli_setatr(struct smbcli_tree *tree, const char *fname, uint16_t mode,
249 time_t t);
250
251/****************************************************************************
252 Do a setfileinfo basic_info call.
253****************************************************************************/
254NTSTATUS smbcli_fsetatr(struct smbcli_tree *tree, int fnum, uint16_t mode,
255 NTTIME create_time, NTTIME access_time,
256 NTTIME write_time, NTTIME change_time);
257
258/****************************************************************************
259 truncate a file to a given size
260****************************************************************************/
261NTSTATUS smbcli_ftruncate(struct smbcli_tree *tree, int fnum, uint64_t size);
262
263/****************************************************************************
264 Check for existence of a dir.
265****************************************************************************/
266NTSTATUS smbcli_chkpath(struct smbcli_tree *tree, const char *path);
267
268/****************************************************************************
269 Query disk space.
270****************************************************************************/
271NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, uint32_t *bsize,
272 uint64_t *total, uint64_t *avail);
273
274/****************************************************************************
275 Create and open a temporary file.
276****************************************************************************/
277int smbcli_ctemp(struct smbcli_tree *tree, const char *path, char **tmp_path);
278
279/****************************************************************************
280 Interpret a long filename structure.
281****************************************************************************/
282int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
283 enum smb_search_data_level level,
284 void (*fn)(struct clilist_file_info *, const char *, void *),
285 void *caller_state);
286
287/****************************************************************************
288 Interpret a short filename structure.
289 The length of the structure is returned.
290****************************************************************************/
291int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
292 void (*fn)(struct clilist_file_info *, const char *, void *),
293 void *caller_state);
294
295/****************************************************************************
296 Do a directory listing, calling fn on each file found.
297 This auto-switches between old and new style.
298****************************************************************************/
299int smbcli_list(struct smbcli_tree *tree, const char *Mask,uint16_t attribute,
300 void (*fn)(struct clilist_file_info *, const char *, void *), void *state);
301
302/****************************************************************************
303send a qpathinfo call
304****************************************************************************/
305NTSTATUS smbcli_qpathinfo(struct smbcli_tree *tree, const char *fname,
306 time_t *c_time, time_t *a_time, time_t *m_time,
307 size_t *size, uint16_t *mode);
308
309/****************************************************************************
310send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level
311****************************************************************************/
312NTSTATUS smbcli_qpathinfo2(struct smbcli_tree *tree, const char *fname,
313 time_t *c_time, time_t *a_time, time_t *m_time,
314 time_t *w_time, size_t *size, uint16_t *mode,
315 ino_t *ino);
316
317/****************************************************************************
318send a qfileinfo QUERY_FILE_NAME_INFO call
319****************************************************************************/
320NTSTATUS smbcli_qfilename(struct smbcli_tree *tree, int fnum, const char **name);
321
322/****************************************************************************
323send a qfileinfo call
324****************************************************************************/
325NTSTATUS smbcli_qfileinfo(struct smbcli_tree *tree, int fnum,
326 uint16_t *mode, size_t *size,
327 time_t *c_time, time_t *a_time, time_t *m_time,
328 time_t *w_time, ino_t *ino);
329
330/****************************************************************************
331send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call
332****************************************************************************/
333NTSTATUS smbcli_qpathinfo_alt_name(struct smbcli_tree *tree, const char *fname,
334 const char **alt_name);
335
336/* The following definitions come from ../source4/libcli/climessage.c */
337
338
339/****************************************************************************
340start a message sequence
341****************************************************************************/
342bool smbcli_message_start(struct smbcli_tree *tree, const char *host, const char *username,
343 int *grp);
344
345/****************************************************************************
346send a message
347****************************************************************************/
348bool smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp);
349
350/****************************************************************************
351end a message
352****************************************************************************/
353bool smbcli_message_end(struct smbcli_tree *tree, int grp);
354
355int smbcli_deltree(struct smbcli_tree *tree, const char *dname);
356
357#endif /* __LIBCLI_H__ */
Note: See TracBrowser for help on using the repository browser.