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
85 #define SMB_SET_FILE_UNIX_BASIC 0x200
86 #define SMB_SET_FILE_UNIX_LINK 0x201
87 #define SMB_SET_FILE_UNIX_HLINK 0x203
90 #define SMB_NOPCODES 256 /* # of opcodes in the dispatch table */
93 #define SMB_THREADSPERVC 4 /* threads per VC */
95 /* flags for functions */
96 #define SMB_FLAG_CREATE 1 /* create the structure if necessary */
97 #define SMB_FLAG_AFSLOGON 2 /* operating on behalf of afslogon.dll */
99 /* max # of bytes we'll receive in an incoming SMB message */
100 /* the maximum is 2^18-1 for NBT and 2^25-1 for Raw transport messages */
101 /* we will use something smaller but large enough to be efficient */
102 #define SMB_PACKETSIZE 32768 /* was 8400 */
103 /* raw mode is considered obsolete and cannot be used with message signing */
104 #define SMB_MAXRAWSIZE 65536
106 /* Negotiate protocol constants */
108 #define NEGOTIATE_SECURITY_USER_LEVEL 0x01
109 #define NEGOTIATE_SECURITY_CHALLENGE_RESPONSE 0x02
110 #define NEGOTIATE_SECURITY_SIGNATURES_ENABLED 0x04
111 #define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
114 #define NTNEGOTIATE_CAPABILITY_RAWMODE 0x00000001L
115 #define NTNEGOTIATE_CAPABILITY_MPXMODE 0x00000002L
116 #define NTNEGOTIATE_CAPABILITY_UNICODE 0x00000004L
117 #define NTNEGOTIATE_CAPABILITY_LARGEFILES 0x00000008L
118 #define NTNEGOTIATE_CAPABILITY_NTSMB 0x00000010L
119 #define NTNEGOTIATE_CAPABILITY_RPCAPI 0x00000020L
120 #define NTNEGOTIATE_CAPABILITY_NTSTATUS 0x00000040L
121 #define NTNEGOTIATE_CAPABILITY_LEVEL_II_OPLOCKS 0x00000080L
122 #define NTNEGOTIATE_CAPABILITY_LOCK_AND_READ 0x00000100L
123 #define NTNEGOTIATE_CAPABILITY_NTFIND 0x00000200L
124 #define NTNEGOTIATE_CAPABILITY_DFS 0x00001000L
125 #define NTNEGOTIATE_CAPABILITY_NT_INFO_PASSTHRU 0x00002000L
126 #define NTNEGOTIATE_CAPABILITY_LARGE_READX 0x00004000L
127 #define NTNEGOTIATE_CAPABILITY_LARGE_WRITEX 0x00008000L
128 #define NTNEGOTIATE_CAPABILITY_UNIX 0x00800000L
129 #define NTNEGOTIATE_CAPABILITY_BULK_TRANSFER 0x20000000L
130 #define NTNEGOTIATE_CAPABILITY_COMPRESSED 0x40000000L
131 #define NTNEGOTIATE_CAPABILITY_EXTENDED_SECURITY 0x80000000L
133 /* a packet structure for receiving SMB messages; locked by smb_globalLock.
134 * Most of the work involved is in handling chained requests and responses.
136 * When handling input, inWctp points to the current request's wct field (and
137 * the other parameters and request data can be found from this field). The
138 * opcode, unfortunately, isn't available there, so is instead copied to the
139 * packet's inCom field. It is initially set to com, but each chained
140 * operation sets it, also.
141 * The function smb_AdvanceInput advances an input packet to the next request
142 * in the chain. The inCom field is set to 0xFF when there are no more
143 * requests. The inCount field is 0 if this is the first request, and
144 * otherwise counts which request it is.
146 * When handling output, we also have to chain all of the responses together.
147 * The function smb_GetResponsePacket will setup outWctp to point to the right
150 #define SMB_PACKETMAGIC 0x7436353 /* magic # for packets */
151 typedef struct smb_packet {
152 char data[SMB_PACKETSIZE];
153 struct smb_packet *nextp; /* in free list, or whatever */
155 cm_space_t *spacep; /* use this for stripping last component */
156 NCB *ncbp; /* use this for sending */
158 unsigned long resumeCode;
159 unsigned short inCount;
160 unsigned short fid; /* for calls bundled with openAndX */
163 unsigned char oddByte;
164 unsigned short ncb_length;
168 unsigned int dos_pkt_sel;
172 /* smb_packet flags */
173 #define SMB_PACKETFLAG_NOSEND 1
174 #define SMB_PACKETFLAG_SUSPENDED 2
176 /* a structure for making Netbios calls; locked by smb_globalLock */
177 #define SMB_NCBMAGIC 0x2334344
178 typedef struct myncb {
179 NCB ncb; /* ncb to use */
180 struct myncb *nextp; /* when on free list */
184 smb_packet_t *orig_pkt;
185 unsigned int dos_ncb_sel;
189 /* structures representing environments from kernel / SMB network.
190 * Most have their own locks, but the tree connection fields and
191 * reference counts are locked by the smb_rctLock. Those fields will
192 * be marked in comments.
195 /* one per virtual circuit */
196 typedef struct smb_vc {
197 struct smb_vc *nextp; /* not used */
198 afs_uint32 magic; /* a magic value to detect bad entries */
199 unsigned long refCount; /* the reference count */
200 long flags; /* the flags, if any; locked by mx */
201 osi_mutex_t mx; /* the mutex */
202 long vcID; /* VC id */
203 unsigned short lsn; /* the NCB LSN associated with this */
204 unsigned short uidCounter; /* session ID counter */
205 unsigned short tidCounter; /* tree ID counter */
206 unsigned short fidCounter; /* file handle ID counter */
207 struct smb_tid *tidsp; /* the first child in the tid list */
208 struct smb_user *usersp; /* the first child in the user session list */
209 struct smb_fid *fidsp; /* the first child in the open file list */
210 unsigned char errorCount;
213 char encKey[MSV1_0_CHALLENGE_LENGTH]; /* MSV1_0_CHALLENGE_LENGTH is 8 */
214 void * secCtx; /* security context when negotiating SMB extended auth
215 * valid when SMB_VCFLAG_AUTH_IN_PROGRESS is set
217 unsigned short session; /* This is the Session Index associated with the NCBs */
220 #define SMB_VC_MAGIC ('S' | 'C'<<8 | 'A'<<16 | 'C'<<24)
221 /* have we negotiated ... */
222 #define SMB_VCFLAG_USEV3 1 /* ... version 3 of the protocol */
223 #define SMB_VCFLAG_USECORE 2 /* ... the core protocol */
224 #define SMB_VCFLAG_USENT 4 /* ... NT LM 0.12 or beyond */
225 #define SMB_VCFLAG_STATUS32 8 /* use 32-bit NT status codes */
226 #define SMB_VCFLAG_REMOTECONN 0x10 /* bad: remote conns not allowed */
227 #define SMB_VCFLAG_ALREADYDEAD 0x20 /* do not get tokens from this vc */
228 #define SMB_VCFLAG_SESSX_RCVD 0x40 /* we received at least one session setups on this vc */
229 #define SMB_VCFLAG_AUTH_IN_PROGRESS 0x80 /* a SMB NT extended authentication is in progress */
230 #define SMB_VCFLAG_CLEAN_IN_PROGRESS 0x100
232 /* one per user session */
233 typedef struct smb_user {
234 struct smb_user *nextp; /* next sibling */
235 unsigned long refCount; /* ref count */
236 afs_uint32 flags; /* flags; locked by mx */
238 unsigned short userID; /* the session identifier */
239 struct smb_vc *vcp; /* back ptr to virtual circuit */
240 struct smb_username *unp; /* user name struct */
241 afs_uint32 delete; /* ok to del: locked by smb_rctLock */
244 #define SMB_USERFLAG_DELETE 1 /* delete struct when ref count zero */
246 typedef struct smb_username {
247 struct smb_username *nextp; /* next sibling */
248 unsigned long refCount; /* ref count */
249 long flags; /* flags; locked by mx */
251 struct cm_user *userp; /* CM user structure */
252 char *name; /* user name */
253 char *machine; /* machine name */
254 time_t last_logoff_t; /* most recent logoff time */
257 /* The SMB_USERNAMEFLAG_AFSLOGON is used to preserve the existence of an
258 * smb_username_t even when the refCount is zero. This is used to ensure
259 * that tokens set to a username during the integrated logon process are
260 * preserved until the SMB Session that will require the tokens is created.
261 * The cm_IoctlSetTokens() function when executed from the Network Provider
262 * connects to the AFS Client Service using the credentials of the machine
263 * and not the user for whom the tokens are being configured. */
264 #define SMB_USERNAMEFLAG_AFSLOGON 1
266 /* The SMB_USERNAMEFLAG_LOGOFF is used to indicate that the user most
267 * recently logged off at 'last_logoff_t'. The smb_username_t should not
268 * be deleted even if the refCount is zero before 'last_logoff_t' +
269 * 'smb_LogoffTransferTimeout' if 'smb_LogoffTokenTransfer' is non-zero.
270 * The smb_Daemon() thread is responsible for purging the expired objects */
272 #define SMB_USERNAMEFLAG_LOGOFF 2
274 #define SMB_MAX_USERNAME_LENGTH 256
276 /* one per tree-connect */
277 typedef struct smb_tid {
278 struct smb_tid *nextp; /* next sibling */
279 unsigned long refCount;
280 afs_uint32 flags; /* protected by mx */
281 osi_mutex_t mx; /* for non-tree-related stuff */
282 unsigned short tid; /* the tid */
283 struct smb_vc *vcp; /* back ptr */
284 struct cm_user *userp; /* user logged in at the
285 * tree connect level (base) */
286 char *pathname; /* pathname derived from sharename */
287 afs_uint32 delete; /* ok to del: locked by smb_rctLock */
290 #define SMB_TIDFLAG_IPC 1 /* IPC$ */
292 /* one per process ID */
293 typedef struct smb_pid {
294 struct smb_pid *nextp; /* next sibling */
295 unsigned long refCount;
297 osi_mutex_t mx; /* for non-tree-related stuff */
298 unsigned short pid; /* the pid */
299 struct smb_tid *tidp; /* back ptr */
302 /* ioctl parameter, while being assembled and/or processed */
303 typedef struct smb_ioctl {
305 char *inDatap; /* ioctl func's current position
306 * in input parameter block */
307 char *inAllocp; /* allocated input parameter block */
308 long inCopied; /* # of input bytes copied in so far
310 cm_space_t *prefix; /* prefix for subst drives */
311 char *tidPathp; /* Pathname associated with Tree ID */
314 char *outDatap; /* output results assembled so far */
315 char *outAllocp; /* output results assembled so far */
316 long outCopied; /* # of output bytes copied back so far
323 struct smb_fid *fidp;
329 /* flags for smb_ioctl_t */
330 #define SMB_IOCTLFLAG_DATAIN 1 /* reading data from client to server */
331 #define SMB_IOCTLFLAG_LOGON 2 /* got tokens from integrated logon */
333 /* one per file ID; these are really file descriptors */
334 typedef struct smb_fid {
336 unsigned long refCount;
337 afs_uint32 flags; /* protected by mx */
338 osi_mutex_t mx; /* for non-tree-related stuff */
339 unsigned short fid; /* the file ID */
340 struct smb_vc *vcp; /* back ptr */
341 struct cm_scache *scp; /* scache of open file */
342 struct cm_user *userp; /* user that opened the file
343 originally (used to close
344 the file if session is
346 osi_hyper_t offset; /* our file pointer */
347 smb_ioctl_t *ioctlp; /* ptr to ioctl structure */
348 /* Under NT, we may need to know the
349 * parent directory and pathname used
350 * to open the file, either to delete
351 * the file on close, or to do a
352 * change notification */
353 struct cm_scache *NTopen_dscp; /* parent directory (NT) */
354 char *NTopen_pathp; /* path used in open (NT) */
355 char *NTopen_wholepathp; /* entire path, not just last name */
356 int curr_chunk; /* chunk being read */
357 int prev_chunk; /* previous chunk read */
358 int raw_writers; /* pending async raw writes */
359 EVENT_HANDLE raw_write_event; /* signal this when raw_writers zero */
360 afs_uint32 delete; /* ok to del: locked by smb_rctLock */
363 #define SMB_FID_OPENREAD 1 /* open for reading */
364 #define SMB_FID_OPENWRITE 2 /* open for writing */
365 #define SMB_FID_CREATED 4 /* a new file */
366 #define SMB_FID_IOCTL 8 /* a file descriptor for the
367 * magic ioctl file */
368 #define SMB_FID_OPENDELETE 0x10 /* open for deletion (NT) */
369 #define SMB_FID_DELONCLOSE 0x20 /* marked for deletion */
372 * Now some special flags to work around a bug in NT Client
374 #define SMB_FID_LENGTHSETDONE 0x40 /* have done 0-length write */
375 #define SMB_FID_MTIMESETDONE 0x80 /* have set modtime via Tr2 */
376 #define SMB_FID_LOOKSLIKECOPY (SMB_FID_LENGTHSETDONE | SMB_FID_MTIMESETDONE)
377 #define SMB_FID_NTOPEN 0x100 /* have dscp and pathp */
379 #define SMB_FID_SHARE_READ 0x1000
380 #define SMB_FID_SHARE_WRITE 0x2000
382 #define SMB_FID_QLOCK_HIGH 0x7f000000
383 #define SMB_FID_QLOCK_LOW 0x00000000
384 #define SMB_FID_QLOCK_LENGTH 1
385 #define SMB_FID_QLOCK_PID 0
388 * SMB file attributes (32-bit)
390 #define SMB_ATTR_READONLY 0x0001
391 #define SMB_ATTR_HIDDEN 0x0002 /* hidden file for the purpose of dir listings */
392 #define SMB_ATTR_SYSTEM 0x0004
393 #define SMB_ATTR_VOLUMEID 0x0008 /* obsolete */
394 #define SMB_ATTR_DIRECTORY 0x0010
395 #define SMB_ATTR_ARCHIVE 0x0020
396 #define SMB_ATTR_DEVICE 0x0040
397 #define SMB_ATTR_NORMAL 0x0080 /* normal file. Only valid if used alone */
398 #define SMB_ATTR_TEMPORARY 0x0100
399 #define SMB_ATTR_SPARSE_FILE 0x0200 /* used with dfs links */
400 #define SMB_ATTR_REPARSE_POINT 0x0400
401 #define SMB_ATTR_COMPRESSED 0x0800 /* file or dir is compressed */
402 #define SMB_ATTR_OFFLINE 0x1000
403 #define SMB_ATTR_NOT_CONTENT_INDEXED 0x2000
404 #define SMB_ATTR_ENCRYPTED 0x4000
406 #define LOCKING_ANDX_SHARED_LOCK 0x01 /* Read-only lock */
407 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02 /* Oplock break notification */
408 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04 /* Change lock type */
409 #define LOCKING_ANDX_CANCEL_LOCK 0x08 /* Cancel outstanding request */
410 #define LOCKING_ANDX_LARGE_FILES 0x10 /* Large file locking format */
412 /* for tracking in-progress directory searches */
413 typedef struct smb_dirSearch {
414 osi_queue_t q; /* queue of all outstanding cookies */
415 osi_mutex_t mx; /* just in case the caller screws up */
416 unsigned long refCount; /* reference count */
417 long cookie; /* value returned to the caller */
418 struct cm_scache *scp; /* vnode of the dir we're searching */
419 time_t lastTime; /* last time we used this (osi_Time) */
420 long flags; /* flags (see below);
421 * locked by smb_globalLock */
422 unsigned short attribute; /* search attribute
423 * (used for extended protocol) */
424 char mask[256]; /* search mask for V3 */
427 #define SMB_DIRSEARCH_DELETE 1 /* delete struct when ref count zero */
428 #define SMB_DIRSEARCH_HITEOF 2 /* perhaps useful for advisory later */
429 #define SMB_DIRSEARCH_SMALLID 4 /* cookie can only be 8 bits, not 16 */
430 #define SMB_DIRSEARCH_BULKST 8 /* get bulk stat info */
432 /* type for patching directory listings */
433 typedef struct smb_dirListPatch {
435 char *dptr; /* ptr to attr, time, data, sizel, sizeh */
436 long flags; /* flags. See below */
438 cm_dirEntry_t *dep; /* temp */
439 } smb_dirListPatch_t;
441 /* dirListPatch Flags */
442 #define SMB_DIRLISTPATCH_DOTFILE 1
443 /* the file referenced is a dot file
444 * Note: will not be set if smb_hideDotFiles is false
447 /* individual lock on a waiting lock request */
448 typedef struct smb_waitingLock {
451 LARGE_INTEGER LOffset;
452 LARGE_INTEGER LLength;
453 cm_file_lock_t * lockp;
457 #define SMB_WAITINGLOCKSTATE_WAITING 0
458 #define SMB_WAITINGLOCKSTATE_DONE 1
459 #define SMB_WAITINGLOCKSTATE_ERROR 2
461 /* waiting lock request */
462 typedef struct smb_waitingLockRequest {
469 time_t timeRemaining;
470 smb_waitingLock_t * locks;
471 } smb_waitingLockRequest_t;
473 extern smb_waitingLockRequest_t *smb_allWaitingLocks;
475 typedef long (smb_proc_t)(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
477 typedef struct smb_dispatch {
478 smb_proc_t *procp; /* proc to call */
479 int flags; /* flags describing function */
482 #define SMB_DISPATCHFLAG_CHAINED 1 /* this is an _AND_X function */
483 #define SMB_DISPATCHFLAG_NORESPONSE 2 /* don't send the response
484 * packet, typically because
485 * the response was already
488 #define SMB_MAX_PATH 256 /* max path length */
492 extern void smb_Init(osi_log_t *logp, char *smbNamep, int useV3, int LANadapt,
499 extern void smb_LargeSearchTimeFromUnixTime(FILETIME *largeTimep, time_t unixTime);
501 extern void smb_UnixTimeFromLargeSearchTime(time_t *unixTimep, FILETIME *largeTimep);
503 extern void smb_SearchTimeFromUnixTime(afs_uint32 *searchTimep, time_t unixTime);
505 extern void smb_UnixTimeFromSearchTime(time_t *unixTimep, afs_uint32 searchTime);
507 extern void smb_DosUTimeFromUnixTime(afs_uint32 *dosUTimep, time_t unixTime);
509 extern void smb_UnixTimeFromDosUTime(time_t *unixTimep, afs_uint32 dosUTime);
511 extern void CompensateForSmbClientLastWriteTimeBugs(afs_uint32 *dosTimep);
513 extern smb_vc_t *smb_FindVC(unsigned short lsn, int flags, int lana);
515 extern void smb_CleanupDeadVC(smb_vc_t *vcp);
517 extern void smb_ReleaseVC(smb_vc_t *vcp);
519 extern void smb_ReleaseVCNoLock(smb_vc_t *vcp);
521 extern smb_tid_t *smb_FindTID(smb_vc_t *vcp, unsigned short tid, int flags);
523 extern void smb_HoldTIDNoLock(smb_tid_t *tidp);
525 extern void smb_ReleaseTID(smb_tid_t *tidp);
527 extern smb_user_t *smb_FindUID(smb_vc_t *vcp, unsigned short uid, int flags);
529 extern smb_username_t *smb_FindUserByName(char *usern, char *machine, afs_uint32 flags);
531 extern smb_user_t *smb_FindUserByNameThisSession(smb_vc_t *vcp, char *usern);
533 extern void smb_ReleaseUsername(smb_username_t *unp);
535 extern void smb_HoldUIDNoLock(smb_user_t *uidp);
537 extern void smb_ReleaseUID(smb_user_t *uidp);
539 extern cm_user_t *smb_GetUserFromVCP(smb_vc_t *vcp, smb_packet_t *inp);
541 extern cm_user_t *smb_GetUserFromUID(smb_user_t *uidp);
543 extern long smb_LookupTIDPath(smb_vc_t *vcp, unsigned short tid, char ** tidPathp);
545 extern smb_fid_t *smb_FindFID(smb_vc_t *vcp, unsigned short fid, int flags);
547 extern void smb_HoldFIDNoLock(smb_fid_t *fidp);
549 extern void smb_ReleaseFID(smb_fid_t *fidp);
551 extern long smb_CloseFID(smb_vc_t *vcp, smb_fid_t *fidp, cm_user_t *userp,
554 extern int smb_FindShare(smb_vc_t *vcp, smb_user_t *uidp, char *shareName, char **pathNamep);
556 extern int smb_FindShareCSCPolicy(char *shareName);
558 extern smb_dirSearch_t *smb_FindDirSearchNL(long cookie);
560 extern void smb_DeleteDirSearch(smb_dirSearch_t *dsp);
562 extern void smb_ReleaseDirSearch(smb_dirSearch_t *dsp);
564 extern smb_dirSearch_t *smb_FindDirSearch(long cookie);
566 extern smb_dirSearch_t *smb_NewDirSearch(int isV3);
568 extern smb_packet_t *smb_CopyPacket(smb_packet_t *packetp);
570 extern void smb_FreePacket(smb_packet_t *packetp);
572 extern unsigned char *smb_GetSMBData(smb_packet_t *smbp, int *nbytesp);
574 extern void smb_SetSMBDataLength(smb_packet_t *smbp, unsigned int dsize);
576 extern unsigned int smb_GetSMBParm(smb_packet_t *smbp, int parm);
578 extern unsigned int smb_GetSMBOffsetParm(smb_packet_t *smbp, int parm, int offset);
580 extern void smb_SetSMBParm(smb_packet_t *smbp, int slot, unsigned int parmValue);
582 extern void smb_SetSMBParmLong(smb_packet_t *smbp, int slot, unsigned int parmValue);
584 extern void smb_SetSMBParmDouble(smb_packet_t *smbp, int slot, char *parmValuep);
586 extern void smb_SetSMBParmByte(smb_packet_t *smbp, int slot, unsigned int parmValue);
588 extern void smb_StripLastComponent(char *outPathp, char **lastComponentp,
591 extern unsigned char *smb_ParseASCIIBlock(unsigned char *inp, char **chainpp);
593 extern unsigned char *smb_ParseVblBlock(unsigned char *inp, char **chainpp,
596 extern smb_packet_t *smb_GetResponsePacket(smb_vc_t *vcp, smb_packet_t *inp);
598 extern void smb_SendPacket(smb_vc_t *vcp, smb_packet_t *inp);
600 extern void smb_MapCoreError(long code, smb_vc_t *vcp, unsigned short *scodep,
601 unsigned char *classp);
603 extern void smb_MapNTError(long code, unsigned long *NTStatusp);
605 extern void smb_HoldVC(smb_vc_t *vcp);
607 extern void smb_HoldVCNoLock(smb_vc_t *vcp);
609 /* some globals, too */
610 extern char *smb_localNamep;
612 extern osi_log_t *smb_logp;
614 extern osi_rwlock_t smb_globalLock;
616 extern osi_rwlock_t smb_rctLock;
618 extern int smb_LogoffTokenTransfer;
619 extern time_t smb_LogoffTransferTimeout;
621 extern int smb_maxVCPerServer; /* max # of VCs per server */
622 extern int smb_maxMpxRequests; /* max # of mpx requests */
624 extern int smb_StoreAnsiFilenames;
625 extern int smb_hideDotFiles;
626 extern unsigned int smb_IsDotFile(char *lastComp);
628 /* the following are used for smb auth */
629 extern int smb_authType; /* Type of SMB authentication to be used. One from below. */
631 #define SMB_AUTH_NONE 0
632 #define SMB_AUTH_NTLM 1
633 #define SMB_AUTH_EXTENDED 2
635 extern HANDLE smb_lsaHandle; /* LSA handle obtained during smb_init if using SMB auth */
636 extern ULONG smb_lsaSecPackage; /* LSA security package id. Set during smb_init */
637 extern char smb_ServerDomainName[];
638 extern int smb_ServerDomainNameLength;
639 extern char smb_ServerOS[];
640 extern int smb_ServerOSLength;
641 extern char smb_ServerLanManager[];
642 extern int smb_ServerLanManagerLength;
643 extern GUID smb_ServerGUID;
644 extern LSA_STRING smb_lsaLogonOrigin;
646 /* used for getting a challenge for SMB auth */
647 typedef struct _MSV1_0_LM20_CHALLENGE_REQUEST {
648 MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
649 } MSV1_0_LM20_CHALLENGE_REQUEST, *PMSV1_0_LM20_CHALLENGE_REQUEST;
651 typedef struct _MSV1_0_LM20_CHALLENGE_RESPONSE {
652 MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
653 UCHAR ChallengeToClient[MSV1_0_CHALLENGE_LENGTH];
654 } MSV1_0_LM20_CHALLENGE_RESPONSE, *PMSV1_0_LM20_CHALLENGE_RESPONSE;
657 extern long smb_AuthenticateUserLM(smb_vc_t *vcp, char * accountName, char * primaryDomain, char * ciPwd, unsigned ciPwdLength, char * csPwd, unsigned csPwdLength);
659 extern long smb_GetNormalizedUsername(char * usern, const char * accountName, const char * domainName);
661 extern void smb_FormatResponsePacket(smb_vc_t *vcp, smb_packet_t *inp,
664 extern char *myCrt_Dispatch(int i);
666 extern char *myCrt_2Dispatch(int i);
668 extern char *myCrt_RapDispatch(int i);
670 extern unsigned int smb_Attributes(cm_scache_t *scp);
672 extern int smb_ChainFID(int fid, smb_packet_t *inp);
674 extern smb_fid_t *smb_FindFID(smb_vc_t *vcp, unsigned short fid, int flags);
676 extern void smb_ReleaseFID(smb_fid_t *fidp);
678 extern unsigned char *smb_ParseDataBlock(unsigned char *inp, char **chainpp, int *lengthp);
680 extern unsigned char *smb_ParseASCIIBlock(unsigned char *inp, char **chainpp);
682 extern unsigned char *smb_ParseVblBlock(unsigned char *inp, char **chainpp, int *lengthp);
684 extern int smb_SUser(cm_user_t *userp);
687 extern long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count,
688 char *op, cm_user_t *userp, long *readp);
690 extern long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count,
691 char *op, cm_user_t *userp, long *readp, int dosflag);
694 extern long smb_Rename(smb_vc_t *vcp, smb_packet_t *inp, char *oldPathp, char *newPathp, int attrs);
696 extern long smb_Link(smb_vc_t *vcp, smb_packet_t *inp, char *oldPathp, char *newPathp);
698 extern BOOL smb_IsLegalFilename(char *filename);
700 extern char *smb_GetSharename(void);
702 extern DWORD smb_ServerExceptionFilter(void);
704 extern void smb_UpdateServerPriority(void);
705 extern void smb_SetRequestStartTime(void);
706 extern void smb_ResetServerPriority(void);
708 /* include other include files */
710 #include "smb_ioctl.h"
711 #include "smb_iocons.h"
713 cm_user_t *smb_FindOrCreateUser(smb_vc_t *vcp, char *usern);
716 extern void smb_LogPacket(smb_packet_t *packet);
717 #endif /* NOTSERVICE */
719 #ifndef MSV1_0_OPTION_ALLOW_BLANK_PASSWORD
720 #define MSV1_0_OPTION_ALLOW_BLANK_PASSWORD 0x1
721 #define MSV1_0_OPTION_DISABLE_ADMIN_LOCKOUT 0x2
722 #define MSV1_0_OPTION_DISABLE_FORCE_GUEST 0x4
723 #define MSV1_0_OPTION_TRY_CACHE_FIRST 0x10
725 typedef struct _MSV1_0_SETPROCESSOPTION_REQUEST {
726 MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
727 ULONG ProcessOptions;
728 BOOLEAN DisableOptions;
729 } MSV1_0_SETPROCESSOPTION_REQUEST, *PMSV1_0_SETPROCESSOPTION_REQUEST;
732 #endif /* whole file */