1 #ifndef HEADER_CURL_SMB_H
2 #define HEADER_CURL_SMB_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
11 * Copyright (C) 2018 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
13 * This software is licensed as described in the file COPYING, which
14 * you should have received as part of this distribution. The terms
15 * are also available at https://curl.haxx.se/docs/copyright.html.
17 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
18 * copies of the Software, and permit persons to whom the Software is
19 * furnished to do so, under the terms of the COPYING file.
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
24 ***************************************************************************/
27 SMB_NOT_CONNECTED = 0,
35 enum smb_conn_state state;
39 unsigned char challenge[8];
40 unsigned int session_key;
50 * Definitions for SMB protocol data structures
52 #ifdef BUILDING_CURL_SMB_C
54 #if defined(_MSC_VER) || defined(__ILEC400__)
58 #elif defined(__GNUC__)
59 # define PACK __attribute__((packed))
64 #define SMB_COM_CLOSE 0x04
65 #define SMB_COM_READ_ANDX 0x2e
66 #define SMB_COM_WRITE_ANDX 0x2f
67 #define SMB_COM_TREE_DISCONNECT 0x71
68 #define SMB_COM_NEGOTIATE 0x72
69 #define SMB_COM_SETUP_ANDX 0x73
70 #define SMB_COM_TREE_CONNECT_ANDX 0x75
71 #define SMB_COM_NT_CREATE_ANDX 0xa2
72 #define SMB_COM_NO_ANDX_COMMAND 0xff
74 #define SMB_WC_CLOSE 0x03
75 #define SMB_WC_READ_ANDX 0x0c
76 #define SMB_WC_WRITE_ANDX 0x0e
77 #define SMB_WC_SETUP_ANDX 0x0d
78 #define SMB_WC_TREE_CONNECT_ANDX 0x04
79 #define SMB_WC_NT_CREATE_ANDX 0x18
81 #define SMB_FLAGS_CANONICAL_PATHNAMES 0x10
82 #define SMB_FLAGS_CASELESS_PATHNAMES 0x08
83 #define SMB_FLAGS2_UNICODE_STRINGS 0x8000
84 #define SMB_FLAGS2_IS_LONG_NAME 0x0040
85 #define SMB_FLAGS2_KNOWS_LONG_NAME 0x0001
87 #define SMB_CAP_LARGE_FILES 0x08
88 #define SMB_GENERIC_WRITE 0x40000000
89 #define SMB_GENERIC_READ 0x80000000
90 #define SMB_FILE_SHARE_ALL 0x07
91 #define SMB_FILE_OPEN 0x01
92 #define SMB_FILE_OVERWRITE_IF 0x05
94 #define SMB_ERR_NOACCESS 0x00050001
97 unsigned char nbt_type;
98 unsigned char nbt_flags;
99 unsigned short nbt_length;
100 unsigned char magic[4];
101 unsigned char command;
104 unsigned short flags2;
105 unsigned short pid_high;
106 unsigned char signature[8];
114 struct smb_negotiate_response {
116 unsigned char word_count;
117 unsigned short dialect_index;
118 unsigned char security_mode;
119 unsigned short max_mpx_count;
120 unsigned short max_number_vcs;
121 unsigned int max_buffer_size;
122 unsigned int max_raw_size;
123 unsigned int session_key;
124 unsigned int capabilities;
125 unsigned int system_time_low;
126 unsigned int system_time_high;
127 unsigned short server_time_zone;
128 unsigned char encryption_key_length;
129 unsigned short byte_count;
134 unsigned char command;
136 unsigned short offset;
140 unsigned char word_count;
142 unsigned short max_buffer_size;
143 unsigned short max_mpx_count;
144 unsigned short vc_number;
145 unsigned int session_key;
146 unsigned short lengths[2];
148 unsigned int capabilities;
149 unsigned short byte_count;
153 struct smb_tree_connect {
154 unsigned char word_count;
156 unsigned short flags;
157 unsigned short pw_len;
158 unsigned short byte_count;
162 struct smb_nt_create {
163 unsigned char word_count;
166 unsigned short name_length;
168 unsigned int root_fid;
170 curl_off_t allocation_size;
171 unsigned int ext_file_attributes;
172 unsigned int share_access;
173 unsigned int create_disposition;
174 unsigned int create_options;
175 unsigned int impersonation_level;
176 unsigned char security_flags;
177 unsigned short byte_count;
181 struct smb_nt_create_response {
183 unsigned char word_count;
185 unsigned char op_lock_level;
187 unsigned int create_disposition;
189 curl_off_t create_time;
190 curl_off_t last_access_time;
191 curl_off_t last_write_time;
192 curl_off_t last_change_time;
193 unsigned int ext_file_attributes;
194 curl_off_t allocation_size;
195 curl_off_t end_of_file;
199 unsigned char word_count;
203 unsigned short max_bytes;
204 unsigned short min_bytes;
205 unsigned int timeout;
206 unsigned short remaining;
207 unsigned int offset_high;
208 unsigned short byte_count;
213 unsigned char word_count;
217 unsigned int timeout;
218 unsigned short write_mode;
219 unsigned short remaining;
221 unsigned short data_length;
222 unsigned short data_offset;
223 unsigned int offset_high;
224 unsigned short byte_count;
229 unsigned char word_count;
231 unsigned int last_mtime;
232 unsigned short byte_count;
235 struct smb_tree_disconnect {
236 unsigned char word_count;
237 unsigned short byte_count;
240 #if defined(_MSC_VER) || defined(__ILEC400__)
244 #endif /* BUILDING_CURL_SMB_C */
246 #if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) && \
247 (CURL_SIZEOF_CURL_OFF_T > 4)
249 extern const struct Curl_handler Curl_handler_smb;
250 extern const struct Curl_handler Curl_handler_smbs;
252 #endif /* CURL_DISABLE_SMB && USE_CURL_NTLM_CORE &&
253 CURL_SIZEOF_CURL_OFF_T > 4 */
255 #endif /* HEADER_CURL_SMB_H */