1/* 2 * Copyright (c) 2009 - 2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#ifndef _SMBCLIENT_INTERNAL_H_ 25#define _SMBCLIENT_INTERNAL_H_ 26 27/* 28 * This is private to SMB Client Project code and is not for external use. 29 */ 30 31#ifdef __cplusplus 32extern "C" { 33#endif 34 35/* Optional smbfs mount flags */ 36#define SMBFS_MNT_SOFT 0x0001 37#define SMBFS_MNT_NOTIFY_OFF 0x0002 38#define SMBFS_MNT_STREAMS_ON 0x0004 39#define SMBFS_MNT_DEBUG_ACL_ON 0x0008 40#define SMBFS_MNT_DFS_SHARE 0x0010 41#define SMBFS_MNT_COMPOUND_ON 0x0020 42#define SMBFS_MNT_TIME_MACHINE 0x0040 43#define SMBFS_MNT_READDIRATTR_OFF 0x0080 44#define SMBFS_MNT_KERBEROS_OFF 0x0100 /* tmp until <12991970> is fixed */ 45#define SMBFS_MNT_FILE_IDS_OFF 0x0200 46#define SMBFS_MNT_AAPL_OFF 0x0400 47#define SMBFS_MNT_VALIDATE_NEG_OFF 0x0800 48 49#ifndef KERNEL 50#include <asl.h> 51#include <sys/mount.h> 52#include <CoreFoundation/CoreFoundation.h> 53 54/* Once we add more we may want to make this an enum, also may want to make public */ 55#define kHasNtwrkSID 0x01 56#define kLanmanOn 0x02 57 58/* These must match the values in dfs.h */ 59#define kReferralList CFSTR("ReferralList") 60#define kRequestFileName CFSTR("RequestFileName") 61#define kDFSPath CFSTR("DFSPath") 62#define kServerType CFSTR("ServerType") 63#define kNetworkAddress CFSTR("NetworkAddress") 64#define kNewReferral CFSTR("NewReferral") 65#define kDfsServerArray CFSTR("DfsServerArray") 66#define kDfsADServerArray CFSTR("DfsADServerArray") 67#define kDfsReferralArray CFSTR("DfsReferralArray") 68#define kSpecialName CFSTR("SpecialName") 69#define kNumberOfExpandedNames CFSTR("NumberOfExpandedNames") 70#define kExpandedNameArray CFSTR("ExpandedNameArray") 71 72/*! 73 * @function SMBLogInfo 74 * @abstract Helper routine for logging information the same as the framework. 75 * @printf style routine 76 */ 77SMBCLIENT_EXPORT 78void 79SMBLogInfo( const char *, int,...) __printflike(1, 3) 80__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA) 81; 82 83 84/*! 85 * @function SMBMountShare 86 * @abstract Mount a SMB share 87 * @param inConnection A handle to the connection 88 * @param targetShare A UTF-8 encoded share name, may be null. 89 * @param mountPoint A UTF-8 encoded mount point that must exist. 90 * @param mountFlags See man mount. 91 * @param mountOptions Set of options that support the alternative mount flags 92 * @param fileMode Specify permissions that should be assigned to files. The 93 * value must be specified as octal numbers. To use the default value set to 94 * zero. 95 * @param dirMode Specify permissions that should be assigned to directories. 96 * The value must be specified as octal numbers. To use the default value set to 97 * zero. 98 * @result Returns an NTSTATUS error code. 99 */ 100SMBCLIENT_EXPORT 101NTSTATUS 102SMBMountShareEx( 103 SMBHANDLE inConnection, 104 const char *targetShare, 105 const char *mountPoint, 106 unsigned mountFlags, 107 uint64_t mountOptions, 108 mode_t fileMode, 109 mode_t dirMode, 110 void (*)(void *, void *), 111 void *args) 112__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA) 113; 114 115/*! 116 * @function SMBAllocateAndSetContext 117 * @abstract Creates a SMBHANDLE that contains the smb library internal session 118 * context passed into it. The handle can be used to access other SMBClient 119 * Framework routines. 120 * @param session - A smb library internal session context 121 * @result Returns an SMBHANDLE that can be used to access the session or NULL 122 */ 123SMBCLIENT_EXPORT 124SMBHANDLE 125SMBAllocateAndSetContext( 126 void * session) 127__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA) 128; 129 130/*! 131 * @function SMBCheckForAlreadyMountedShare 132 * @abstract Private routine for getting information about a list of shares 133 * @inConnection - A handle to the connection 134 * @shareRef - the share in question 135 * @mdictRef - a dictionary to add the share to 136 * @fs - List of file systems 137 * @fs_cnt - Number of file systems 138 * @result Returns an errno on failure and zero on success 139 */ 140SMBCLIENT_EXPORT 141int 142SMBCheckForAlreadyMountedShare( 143 SMBHANDLE inConnection, 144 CFStringRef shareRef, 145 CFMutableDictionaryRef mdictRef, 146 struct statfs *fs, 147 int fs_cnt) 148__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA) 149; 150 151/*! 152 * @function SMBSetNetworkIdentity 153 * @abstract Private routine for getting identity information of a users 154 * connection. 155 * @inConnection - A handle to the connection 156 * @network_sid - On success the users network sid 157 * @account - On success the users account name 158 * @domain - On success the domain the user belongs to 159 * @result Returns an errno on failure and zero on success 160 */ 161SMBCLIENT_EXPORT 162int 163SMBSetNetworkIdentity( 164 SMBHANDLE inConnection, 165 void *network_sid, 166 char *account, 167 char *domain) 168__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA) 169; 170 171/*! 172 * @function SMBRemountServer 173 * @abstract Private routine for remouting Dfs 174 * @inputBuffer - Internal only should never be looked at. 175 * @inputBufferLen - Size of the inputBuffer. 176 */ 177SMBCLIENT_EXPORT 178void 179SMBRemountServer( 180 const void *inputBuffer, 181 size_t inputBufferLen) 182__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA) 183; 184 185/*! 186 * @function SMBGetDfsReferral 187 * @abstract Private routine for resolving a dfs referral for smbutil 188 * @url - dfs referral to resolve 189 * @dfsReferralDict - dfs resolution results 190 */ 191SMBCLIENT_EXPORT 192int SMBGetDfsReferral( 193 const char * url, 194 CFMutableDictionaryRef dfsReferralDict); 195 196/*! 197 * @function SMBQueryDir 198 * @abstract Private routine for enumerating a directory, only SMB 2 or later 199 * @inConnection - A handle to the connection 200 * @file_info_class - file info class that describes return data format 201 * @flags - controls how the query dir should be done 202 * @file_index - starting byte offset within the dir 203 * @fid - dir File ID to do query dir on 204 * @name - search pattern 205 * @name_len - length of the search pattern 206 * @rcv_output_buffer - buffer to return Query Dir results in 207 * @rcv_max_output_len - size of the rcv_output_buffer 208 * @rcv_output_len - actual number of bytes returned in rcv_output_buffer 209 * @query_dir_reply_len - number of bytes returned in Query Dir reply 210 */ 211SMBCLIENT_EXPORT 212NTSTATUS 213SMBQueryDir( 214 SMBHANDLE inConnection, 215 uint8_t file_info_class, 216 uint8_t flags, 217 uint32_t file_index, 218 SMBFID fid, 219 const char * name, 220 uint32_t name_len, 221 char * rcv_output_buffer, 222 uint32_t rcv_max_output_len, 223 uint32_t * rcv_output_len, 224 uint32_t * query_dir_reply_len) 225__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_NA) 226; 227 228 229#endif // KERNEL 230 231 232#ifdef __cplusplus 233} // extern "C" 234#endif 235 236#endif // _SMBCLIENT_INTERNAL_H_ 237