14bff34e3Sthurlow /* 24bff34e3Sthurlow * Copyright (c) 2000-2001 Boris Popov 34bff34e3Sthurlow * All rights reserved. 44bff34e3Sthurlow * 54bff34e3Sthurlow * Now many of these defines are from samba4 code, by Andrew Tridgell. 64bff34e3Sthurlow * (Permission given to Conrad Minshall at CIFS plugfest Aug 13 2003.) 74bff34e3Sthurlow * (Note the main decision was whether to use defines found in MS includes 84bff34e3Sthurlow * and web pages, versus Samba, and the deciding factor is which developers 94bff34e3Sthurlow * are more likely to be looking at this code base.) 104bff34e3Sthurlow * 114bff34e3Sthurlow * Redistribution and use in source and binary forms, with or without 124bff34e3Sthurlow * modification, are permitted provided that the following conditions 134bff34e3Sthurlow * are met: 144bff34e3Sthurlow * 1. Redistributions of source code must retain the above copyright 154bff34e3Sthurlow * notice, this list of conditions and the following disclaimer. 164bff34e3Sthurlow * 2. Redistributions in binary form must reproduce the above copyright 174bff34e3Sthurlow * notice, this list of conditions and the following disclaimer in the 184bff34e3Sthurlow * documentation and/or other materials provided with the distribution. 194bff34e3Sthurlow * 3. All advertising materials mentioning features or use of this software 204bff34e3Sthurlow * must display the following acknowledgement: 214bff34e3Sthurlow * This product includes software developed by Boris Popov. 224bff34e3Sthurlow * 4. Neither the name of the author nor the names of any co-contributors 234bff34e3Sthurlow * may be used to endorse or promote products derived from this software 244bff34e3Sthurlow * without specific prior written permission. 254bff34e3Sthurlow * 264bff34e3Sthurlow * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 274bff34e3Sthurlow * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 284bff34e3Sthurlow * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 294bff34e3Sthurlow * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 304bff34e3Sthurlow * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 314bff34e3Sthurlow * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 324bff34e3Sthurlow * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 334bff34e3Sthurlow * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 344bff34e3Sthurlow * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 354bff34e3Sthurlow * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 364bff34e3Sthurlow * SUCH DAMAGE. 374bff34e3Sthurlow * 384bff34e3Sthurlow * $Id: smb.h,v 1.36.90.1 2005/05/27 02:35:29 lindak Exp $ 394bff34e3Sthurlow */ 404bff34e3Sthurlow 414bff34e3Sthurlow /* 42*148c5f43SAlan Wright * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 434bff34e3Sthurlow */ 444bff34e3Sthurlow 454bff34e3Sthurlow #ifndef _NETSMB_SMB_H_ 464bff34e3Sthurlow #define _NETSMB_SMB_H_ 474bff34e3Sthurlow 484bff34e3Sthurlow /* 49*148c5f43SAlan Wright * Common definitions and structures for SMB/CIFS protocol 504bff34e3Sthurlow * This file should be purely SMB protocol definition stuff. 514bff34e3Sthurlow * (Please don't make it a catch-all:) 524bff34e3Sthurlow */ 534bff34e3Sthurlow 54*148c5f43SAlan Wright #include <smb/doserror.h> 55*148c5f43SAlan Wright #include <smb/lmerr.h> 56*148c5f43SAlan Wright #include <smb/nterror.h> 57*148c5f43SAlan Wright #include <smb/ntstatus.h> 58*148c5f43SAlan Wright 594bff34e3Sthurlow /* 604bff34e3Sthurlow * SMB dialects that we have to deal with. 614bff34e3Sthurlow */ 624bff34e3Sthurlow enum smb_dialects { 634bff34e3Sthurlow SMB_DIALECT_NONE, 644bff34e3Sthurlow SMB_DIALECT_CORE, /* PC NETWORK PROGRAM 1.0, PCLAN1.0 */ 654bff34e3Sthurlow SMB_DIALECT_COREPLUS, /* MICROSOFT NETWORKS 1.03 */ 664bff34e3Sthurlow SMB_DIALECT_LANMAN1_0, /* MICROSOFT NETWORKS 3.0, LANMAN1.0 */ 674bff34e3Sthurlow SMB_DIALECT_LANMAN2_0, /* LM1.2X002, DOS LM1.2X002, Samba */ 684bff34e3Sthurlow SMB_DIALECT_LANMAN2_1, /* DOS LANMAN2.1, LANMAN2.1 */ 694bff34e3Sthurlow SMB_DIALECT_NTLM0_12 /* NT LM 0.12, Windows for Workgroups */ 704bff34e3Sthurlow /* 3.1a, * NT LANMAN 1.0 */ 714bff34e3Sthurlow }; 724bff34e3Sthurlow 734bff34e3Sthurlow /* 744bff34e3Sthurlow * Formats of data/string buffers 754bff34e3Sthurlow */ 764bff34e3Sthurlow #define SMB_DT_DATA 1 774bff34e3Sthurlow #define SMB_DT_DIALECT 2 784bff34e3Sthurlow #define SMB_DT_PATHNAME 3 794bff34e3Sthurlow #define SMB_DT_ASCII 4 804bff34e3Sthurlow #define SMB_DT_VARIABLE 5 814bff34e3Sthurlow 824bff34e3Sthurlow /* 834bff34e3Sthurlow * SMB header 844bff34e3Sthurlow */ 854bff34e3Sthurlow #define SMB_SIGNATURE "\xFFSMB" 864bff34e3Sthurlow #define SMB_SIGLEN 4 874bff34e3Sthurlow #define SMB_HDRCMD(p) (*((uchar_t *)(p) + SMB_SIGLEN)) 88613a2f6bSGordon Ross #define SMB_HDRMID(p) (*(ushort_t *)((uchar_t *)(p) + 30)) 894bff34e3Sthurlow #define SMB_HDRLEN 32 904bff34e3Sthurlow /* 914bff34e3Sthurlow * bits in the smb_flags field 924bff34e3Sthurlow */ 934bff34e3Sthurlow #define SMB_FLAGS_SUPPORT_LOCKREAD 0x01 944bff34e3Sthurlow #define SMB_FLAGS_CLIENT_BUF_AVAIL 0x02 954bff34e3Sthurlow #define SMB_FLAGS_CASELESS 0x08 964bff34e3Sthurlow #define SMB_FLAGS_CANONICAL_PATHNAMES 0x10 974bff34e3Sthurlow #define SMB_FLAGS_REQUEST_OPLOCK 0x20 984bff34e3Sthurlow #define SMB_FLAGS_REQUEST_BATCH_OPLOCK 0x40 994bff34e3Sthurlow #define SMB_FLAGS_SERVER_RESP 0x80 1004bff34e3Sthurlow 1014bff34e3Sthurlow /* 1024bff34e3Sthurlow * bits in the smb_flags2 field 1034bff34e3Sthurlow */ 1044bff34e3Sthurlow #define SMB_FLAGS2_KNOWS_LONG_NAMES 0x0001 1054bff34e3Sthurlow #define SMB_FLAGS2_KNOWS_EAS 0x0002 /* client know about EAs */ 1064bff34e3Sthurlow #define SMB_FLAGS2_SECURITY_SIGNATURE 0x0004 /* check SMB integrity */ 1074bff34e3Sthurlow #define SMB_FLAGS2_IS_LONG_NAME 0x0040 /* any path name is long name */ 1084bff34e3Sthurlow #define SMB_FLAGS2_EXT_SEC 0x0800 /* client aware of Extended */ 1094bff34e3Sthurlow /* Security negotiation */ 1104bff34e3Sthurlow #define SMB_FLAGS2_DFS 0x1000 /* resolve paths in DFS */ 1114bff34e3Sthurlow #define SMB_FLAGS2_PAGING_IO 0x2000 /* for exec */ 1124bff34e3Sthurlow #define SMB_FLAGS2_ERR_STATUS 0x4000 /* 1 - status.status */ 1134bff34e3Sthurlow #define SMB_FLAGS2_UNICODE 0x8000 /* use Unicode for strings */ 1144bff34e3Sthurlow 1154bff34e3Sthurlow #define SMB_UID_UNKNOWN 0xffff 1164bff34e3Sthurlow #define SMB_TID_UNKNOWN 0xffff 1174bff34e3Sthurlow #define SMB_FID_UNUSED 0xffff 1184bff34e3Sthurlow 1194bff34e3Sthurlow /* 1204bff34e3Sthurlow * Security mode bits 1214bff34e3Sthurlow */ 1224bff34e3Sthurlow #define SMB_SM_USER 0x01 /* server in the user security mode */ 1234bff34e3Sthurlow #define SMB_SM_ENCRYPT 0x02 /* use challenge/responce */ 1244bff34e3Sthurlow #define SMB_SM_SIGS 0x04 1254bff34e3Sthurlow #define SMB_SM_SIGS_REQUIRE 0x08 1264bff34e3Sthurlow 1274bff34e3Sthurlow /* 1284bff34e3Sthurlow * Action bits in session setup reply 1294bff34e3Sthurlow */ 1304bff34e3Sthurlow #define SMB_ACT_GUEST 0x01 1314bff34e3Sthurlow 1324bff34e3Sthurlow /* 1334bff34e3Sthurlow * NTLM capabilities 1344bff34e3Sthurlow */ 1354bff34e3Sthurlow #define SMB_CAP_RAW_MODE 0x0001 1364bff34e3Sthurlow #define SMB_CAP_MPX_MODE 0x0002 1374bff34e3Sthurlow #define SMB_CAP_UNICODE 0x0004 1384bff34e3Sthurlow #define SMB_CAP_LARGE_FILES 0x0008 /* 64 bit offsets supported */ 1394bff34e3Sthurlow #define SMB_CAP_NT_SMBS 0x0010 1404bff34e3Sthurlow #define SMB_CAP_RPC_REMOTE_APIS 0x0020 1414bff34e3Sthurlow #define SMB_CAP_STATUS32 0x0040 1424bff34e3Sthurlow #define SMB_CAP_LEVEL_II_OPLOCKS 0x0080 1434bff34e3Sthurlow #define SMB_CAP_LOCK_AND_READ 0x0100 1444bff34e3Sthurlow #define SMB_CAP_NT_FIND 0x0200 1454bff34e3Sthurlow #define SMB_CAP_DFS 0x1000 1464bff34e3Sthurlow #define SMB_CAP_INFOLEVEL_PASSTHRU 0x2000 1474bff34e3Sthurlow #define SMB_CAP_LARGE_READX 0x4000 1484bff34e3Sthurlow #define SMB_CAP_LARGE_WRITEX 0x8000 1494bff34e3Sthurlow #define SMB_CAP_UNIX 0x00800000 1504bff34e3Sthurlow #define SMB_CAP_BULK_TRANSFER 0x20000000 1514bff34e3Sthurlow #define SMB_CAP_COMPRESSED_DATA 0x40000000 1524bff34e3Sthurlow #define SMB_CAP_EXT_SECURITY 0x80000000 1534bff34e3Sthurlow 1544bff34e3Sthurlow /* 1554bff34e3Sthurlow * File attributes 1564bff34e3Sthurlow */ 1574bff34e3Sthurlow #define SMB_FA_RDONLY 0x01 1584bff34e3Sthurlow #define SMB_FA_HIDDEN 0x02 1594bff34e3Sthurlow #define SMB_FA_SYSTEM 0x04 1604bff34e3Sthurlow #define SMB_FA_VOLUME 0x08 1614bff34e3Sthurlow #define SMB_FA_DIR 0x10 1624bff34e3Sthurlow #define SMB_FA_ARCHIVE 0x20 1634bff34e3Sthurlow 1644bff34e3Sthurlow /* 1654bff34e3Sthurlow * Extended file attributes 1664bff34e3Sthurlow */ 1674bff34e3Sthurlow #define SMB_EFA_RDONLY 0x00000001 1684bff34e3Sthurlow #define SMB_EFA_HIDDEN 0x00000002 1694bff34e3Sthurlow #define SMB_EFA_SYSTEM 0x00000004 1704bff34e3Sthurlow #define SMB_EFA_VOLUME 0x00000008 1714bff34e3Sthurlow #define SMB_EFA_DIRECTORY 0x00000010 1724bff34e3Sthurlow #define SMB_EFA_ARCHIVE 0x00000020 1734bff34e3Sthurlow #define SMB_EFA_DEVICE 0x00000040 1744bff34e3Sthurlow #define SMB_EFA_NORMAL 0x00000080 1754bff34e3Sthurlow #define SMB_EFA_TEMPORARY 0x00000100 1764bff34e3Sthurlow #define SMB_EFA_SPARSE 0x00000200 1774bff34e3Sthurlow #define SMB_EFA_REPARSE_POINT 0x00000400 1784bff34e3Sthurlow #define SMB_EFA_COMPRESSED 0x00000800 1794bff34e3Sthurlow #define SMB_EFA_OFFLINE 0x00001000 1804bff34e3Sthurlow #define SMB_EFA_NONINDEXED 0x00002000 1814bff34e3Sthurlow #define SMB_EFA_ENCRYPTED 0x00004000 1824bff34e3Sthurlow #define SMB_EFA_POSIX_SEMANTICS 0x01000000 1834bff34e3Sthurlow #define SMB_EFA_BACKUP_SEMANTICS 0x02000000 1844bff34e3Sthurlow #define SMB_EFA_DELETE_ON_CLOSE 0x04000000 1854bff34e3Sthurlow #define SMB_EFA_SEQUENTIAL_SCAN 0x08000000 1864bff34e3Sthurlow #define SMB_EFA_RANDOM_ACCESS 0x10000000 1874bff34e3Sthurlow #define SMB_EFA_NO_BUFFERING 0x20000000 1884bff34e3Sthurlow #define SMB_EFA_WRITE_THROUGH 0x80000000 1894bff34e3Sthurlow 1904bff34e3Sthurlow /* 1914bff34e3Sthurlow * Access Mode Encoding 1924bff34e3Sthurlow */ 1934bff34e3Sthurlow #define SMB_AM_OPENREAD 0x0000 1944bff34e3Sthurlow #define SMB_AM_OPENWRITE 0x0001 1954bff34e3Sthurlow #define SMB_AM_OPENRW 0x0002 1964bff34e3Sthurlow #define SMB_AM_OPENEXEC 0x0003 1974bff34e3Sthurlow #define SMB_AM_OPENMODE 0x0003 /* mask for access mode bits */ 1984bff34e3Sthurlow #define SMB_SM_COMPAT 0x0000 1994bff34e3Sthurlow #define SMB_SM_EXCLUSIVE 0x0010 2004bff34e3Sthurlow #define SMB_SM_DENYWRITE 0x0020 2014bff34e3Sthurlow #define SMB_SM_DENYREADEXEC 0x0030 2024bff34e3Sthurlow #define SMB_SM_DENYNONE 0x0040 2034bff34e3Sthurlow 2044bff34e3Sthurlow /* NT_CREATE_ANDX flags */ 2054bff34e3Sthurlow #define NTCREATEX_FLAGS_REQUEST_OPLOCK 0x02 2064bff34e3Sthurlow #define NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK 0x04 2074bff34e3Sthurlow #define NTCREATEX_FLAGS_OPEN_DIRECTORY 0x08 2084bff34e3Sthurlow #define NTCREATEX_FLAGS_EXTENDED 0x10 2094bff34e3Sthurlow 2104bff34e3Sthurlow /* NT_CREATE_ANDX share_access (share mode) */ 2114bff34e3Sthurlow #define NTCREATEX_SHARE_ACCESS_NONE 0 2124bff34e3Sthurlow #define NTCREATEX_SHARE_ACCESS_READ 1 2134bff34e3Sthurlow #define NTCREATEX_SHARE_ACCESS_WRITE 2 2144bff34e3Sthurlow #define NTCREATEX_SHARE_ACCESS_DELETE 4 2154bff34e3Sthurlow #define NTCREATEX_SHARE_ACCESS_ALL 7 2164bff34e3Sthurlow 2174bff34e3Sthurlow /* NT_CREATE_ANDX open_disposition */ 2184bff34e3Sthurlow #define NTCREATEX_DISP_SUPERSEDE 0 /* if file exists supersede it */ 2194bff34e3Sthurlow #define NTCREATEX_DISP_OPEN 1 /* exists ? open it : fail */ 2204bff34e3Sthurlow #define NTCREATEX_DISP_CREATE 2 /* exists ? fail : create it */ 2214bff34e3Sthurlow #define NTCREATEX_DISP_OPEN_IF 3 /* exists ? open it : create it */ 2224bff34e3Sthurlow #define NTCREATEX_DISP_OVERWRITE 4 /* exists ? overwrite : fail */ 2234bff34e3Sthurlow #define NTCREATEX_DISP_OVERWRITE_IF 5 /* exists ? overwrite : create */ 2244bff34e3Sthurlow 2254bff34e3Sthurlow /* NT_CREATE_ANDX create_options */ 2264bff34e3Sthurlow #define NTCREATEX_OPTIONS_DIRECTORY 0x0001 2274bff34e3Sthurlow #define NTCREATEX_OPTIONS_WRITE_THROUGH 0x0002 2284bff34e3Sthurlow #define NTCREATEX_OPTIONS_SEQUENTIAL_ONLY 0x0004 2294bff34e3Sthurlow #define NTCREATEX_OPTIONS_SYNC_ALERT 0x0010 2304bff34e3Sthurlow #define NTCREATEX_OPTIONS_ASYNC_ALERT 0x0020 2314bff34e3Sthurlow #define NTCREATEX_OPTIONS_NON_DIRECTORY_FILE 0x0040 2324bff34e3Sthurlow #define NTCREATEX_OPTIONS_NO_EA_KNOWLEDGE 0x0200 2334bff34e3Sthurlow #define NTCREATEX_OPTIONS_EIGHT_DOT_THREE_ONLY 0x0400 2344bff34e3Sthurlow #define NTCREATEX_OPTIONS_RANDOM_ACCESS 0x0800 2354bff34e3Sthurlow #define NTCREATEX_OPTIONS_DELETE_ON_CLOSE 0x1000 2364bff34e3Sthurlow #define NTCREATEX_OPTIONS_OPEN_BY_FILE_ID 0x2000 2374bff34e3Sthurlow 2384bff34e3Sthurlow /* NT_CREATE_ANDX "impersonation" */ 2394bff34e3Sthurlow #define NTCREATEX_IMPERSONATION_ANONYMOUS 0 2404bff34e3Sthurlow #define NTCREATEX_IMPERSONATION_IDENTIFICATION 1 2414bff34e3Sthurlow #define NTCREATEX_IMPERSONATION_IMPERSONATION 2 2424bff34e3Sthurlow #define NTCREATEX_IMPERSONATION_DELEGATION 3 2434bff34e3Sthurlow 2444bff34e3Sthurlow /* NT_CREATE_ANDX security flags */ 2454bff34e3Sthurlow #define NTCREATEX_SECURITY_DYNAMIC 1 2464bff34e3Sthurlow #define NTCREATEX_SECURITY_ALL 2 2474bff34e3Sthurlow 2484bff34e3Sthurlow /* NT_CREATE_ANDX create_action in reply */ 2494bff34e3Sthurlow #define NTCREATEX_ACTION_EXISTED 1 2504bff34e3Sthurlow #define NTCREATEX_ACTION_CREATED 2 2514bff34e3Sthurlow #define NTCREATEX_ACTION_TRUNCATED 3 2524bff34e3Sthurlow 2534bff34e3Sthurlow /* SMB_TRANS2_FIND_FIRST2/SMB_TRANS2_FIND_NEXT2 flags */ 2544bff34e3Sthurlow #define FIND2_CLOSE_AFTER_REQUEST 0x0001 2554bff34e3Sthurlow #define FIND2_CLOSE_ON_EOS 0x0002 2564bff34e3Sthurlow #define FIND2_RETURN_RESUME_KEYS 0x0004 2574bff34e3Sthurlow #define FIND2_CONTINUE_SEARCH 0x0008 2584bff34e3Sthurlow #define FIND2_BACKUP_INTENT 0x0010 2594bff34e3Sthurlow 2604bff34e3Sthurlow /* 2614bff34e3Sthurlow * SMB commands 2624bff34e3Sthurlow */ 2634bff34e3Sthurlow #define SMB_COM_CREATE_DIRECTORY 0x00 2644bff34e3Sthurlow #define SMB_COM_DELETE_DIRECTORY 0x01 2654bff34e3Sthurlow #define SMB_COM_OPEN 0x02 2664bff34e3Sthurlow #define SMB_COM_CREATE 0x03 2674bff34e3Sthurlow #define SMB_COM_CLOSE 0x04 2684bff34e3Sthurlow #define SMB_COM_FLUSH 0x05 2694bff34e3Sthurlow #define SMB_COM_DELETE 0x06 2704bff34e3Sthurlow #define SMB_COM_RENAME 0x07 2714bff34e3Sthurlow #define SMB_COM_QUERY_INFORMATION 0x08 2724bff34e3Sthurlow #define SMB_COM_SET_INFORMATION 0x09 2734bff34e3Sthurlow #define SMB_COM_READ 0x0A 2744bff34e3Sthurlow #define SMB_COM_WRITE 0x0B 2754bff34e3Sthurlow #define SMB_COM_LOCK_BYTE_RANGE 0x0C 2764bff34e3Sthurlow #define SMB_COM_UNLOCK_BYTE_RANGE 0x0D 2774bff34e3Sthurlow #define SMB_COM_CREATE_TEMPORARY 0x0E 2784bff34e3Sthurlow #define SMB_COM_CREATE_NEW 0x0F 2794bff34e3Sthurlow #define SMB_COM_CHECK_DIRECTORY 0x10 2804bff34e3Sthurlow #define SMB_COM_PROCESS_EXIT 0x11 2814bff34e3Sthurlow #define SMB_COM_SEEK 0x12 2824bff34e3Sthurlow #define SMB_COM_LOCK_AND_READ 0x13 2834bff34e3Sthurlow #define SMB_COM_WRITE_AND_UNLOCK 0x14 2844bff34e3Sthurlow #define SMB_COM_READ_RAW 0x1A 2854bff34e3Sthurlow #define SMB_COM_READ_MPX 0x1B 2864bff34e3Sthurlow #define SMB_COM_READ_MPX_SECONDARY 0x1C 2874bff34e3Sthurlow #define SMB_COM_WRITE_RAW 0x1D 2884bff34e3Sthurlow #define SMB_COM_WRITE_MPX 0x1E 2894bff34e3Sthurlow #define SMB_COM_WRITE_COMPLETE 0x20 2904bff34e3Sthurlow #define SMB_COM_SET_INFORMATION2 0x22 2914bff34e3Sthurlow #define SMB_COM_QUERY_INFORMATION2 0x23 2924bff34e3Sthurlow #define SMB_COM_LOCKING_ANDX 0x24 2934bff34e3Sthurlow #define SMB_COM_TRANSACTION 0x25 2944bff34e3Sthurlow #define SMB_COM_TRANSACTION_SECONDARY 0x26 2954bff34e3Sthurlow #define SMB_COM_IOCTL 0x27 2964bff34e3Sthurlow #define SMB_COM_IOCTL_SECONDARY 0x28 2974bff34e3Sthurlow #define SMB_COM_COPY 0x29 2984bff34e3Sthurlow #define SMB_COM_MOVE 0x2A 2994bff34e3Sthurlow #define SMB_COM_ECHO 0x2B 3004bff34e3Sthurlow #define SMB_COM_WRITE_AND_CLOSE 0x2C 3014bff34e3Sthurlow #define SMB_COM_OPEN_ANDX 0x2D 3024bff34e3Sthurlow #define SMB_COM_READ_ANDX 0x2E 3034bff34e3Sthurlow #define SMB_COM_WRITE_ANDX 0x2F 3044bff34e3Sthurlow #define SMB_COM_CLOSE_AND_TREE_DISC 0x31 3054bff34e3Sthurlow #define SMB_COM_TRANSACTION2 0x32 3064bff34e3Sthurlow #define SMB_COM_TRANSACTION2_SECONDARY 0x33 3074bff34e3Sthurlow #define SMB_COM_FIND_CLOSE2 0x34 3084bff34e3Sthurlow #define SMB_COM_FIND_NOTIFY_CLOSE 0x35 3094bff34e3Sthurlow #define SMB_COM_TREE_CONNECT 0x70 3104bff34e3Sthurlow #define SMB_COM_TREE_DISCONNECT 0x71 3114bff34e3Sthurlow #define SMB_COM_NEGOTIATE 0x72 3124bff34e3Sthurlow #define SMB_COM_SESSION_SETUP_ANDX 0x73 3134bff34e3Sthurlow #define SMB_COM_LOGOFF_ANDX 0x74 3144bff34e3Sthurlow #define SMB_COM_TREE_CONNECT_ANDX 0x75 3154bff34e3Sthurlow #define SMB_COM_QUERY_INFORMATION_DISK 0x80 3164bff34e3Sthurlow #define SMB_COM_SEARCH 0x81 3174bff34e3Sthurlow #define SMB_COM_FIND 0x82 3184bff34e3Sthurlow #define SMB_COM_FIND_UNIQUE 0x83 3194bff34e3Sthurlow #define SMB_COM_NT_TRANSACT 0xA0 3204bff34e3Sthurlow #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1 3214bff34e3Sthurlow #define SMB_COM_NT_CREATE_ANDX 0xA2 3224bff34e3Sthurlow #define SMB_COM_NT_CANCEL 0xA4 3234bff34e3Sthurlow #define SMB_COM_OPEN_PRINT_FILE 0xC0 3244bff34e3Sthurlow #define SMB_COM_WRITE_PRINT_FILE 0xC1 3254bff34e3Sthurlow #define SMB_COM_CLOSE_PRINT_FILE 0xC2 3264bff34e3Sthurlow #define SMB_COM_GET_PRINT_QUEUE 0xC3 3274bff34e3Sthurlow #define SMB_COM_READ_BULK 0xD8 3284bff34e3Sthurlow #define SMB_COM_WRITE_BULK 0xD9 3294bff34e3Sthurlow #define SMB_COM_WRITE_BULK_DATA 0xDA 3304bff34e3Sthurlow 3314bff34e3Sthurlow /* 3324bff34e3Sthurlow * SMB_COM_TRANSACTION2 subcommands 3334bff34e3Sthurlow */ 3344bff34e3Sthurlow #define SMB_TRANS2_OPEN2 0x00 3354bff34e3Sthurlow #define SMB_TRANS2_FIND_FIRST2 0x01 3364bff34e3Sthurlow #define SMB_TRANS2_FIND_NEXT2 0x02 3374bff34e3Sthurlow #define SMB_TRANS2_QUERY_FS_INFORMATION 0x03 3384bff34e3Sthurlow #define SMB_TRANS2_SETFSINFO 0x04 3394bff34e3Sthurlow #define SMB_TRANS2_QUERY_PATH_INFORMATION 0x05 3404bff34e3Sthurlow #define SMB_TRANS2_SET_PATH_INFORMATION 0x06 3414bff34e3Sthurlow #define SMB_TRANS2_QUERY_FILE_INFORMATION 0x07 3424bff34e3Sthurlow #define SMB_TRANS2_SET_FILE_INFORMATION 0x08 3434bff34e3Sthurlow #define SMB_TRANS2_FSCTL 0x09 3444bff34e3Sthurlow #define SMB_TRANS2_IOCTL2 0x0A 3454bff34e3Sthurlow #define SMB_TRANS2_FIND_NOTIFY_FIRST 0x0B 3464bff34e3Sthurlow #define SMB_TRANS2_FIND_NOTIFY_NEXT 0x0C 3474bff34e3Sthurlow #define SMB_TRANS2_CREATE_DIRECTORY 0x0D 3484bff34e3Sthurlow #define SMB_TRANS2_SESSION_SETUP 0x0E 3494bff34e3Sthurlow #define SMB_TRANS2_GET_DFS_REFERRAL 0x10 3504bff34e3Sthurlow #define SMB_TRANS2_REPORT_DFS_INCONSISTENCY 0x11 3514bff34e3Sthurlow 3524bff34e3Sthurlow /* 3534bff34e3Sthurlow * SMB_COM_NT_TRANSACT subcommands 3544bff34e3Sthurlow */ 3554bff34e3Sthurlow #define NT_TRANSACT_CREATE 0x01 3564bff34e3Sthurlow #define NT_TRANSACT_IOCTL 0x02 3574bff34e3Sthurlow #define NT_TRANSACT_SET_SECURITY_DESC 0x03 3584bff34e3Sthurlow #define NT_TRANSACT_NOTIFY_CHANGE 0x04 3594bff34e3Sthurlow #define NT_TRANSACT_RENAME 0x05 3604bff34e3Sthurlow #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06 3614bff34e3Sthurlow #define NT_TRANSACT_GET_USER_QUOTA 0x07 3624bff34e3Sthurlow #define NT_TRANSACT_SET_USER_QUOTA 0x08 3634bff34e3Sthurlow 3644bff34e3Sthurlow /* 3654bff34e3Sthurlow * SMB_TRANS2_QUERY_FS_INFORMATION levels 3664bff34e3Sthurlow */ 3674bff34e3Sthurlow #define SMB_QFS_ALLOCATION 1 3684bff34e3Sthurlow #define SMB_QFS_VOLUME 2 3694bff34e3Sthurlow #define SMB_QFS_LABEL_INFO 0x101 3704bff34e3Sthurlow #define SMB_QFS_VOLUME_INFO 0x102 3714bff34e3Sthurlow #define SMB_QFS_SIZE_INFO 0x103 3724bff34e3Sthurlow #define SMB_QFS_DEVICE_INFO 0x104 3734bff34e3Sthurlow #define SMB_QFS_ATTRIBUTE_INFO 0x105 3744bff34e3Sthurlow #define SMB_QFS_UNIX_INFO 0x200 3754bff34e3Sthurlow #define SMB_QFS_MAC_FS_INFO 0x301 3764bff34e3Sthurlow #define SMB_QFS_VOLUME_INFORMATION 1001 3774bff34e3Sthurlow #define SMB_QFS_SIZE_INFORMATION 1003 3784bff34e3Sthurlow #define SMB_QFS_DEVICE_INFORMATION 1004 3794bff34e3Sthurlow #define SMB_QFS_ATTRIBUTE_INFORMATION 1005 3804bff34e3Sthurlow #define SMB_QFS_QUOTA_INFORMATION 1006 3814bff34e3Sthurlow #define SMB_QFS_FULL_SIZE_INFORMATION 1007 3824bff34e3Sthurlow #define SMB_QFS_OBJECTID_INFORMATION 1008 3834bff34e3Sthurlow 3844bff34e3Sthurlow 3854bff34e3Sthurlow /* 3864bff34e3Sthurlow * SMB_QFS_ATTRIBUTE_INFO bits. 3874bff34e3Sthurlow * The following info found in msdn 3884bff34e3Sthurlow * (http://msdn.microsoft.com/library/default.asp? 3894bff34e3Sthurlow * url=/library/en-us/wmisdk/wmi/win32_cdromdrive.asp) 3904bff34e3Sthurlow * Naming is mostly as in samba, to help Those Who Google. 3914bff34e3Sthurlow */ 3924bff34e3Sthurlow #define FILE_CASE_SENSITIVE_SEARCH 0x00000001 3934bff34e3Sthurlow #define FILE_CASE_PRESERVED_NAMES 0x00000002 3944bff34e3Sthurlow #define FILE_UNICODE_ON_DISK 0x00000004 3954bff34e3Sthurlow #define FILE_PERSISTENT_ACLS 0x00000008 3964bff34e3Sthurlow #define FILE_FILE_COMPRESSION 0x00000010 3974bff34e3Sthurlow #define FILE_VOLUME_QUOTAS 0x00000020 3984bff34e3Sthurlow #define FILE_SUPPORTS_SPARSE_FILES 0x00000040 3994bff34e3Sthurlow #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080 4004bff34e3Sthurlow #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100 4014bff34e3Sthurlow #define FILE_SUPPORTS_LONG_NAMES 0x00004000 4024bff34e3Sthurlow #define FILE_VOLUME_IS_COMPRESSED 0x00008000 4034bff34e3Sthurlow #define FILE_SUPPORTS_OBJECT_IDS 0x00010000 4044bff34e3Sthurlow #define FILE_SUPPORTS_ENCRYPTION 0x00020000 4054bff34e3Sthurlow #define FILE_NAMED_STREAMS 0x00040000 4064bff34e3Sthurlow 4074bff34e3Sthurlow /* 4084bff34e3Sthurlow * SMB_TRANS2_QUERY_PATH levels 4094bff34e3Sthurlow */ 4104bff34e3Sthurlow #define SMB_QFILEINFO_STANDARD 1 4114bff34e3Sthurlow #define SMB_QFILEINFO_EA_SIZE 2 4124bff34e3Sthurlow #define SMB_QFILEINFO_EAS_FROM_LIST 3 4134bff34e3Sthurlow #define SMB_QFILEINFO_ALL_EAS 4 4144bff34e3Sthurlow #define SMB_QFILEINFO_IS_NAME_VALID 6 /* QPATHINFO only? */ 4154bff34e3Sthurlow #define SMB_QFILEINFO_BASIC_INFO 0x101 4164bff34e3Sthurlow #define SMB_QFILEINFO_STANDARD_INFO 0x102 4174bff34e3Sthurlow #define SMB_QFILEINFO_EA_INFO 0x103 4184bff34e3Sthurlow #define SMB_QFILEINFO_NAME_INFO 0x104 4194bff34e3Sthurlow #define SMB_QFILEINFO_ALLOCATION_INFO 0x105 4204bff34e3Sthurlow #define SMB_QFILEINFO_END_OF_FILE_INFO 0x106 4214bff34e3Sthurlow #define SMB_QFILEINFO_ALL_INFO 0x107 4224bff34e3Sthurlow #define SMB_QFILEINFO_ALT_NAME_INFO 0x108 4234bff34e3Sthurlow #define SMB_QFILEINFO_STREAM_INFO 0x109 4244bff34e3Sthurlow #define SMB_QFILEINFO_COMPRESSION_INFO 0x10b 4254bff34e3Sthurlow #define SMB_QFILEINFO_UNIX_BASIC 0x200 4264bff34e3Sthurlow #define SMB_QFILEINFO_UNIX_LINK 0x201 4274bff34e3Sthurlow #define SMB_QFILEINFO_MAC_DT_GET_APPL 0x306 4284bff34e3Sthurlow #define SMB_QFILEINFO_MAC_DT_GET_ICON 0x307 4294bff34e3Sthurlow #define SMB_QFILEINFO_MAC_DT_GET_ICON_INFO 0x308 4304bff34e3Sthurlow #define SMB_QFILEINFO_BASIC_INFORMATION 1004 4314bff34e3Sthurlow #define SMB_QFILEINFO_STANDARD_INFORMATION 1005 4324bff34e3Sthurlow #define SMB_QFILEINFO_INTERNAL_INFORMATION 1006 4334bff34e3Sthurlow #define SMB_QFILEINFO_EA_INFORMATION 1007 4344bff34e3Sthurlow #define SMB_QFILEINFO_ACCESS_INFORMATION 1008 4354bff34e3Sthurlow #define SMB_QFILEINFO_NAME_INFORMATION 1009 4364bff34e3Sthurlow #define SMB_QFILEINFO_POSITION_INFORMATION 1014 4374bff34e3Sthurlow #define SMB_QFILEINFO_MODE_INFORMATION 1016 4384bff34e3Sthurlow #define SMB_QFILEINFO_ALIGNMENT_INFORMATION 1017 4394bff34e3Sthurlow #define SMB_QFILEINFO_ALL_INFORMATION 1018 4404bff34e3Sthurlow #define SMB_QFILEINFO_ALT_NAME_INFORMATION 1021 4414bff34e3Sthurlow #define SMB_QFILEINFO_STREAM_INFORMATION 1022 4424bff34e3Sthurlow #define SMB_QFILEINFO_COMPRESSION_INFORMATION 1028 4434bff34e3Sthurlow #define SMB_QFILEINFO_NETWORK_OPEN_INFORMATION 1034 4444bff34e3Sthurlow #define SMB_QFILEINFO_ATTRIBUTE_TAG_INFORMATION 1035 4454bff34e3Sthurlow 4464bff34e3Sthurlow /* 4474bff34e3Sthurlow * SMB_TRANS2_FIND_FIRST2 information levels 4484bff34e3Sthurlow */ 4494bff34e3Sthurlow #define SMB_FIND_STANDARD 1 4504bff34e3Sthurlow #define SMB_FIND_EA_SIZE 2 4514bff34e3Sthurlow #define SMB_FIND_EAS_FROM_LIST 3 4524bff34e3Sthurlow #define SMB_FIND_DIRECTORY_INFO 0x101 4534bff34e3Sthurlow #define SMB_FIND_FULL_DIRECTORY_INFO 0x102 4544bff34e3Sthurlow #define SMB_FIND_NAME_INFO 0x103 4554bff34e3Sthurlow #define SMB_FIND_BOTH_DIRECTORY_INFO 0x104 4564bff34e3Sthurlow #define SMB_FIND_UNIX_INFO 0x200 4574bff34e3Sthurlow 4584bff34e3Sthurlow /* 4594bff34e3Sthurlow * Selectors for NT_TRANSACT_QUERY_SECURITY_DESC and 4604bff34e3Sthurlow * NT_TRANSACT_SET_SECURITY_DESC. Details found in the MSDN 4614bff34e3Sthurlow * library by searching on security_information. 4624bff34e3Sthurlow * Note the protected/unprotected bits did not exist in NT. 4634bff34e3Sthurlow */ 4644bff34e3Sthurlow 4654bff34e3Sthurlow #define OWNER_SECURITY_INFORMATION 0x00000001 4664bff34e3Sthurlow #define GROUP_SECURITY_INFORMATION 0x00000002 4674bff34e3Sthurlow #define DACL_SECURITY_INFORMATION 0x00000004 4684bff34e3Sthurlow #define SACL_SECURITY_INFORMATION 0x00000008 4694bff34e3Sthurlow #define UNPROTECTED_SACL_SECURITY_INFORMATION 0x10000000 4704bff34e3Sthurlow #define UNPROTECTED_DACL_SECURITY_INFORMATION 0x20000000 4714bff34e3Sthurlow #define PROTECTED_SACL_SECURITY_INFORMATION 0x40000000 4724bff34e3Sthurlow #define PROTECTED_DACL_SECURITY_INFORMATION 0x80000000 4734bff34e3Sthurlow 4744bff34e3Sthurlow /* 4754bff34e3Sthurlow * security descriptor header 4764bff34e3Sthurlow * it is followed by the optional SIDs and ACLs 4774bff34e3Sthurlow * note this is "raw", ie little-endian 4784bff34e3Sthurlow */ 4794bff34e3Sthurlow struct ntsecdesc { 4804bff34e3Sthurlow uint8_t sd_revision; /* 0x01 observed between W2K */ 4814bff34e3Sthurlow uint8_t sd_pad1; 4824bff34e3Sthurlow uint16_t sd_flags; 4834bff34e3Sthurlow uint32_t sd_owneroff; /* offset to owner SID */ 4844bff34e3Sthurlow uint32_t sd_groupoff; /* offset to group SID */ 4854bff34e3Sthurlow uint32_t sd_sacloff; /* offset to system/audit ACL */ 4864bff34e3Sthurlow uint32_t sd_dacloff; /* offset to discretionary ACL */ 4874bff34e3Sthurlow }; /* XXX: __attribute__((__packed__)); */ 4884bff34e3Sthurlow typedef struct ntsecdesc ntsecdesc_t; 4894bff34e3Sthurlow 4904bff34e3Sthurlow #define wset_sdrevision(s) ((s)->sd_revision = 0x01) 4914bff34e3Sthurlow #define sdflags(s) (letohs((s)->sd_flags)) 4924bff34e3Sthurlow #define wset_sdflags(s, f) ((s)->sd_flags = letohs(f)) 4934bff34e3Sthurlow #define sdowner(s) \ 4944bff34e3Sthurlow ((struct ntsid *)((s)->sd_owneroff ? \ 4954bff34e3Sthurlow (char *)(s) + letohl((s)->sd_owneroff) : \ 4964bff34e3Sthurlow NULL)) 4974bff34e3Sthurlow #define wset_sdowneroff(s, o) ((s)->sd_owneroff = htolel(o)) 4984bff34e3Sthurlow #define sdgroup(s) \ 4994bff34e3Sthurlow ((struct ntsid *)((s)->sd_groupoff ? \ 5004bff34e3Sthurlow (char *)(s) + letohl((s)->sd_groupoff) : \ 5014bff34e3Sthurlow NULL)) 5024bff34e3Sthurlow #define wset_sdgroupoff(s, o) ((s)->sd_groupoff = htolel(o)) 5034bff34e3Sthurlow #define sdsacl(s) \ 5044bff34e3Sthurlow ((struct ntacl *)((s)->sd_sacloff ? \ 5054bff34e3Sthurlow (char *)(s) + letohl((s)->sd_sacloff) : \ 5064bff34e3Sthurlow NULL)) 5074bff34e3Sthurlow #define wset_sdsacloff(s, o) ((s)->sd_sacloff = htolel(o)) 5084bff34e3Sthurlow #define sddacl(s) \ 5094bff34e3Sthurlow ((struct ntacl *)((s)->sd_dacloff ? \ 5104bff34e3Sthurlow (char *)(s) + letohl((s)->sd_dacloff) : \ 5114bff34e3Sthurlow NULL)) 5124bff34e3Sthurlow #define wset_sddacloff(s, o) ((s)->sd_dacloff = htolel(o)) 5134bff34e3Sthurlow 5144bff34e3Sthurlow /* 5154bff34e3Sthurlow * sd_flags bits 5164bff34e3Sthurlow */ 5174bff34e3Sthurlow #define SD_OWNER_DEFAULTED 0x0001 5184bff34e3Sthurlow #define SD_GROUP_DEFAULTED 0x0002 5194bff34e3Sthurlow #define SD_DACL_PRESENT 0x0004 5204bff34e3Sthurlow #define SD_DACL_DEFAULTED 0x0008 5214bff34e3Sthurlow #define SD_SACL_PRESENT 0x0010 5224bff34e3Sthurlow #define SD_SACL_DEFAULTED 0x0020 5234bff34e3Sthurlow #define SD_DACL_TRUSTED 0x0040 5244bff34e3Sthurlow #define SD_SERVER_SECURITY 0x0080 5254bff34e3Sthurlow #define SD_DACL_AUTO_INHERIT_REQ 0x0100 5264bff34e3Sthurlow #define SD_SACL_AUTO_INHERIT_REQ 0x0200 5274bff34e3Sthurlow #define SD_DACL_AUTO_INHERITED 0x0400 5284bff34e3Sthurlow #define SD_SACL_AUTO_INHERITED 0x0800 5294bff34e3Sthurlow #define SD_DACL_PROTECTED 0x1000 5304bff34e3Sthurlow #define SD_SACL_PROTECTED 0x2000 5314bff34e3Sthurlow #define SD_RM_CONTROL_VALID 0x4000 5324bff34e3Sthurlow #define SD_SELF_RELATIVE 0x8000 5334bff34e3Sthurlow 5344bff34e3Sthurlow /* 5354bff34e3Sthurlow * access control list header 5364bff34e3Sthurlow * it is followed by the ACEs 5374bff34e3Sthurlow * note this is "raw", ie little-endian 5384bff34e3Sthurlow */ 5394bff34e3Sthurlow struct ntacl { 5404bff34e3Sthurlow uint8_t acl_revision; /* 0x02 observed with W2K */ 5414bff34e3Sthurlow uint8_t acl_pad1; 5424bff34e3Sthurlow uint16_t acl_len; /* bytes; includes this header */ 5434bff34e3Sthurlow uint16_t acl_acecount; 5444bff34e3Sthurlow uint16_t acl_pad2; 5454bff34e3Sthurlow }; /* XXX: __attribute__((__packed__)); */ 5464bff34e3Sthurlow typedef struct ntacl ntacl_t; 5474bff34e3Sthurlow 5484bff34e3Sthurlow #define wset_aclrevision(a) ((a)->acl_revision = 0x02) 5494bff34e3Sthurlow #define acllen(a) (letohs((a)->acl_len)) 5504bff34e3Sthurlow #define wset_acllen(a, l) ((a)->acl_len = htoles(l)) 5514bff34e3Sthurlow #define aclacecount(a) (letohs((a)->acl_acecount)) 5524bff34e3Sthurlow #define wset_aclacecount(a, c) ((a)->acl_acecount = htoles(c)) 5534bff34e3Sthurlow #define aclace(a) ((struct ntace *)((char *)(a) + sizeof (struct ntacl))) 5544bff34e3Sthurlow 5554bff34e3Sthurlow /* 5564bff34e3Sthurlow * access control entry header 5574bff34e3Sthurlow * it is followed by type-specific ace data, 5584bff34e3Sthurlow * which for the simple types is just a SID 5594bff34e3Sthurlow * note this is "raw", ie little-endian 5604bff34e3Sthurlow */ 5614bff34e3Sthurlow struct ntace { 5624bff34e3Sthurlow uint8_t ace_type; 5634bff34e3Sthurlow uint8_t ace_flags; 5644bff34e3Sthurlow uint16_t ace_len; /* bytes; includes this header */ 5654bff34e3Sthurlow uint32_t ace_rights; /* generic, standard, specific, etc */ 5664bff34e3Sthurlow }; /* XXX: __attribute__((__packed__)); */ 5674bff34e3Sthurlow 5684bff34e3Sthurlow #define acetype(a) ((a)->ace_type) 5694bff34e3Sthurlow #define wset_acetype(a, t) ((a)->ace_type = (t)) 5704bff34e3Sthurlow #define aceflags(a) ((a)->ace_flags) 5714bff34e3Sthurlow #define wset_aceflags(a, f) ((a)->ace_flags = (f)) 5724bff34e3Sthurlow #define acelen(a) (letohs((a)->ace_len)) 5734bff34e3Sthurlow #define wset_acelen(a, l) ((a)->ace_len = htoles(l)) 5744bff34e3Sthurlow #define acerights(a) (letohl((a)->ace_rights)) 5754bff34e3Sthurlow #define wset_acerights(a, r) ((a)->ace_rights = htolel(r)) 5764bff34e3Sthurlow #define aceace(a) ((struct ntace *)((char *)(a) + acelen(a))) 5774bff34e3Sthurlow #define acesid(a) ((struct ntsid *)((char *)(a) + sizeof (struct ntace))) 5784bff34e3Sthurlow 5794bff34e3Sthurlow /* 5804bff34e3Sthurlow * ace_rights 5814bff34e3Sthurlow * (Samba bit names are used here, with permission, as the shorter Windows 5824bff34e3Sthurlow * names are more likely to cause namespace collisions) 5834bff34e3Sthurlow */ 5844bff34e3Sthurlow #define SA_RIGHT_FILE_READ_DATA 0x00000001 5854bff34e3Sthurlow #define SA_RIGHT_FILE_WRITE_DATA 0x00000002 5864bff34e3Sthurlow #define SA_RIGHT_FILE_APPEND_DATA 0x00000004 5874bff34e3Sthurlow #define SA_RIGHT_FILE_READ_EA 0x00000008 5884bff34e3Sthurlow #define SA_RIGHT_FILE_WRITE_EA 0x00000010 5894bff34e3Sthurlow #define SA_RIGHT_FILE_EXECUTE 0x00000020 5904bff34e3Sthurlow #define SA_RIGHT_FILE_DELETE_CHILD 0x00000040 5914bff34e3Sthurlow #define SA_RIGHT_FILE_READ_ATTRIBUTES 0x00000080 5924bff34e3Sthurlow #define SA_RIGHT_FILE_WRITE_ATTRIBUTES 0x00000100 5934bff34e3Sthurlow #define SA_RIGHT_FILE_ALL_ACCESS 0x000001FF 5944bff34e3Sthurlow 5954bff34e3Sthurlow #define STD_RIGHT_DELETE_ACCESS 0x00010000 5964bff34e3Sthurlow #define STD_RIGHT_READ_CONTROL_ACCESS 0x00020000 5974bff34e3Sthurlow #define STD_RIGHT_WRITE_DAC_ACCESS 0x00040000 5984bff34e3Sthurlow #define STD_RIGHT_WRITE_OWNER_ACCESS 0x00080000 5994bff34e3Sthurlow #define STD_RIGHT_SYNCHRONIZE_ACCESS 0x00100000 6004bff34e3Sthurlow #define STD_RIGHT_ALL_ACCESS 0x001F0000 6014bff34e3Sthurlow 6024bff34e3Sthurlow #define SEC_RIGHT_SYSTEM_SECURITY 0x01000000 6034bff34e3Sthurlow /* 6044bff34e3Sthurlow * Don't use MAXIMUM_ALLOWED as Samba (2.2.3 at least) will 6054bff34e3Sthurlow * return NT_STATUS_INVALID_LOCK_SEQUENCE 6064bff34e3Sthurlow */ 6074bff34e3Sthurlow #define SEC_RIGHT_MAXIMUM_ALLOWED 0x02000000 6084bff34e3Sthurlow 6094bff34e3Sthurlow #define GENERIC_RIGHT_ALL_ACCESS 0x10000000 6104bff34e3Sthurlow #define GENERIC_RIGHT_EXECUTE_ACCESS 0x20000000 6114bff34e3Sthurlow #define GENERIC_RIGHT_WRITE_ACCESS 0x40000000 6124bff34e3Sthurlow #define GENERIC_RIGHT_READ_ACCESS 0x80000000 6134bff34e3Sthurlow 6144bff34e3Sthurlow /* 6154bff34e3Sthurlow * these mappings are from Windows sample code but are likely incomplete 6164bff34e3Sthurlow * 6174bff34e3Sthurlow * GENERIC_RIGHT_READ_ACCESS : 6184bff34e3Sthurlow * STD_RIGHT_SYNCHRONIZE_ACCESS | 6194bff34e3Sthurlow * STD_RIGHT_READ_CONTROL_ACCESS | 6204bff34e3Sthurlow * SA_RIGHT_FILE_READ_ATTRIBUTES | 6214bff34e3Sthurlow * SA_RIGHT_FILE_READ_EA | 6224bff34e3Sthurlow * SA_RIGHT_FILE_READ_DATA 6234bff34e3Sthurlow * GENERIC_RIGHT_WRITE_ACCESS : 6244bff34e3Sthurlow * STD_RIGHT_SYNCHRONIZE_ACCESS | 6254bff34e3Sthurlow * STD_RIGHT_READ_CONTROL_ACCESS | 6264bff34e3Sthurlow * SA_RIGHT_FILE_WRITE_ATTRIBUTES | 6274bff34e3Sthurlow * SA_RIGHT_FILE_WRITE_EA | 6284bff34e3Sthurlow * SA_RIGHT_FILE_APPEND_DATA | 6294bff34e3Sthurlow * SA_RIGHT_FILE_WRITE_DATA 6304bff34e3Sthurlow * GENERIC_RIGHT_EXECUTE_ACCESS : 6314bff34e3Sthurlow * STD_RIGHT_SYNCHRONIZE_ACCESS | 6324bff34e3Sthurlow * STD_RIGHT_READ_CONTROL_ACCESS | 6334bff34e3Sthurlow * SA_RIGHT_FILE_READ_ATTRIBUTES | 6344bff34e3Sthurlow * SA_RIGHT_FILE_EXECUTE 6354bff34e3Sthurlow * GENERIC_RIGHT_ALL_ACCESS : 6364bff34e3Sthurlow * STD_RIGHT_SYNCHRONIZE_ACCESS | 6374bff34e3Sthurlow * STD_RIGHT_WRITE_OWNER_ACCESS | 6384bff34e3Sthurlow * STD_RIGHT_WRITE_DAC_ACCESS | 6394bff34e3Sthurlow * STD_RIGHT_READ_CONTROL_ACCESS | 6404bff34e3Sthurlow * STD_RIGHT_DELETE_ACCESS | 6414bff34e3Sthurlow * SA_RIGHT_FILE_ALL_ACCESS 6424bff34e3Sthurlow */ 6434bff34e3Sthurlow 6444bff34e3Sthurlow /* 6454bff34e3Sthurlow * security identifier header 6464bff34e3Sthurlow * it is followed by sid_numauth sub-authorities, 6474bff34e3Sthurlow * which are 32 bits each. 6484bff34e3Sthurlow * note the subauths are little-endian on the wire, but 6494bff34e3Sthurlow * need to be big-endian for memberd/DS 6504bff34e3Sthurlow */ 6514bff34e3Sthurlow #define SIDAUTHSIZE 6 6524bff34e3Sthurlow struct ntsid { 6534bff34e3Sthurlow uint8_t sid_revision; 6544bff34e3Sthurlow uint8_t sid_subauthcount; 6554bff34e3Sthurlow uint8_t sid_authority[SIDAUTHSIZE]; /* ie not little endian */ 6564bff34e3Sthurlow }; /* XXX: __attribute__((__packed__)); */ 6574bff34e3Sthurlow typedef struct ntsid ntsid_t; 6584bff34e3Sthurlow 6594bff34e3Sthurlow #define sidsubauthcount(s) (s->sid_subauthcount) 6604bff34e3Sthurlow #define sidlen(s) (sizeof (struct ntsid) + 4 * (s)->sid_subauthcount) 6614bff34e3Sthurlow #define MAXSIDLEN (sizeof (struct ntsid) + 4 * KAUTH_NTSID_MAX_AUTHORITIES) 6624bff34e3Sthurlow #define sidsub(s) ((uint32_t *)((char *)(s) + sizeof (struct ntsid))) 6634bff34e3Sthurlow 6644bff34e3Sthurlow /* 6654bff34e3Sthurlow * MS' defined values for ace_type 6664bff34e3Sthurlow */ 6674bff34e3Sthurlow #define ACCESS_ALLOWED_ACE_TYPE 0x0 6684bff34e3Sthurlow #define ACCESS_DENIED_ACE_TYPE 0x1 6694bff34e3Sthurlow #define SYSTEM_AUDIT_ACE_TYPE 0x2 6704bff34e3Sthurlow #define SYSTEM_ALARM_ACE_TYPE 0x3 6714bff34e3Sthurlow #define ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x4 6724bff34e3Sthurlow #define ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x5 6734bff34e3Sthurlow #define ACCESS_DENIED_OBJECT_ACE_TYPE 0x6 6744bff34e3Sthurlow #define SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x7 6754bff34e3Sthurlow #define SYSTEM_ALARM_OBJECT_ACE_TYPE 0x8 6764bff34e3Sthurlow #define ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x9 6774bff34e3Sthurlow #define ACCESS_DENIED_CALLBACK_ACE_TYPE 0xA 6784bff34e3Sthurlow #define ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0xB 6794bff34e3Sthurlow #define ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0xC 6804bff34e3Sthurlow #define SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0xD 6814bff34e3Sthurlow #define SYSTEM_ALARM_CALLBACK_ACE_TYPE 0xE 6824bff34e3Sthurlow #define SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0xF 6834bff34e3Sthurlow #define SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10 6844bff34e3Sthurlow 6854bff34e3Sthurlow /* 6864bff34e3Sthurlow * MS' defined values for ace_flags 6874bff34e3Sthurlow */ 6884bff34e3Sthurlow #define OBJECT_INHERIT_ACE_FLAG 0x01 6894bff34e3Sthurlow #define CONTAINER_INHERIT_ACE_FLAG 0x02 6904bff34e3Sthurlow #define NO_PROPAGATE_INHERIT_ACE_FLAG 0x04 6914bff34e3Sthurlow #define INHERIT_ONLY_ACE_FLAG 0x08 6924bff34e3Sthurlow #define INHERITED_ACE_FLAG 0x10 6934bff34e3Sthurlow #define UNDEF_ACE_FLAG 0x20 /* MS doesn't define it */ 6944bff34e3Sthurlow #define VALID_INHERIT_ACE_FLAGS 0x1F 6954bff34e3Sthurlow #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40 6964bff34e3Sthurlow #define FAILED_ACCESS_ACE_FLAG 0x80 6974bff34e3Sthurlow 6984bff34e3Sthurlow /* 6994bff34e3Sthurlow * Set PATH/FILE information levels 7004bff34e3Sthurlow */ 7014bff34e3Sthurlow #define SMB_SFILEINFO_STANDARD 1 7024bff34e3Sthurlow #define SMB_SFILEINFO_EA_SET 2 7034bff34e3Sthurlow #define SMB_SFILEINFO_BASIC_INFO 0x101 7044bff34e3Sthurlow #define SMB_SFILEINFO_DISPOSITION_INFO 0x102 7054bff34e3Sthurlow #define SMB_SFILEINFO_ALLOCATION_INFO 0x103 7064bff34e3Sthurlow #define SMB_SFILEINFO_END_OF_FILE_INFO 0x104 7074bff34e3Sthurlow #define SMB_SFILEINFO_UNIX_BASIC 0x200 7084bff34e3Sthurlow #define SMB_SFILEINFO_UNIX_LINK 0x201 7094bff34e3Sthurlow #define SMB_SFILEINFO_UNIX_HLINK 0x203 7104bff34e3Sthurlow #define SMB_SFILEINFO_DIRECTORY_INFORMATION 1001 7114bff34e3Sthurlow #define SMB_SFILEINFO_FULL_DIRECTORY_INFORMATION 1002 7124bff34e3Sthurlow #define SMB_SFILEINFO_BOTH_DIRECTORY_INFORMATION 1003 7134bff34e3Sthurlow #define SMB_SFILEINFO_BASIC_INFORMATION 1004 7144bff34e3Sthurlow #define SMB_SFILEINFO_STANDARD_INFORMATION 1005 7154bff34e3Sthurlow #define SMB_SFILEINFO_INTERNAL_INFORMATION 1006 7164bff34e3Sthurlow #define SMB_SFILEINFO_EA_INFORMATION 1007 7174bff34e3Sthurlow #define SMB_SFILEINFO_ACCESS_INFORMATION 1008 7184bff34e3Sthurlow #define SMB_SFILEINFO_NAME_INFORMATION 1009 7194bff34e3Sthurlow #define SMB_SFILEINFO_RENAME_INFORMATION 1010 7204bff34e3Sthurlow #define SMB_SFILEINFO_LINK_INFORMATION 1011 7214bff34e3Sthurlow #define SMB_SFILEINFO_NAMES_INFORMATION 1012 7224bff34e3Sthurlow #define SMB_SFILEINFO_DISPOSITION_INFORMATION 1013 7234bff34e3Sthurlow #define SMB_SFILEINFO_POSITION_INFORMATION 1014 7244bff34e3Sthurlow #define SMB_SFILEINFO_1015 1015 /* ? */ 7254bff34e3Sthurlow #define SMB_SFILEINFO_MODE_INFORMATION 1016 7264bff34e3Sthurlow #define SMB_SFILEINFO_ALIGNMENT_INFORMATION 1017 7274bff34e3Sthurlow #define SMB_SFILEINFO_ALL_INFORMATION 1018 7284bff34e3Sthurlow #define SMB_SFILEINFO_ALLOCATION_INFORMATION 1019 7294bff34e3Sthurlow #define SMB_SFILEINFO_END_OF_FILE_INFORMATION 1020 7304bff34e3Sthurlow #define SMB_SFILEINFO_ALT_NAME_INFORMATION 1021 7314bff34e3Sthurlow #define SMB_SFILEINFO_STREAM_INFORMATION 1022 7324bff34e3Sthurlow #define SMB_SFILEINFO_PIPE_INFORMATION 1023 7334bff34e3Sthurlow #define SMB_SFILEINFO_PIPE_LOCAL_INFORMATION 1024 7344bff34e3Sthurlow #define SMB_SFILEINFO_PIPE_REMOTE_INFORMATION 1025 7354bff34e3Sthurlow #define SMB_SFILEINFO_MAILSLOT_QUERY_INFORMATION 1026 7364bff34e3Sthurlow #define SMB_SFILEINFO_MAILSLOT_SET_INFORMATION 1027 7374bff34e3Sthurlow #define SMB_SFILEINFO_COMPRESSION_INFORMATION 1028 7384bff34e3Sthurlow #define SMB_SFILEINFO_OBJECT_ID_INFORMATION 1029 7394bff34e3Sthurlow #define SMB_SFILEINFO_COMPLETION_INFORMATION 1030 7404bff34e3Sthurlow #define SMB_SFILEINFO_MOVE_CLUSTER_INFORMATION 1031 7414bff34e3Sthurlow #define SMB_SFILEINFO_QUOTA_INFORMATION 1032 7424bff34e3Sthurlow #define SMB_SFILEINFO_REPARSE_POINT_INFORMATION 1033 7434bff34e3Sthurlow #define SMB_SFILEINFO_NETWORK_OPEN_INFORMATION 1034 7444bff34e3Sthurlow #define SMB_SFILEINFO_ATTRIBUTE_TAG_INFORMATION 1035 7454bff34e3Sthurlow #define SMB_SFILEINFO_TRACKING_INFORMATION 1036 7464bff34e3Sthurlow #define SMB_SFILEINFO_MAXIMUM_INFORMATION 1037 7474bff34e3Sthurlow 7484bff34e3Sthurlow /* 7494bff34e3Sthurlow * LOCKING_ANDX LockType flags 7504bff34e3Sthurlow */ 7514bff34e3Sthurlow #define SMB_LOCKING_ANDX_SHARED_LOCK 0x01 7524bff34e3Sthurlow #define SMB_LOCKING_ANDX_OPLOCK_RELEASE 0x02 7534bff34e3Sthurlow #define SMB_LOCKING_ANDX_CHANGE_LOCKTYPE 0x04 7544bff34e3Sthurlow #define SMB_LOCKING_ANDX_CANCEL_LOCK 0x08 7554bff34e3Sthurlow #define SMB_LOCKING_ANDX_LARGE_FILES 0x10 7564bff34e3Sthurlow 7574bff34e3Sthurlow 7584bff34e3Sthurlow /* 7594bff34e3Sthurlow * size of the GUID returned in an extended security negotiate response 7604bff34e3Sthurlow */ 7614bff34e3Sthurlow #define SMB_GUIDLEN 16 7624bff34e3Sthurlow 7634bff34e3Sthurlow typedef uint16_t smbfh; 7644bff34e3Sthurlow 7654bff34e3Sthurlow /* 7664bff34e3Sthurlow * NTLMv2 blob header structure. 7674bff34e3Sthurlow */ 7684bff34e3Sthurlow struct ntlmv2_blobhdr { 7694bff34e3Sthurlow uint32_t header; 7704bff34e3Sthurlow uint32_t reserved; 7714bff34e3Sthurlow uint64_t timestamp; 7724bff34e3Sthurlow uint64_t client_nonce; 7734bff34e3Sthurlow uint32_t unknown1; 7744bff34e3Sthurlow }; 7754bff34e3Sthurlow typedef struct ntlmv2_blobhdr ntlmv2_blobhdr_t; 7764bff34e3Sthurlow 7774bff34e3Sthurlow /* 7784bff34e3Sthurlow * NTLMv2 name header structure, for names in a blob. 7794bff34e3Sthurlow */ 7804bff34e3Sthurlow struct ntlmv2_namehdr { 7814bff34e3Sthurlow uint16_t type; 7824bff34e3Sthurlow uint16_t len; 7834bff34e3Sthurlow }; 7844bff34e3Sthurlow typedef struct ntlmv2_namehdr ntlmv2_namehdr_t; 7854bff34e3Sthurlow 7864bff34e3Sthurlow #define NAMETYPE_EOL 0x0000 /* end of list of names */ 7874bff34e3Sthurlow #define NAMETYPE_MACHINE_NB 0x0001 /* NetBIOS machine name */ 7884bff34e3Sthurlow #define NAMETYPE_DOMAIN_NB 0x0002 /* NetBIOS domain name */ 7894bff34e3Sthurlow #define NAMETYPE_MACHINE_DNS 0x0003 /* DNS machine name */ 7904bff34e3Sthurlow #define NAMETYPE_DOMAIN_DNS 0x0004 /* DNS Active Directory domain name */ 7914bff34e3Sthurlow 7924bff34e3Sthurlow /* 7934bff34e3Sthurlow * Named pipe commands. 7944bff34e3Sthurlow */ 7954bff34e3Sthurlow #define TRANS_CALL_NAMED_PIPE 0x54 /* open/write/read/close pipe */ 7964bff34e3Sthurlow #define TRANS_WAIT_NAMED_PIPE 0x53 /* wait for pipe to be !busy */ 7974bff34e3Sthurlow #define TRANS_PEEK_NAMED_PIPE 0x23 /* read but don't remove data */ 7984bff34e3Sthurlow #define TRANS_Q_NAMED_PIPE_HAND_STATE 0x21 /* query pipe handle modes */ 7994bff34e3Sthurlow #define TRANS_SET_NAMED_PIPE_HAND_STATE 0x01 /* set pipe handle modes */ 8004bff34e3Sthurlow #define TRANS_Q_NAMED_PIPE_INFO 0x22 /* query pipe attributes */ 8014bff34e3Sthurlow #define TRANS_TRANSACT_NAMED_PIPE 0x26 /* r/w operation on pipe */ 8024bff34e3Sthurlow #define TRANS_READ_NAMED_PIPE 0x11 /* read pipe in "raw" mode */ 8034bff34e3Sthurlow /* (non message mode) */ 8044bff34e3Sthurlow #define TRANS_WRITE_NAMED_PIPE 0x31 /* write pipe "raw" mode */ 8054bff34e3Sthurlow /* (non message mode) */ 8064bff34e3Sthurlow 8074bff34e3Sthurlow /* 8084bff34e3Sthurlow * Share types, visible via NetShareEnum 8094bff34e3Sthurlow */ 8104bff34e3Sthurlow #define STYPE_DISKTREE 0x00000000 8114bff34e3Sthurlow #define STYPE_PRINTQ 0x00000001 8124bff34e3Sthurlow #define STYPE_DEVICE 0x00000002 8134bff34e3Sthurlow #define STYPE_IPC 0x00000003 8144bff34e3Sthurlow #define STYPE_UNKNOWN 0x00000004 8154bff34e3Sthurlow #define STYPE_MASK 0x0000000F 8164bff34e3Sthurlow #define STYPE_TEMPORARY 0x40000000 8174bff34e3Sthurlow #define STYPE_HIDDEN 0x80000000 8184bff34e3Sthurlow 8194bff34e3Sthurlow #endif /* _NETSMB_SMB_H_ */ 820