Annotation of embedaddon/curl/lib/smb.h, revision 1.1
1.1 ! misho 1: #ifndef HEADER_CURL_SMB_H
! 2: #define HEADER_CURL_SMB_H
! 3: /***************************************************************************
! 4: * _ _ ____ _
! 5: * Project ___| | | | _ \| |
! 6: * / __| | | | |_) | |
! 7: * | (__| |_| | _ <| |___
! 8: * \___|\___/|_| \_\_____|
! 9: *
! 10: * Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
! 11: * Copyright (C) 2018 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
! 12: *
! 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.
! 16: *
! 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.
! 20: *
! 21: * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
! 22: * KIND, either express or implied.
! 23: *
! 24: ***************************************************************************/
! 25:
! 26: enum smb_conn_state {
! 27: SMB_NOT_CONNECTED = 0,
! 28: SMB_CONNECTING,
! 29: SMB_NEGOTIATE,
! 30: SMB_SETUP,
! 31: SMB_CONNECTED
! 32: };
! 33:
! 34: struct smb_conn {
! 35: enum smb_conn_state state;
! 36: char *user;
! 37: char *domain;
! 38: char *share;
! 39: unsigned char challenge[8];
! 40: unsigned int session_key;
! 41: unsigned short uid;
! 42: char *recv_buf;
! 43: size_t upload_size;
! 44: size_t send_size;
! 45: size_t sent;
! 46: size_t got;
! 47: };
! 48:
! 49: /*
! 50: * Definitions for SMB protocol data structures
! 51: */
! 52: #ifdef BUILDING_CURL_SMB_C
! 53:
! 54: #if defined(_MSC_VER) || defined(__ILEC400__)
! 55: # define PACK
! 56: # pragma pack(push)
! 57: # pragma pack(1)
! 58: #elif defined(__GNUC__)
! 59: # define PACK __attribute__((packed))
! 60: #else
! 61: # define PACK
! 62: #endif
! 63:
! 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
! 73:
! 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
! 80:
! 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
! 86:
! 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
! 93:
! 94: #define SMB_ERR_NOACCESS 0x00050001
! 95:
! 96: struct smb_header {
! 97: unsigned char nbt_type;
! 98: unsigned char nbt_flags;
! 99: unsigned short nbt_length;
! 100: unsigned char magic[4];
! 101: unsigned char command;
! 102: unsigned int status;
! 103: unsigned char flags;
! 104: unsigned short flags2;
! 105: unsigned short pid_high;
! 106: unsigned char signature[8];
! 107: unsigned short pad;
! 108: unsigned short tid;
! 109: unsigned short pid;
! 110: unsigned short uid;
! 111: unsigned short mid;
! 112: } PACK;
! 113:
! 114: struct smb_negotiate_response {
! 115: struct smb_header h;
! 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;
! 130: char bytes[1];
! 131: } PACK;
! 132:
! 133: struct andx {
! 134: unsigned char command;
! 135: unsigned char pad;
! 136: unsigned short offset;
! 137: } PACK;
! 138:
! 139: struct smb_setup {
! 140: unsigned char word_count;
! 141: struct andx andx;
! 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];
! 147: unsigned int pad;
! 148: unsigned int capabilities;
! 149: unsigned short byte_count;
! 150: char bytes[1024];
! 151: } PACK;
! 152:
! 153: struct smb_tree_connect {
! 154: unsigned char word_count;
! 155: struct andx andx;
! 156: unsigned short flags;
! 157: unsigned short pw_len;
! 158: unsigned short byte_count;
! 159: char bytes[1024];
! 160: } PACK;
! 161:
! 162: struct smb_nt_create {
! 163: unsigned char word_count;
! 164: struct andx andx;
! 165: unsigned char pad;
! 166: unsigned short name_length;
! 167: unsigned int flags;
! 168: unsigned int root_fid;
! 169: unsigned int access;
! 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;
! 178: char bytes[1024];
! 179: } PACK;
! 180:
! 181: struct smb_nt_create_response {
! 182: struct smb_header h;
! 183: unsigned char word_count;
! 184: struct andx andx;
! 185: unsigned char op_lock_level;
! 186: unsigned short fid;
! 187: unsigned int create_disposition;
! 188:
! 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;
! 196: } PACK;
! 197:
! 198: struct smb_read {
! 199: unsigned char word_count;
! 200: struct andx andx;
! 201: unsigned short fid;
! 202: unsigned int offset;
! 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;
! 209: } PACK;
! 210:
! 211: struct smb_write {
! 212: struct smb_header h;
! 213: unsigned char word_count;
! 214: struct andx andx;
! 215: unsigned short fid;
! 216: unsigned int offset;
! 217: unsigned int timeout;
! 218: unsigned short write_mode;
! 219: unsigned short remaining;
! 220: unsigned short pad;
! 221: unsigned short data_length;
! 222: unsigned short data_offset;
! 223: unsigned int offset_high;
! 224: unsigned short byte_count;
! 225: unsigned char pad2;
! 226: } PACK;
! 227:
! 228: struct smb_close {
! 229: unsigned char word_count;
! 230: unsigned short fid;
! 231: unsigned int last_mtime;
! 232: unsigned short byte_count;
! 233: } PACK;
! 234:
! 235: struct smb_tree_disconnect {
! 236: unsigned char word_count;
! 237: unsigned short byte_count;
! 238: } PACK;
! 239:
! 240: #if defined(_MSC_VER) || defined(__ILEC400__)
! 241: # pragma pack(pop)
! 242: #endif
! 243:
! 244: #endif /* BUILDING_CURL_SMB_C */
! 245:
! 246: #if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \
! 247: (CURL_SIZEOF_CURL_OFF_T > 4)
! 248:
! 249: #if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)
! 250:
! 251: extern const struct Curl_handler Curl_handler_smb;
! 252: extern const struct Curl_handler Curl_handler_smbs;
! 253:
! 254: #endif /* !USE_WINDOWS_SSPI || USE_WIN32_CRYPTO */
! 255:
! 256: #endif /* CURL_DISABLE_SMB && USE_NTLM && CURL_SIZEOF_CURL_OFF_T > 4 */
! 257:
! 258: #endif /* HEADER_CURL_SMB_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>