1 #ifndef HEADER_CURL_SMB_H
2 #define HEADER_CURL_SMB_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 2018, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
11 * Copyright (C) 2018 - 2022, 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.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 * SPDX-License-Identifier: curl
26 ***************************************************************************/
29 SMB_NOT_CONNECTED = 0,
37 enum smb_conn_state state;
41 unsigned char challenge[8];
42 unsigned int session_key;
52 * Definitions for SMB protocol data structures
54 #ifdef BUILDING_CURL_SMB_C
56 #if defined(_MSC_VER) || defined(__ILEC400__)
60 #elif defined(__GNUC__)
61 # define PACK __attribute__((packed))
66 #define SMB_COM_CLOSE 0x04
67 #define SMB_COM_READ_ANDX 0x2e
68 #define SMB_COM_WRITE_ANDX 0x2f
69 #define SMB_COM_TREE_DISCONNECT 0x71
70 #define SMB_COM_NEGOTIATE 0x72
71 #define SMB_COM_SETUP_ANDX 0x73
72 #define SMB_COM_TREE_CONNECT_ANDX 0x75
73 #define SMB_COM_NT_CREATE_ANDX 0xa2
74 #define SMB_COM_NO_ANDX_COMMAND 0xff
76 #define SMB_WC_CLOSE 0x03
77 #define SMB_WC_READ_ANDX 0x0c
78 #define SMB_WC_WRITE_ANDX 0x0e
79 #define SMB_WC_SETUP_ANDX 0x0d
80 #define SMB_WC_TREE_CONNECT_ANDX 0x04
81 #define SMB_WC_NT_CREATE_ANDX 0x18
83 #define SMB_FLAGS_CANONICAL_PATHNAMES 0x10
84 #define SMB_FLAGS_CASELESS_PATHNAMES 0x08
85 #define SMB_FLAGS2_UNICODE_STRINGS 0x8000
86 #define SMB_FLAGS2_IS_LONG_NAME 0x0040
87 #define SMB_FLAGS2_KNOWS_LONG_NAME 0x0001
89 #define SMB_CAP_LARGE_FILES 0x08
90 #define SMB_GENERIC_WRITE 0x40000000
91 #define SMB_GENERIC_READ 0x80000000
92 #define SMB_FILE_SHARE_ALL 0x07
93 #define SMB_FILE_OPEN 0x01
94 #define SMB_FILE_OVERWRITE_IF 0x05
96 #define SMB_ERR_NOACCESS 0x00050001
99 unsigned char nbt_type;
100 unsigned char nbt_flags;
101 unsigned short nbt_length;
102 unsigned char magic[4];
103 unsigned char command;
106 unsigned short flags2;
107 unsigned short pid_high;
108 unsigned char signature[8];
116 struct smb_negotiate_response {
118 unsigned char word_count;
119 unsigned short dialect_index;
120 unsigned char security_mode;
121 unsigned short max_mpx_count;
122 unsigned short max_number_vcs;
123 unsigned int max_buffer_size;
124 unsigned int max_raw_size;
125 unsigned int session_key;
126 unsigned int capabilities;
127 unsigned int system_time_low;
128 unsigned int system_time_high;
129 unsigned short server_time_zone;
130 unsigned char encryption_key_length;
131 unsigned short byte_count;
136 unsigned char command;
138 unsigned short offset;
142 unsigned char word_count;
144 unsigned short max_buffer_size;
145 unsigned short max_mpx_count;
146 unsigned short vc_number;
147 unsigned int session_key;
148 unsigned short lengths[2];
150 unsigned int capabilities;
151 unsigned short byte_count;
155 struct smb_tree_connect {
156 unsigned char word_count;
158 unsigned short flags;
159 unsigned short pw_len;
160 unsigned short byte_count;
164 struct smb_nt_create {
165 unsigned char word_count;
168 unsigned short name_length;
170 unsigned int root_fid;
172 curl_off_t 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 curl_off_t create_time;
192 curl_off_t last_access_time;
193 curl_off_t last_write_time;
194 curl_off_t last_change_time;
195 unsigned int ext_file_attributes;
196 curl_off_t allocation_size;
197 curl_off_t end_of_file;
201 unsigned char word_count;
205 unsigned short max_bytes;
206 unsigned short min_bytes;
207 unsigned int timeout;
208 unsigned short remaining;
209 unsigned int offset_high;
210 unsigned short byte_count;
215 unsigned char word_count;
219 unsigned int timeout;
220 unsigned short write_mode;
221 unsigned short remaining;
223 unsigned short data_length;
224 unsigned short data_offset;
225 unsigned int offset_high;
226 unsigned short byte_count;
231 unsigned char word_count;
233 unsigned int last_mtime;
234 unsigned short byte_count;
237 struct smb_tree_disconnect {
238 unsigned char word_count;
239 unsigned short byte_count;
242 #if defined(_MSC_VER) || defined(__ILEC400__)
246 #endif /* BUILDING_CURL_SMB_C */
248 #if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) && \
249 (SIZEOF_CURL_OFF_T > 4)
251 extern const struct Curl_handler Curl_handler_smb;
252 extern const struct Curl_handler Curl_handler_smbs;
254 #endif /* CURL_DISABLE_SMB && USE_CURL_NTLM_CORE &&
255 SIZEOF_CURL_OFF_T > 4 */
257 #endif /* HEADER_CURL_SMB_H */