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
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.haxx.se/docs/copyright.html.
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
26 SMB_NOT_CONNECTED = 0,
34 enum smb_conn_state state;
37 unsigned char challenge[8];
38 unsigned int session_key;
48 * Definitions for SMB protocol data structures
50 #ifdef BUILDING_CURL_SMB_C
52 #if defined(_MSC_VER) || defined(__ILEC400__)
56 #elif defined(__GNUC__)
57 # define PACK __attribute__((packed))
62 #define SMB_COM_CLOSE 0x04
63 #define SMB_COM_READ_ANDX 0x2e
64 #define SMB_COM_WRITE_ANDX 0x2f
65 #define SMB_COM_TREE_DISCONNECT 0x71
66 #define SMB_COM_NEGOTIATE 0x72
67 #define SMB_COM_SETUP_ANDX 0x73
68 #define SMB_COM_TREE_CONNECT_ANDX 0x75
69 #define SMB_COM_NT_CREATE_ANDX 0xa2
70 #define SMB_COM_NO_ANDX_COMMAND 0xff
72 #define SMB_WC_CLOSE 0x03
73 #define SMB_WC_READ_ANDX 0x0c
74 #define SMB_WC_WRITE_ANDX 0x0e
75 #define SMB_WC_SETUP_ANDX 0x0d
76 #define SMB_WC_TREE_CONNECT_ANDX 0x04
77 #define SMB_WC_NT_CREATE_ANDX 0x18
79 #define SMB_FLAGS_CANONICAL_PATHNAMES 0x10
80 #define SMB_FLAGS_CASELESS_PATHNAMES 0x08
81 #define SMB_FLAGS2_UNICODE_STRINGS 0x8000
82 #define SMB_FLAGS2_IS_LONG_NAME 0x0040
83 #define SMB_FLAGS2_KNOWS_LONG_NAME 0x0001
85 #define SMB_CAP_LARGE_FILES 0x08
86 #define SMB_GENERIC_WRITE 0x40000000
87 #define SMB_GENERIC_READ 0x80000000
88 #define SMB_FILE_SHARE_ALL 0x07
89 #define SMB_FILE_OPEN 0x01
90 #define SMB_FILE_OVERWRITE_IF 0x05
92 #define SMB_ERR_NOACCESS 0x00050001
95 unsigned char nbt_type;
96 unsigned char nbt_flags;
97 unsigned short nbt_length;
98 unsigned char magic[4];
99 unsigned char command;
102 unsigned short flags2;
103 unsigned short pid_high;
104 unsigned char signature[8];
112 struct smb_negotiate_response {
114 unsigned char word_count;
115 unsigned short dialect_index;
116 unsigned char security_mode;
117 unsigned short max_mpx_count;
118 unsigned short max_number_vcs;
119 unsigned int max_buffer_size;
120 unsigned int max_raw_size;
121 unsigned int session_key;
122 unsigned int capabilities;
123 unsigned int system_time_low;
124 unsigned int system_time_high;
125 unsigned short server_time_zone;
126 unsigned char encryption_key_length;
127 unsigned short byte_count;
132 unsigned char command;
134 unsigned short offset;
138 unsigned char word_count;
140 unsigned short max_buffer_size;
141 unsigned short max_mpx_count;
142 unsigned short vc_number;
143 unsigned int session_key;
144 unsigned short lengths[2];
146 unsigned int capabilities;
147 unsigned short byte_count;
151 struct smb_tree_connect {
152 unsigned char word_count;
154 unsigned short flags;
155 unsigned short pw_len;
156 unsigned short byte_count;
160 struct smb_nt_create {
161 unsigned char word_count;
164 unsigned short name_length;
166 unsigned int root_fid;
169 unsigned long long allocation_size;
171 unsigned __int64 allocation_size;
173 unsigned int ext_file_attributes;
174 unsigned int share_access;
175 unsigned int create_disposition;
176 unsigned int create_options;
177 unsigned int impersonation_level;
178 unsigned char security_flags;
179 unsigned short byte_count;
183 struct smb_nt_create_response {
185 unsigned char word_count;
187 unsigned char op_lock_level;
189 unsigned int create_disposition;
191 unsigned long long create_time;
192 unsigned long long last_access_time;
193 unsigned long long last_write_time;
194 unsigned long long last_change_time;
196 unsigned __int64 create_time;
197 unsigned __int64 last_access_time;
198 unsigned __int64 last_write_time;
199 unsigned __int64 last_change_time;
201 unsigned int ext_file_attributes;
203 unsigned long long allocation_size;
204 unsigned long long end_of_file;
206 unsigned __int64 allocation_size;
207 unsigned __int64 end_of_file;
212 unsigned char word_count;
216 unsigned short max_bytes;
217 unsigned short min_bytes;
218 unsigned int timeout;
219 unsigned short remaining;
220 unsigned int offset_high;
221 unsigned short byte_count;
226 unsigned char word_count;
230 unsigned int timeout;
231 unsigned short write_mode;
232 unsigned short remaining;
234 unsigned short data_length;
235 unsigned short data_offset;
236 unsigned int offset_high;
237 unsigned short byte_count;
242 unsigned char word_count;
244 unsigned int last_mtime;
245 unsigned short byte_count;
248 struct smb_tree_disconnect {
249 unsigned char word_count;
250 unsigned short byte_count;
253 #if defined(_MSC_VER) || defined(__ILEC400__)
257 #endif /* BUILDING_CURL_SMB_C */
259 #if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \
260 (CURL_SIZEOF_CURL_OFF_T > 4)
262 #if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)
264 extern const struct Curl_handler Curl_handler_smb;
265 extern const struct Curl_handler Curl_handler_smbs;
267 #endif /* !USE_WINDOWS_SSPI || USE_WIN32_CRYPTO */
269 #endif /* CURL_DISABLE_SMB && USE_NTLM && CURL_SIZEOF_CURL_OFF_T > 4 */
271 #endif /* HEADER_CURL_SMB_H */