Go to the documentation of this file.00001 #ifndef HEADER_CURL_SMB_H
00002 #define HEADER_CURL_SMB_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 enum smb_conn_state {
00026 SMB_NOT_CONNECTED = 0,
00027 SMB_CONNECTING,
00028 SMB_NEGOTIATE,
00029 SMB_SETUP,
00030 SMB_CONNECTED
00031 };
00032
00033 struct smb_conn {
00034 enum smb_conn_state state;
00035 char *user;
00036 char *domain;
00037 unsigned char challenge[8];
00038 unsigned int session_key;
00039 unsigned short uid;
00040 char *recv_buf;
00041 size_t upload_size;
00042 size_t send_size;
00043 size_t sent;
00044 size_t got;
00045 };
00046
00047
00048
00049
00050 #ifdef BUILDING_CURL_SMB_C
00051
00052 #if defined(_MSC_VER) || defined(__ILEC400__)
00053 # define PACK
00054 # pragma pack(push)
00055 # pragma pack(1)
00056 #elif defined(__GNUC__)
00057 # define PACK __attribute__((packed))
00058 #else
00059 # define PACK
00060 #endif
00061
00062 #define SMB_COM_CLOSE 0x04
00063 #define SMB_COM_READ_ANDX 0x2e
00064 #define SMB_COM_WRITE_ANDX 0x2f
00065 #define SMB_COM_TREE_DISCONNECT 0x71
00066 #define SMB_COM_NEGOTIATE 0x72
00067 #define SMB_COM_SETUP_ANDX 0x73
00068 #define SMB_COM_TREE_CONNECT_ANDX 0x75
00069 #define SMB_COM_NT_CREATE_ANDX 0xa2
00070 #define SMB_COM_NO_ANDX_COMMAND 0xff
00071
00072 #define SMB_WC_CLOSE 0x03
00073 #define SMB_WC_READ_ANDX 0x0c
00074 #define SMB_WC_WRITE_ANDX 0x0e
00075 #define SMB_WC_SETUP_ANDX 0x0d
00076 #define SMB_WC_TREE_CONNECT_ANDX 0x04
00077 #define SMB_WC_NT_CREATE_ANDX 0x18
00078
00079 #define SMB_FLAGS_CANONICAL_PATHNAMES 0x10
00080 #define SMB_FLAGS_CASELESS_PATHNAMES 0x08
00081 #define SMB_FLAGS2_UNICODE_STRINGS 0x8000
00082 #define SMB_FLAGS2_IS_LONG_NAME 0x0040
00083 #define SMB_FLAGS2_KNOWS_LONG_NAME 0x0001
00084
00085 #define SMB_CAP_LARGE_FILES 0x08
00086 #define SMB_GENERIC_WRITE 0x40000000
00087 #define SMB_GENERIC_READ 0x80000000
00088 #define SMB_FILE_SHARE_ALL 0x07
00089 #define SMB_FILE_OPEN 0x01
00090 #define SMB_FILE_OVERWRITE_IF 0x05
00091
00092 #define SMB_ERR_NOACCESS 0x00050001
00093
00094 struct smb_header {
00095 unsigned char nbt_type;
00096 unsigned char nbt_flags;
00097 unsigned short nbt_length;
00098 unsigned char magic[4];
00099 unsigned char command;
00100 unsigned int status;
00101 unsigned char flags;
00102 unsigned short flags2;
00103 unsigned short pid_high;
00104 unsigned char signature[8];
00105 unsigned short pad;
00106 unsigned short tid;
00107 unsigned short pid;
00108 unsigned short uid;
00109 unsigned short mid;
00110 } PACK;
00111
00112 struct smb_negotiate_response {
00113 struct smb_header h;
00114 unsigned char word_count;
00115 unsigned short dialect_index;
00116 unsigned char security_mode;
00117 unsigned short max_mpx_count;
00118 unsigned short max_number_vcs;
00119 unsigned int max_buffer_size;
00120 unsigned int max_raw_size;
00121 unsigned int session_key;
00122 unsigned int capabilities;
00123 unsigned int system_time_low;
00124 unsigned int system_time_high;
00125 unsigned short server_time_zone;
00126 unsigned char encryption_key_length;
00127 unsigned short byte_count;
00128 char bytes[1];
00129 } PACK;
00130
00131 struct andx {
00132 unsigned char command;
00133 unsigned char pad;
00134 unsigned short offset;
00135 } PACK;
00136
00137 struct smb_setup {
00138 unsigned char word_count;
00139 struct andx andx;
00140 unsigned short max_buffer_size;
00141 unsigned short max_mpx_count;
00142 unsigned short vc_number;
00143 unsigned int session_key;
00144 unsigned short lengths[2];
00145 unsigned int pad;
00146 unsigned int capabilities;
00147 unsigned short byte_count;
00148 char bytes[1024];
00149 } PACK;
00150
00151 struct smb_tree_connect {
00152 unsigned char word_count;
00153 struct andx andx;
00154 unsigned short flags;
00155 unsigned short pw_len;
00156 unsigned short byte_count;
00157 char bytes[1024];
00158 } PACK;
00159
00160 struct smb_nt_create {
00161 unsigned char word_count;
00162 struct andx andx;
00163 unsigned char pad;
00164 unsigned short name_length;
00165 unsigned int flags;
00166 unsigned int root_fid;
00167 unsigned int access;
00168 #ifdef HAVE_LONGLONG
00169 unsigned long long allocation_size;
00170 #else
00171 unsigned __int64 allocation_size;
00172 #endif
00173 unsigned int ext_file_attributes;
00174 unsigned int share_access;
00175 unsigned int create_disposition;
00176 unsigned int create_options;
00177 unsigned int impersonation_level;
00178 unsigned char security_flags;
00179 unsigned short byte_count;
00180 char bytes[1024];
00181 } PACK;
00182
00183 struct smb_nt_create_response {
00184 struct smb_header h;
00185 unsigned char word_count;
00186 struct andx andx;
00187 unsigned char op_lock_level;
00188 unsigned short fid;
00189 unsigned int create_disposition;
00190 #ifdef HAVE_LONGLONG
00191 unsigned long long create_time;
00192 unsigned long long last_access_time;
00193 unsigned long long last_write_time;
00194 unsigned long long last_change_time;
00195 #else
00196 unsigned __int64 create_time;
00197 unsigned __int64 last_access_time;
00198 unsigned __int64 last_write_time;
00199 unsigned __int64 last_change_time;
00200 #endif
00201 unsigned int ext_file_attributes;
00202 #ifdef HAVE_LONGLONG
00203 unsigned long long allocation_size;
00204 unsigned long long end_of_file;
00205 #else
00206 unsigned __int64 allocation_size;
00207 unsigned __int64 end_of_file;
00208 #endif
00209 } PACK;
00210
00211 struct smb_read {
00212 unsigned char word_count;
00213 struct andx andx;
00214 unsigned short fid;
00215 unsigned int offset;
00216 unsigned short max_bytes;
00217 unsigned short min_bytes;
00218 unsigned int timeout;
00219 unsigned short remaining;
00220 unsigned int offset_high;
00221 unsigned short byte_count;
00222 } PACK;
00223
00224 struct smb_write {
00225 struct smb_header h;
00226 unsigned char word_count;
00227 struct andx andx;
00228 unsigned short fid;
00229 unsigned int offset;
00230 unsigned int timeout;
00231 unsigned short write_mode;
00232 unsigned short remaining;
00233 unsigned short pad;
00234 unsigned short data_length;
00235 unsigned short data_offset;
00236 unsigned int offset_high;
00237 unsigned short byte_count;
00238 unsigned char pad2;
00239 } PACK;
00240
00241 struct smb_close {
00242 unsigned char word_count;
00243 unsigned short fid;
00244 unsigned int last_mtime;
00245 unsigned short byte_count;
00246 } PACK;
00247
00248 struct smb_tree_disconnect {
00249 unsigned char word_count;
00250 unsigned short byte_count;
00251 } PACK;
00252
00253 #if defined(_MSC_VER) || defined(__ILEC400__)
00254 # pragma pack(pop)
00255 #endif
00256
00257 #endif
00258
00259 #if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \
00260 (CURL_SIZEOF_CURL_OFF_T > 4)
00261
00262 #if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)
00263
00264 extern const struct Curl_handler Curl_handler_smb;
00265 extern const struct Curl_handler Curl_handler_smbs;
00266
00267 #endif
00268
00269 #endif
00270
00271 #endif