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>
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.
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, see <http://www.gnu.org/licenses/>.
24 #include "librpc/gen_ndr/nbt.h"
26 struct substitute_context
;
29 smbcli_state: internal state used in libcli library for single-threaded callers,
30 i.e. a single session on a single socket.
33 struct smbcli_transport
*transport
;
34 struct smbcli_session
*session
;
35 struct smbcli_tree
*tree
;
36 struct substitute_context
*substitute
;
37 struct smblsa_state
*lsa
;
40 struct clilist_file_info
{
45 const char *short_name
;
53 struct cli_credentials
;
54 struct tevent_context
;
56 /* passed to br lock code. */
64 #include "libcli/raw/libcliraw.h"
65 struct gensec_settings
;
67 ssize_t
smbcli_read(struct smbcli_tree
*tree
, int fnum
, void *_buf
, off_t offset
, size_t size
);
69 /****************************************************************************
71 write_mode: 0x0001 disallow write cacheing
72 0x0002 return bytes remaining
73 0x0004 use raw named pipe protocol
74 0x0008 start of message mode named pipe protocol
75 ****************************************************************************/
76 ssize_t
smbcli_write(struct smbcli_tree
*tree
,
77 int fnum
, uint16_t write_mode
,
78 const void *_buf
, off_t offset
, size_t size
);
80 /****************************************************************************
81 write to a file using a SMBwrite and not bypassing 0 byte writes
82 ****************************************************************************/
83 ssize_t
smbcli_smbwrite(struct smbcli_tree
*tree
,
84 int fnum
, const void *_buf
, off_t offset
, size_t size1
);
86 bool smbcli_socket_connect(struct smbcli_state
*cli
, const char *server
,
88 struct tevent_context
*ev_ctx
,
89 struct resolve_context
*resolve_ctx
,
90 struct smbcli_options
*options
,
91 const char *socket_options
);
92 bool smbcli_transport_establish(struct smbcli_state
*cli
,
93 struct nbt_name
*calling
,
94 struct nbt_name
*called
);
95 NTSTATUS
smbcli_negprot(struct smbcli_state
*cli
, bool unicode
, int maxprotocol
);
96 NTSTATUS
smbcli_session_setup(struct smbcli_state
*cli
,
97 struct cli_credentials
*credentials
,
98 const char *workgroup
,
99 struct smbcli_session_options options
,
100 struct gensec_settings
*gensec_settings
);
101 NTSTATUS
smbcli_tconX(struct smbcli_state
*cli
, const char *sharename
,
102 const char *devtype
, const char *password
);
103 NTSTATUS
smbcli_full_connection(TALLOC_CTX
*parent_ctx
,
104 struct smbcli_state
**ret_cli
,
107 const char *sharename
,
109 const char *socket_options
,
110 struct cli_credentials
*credentials
,
111 struct resolve_context
*resolve_ctx
,
112 struct tevent_context
*ev
,
113 struct smbcli_options
*options
,
114 struct smbcli_session_options
*session_options
,
115 struct gensec_settings
*gensec_settings
);
116 NTSTATUS
smbcli_tdis(struct smbcli_state
*cli
);
118 /****************************************************************************
119 Initialise a client state structure.
120 ****************************************************************************/
121 struct smbcli_state
*smbcli_state_init(TALLOC_CTX
*mem_ctx
);
122 bool smbcli_parse_unc(const char *unc_name
, TALLOC_CTX
*mem_ctx
,
123 char **hostname
, char **sharename
);
125 /****************************************************************************
126 Symlink a file (UNIX extensions).
127 ****************************************************************************/
128 NTSTATUS
smbcli_unix_symlink(struct smbcli_tree
*tree
, const char *fname_src
,
129 const char *fname_dst
);
131 /****************************************************************************
132 Hard a file (UNIX extensions).
133 ****************************************************************************/
134 NTSTATUS
smbcli_unix_hardlink(struct smbcli_tree
*tree
, const char *fname_src
,
135 const char *fname_dst
);
137 /****************************************************************************
138 chmod a file (UNIX extensions).
139 ****************************************************************************/
140 NTSTATUS
smbcli_unix_chmod(struct smbcli_tree
*tree
, const char *fname
, mode_t mode
);
142 /****************************************************************************
143 chown a file (UNIX extensions).
144 ****************************************************************************/
145 NTSTATUS
smbcli_unix_chown(struct smbcli_tree
*tree
, const char *fname
, uid_t uid
,
148 /****************************************************************************
150 ****************************************************************************/
151 NTSTATUS
smbcli_rename(struct smbcli_tree
*tree
, const char *fname_src
,
152 const char *fname_dst
);
154 /****************************************************************************
156 ****************************************************************************/
157 NTSTATUS
smbcli_unlink(struct smbcli_tree
*tree
, const char *fname
);
159 /****************************************************************************
161 ****************************************************************************/
162 NTSTATUS
smbcli_mkdir(struct smbcli_tree
*tree
, const char *dname
);
164 /****************************************************************************
166 ****************************************************************************/
167 NTSTATUS
smbcli_rmdir(struct smbcli_tree
*tree
, const char *dname
);
169 /****************************************************************************
170 Set or clear the delete on close flag.
171 ****************************************************************************/
172 NTSTATUS
smbcli_nt_delete_on_close(struct smbcli_tree
*tree
, int fnum
,
175 /****************************************************************************
176 Create/open a file - exposing the full horror of the NT API :-).
177 Used in CIFS-on-CIFS NTVFS.
178 ****************************************************************************/
179 int smbcli_nt_create_full(struct smbcli_tree
*tree
, const char *fname
,
180 uint32_t CreatFlags
, uint32_t DesiredAccess
,
181 uint32_t FileAttributes
, uint32_t ShareAccess
,
182 uint32_t CreateDisposition
, uint32_t CreateOptions
,
183 uint8_t SecurityFlags
);
185 /****************************************************************************
186 Open a file (using SMBopenx)
187 WARNING: if you open with O_WRONLY then getattrE won't work!
188 ****************************************************************************/
189 int smbcli_open(struct smbcli_tree
*tree
, const char *fname
, int flags
,
192 /****************************************************************************
194 ****************************************************************************/
195 NTSTATUS
smbcli_close(struct smbcli_tree
*tree
, int fnum
);
197 /****************************************************************************
198 send a lock with a specified locktype
199 this is used for testing LOCKING_ANDX_CANCEL_LOCK
200 ****************************************************************************/
201 NTSTATUS
smbcli_locktype(struct smbcli_tree
*tree
, int fnum
,
202 uint32_t offset
, uint32_t len
, int timeout
,
205 /****************************************************************************
207 ****************************************************************************/
208 NTSTATUS
smbcli_lock(struct smbcli_tree
*tree
, int fnum
,
209 uint32_t offset
, uint32_t len
, int timeout
,
210 enum brl_type lock_type
);
212 /****************************************************************************
214 ****************************************************************************/
215 NTSTATUS
smbcli_unlock(struct smbcli_tree
*tree
, int fnum
, uint32_t offset
, uint32_t len
);
217 /****************************************************************************
218 Lock a file with 64 bit offsets.
219 ****************************************************************************/
220 NTSTATUS
smbcli_lock64(struct smbcli_tree
*tree
, int fnum
,
221 off_t offset
, off_t len
, int timeout
,
222 enum brl_type lock_type
);
224 /****************************************************************************
225 Unlock a file with 64 bit offsets.
226 ****************************************************************************/
227 NTSTATUS
smbcli_unlock64(struct smbcli_tree
*tree
, int fnum
, off_t offset
,
230 /****************************************************************************
231 Do a SMBgetattrE call.
232 ****************************************************************************/
233 NTSTATUS
smbcli_getattrE(struct smbcli_tree
*tree
, int fnum
,
234 uint16_t *attr
, size_t *size
,
235 time_t *c_time
, time_t *a_time
, time_t *m_time
);
237 /****************************************************************************
239 ****************************************************************************/
240 NTSTATUS
smbcli_getatr(struct smbcli_tree
*tree
, const char *fname
,
241 uint16_t *attr
, size_t *size
, time_t *t
);
243 /****************************************************************************
245 ****************************************************************************/
246 NTSTATUS
smbcli_setatr(struct smbcli_tree
*tree
, const char *fname
, uint16_t mode
,
249 /****************************************************************************
250 Do a setfileinfo basic_info call.
251 ****************************************************************************/
252 NTSTATUS
smbcli_fsetatr(struct smbcli_tree
*tree
, int fnum
, uint16_t mode
,
253 NTTIME create_time
, NTTIME access_time
,
254 NTTIME write_time
, NTTIME change_time
);
256 /****************************************************************************
257 truncate a file to a given size
258 ****************************************************************************/
259 NTSTATUS
smbcli_ftruncate(struct smbcli_tree
*tree
, int fnum
, uint64_t size
);
261 /****************************************************************************
262 Check for existence of a dir.
263 ****************************************************************************/
264 NTSTATUS
smbcli_chkpath(struct smbcli_tree
*tree
, const char *path
);
266 /****************************************************************************
268 ****************************************************************************/
269 NTSTATUS
smbcli_dskattr(struct smbcli_tree
*tree
, uint32_t *bsize
,
270 uint64_t *total
, uint64_t *avail
);
272 /****************************************************************************
273 Create and open a temporary file.
274 ****************************************************************************/
275 int smbcli_ctemp(struct smbcli_tree
*tree
, const char *path
, char **tmp_path
);
277 /****************************************************************************
278 Interpret a long filename structure.
279 ****************************************************************************/
280 int smbcli_list_new(struct smbcli_tree
*tree
, const char *Mask
, uint16_t attribute
,
281 enum smb_search_data_level level
,
282 void (*fn
)(struct clilist_file_info
*, const char *, void *),
285 /****************************************************************************
286 Interpret a short filename structure.
287 The length of the structure is returned.
288 ****************************************************************************/
289 int smbcli_list_old(struct smbcli_tree
*tree
, const char *Mask
, uint16_t attribute
,
290 void (*fn
)(struct clilist_file_info
*, const char *, void *),
293 /****************************************************************************
294 Do a directory listing, calling fn on each file found.
295 This auto-switches between old and new style.
296 ****************************************************************************/
297 int smbcli_list(struct smbcli_tree
*tree
, const char *Mask
,uint16_t attribute
,
298 void (*fn
)(struct clilist_file_info
*, const char *, void *), void *state
);
300 /****************************************************************************
301 send a qpathinfo call
302 ****************************************************************************/
303 NTSTATUS
smbcli_qpathinfo(struct smbcli_tree
*tree
, const char *fname
,
304 time_t *c_time
, time_t *a_time
, time_t *m_time
,
305 size_t *size
, uint16_t *mode
);
307 /****************************************************************************
308 send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level
309 ****************************************************************************/
310 NTSTATUS
smbcli_qpathinfo2(struct smbcli_tree
*tree
, const char *fname
,
311 time_t *c_time
, time_t *a_time
, time_t *m_time
,
312 time_t *w_time
, size_t *size
, uint16_t *mode
,
315 /****************************************************************************
316 send a qfileinfo QUERY_FILE_NAME_INFO call
317 ****************************************************************************/
318 NTSTATUS
smbcli_qfilename(struct smbcli_tree
*tree
, int fnum
, const char **name
);
320 /****************************************************************************
321 send a qfileinfo call
322 ****************************************************************************/
323 NTSTATUS
smbcli_qfileinfo(struct smbcli_tree
*tree
, int fnum
,
324 uint16_t *mode
, size_t *size
,
325 time_t *c_time
, time_t *a_time
, time_t *m_time
,
326 time_t *w_time
, ino_t
*ino
);
328 /****************************************************************************
329 send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call
330 ****************************************************************************/
331 NTSTATUS
smbcli_qpathinfo_alt_name(struct smbcli_tree
*tree
, const char *fname
,
332 const char **alt_name
);
334 /* The following definitions come from ../source4/libcli/climessage.c */
337 /****************************************************************************
338 start a message sequence
339 ****************************************************************************/
340 bool smbcli_message_start(struct smbcli_tree
*tree
, const char *host
, const char *username
,
343 /****************************************************************************
345 ****************************************************************************/
346 bool smbcli_message_text(struct smbcli_tree
*tree
, char *msg
, int len
, int grp
);
348 /****************************************************************************
350 ****************************************************************************/
351 bool smbcli_message_end(struct smbcli_tree
*tree
, int grp
);
353 int smbcli_deltree(struct smbcli_tree
*tree
, const char *dname
);
355 #endif /* __LIBCLI_H__ */