2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #define __SMB_H_ENV__ 1
14 #include "netbios95.h"
19 /* Support largefiles by default */
20 #define AFS_LARGEFILES
22 /* basic core protocol SMB structure */
29 unsigned char errHigh;
32 unsigned short res[6];
38 unsigned char vdata[1];
43 #define SMB_FLAGS_SUPPORT_LOCKREAD 0x01
44 #define SMB_FLAGS_CLIENT_BUF_AVAIL 0x02
45 #define SMB_FLAGS_CASELESS_PATHNAMES 0x08
46 #define SMB_FLAGS_CANONICAL_PATHNAMES 0x10
47 #define SMB_FLAGS_REQUEST_OPLOCK 0x20
48 #define SMB_FLAGS_REQUEST_BATCH_OPLOCK 0x40
49 #define SMB_FLAGS_SERVER_TO_CLIENT 0x80
53 #define SMB_FLAGS2_KNOWS_LONG_NAMES 0x0001
54 #define SMB_FLAGS2_KNOWS_EAS 0x0002
55 #define SMB_FLAGS2_SECURITY_SIGNATURE 0x0004
56 #define SMB_FLAGS2_RESERVED1 0x0008
57 #define SMB_FLAGS2_IS_LONG_NAME 0x0040
58 #define SMB_FLAGS2_EXT_SEC 0x0800
59 #define SMB_FLAGS2_DFS_PATHNAMES 0x1000
60 #define SMB_FLAGS2_PAGING_IO 0x2000
61 #define SMB_FLAGS2_32BIT_STATUS 0x4000
62 #define SMB_FLAGS2_UNICODE 0x8000
64 #define KNOWS_LONG_NAMES(inp) ((((smb_t *)inp)->flg2 & SMB_FLAGS2_KNOWS_LONG_NAMES)?1:0)
65 #define WANTS_DFS_PATHNAMES(inp) ((((smb_t *)inp)->flg2 & SMB_FLAGS2_DFS_PATHNAMES)?1:0)
67 /* Information Levels */
68 #define SMB_INFO_STANDARD 1
69 #define SMB_INFO_QUERY_EA_SIZE 2
70 #define SMB_INFO_QUERY_EAS_FROM_LIST 3
71 #define SMB_INFO_QUERY_ALL_EAS 4
72 #define SMB_INFO_IS_NAME_VALID 6
74 #define SMB_QUERY_FILE_BASIC_INFO 0x101
75 #define SMB_QUERY_FILE_STANDARD_INFO 0x102
76 #define SMB_QUERY_FILE_EA_INFO 0x103
77 #define SMB_QUERY_FILE_NAME_INFO 0x104
78 #define SMB_QUERY_FILE_ALL_INFO 0x107
79 #define SMB_QUERY_FILE_ALT_NAME_INFO 0x108
80 #define SMB_QUERY_FILE_STREAM_INFO 0x109
81 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
82 #define SMB_QUERY_FILE_UNIX_BASIC 0x200
83 #define SMB_QUERY_FILE_UNIX_LINK 0x201
84 #define SMB_INFO_PASSTHROUGH 0x1000
86 #define SMB_SET_FILE_UNIX_BASIC 0x200
87 #define SMB_SET_FILE_UNIX_LINK 0x201
88 #define SMB_SET_FILE_UNIX_HLINK 0x203
91 #define SMB_NOPCODES 256 /* # of opcodes in the dispatch table */
94 #define SMB_THREADSPERVC 4 /* threads per VC */
96 /* flags for functions */
97 #define SMB_FLAG_CREATE 1 /* create the structure if necessary */
98 #define SMB_FLAG_AFSLOGON 2 /* operating on behalf of afslogon.dll */
100 /* max # of bytes we'll receive in an incoming SMB message */
101 /* the maximum is 2^18-1 for NBT and 2^25-1 for Raw transport messages */
102 /* we will use something smaller but large enough to be efficient */
103 #define SMB_PACKETSIZE 32768 /* was 8400 */
104 /* raw mode is considered obsolete and cannot be used with message signing */
105 #define SMB_MAXRAWSIZE 65536
107 /* Negotiate protocol constants */
109 #define NEGOTIATE_SECURITY_USER_LEVEL 0x01
110 #define NEGOTIATE_SECURITY_CHALLENGE_RESPONSE 0x02
111 #define NEGOTIATE_SECURITY_SIGNATURES_ENABLED 0x04
112 #define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
115 #define NTNEGOTIATE_CAPABILITY_RAWMODE 0x00000001L
116 #define NTNEGOTIATE_CAPABILITY_MPXMODE 0x00000002L
117 #define NTNEGOTIATE_CAPABILITY_UNICODE 0x00000004L
118 #define NTNEGOTIATE_CAPABILITY_LARGEFILES 0x00000008L
119 #define NTNEGOTIATE_CAPABILITY_NTSMB 0x00000010L
120 #define NTNEGOTIATE_CAPABILITY_RPCAPI 0x00000020L
121 #define NTNEGOTIATE_CAPABILITY_NTSTATUS 0x00000040L
122 #define NTNEGOTIATE_CAPABILITY_LEVEL_II_OPLOCKS 0x00000080L
123 #define NTNEGOTIATE_CAPABILITY_LOCK_AND_READ 0x00000100L
124 #define NTNEGOTIATE_CAPABILITY_NTFIND 0x00000200L
125 #define NTNEGOTIATE_CAPABILITY_DFS 0x00001000L
126 #define NTNEGOTIATE_CAPABILITY_NT_INFO_PASSTHRU 0x00002000L
127 #define NTNEGOTIATE_CAPABILITY_LARGE_READX 0x00004000L
128 #define NTNEGOTIATE_CAPABILITY_LARGE_WRITEX 0x00008000L
129 #define NTNEGOTIATE_CAPABILITY_UNIX 0x00800000L
130 #define NTNEGOTIATE_CAPABILITY_BULK_TRANSFER 0x20000000L
131 #define NTNEGOTIATE_CAPABILITY_COMPRESSED 0x40000000L
132 #define NTNEGOTIATE_CAPABILITY_EXTENDED_SECURITY 0x80000000L
134 /* a packet structure for receiving SMB messages; locked by smb_globalLock.
135 * Most of the work involved is in handling chained requests and responses.
137 * When handling input, inWctp points to the current request's wct field (and
138 * the other parameters and request data can be found from this field). The
139 * opcode, unfortunately, isn't available there, so is instead copied to the
140 * packet's inCom field. It is initially set to com, but each chained
141 * operation sets it, also.
142 * The function smb_AdvanceInput advances an input packet to the next request
143 * in the chain. The inCom field is set to 0xFF when there are no more
144 * requests. The inCount field is 0 if this is the first request, and
145 * otherwise counts which request it is.
147 * When handling output, we also have to chain all of the responses together.
148 * The function smb_GetResponsePacket will setup outWctp to point to the right
151 #define SMB_PACKETMAGIC 0x7436353 /* magic # for packets */
152 typedef struct smb_packet {
153 char data[SMB_PACKETSIZE];
154 struct smb_packet *nextp; /* in free list, or whatever */
156 cm_space_t *spacep; /* use this for stripping last component */
157 NCB *ncbp; /* use this for sending */
159 unsigned long resumeCode;
160 unsigned short inCount;
161 unsigned short fid; /* for calls bundled with openAndX */
164 unsigned char oddByte;
165 unsigned short ncb_length;
169 unsigned int dos_pkt_sel;
173 /* smb_packet flags */
174 #define SMB_PACKETFLAG_NOSEND 1
175 #define SMB_PACKETFLAG_SUSPENDED 2
177 /* a structure for making Netbios calls; locked by smb_globalLock */
178 #define SMB_NCBMAGIC 0x2334344
179 typedef struct myncb {
180 NCB ncb; /* ncb to use */
181 struct myncb *nextp; /* when on free list */
185 smb_packet_t *orig_pkt;
186 unsigned int dos_ncb_sel;
190 /* structures representing environments from kernel / SMB network.
191 * Most have their own locks, but the tree connection fields and
192 * reference counts are locked by the smb_rctLock. Those fields will
193 * be marked in comments.
196 /* one per virtual circuit */
197 typedef struct smb_vc {
198 struct smb_vc *nextp; /* not used */
199 afs_uint32 magic; /* a magic value to detect bad entries */
200 unsigned long refCount; /* the reference count */
201 long flags; /* the flags, if any; locked by mx */
202 osi_mutex_t mx; /* the mutex */
203 long vcID; /* VC id */
204 unsigned short lsn; /* the NCB LSN associated with this */
205 unsigned short uidCounter; /* session ID counter */
206 unsigned short tidCounter; /* tree ID counter */
207 unsigned short fidCounter; /* file handle ID counter */
208 struct smb_tid *tidsp; /* the first child in the tid list */
209 struct smb_user *usersp; /* the first child in the user session list */
210 struct smb_fid *fidsp; /* the first child in the open file list */
211 unsigned char errorCount;
214 char encKey[MSV1_0_CHALLENGE_LENGTH]; /* MSV1_0_CHALLENGE_LENGTH is 8 */
215 void * secCtx; /* security context when negotiating SMB extended auth
216 * valid when SMB_VCFLAG_AUTH_IN_PROGRESS is set
218 unsigned short session; /* This is the Session Index associated with the NCBs */
221 #define SMB_VC_MAGIC ('S' | 'C'<<8 | 'A'<<16 | 'C'<<24)
222 /* have we negotiated ... */
223 #define SMB_VCFLAG_USEV3 1 /* ... version 3 of the protocol */
224 #define SMB_VCFLAG_USECORE 2 /* ... the core protocol */
225 #define SMB_VCFLAG_USENT 4 /* ... NT LM 0.12 or beyond */
226 #define SMB_VCFLAG_STATUS32 8 /* use 32-bit NT status codes */
227 #define SMB_VCFLAG_REMOTECONN 0x10 /* bad: remote conns not allowed */
228 #define SMB_VCFLAG_ALREADYDEAD 0x20 /* do not get tokens from this vc */
229 #define SMB_VCFLAG_SESSX_RCVD 0x40 /* we received at least one session setups on this vc */
230 #define SMB_VCFLAG_AUTH_IN_PROGRESS 0x80 /* a SMB NT extended authentication is in progress */
231 #define SMB_VCFLAG_CLEAN_IN_PROGRESS 0x100
233 /* one per user session */
234 typedef struct smb_user {
235 struct smb_user *nextp; /* next sibling */
236 unsigned long refCount; /* ref count */
237 afs_uint32 flags; /* flags; locked by mx */
239 unsigned short userID; /* the session identifier */
240 struct smb_vc *vcp; /* back ptr to virtual circuit */
241 struct smb_username *unp; /* user name struct */
242 afs_uint32 delete; /* ok to del: locked by smb_rctLock */
245 #define SMB_USERFLAG_DELETE 1 /* delete struct when ref count zero */
247 typedef struct smb_username {
248 struct smb_username *nextp; /* next sibling */
249 unsigned long refCount; /* ref count */
250 long flags; /* flags; locked by mx */
252 struct cm_user *userp; /* CM user structure */
253 char *name; /* user name */
254 char *machine; /* machine name */
255 time_t last_logoff_t; /* most recent logoff time */
258 /* The SMB_USERNAMEFLAG_AFSLOGON is used to preserve the existence of an
259 * smb_username_t even when the refCount is zero. This is used to ensure
260 * that tokens set to a username during the integrated logon process are
261 * preserved until the SMB Session that will require the tokens is created.
262 * The cm_IoctlSetTokens() function when executed from the Network Provider
263 * connects to the AFS Client Service using the credentials of the machine
264 * and not the user for whom the tokens are being configured. */
265 #define SMB_USERNAMEFLAG_AFSLOGON 1
267 /* The SMB_USERNAMEFLAG_LOGOFF is used to indicate that the user most
268 * recently logged off at 'last_logoff_t'. The smb_username_t should not
269 * be deleted even if the refCount is zero before 'last_logoff_t' +
270 * 'smb_LogoffTransferTimeout' if 'smb_LogoffTokenTransfer' is non-zero.
271 * The smb_Daemon() thread is responsible for purging the expired objects */
273 #define SMB_USERNAMEFLAG_LOGOFF 2
275 #define SMB_MAX_USERNAME_LENGTH 256
277 /* one per tree-connect */
278 typedef struct smb_tid {
279 struct smb_tid *nextp; /* next sibling */
280 unsigned long refCount;
281 afs_uint32 flags; /* protected by mx */
282 osi_mutex_t mx; /* for non-tree-related stuff */
283 unsigned short tid; /* the tid */
284 struct smb_vc *vcp; /* back ptr */
285 struct cm_user *userp; /* user logged in at the
286 * tree connect level (base) */
287 char *pathname; /* pathname derived from sharename */
288 afs_uint32 delete; /* ok to del: locked by smb_rctLock */
291 #define SMB_TIDFLAG_IPC 1 /* IPC$ */
293 /* one per process ID */
294 typedef struct smb_pid {
295 struct smb_pid *nextp; /* next sibling */
296 unsigned long refCount;
298 osi_mutex_t mx; /* for non-tree-related stuff */
299 unsigned short pid; /* the pid */
300 struct smb_tid *tidp; /* back ptr */
303 /* ioctl parameter, while being assembled and/or processed */
304 typedef struct smb_ioctl {
306 char *inDatap; /* ioctl func's current position
307 * in input parameter block */
308 char *inAllocp; /* allocated input parameter block */
309 long inCopied; /* # of input bytes copied in so far
311 cm_space_t *prefix; /* prefix for subst drives */
312 char *tidPathp; /* Pathname associated with Tree ID */
315 char *outDatap; /* output results assembled so far */
316 char *outAllocp; /* output results assembled so far */
317 long outCopied; /* # of output bytes copied back so far
324 struct smb_fid *fidp;
330 /* flags for smb_ioctl_t */
331 #define SMB_IOCTLFLAG_DATAIN 1 /* reading data from client to server */
332 #define SMB_IOCTLFLAG_LOGON 2 /* got tokens from integrated logon */
334 /* one per file ID; these are really file descriptors */
335 typedef struct smb_fid {
337 unsigned long refCount;
338 afs_uint32 flags; /* protected by mx */
339 osi_mutex_t mx; /* for non-tree-related stuff */
340 unsigned short fid; /* the file ID */
341 struct smb_vc *vcp; /* back ptr */
342 struct cm_scache *scp; /* scache of open file */
343 struct cm_user *userp; /* user that opened the file
344 originally (used to close
345 the file if session is
347 osi_hyper_t offset; /* our file pointer */
348 smb_ioctl_t *ioctlp; /* ptr to ioctl structure */
349 /* Under NT, we may need to know the
350 * parent directory and pathname used
351 * to open the file, either to delete
352 * the file on close, or to do a
353 * change notification */
354 struct cm_scache *NTopen_dscp; /* parent directory (NT) */
355 char *NTopen_pathp; /* path used in open (NT) */
356 char *NTopen_wholepathp; /* entire path, not just last name */
357 int curr_chunk; /* chunk being read */
358 int prev_chunk; /* previous chunk read */
359 int raw_writers; /* pending async raw writes */
360 EVENT_HANDLE raw_write_event; /* signal this when raw_writers zero */
361 afs_uint32 delete; /* ok to del: locked by smb_rctLock */
364 #define SMB_FID_OPENREAD 1 /* open for reading */
365 #define SMB_FID_OPENWRITE 2 /* open for writing */
366 #define SMB_FID_CREATED 4 /* a new file */
367 #define SMB_FID_IOCTL 8 /* a file descriptor for the
368 * magic ioctl file */
369 #define SMB_FID_OPENDELETE 0x10 /* open for deletion (NT) */
370 #define SMB_FID_DELONCLOSE 0x20 /* marked for deletion */
373 * Now some special flags to work around a bug in NT Client
375 #define SMB_FID_LENGTHSETDONE 0x40 /* have done 0-length write */
376 #define SMB_FID_MTIMESETDONE 0x80 /* have set modtime via Tr2 */
377 #define SMB_FID_LOOKSLIKECOPY (SMB_FID_LENGTHSETDONE | SMB_FID_MTIMESETDONE)
378 #define SMB_FID_NTOPEN 0x100 /* have dscp and pathp */
380 #define SMB_FID_SHARE_READ 0x1000
381 #define SMB_FID_SHARE_WRITE 0x2000
383 #define SMB_FID_QLOCK_HIGH 0x7f000000
384 #define SMB_FID_QLOCK_LOW 0x00000000
385 #define SMB_FID_QLOCK_LENGTH 1
386 #define SMB_FID_QLOCK_PID 0
389 * SMB file attributes (32-bit)
391 #define SMB_ATTR_READONLY 0x0001
392 #define SMB_ATTR_HIDDEN 0x0002 /* hidden file for the purpose of dir listings */
393 #define SMB_ATTR_SYSTEM 0x0004
394 #define SMB_ATTR_VOLUMEID 0x0008 /* obsolete */
395 #define SMB_ATTR_DIRECTORY 0x0010
396 #define SMB_ATTR_ARCHIVE 0x0020
397 #define SMB_ATTR_DEVICE 0x0040
398 #define SMB_ATTR_NORMAL 0x0080 /* normal file. Only valid if used alone */
399 #define SMB_ATTR_TEMPORARY 0x0100
400 #define SMB_ATTR_SPARSE_FILE 0x0200 /* used with dfs links */
401 #define SMB_ATTR_REPARSE_POINT 0x0400
402 #define SMB_ATTR_COMPRESSED 0x0800 /* file or dir is compressed */
403 #define SMB_ATTR_OFFLINE 0x1000
404 #define SMB_ATTR_NOT_CONTENT_INDEXED 0x2000
405 #define SMB_ATTR_ENCRYPTED 0x4000
407 #define LOCKING_ANDX_SHARED_LOCK 0x01 /* Read-only lock */
408 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02 /* Oplock break notification */
409 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04 /* Change lock type */
410 #define LOCKING_ANDX_CANCEL_LOCK 0x08 /* Cancel outstanding request */
411 #define LOCKING_ANDX_LARGE_FILES 0x10 /* Large file locking format */
413 /* for tracking in-progress directory searches */
414 typedef struct smb_dirSearch {
415 osi_queue_t q; /* queue of all outstanding cookies */
416 osi_mutex_t mx; /* just in case the caller screws up */
417 unsigned long refCount; /* reference count */
418 long cookie; /* value returned to the caller */
419 struct cm_scache *scp; /* vnode of the dir we're searching */
420 time_t lastTime; /* last time we used this (osi_Time) */
421 long flags; /* flags (see below);
422 * locked by smb_globalLock */
423 unsigned short attribute; /* search attribute
424 * (used for extended protocol) */
425 char mask[256]; /* search mask for V3 */
428 #define SMB_DIRSEARCH_DELETE 1 /* delete struct when ref count zero */
429 #define SMB_DIRSEARCH_HITEOF 2 /* perhaps useful for advisory later */
430 #define SMB_DIRSEARCH_SMALLID 4 /* cookie can only be 8 bits, not 16 */
431 #define SMB_DIRSEARCH_BULKST 8 /* get bulk stat info */
433 /* type for patching directory listings */
434 typedef struct smb_dirListPatch {
436 char *dptr; /* ptr to attr, time, data, sizel, sizeh */
437 long flags; /* flags. See below */
439 cm_dirEntry_t *dep; /* temp */
440 } smb_dirListPatch_t;
442 /* dirListPatch Flags */
443 #define SMB_DIRLISTPATCH_DOTFILE 1
444 /* the file referenced is a dot file
445 * Note: will not be set if smb_hideDotFiles is false
448 /* individual lock on a waiting lock request */
449 typedef struct smb_waitingLock {
452 LARGE_INTEGER LOffset;
453 LARGE_INTEGER LLength;
454 cm_file_lock_t * lockp;
458 #define SMB_WAITINGLOCKSTATE_WAITING 0
459 #define SMB_WAITINGLOCKSTATE_DONE 1
460 #define SMB_WAITINGLOCKSTATE_ERROR 2
462 /* waiting lock request */
463 typedef struct smb_waitingLockRequest {
470 time_t timeRemaining;
471 smb_waitingLock_t * locks;
472 } smb_waitingLockRequest_t;
474 extern smb_waitingLockRequest_t *smb_allWaitingLocks;
476 typedef long (smb_proc_t)(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
478 typedef struct smb_dispatch {
479 smb_proc_t *procp; /* proc to call */
480 int flags; /* flags describing function */
483 #define SMB_DISPATCHFLAG_CHAINED 1 /* this is an _AND_X function */
484 #define SMB_DISPATCHFLAG_NORESPONSE 2 /* don't send the response
485 * packet, typically because
486 * the response was already
489 #define SMB_MAX_PATH 256 /* max path length */
493 extern void smb_Init(osi_log_t *logp, char *smbNamep, int useV3, int LANadapt,
500 extern void smb_LargeSearchTimeFromUnixTime(FILETIME *largeTimep, time_t unixTime);
502 extern void smb_UnixTimeFromLargeSearchTime(time_t *unixTimep, FILETIME *largeTimep);
504 extern void smb_SearchTimeFromUnixTime(afs_uint32 *searchTimep, time_t unixTime);
506 extern void smb_UnixTimeFromSearchTime(time_t *unixTimep, afs_uint32 searchTime);
508 extern void smb_DosUTimeFromUnixTime(afs_uint32 *dosUTimep, time_t unixTime);
510 extern void smb_UnixTimeFromDosUTime(time_t *unixTimep, afs_uint32 dosUTime);
512 extern void CompensateForSmbClientLastWriteTimeBugs(afs_uint32 *dosTimep);
514 extern smb_vc_t *smb_FindVC(unsigned short lsn, int flags, int lana);
516 extern void smb_CleanupDeadVC(smb_vc_t *vcp);
518 extern void smb_ReleaseVC(smb_vc_t *vcp);
520 extern void smb_ReleaseVCNoLock(smb_vc_t *vcp);
522 extern smb_tid_t *smb_FindTID(smb_vc_t *vcp, unsigned short tid, int flags);
524 extern void smb_HoldTIDNoLock(smb_tid_t *tidp);
526 extern void smb_ReleaseTID(smb_tid_t *tidp);
528 extern smb_user_t *smb_FindUID(smb_vc_t *vcp, unsigned short uid, int flags);
530 extern smb_username_t *smb_FindUserByName(char *usern, char *machine, afs_uint32 flags);
532 extern smb_user_t *smb_FindUserByNameThisSession(smb_vc_t *vcp, char *usern);
534 extern void smb_ReleaseUsername(smb_username_t *unp);
536 extern void smb_HoldUIDNoLock(smb_user_t *uidp);
538 extern void smb_ReleaseUID(smb_user_t *uidp);
540 extern cm_user_t *smb_GetUserFromVCP(smb_vc_t *vcp, smb_packet_t *inp);
542 extern cm_user_t *smb_GetUserFromUID(smb_user_t *uidp);
544 extern long smb_LookupTIDPath(smb_vc_t *vcp, unsigned short tid, char ** tidPathp);
546 extern smb_fid_t *smb_FindFID(smb_vc_t *vcp, unsigned short fid, int flags);
548 extern void smb_HoldFIDNoLock(smb_fid_t *fidp);
550 extern void smb_ReleaseFID(smb_fid_t *fidp);
552 extern long smb_CloseFID(smb_vc_t *vcp, smb_fid_t *fidp, cm_user_t *userp,
555 extern int smb_FindShare(smb_vc_t *vcp, smb_user_t *uidp, char *shareName, char **pathNamep);
557 extern int smb_FindShareCSCPolicy(char *shareName);
559 extern smb_dirSearch_t *smb_FindDirSearchNL(long cookie);
561 extern void smb_DeleteDirSearch(smb_dirSearch_t *dsp);
563 extern void smb_ReleaseDirSearch(smb_dirSearch_t *dsp);
565 extern smb_dirSearch_t *smb_FindDirSearch(long cookie);
567 extern smb_dirSearch_t *smb_NewDirSearch(int isV3);
569 extern smb_packet_t *smb_CopyPacket(smb_packet_t *packetp);
571 extern void smb_FreePacket(smb_packet_t *packetp);
573 extern unsigned char *smb_GetSMBData(smb_packet_t *smbp, int *nbytesp);
575 extern void smb_SetSMBDataLength(smb_packet_t *smbp, unsigned int dsize);
577 extern unsigned int smb_GetSMBParm(smb_packet_t *smbp, int parm);
579 extern unsigned int smb_GetSMBOffsetParm(smb_packet_t *smbp, int parm, int offset);
581 extern void smb_SetSMBParm(smb_packet_t *smbp, int slot, unsigned int parmValue);
583 extern void smb_SetSMBParmLong(smb_packet_t *smbp, int slot, unsigned int parmValue);
585 extern void smb_SetSMBParmDouble(smb_packet_t *smbp, int slot, char *parmValuep);
587 extern void smb_SetSMBParmByte(smb_packet_t *smbp, int slot, unsigned int parmValue);
589 extern void smb_StripLastComponent(char *outPathp, char **lastComponentp,
592 extern unsigned char *smb_ParseASCIIBlock(unsigned char *inp, char **chainpp);
594 extern unsigned char *smb_ParseVblBlock(unsigned char *inp, char **chainpp,
597 extern smb_packet_t *smb_GetResponsePacket(smb_vc_t *vcp, smb_packet_t *inp);
599 extern void smb_SendPacket(smb_vc_t *vcp, smb_packet_t *inp);
601 extern void smb_MapCoreError(long code, smb_vc_t *vcp, unsigned short *scodep,
602 unsigned char *classp);
604 extern void smb_MapNTError(long code, unsigned long *NTStatusp);
606 extern void smb_HoldVC(smb_vc_t *vcp);
608 extern void smb_HoldVCNoLock(smb_vc_t *vcp);
610 /* some globals, too */
611 extern char *smb_localNamep;
613 extern osi_log_t *smb_logp;
615 extern osi_rwlock_t smb_globalLock;
617 extern osi_rwlock_t smb_rctLock;
619 extern int smb_LogoffTokenTransfer;
620 extern time_t smb_LogoffTransferTimeout;
622 extern int smb_maxVCPerServer; /* max # of VCs per server */
623 extern int smb_maxMpxRequests; /* max # of mpx requests */
625 extern int smb_StoreAnsiFilenames;
626 extern int smb_hideDotFiles;
627 extern unsigned int smb_IsDotFile(char *lastComp);
629 /* the following are used for smb auth */
630 extern int smb_authType; /* Type of SMB authentication to be used. One from below. */
632 #define SMB_AUTH_NONE 0
633 #define SMB_AUTH_NTLM 1
634 #define SMB_AUTH_EXTENDED 2
636 extern HANDLE smb_lsaHandle; /* LSA handle obtained during smb_init if using SMB auth */
637 extern ULONG smb_lsaSecPackage; /* LSA security package id. Set during smb_init */
638 extern char smb_ServerDomainName[];
639 extern int smb_ServerDomainNameLength;
640 extern char smb_ServerOS[];
641 extern int smb_ServerOSLength;
642 extern char smb_ServerLanManager[];
643 extern int smb_ServerLanManagerLength;
644 extern GUID smb_ServerGUID;
645 extern LSA_STRING smb_lsaLogonOrigin;
647 /* used for getting a challenge for SMB auth */
648 typedef struct _MSV1_0_LM20_CHALLENGE_REQUEST {
649 MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
650 } MSV1_0_LM20_CHALLENGE_REQUEST, *PMSV1_0_LM20_CHALLENGE_REQUEST;
652 typedef struct _MSV1_0_LM20_CHALLENGE_RESPONSE {
653 MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
654 UCHAR ChallengeToClient[MSV1_0_CHALLENGE_LENGTH];
655 } MSV1_0_LM20_CHALLENGE_RESPONSE, *PMSV1_0_LM20_CHALLENGE_RESPONSE;
658 extern long smb_AuthenticateUserLM(smb_vc_t *vcp, char * accountName, char * primaryDomain, char * ciPwd, unsigned ciPwdLength, char * csPwd, unsigned csPwdLength);
660 extern long smb_GetNormalizedUsername(char * usern, const char * accountName, const char * domainName);
662 extern void smb_FormatResponsePacket(smb_vc_t *vcp, smb_packet_t *inp,
665 extern char *myCrt_Dispatch(int i);
667 extern char *myCrt_2Dispatch(int i);
669 extern char *myCrt_RapDispatch(int i);
671 extern unsigned int smb_Attributes(cm_scache_t *scp);
673 extern int smb_ChainFID(int fid, smb_packet_t *inp);
675 extern smb_fid_t *smb_FindFID(smb_vc_t *vcp, unsigned short fid, int flags);
677 extern void smb_ReleaseFID(smb_fid_t *fidp);
679 extern unsigned char *smb_ParseDataBlock(unsigned char *inp, char **chainpp, int *lengthp);
681 extern unsigned char *smb_ParseASCIIBlock(unsigned char *inp, char **chainpp);
683 extern unsigned char *smb_ParseVblBlock(unsigned char *inp, char **chainpp, int *lengthp);
685 extern int smb_SUser(cm_user_t *userp);
688 long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
689 cm_user_t *userp, long *writtenp);
691 long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
692 cm_user_t *userp, long *writtenp, int dosflag);
696 extern long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count,
697 char *op, cm_user_t *userp, long *readp);
699 extern long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count,
700 char *op, cm_user_t *userp, long *readp, int dosflag);
703 extern long smb_Rename(smb_vc_t *vcp, smb_packet_t *inp, char *oldPathp, char *newPathp, int attrs);
705 extern long smb_Link(smb_vc_t *vcp, smb_packet_t *inp, char *oldPathp, char *newPathp);
707 extern BOOL smb_IsLegalFilename(char *filename);
709 extern char *smb_GetSharename(void);
711 extern DWORD smb_ServerExceptionFilter(void);
713 extern void smb_UpdateServerPriority(void);
714 extern void smb_SetRequestStartTime(void);
715 extern void smb_ResetServerPriority(void);
717 /* include other include files */
719 #include "smb_ioctl.h"
720 #include "smb_iocons.h"
722 cm_user_t *smb_FindOrCreateUser(smb_vc_t *vcp, char *usern);
725 extern void smb_LogPacket(smb_packet_t *packet);
726 #endif /* NOTSERVICE */
728 #ifndef MSV1_0_OPTION_ALLOW_BLANK_PASSWORD
729 #define MSV1_0_OPTION_ALLOW_BLANK_PASSWORD 0x1
730 #define MSV1_0_OPTION_DISABLE_ADMIN_LOCKOUT 0x2
731 #define MSV1_0_OPTION_DISABLE_FORCE_GUEST 0x4
732 #define MSV1_0_OPTION_TRY_CACHE_FIRST 0x10
734 typedef struct _MSV1_0_SETPROCESSOPTION_REQUEST {
735 MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
736 ULONG ProcessOptions;
737 BOOLEAN DisableOptions;
738 } MSV1_0_SETPROCESSOPTION_REQUEST, *PMSV1_0_SETPROCESSOPTION_REQUEST;
741 #endif /* whole file */