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 /* basic core protocol SMB structure */
26 unsigned char errHigh;
29 unsigned short res[6];
35 unsigned char vdata[1];
40 #define SMB_FLAGS_SUPPORT_LOCKREAD 0x01
41 #define SMB_FLAGS_CLIENT_BUF_AVAIL 0x02
42 #define SMB_FLAGS_CASELESS_PATHNAMES 0x08
43 #define SMB_FLAGS_CANONICAL_PATHNAMES 0x10
44 #define SMB_FLAGS_REQUEST_OPLOCK 0x20
45 #define SMB_FLAGS_REQUEST_BATCH_OPLOCK 0x40
46 #define SMB_FLAGS_SERVER_TO_CLIENT 0x80
50 #define SMB_FLAGS2_KNOWS_LONG_NAMES 0x0001
51 #define SMB_FLAGS2_KNOWS_EAS 0x0002
52 #define SMB_FLAGS2_SECURITY_SIGNATURE 0x0004
53 #define SMB_FLAGS2_RESERVED1 0x0008
54 #define SMB_FLAGS2_IS_LONG_NAME 0x0040
55 #define SMB_FLAGS2_EXT_SEC 0x0800
56 #define SMB_FLAGS2_DFS_PATHNAMES 0x1000
57 #define SMB_FLAGS2_PAGING_IO 0x2000
58 #define SMB_FLAGS2_32BIT_STATUS 0x4000
59 #define SMB_FLAGS2_UNICODE 0x8000
61 #define KNOWS_LONG_NAMES(inp) ((((smb_t *)inp)->flg2 & SMB_FLAGS2_KNOWS_LONG_NAMES)?1:0)
62 #define WANTS_DFS_PATHNAMES(inp) ((((smb_t *)inp)->flg2 & SMB_FLAGS2_DFS_PATHNAMES)?1:0)
64 /* Information Levels */
65 #define SMB_INFO_STANDARD 1
66 #define SMB_INFO_QUERY_EA_SIZE 2
67 #define SMB_INFO_QUERY_EAS_FROM_LIST 3
68 #define SMB_INFO_QUERY_ALL_EAS 4
69 #define SMB_INFO_IS_NAME_VALID 6
71 #define SMB_QUERY_FILE_BASIC_INFO 0x101
72 #define SMB_QUERY_FILE_STANDARD_INFO 0x102
73 #define SMB_QUERY_FILE_EA_INFO 0x103
74 #define SMB_QUERY_FILE_NAME_INFO 0x104
75 #define SMB_QUERY_FILE_ALL_INFO 0x107
76 #define SMB_QUERY_FILE_ALT_NAME_INFO 0x108
77 #define SMB_QUERY_FILE_STREAM_INFO 0x109
78 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
79 #define SMB_QUERY_FILE_UNIX_BASIC 0x200
80 #define SMB_QUERY_FILE_UNIX_LINK 0x201
82 #define SMB_SET_FILE_UNIX_BASIC 0x200
83 #define SMB_SET_FILE_UNIX_LINK 0x201
84 #define SMB_SET_FILE_UNIX_HLINK 0x203
87 #define SMB_NOPCODES 256 /* # of opcodes in the dispatch table */
90 #define SMB_THREADSPERVC 4 /* threads per VC */
92 /* flags for functions */
93 #define SMB_FLAG_CREATE 1 /* create the structure if necessary */
95 /* max # of bytes we'll receive in an incoming SMB message */
96 /* the maximum is 2^18-1 for NBT and 2^25-1 for Raw transport messages */
97 /* we will use something smaller but large enough to be efficient */
98 #define SMB_PACKETSIZE 32768 /* was 8400 */
99 /* raw mode is considered obsolete and cannot be used with message signing */
100 #define SMB_MAXRAWSIZE 65536
102 /* Negotiate protocol constants */
104 #define NEGOTIATE_SECURITY_USER_LEVEL 0x01
105 #define NEGOTIATE_SECURITY_CHALLENGE_RESPONSE 0x02
106 #define NEGOTIATE_SECURITY_SIGNATURES_ENABLED 0x04
107 #define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
110 #define NTNEGOTIATE_CAPABILITY_RAWMODE 0x00000001L
111 #define NTNEGOTIATE_CAPABILITY_MPXMODE 0x00000002L
112 #define NTNEGOTIATE_CAPABILITY_UNICODE 0x00000004L
113 #define NTNEGOTIATE_CAPABILITY_LARGEFILES 0x00000008L
114 #define NTNEGOTIATE_CAPABILITY_NTSMB 0x00000010L
115 #define NTNEGOTIATE_CAPABILITY_RPCAPI 0x00000020L
116 #define NTNEGOTIATE_CAPABILITY_NTSTATUS 0x00000040L
117 #define NTNEGOTIATE_CAPABILITY_LEVEL_II_OPLOCKS 0x00000080L
118 #define NTNEGOTIATE_CAPABILITY_LOCK_AND_READ 0x00000100L
119 #define NTNEGOTIATE_CAPABILITY_NTFIND 0x00000200L
120 #define NTNEGOTIATE_CAPABILITY_DFS 0x00001000L
121 #define NTNEGOTIATE_CAPABILITY_NT_INFO_PASSTHRU 0x00002000L
122 #define NTNEGOTIATE_CAPABILITY_LARGE_READX 0x00004000L
123 #define NTNEGOTIATE_CAPABILITY_LARGE_WRITEX 0x00008000L
124 #define NTNEGOTIATE_CAPABILITY_UNIX 0x00800000L
125 #define NTNEGOTIATE_CAPABILITY_BULK_TRANSFER 0x20000000L
126 #define NTNEGOTIATE_CAPABILITY_COMPRESSED 0x40000000L
127 #define NTNEGOTIATE_CAPABILITY_EXTENDED_SECURITY 0x80000000L
129 /* a packet structure for receiving SMB messages; locked by smb_globalLock.
130 * Most of the work involved is in handling chained requests and responses.
132 * When handling input, inWctp points to the current request's wct field (and
133 * the other parameters and request data can be found from this field). The
134 * opcode, unfortunately, isn't available there, so is instead copied to the
135 * packet's inCom field. It is initially set to com, but each chained
136 * operation sets it, also.
137 * The function smb_AdvanceInput advances an input packet to the next request
138 * in the chain. The inCom field is set to 0xFF when there are no more
139 * requests. The inCount field is 0 if this is the first request, and
140 * otherwise counts which request it is.
142 * When handling output, we also have to chain all of the responses together.
143 * The function smb_GetResponsePacket will setup outWctp to point to the right
146 #define SMB_PACKETMAGIC 0x7436353 /* magic # for packets */
147 typedef struct smb_packet {
148 char data[SMB_PACKETSIZE];
149 struct smb_packet *nextp; /* in free list, or whatever */
151 cm_space_t *spacep; /* use this for stripping last component */
152 NCB *ncbp; /* use this for sending */
154 unsigned long resumeCode;
155 unsigned short inCount;
156 unsigned short fid; /* for calls bundled with openAndX */
159 unsigned char oddByte;
160 unsigned short ncb_length;
164 unsigned int dos_pkt_sel;
168 /* smb_packet flags */
169 #define SMB_PACKETFLAG_PROFILE_UPDATE_OK 1
170 #define SMB_PACKETFLAG_NOSEND 2
171 #define SMB_PACKETFLAG_SUSPENDED 4
173 /* a structure for making Netbios calls; locked by smb_globalLock */
174 #define SMB_NCBMAGIC 0x2334344
175 typedef struct myncb {
176 NCB ncb; /* ncb to use */
177 struct myncb *nextp; /* when on free list */
181 smb_packet_t *orig_pkt;
182 unsigned int dos_ncb_sel;
186 /* structures representing environments from kernel / SMB network.
187 * Most have their own locks, but the tree connection fields and
188 * reference counts are locked by the smb_rctLock. Those fields will
189 * be marked in comments.
192 /* one per virtual circuit */
193 typedef struct smb_vc {
194 struct smb_vc *nextp; /* not used */
195 unsigned long refCount; /* the reference count */
196 long flags; /* the flags, if any; locked by mx */
197 osi_mutex_t mx; /* the mutex */
198 long vcID; /* VC id */
199 unsigned short lsn; /* the NCB LSN associated with this */
200 unsigned short uidCounter; /* session ID counter */
201 unsigned short tidCounter; /* tree ID counter */
202 unsigned short fidCounter; /* file handle ID counter */
203 struct smb_tid *tidsp; /* the first child in the tid list */
204 struct smb_user *usersp; /* the first child in the user session list */
205 struct smb_fid *fidsp; /* the first child in the open file list */
206 struct smb_user *justLoggedOut; /* ready for profile upload? */
207 time_t logoffTime; /* tick count when logged off */
208 unsigned char errorCount;
211 char encKey[MSV1_0_CHALLENGE_LENGTH]; /* MSV1_0_CHALLENGE_LENGTH is 8 */
212 void * secCtx; /* security context when negotiating SMB extended auth
213 * valid when SMB_VCFLAG_AUTH_IN_PROGRESS is set
217 /* have we negotiated ... */
218 #define SMB_VCFLAG_USEV3 1 /* ... version 3 of the protocol */
219 #define SMB_VCFLAG_USECORE 2 /* ... the core protocol */
220 #define SMB_VCFLAG_USENT 4 /* ... NT LM 0.12 or beyond */
221 #define SMB_VCFLAG_STATUS32 8 /* use 32-bit NT status codes */
222 #define SMB_VCFLAG_REMOTECONN 0x10 /* bad: remote conns not allowed */
223 #define SMB_VCFLAG_ALREADYDEAD 0x20 /* do not get tokens from this vc */
224 #define SMB_VCFLAG_SESSX_RCVD 0x40 /* we received at least one session setups on this vc */
225 #define SMB_VCFLAG_AUTH_IN_PROGRESS 0x80 /* a SMB NT extended authentication is in progress */
227 /* one per user session */
228 typedef struct smb_user {
229 struct smb_user *nextp; /* next sibling */
230 unsigned long refCount; /* ref count */
231 long flags; /* flags; locked by mx */
233 long userID; /* the session identifier */
234 struct smb_vc *vcp; /* back ptr to virtual circuit */
235 struct smb_username *unp; /* user name struct */
238 typedef struct smb_username {
239 struct smb_username *nextp; /* next sibling */
240 unsigned long refCount; /* ref count */
241 long flags; /* flags; locked by mx */
243 struct cm_user *userp; /* CM user structure */
244 char *name; /* user name */
245 char *machine; /* machine name */
248 #define SMB_USERFLAG_DELETE 1 /* delete struct when ref count zero */
250 #define SMB_MAX_USERNAME_LENGTH 256
252 /* one per tree-connect */
253 typedef struct smb_tid {
254 struct smb_tid *nextp; /* next sibling */
255 unsigned long refCount;
257 osi_mutex_t mx; /* for non-tree-related stuff */
258 unsigned short tid; /* the tid */
259 struct smb_vc *vcp; /* back ptr */
260 struct cm_user *userp; /* user logged in at the
261 * tree connect level (base) */
262 char *pathname; /* pathname derived from sharename */
265 #define SMB_TIDFLAG_DELETE 1 /* delete struct when ref count zero */
266 #define SMB_TIDFLAG_IPC 2 /* IPC$ */
268 /* one per process ID */
269 typedef struct smb_pid {
270 struct smb_pid *nextp; /* next sibling */
271 unsigned long refCount;
273 osi_mutex_t mx; /* for non-tree-related stuff */
274 unsigned short pid; /* the pid */
275 struct smb_tid *tidp; /* back ptr */
278 /* ioctl parameter, while being assembled and/or processed */
279 typedef struct smb_ioctl {
281 char *inDatap; /* ioctl func's current position
282 * in input parameter block */
283 char *inAllocp; /* allocated input parameter block */
284 long inCopied; /* # of input bytes copied in so far
286 cm_space_t *prefix; /* prefix for subst drives */
287 char *tidPathp; /* Pathname associated with Tree ID */
290 char *outDatap; /* output results assembled so far */
291 char *outAllocp; /* output results assembled so far */
292 long outCopied; /* # of output bytes copied back so far
299 struct smb_fid *fidp;
305 /* flags for smb_ioctl_t */
306 #define SMB_IOCTLFLAG_DATAIN 1 /* reading data from client to server */
307 #define SMB_IOCTLFLAG_LOGON 2 /* got tokens from integrated logon */
309 /* one per file ID; these are really file descriptors */
310 typedef struct smb_fid {
312 unsigned long refCount;
314 osi_mutex_t mx; /* for non-tree-related stuff */
315 unsigned short fid; /* the file ID */
316 struct smb_vc *vcp; /* back ptr */
317 struct cm_scache *scp; /* scache of open file */
318 long offset; /* our file pointer */
319 smb_ioctl_t *ioctlp; /* ptr to ioctl structure */
320 /* Under NT, we may need to know the
321 * parent directory and pathname used
322 * to open the file, either to delete
323 * the file on close, or to do a
324 * change notification */
325 struct cm_scache *NTopen_dscp; /* parent directory (NT) */
326 char *NTopen_pathp; /* path used in open (NT) */
327 char *NTopen_wholepathp; /* entire path, not just last name */
328 int curr_chunk; /* chunk being read */
329 int prev_chunk; /* previous chunk read */
330 int raw_writers; /* pending async raw writes */
331 EVENT_HANDLE raw_write_event; /* signal this when raw_writers zero */
334 #define SMB_FID_OPENREAD 1 /* open for reading */
335 #define SMB_FID_OPENWRITE 2 /* open for writing */
336 #define SMB_FID_DELETE 4 /* delete struct on ref count 0 */
337 #define SMB_FID_IOCTL 8 /* a file descriptor for the
338 * magic ioctl file */
339 #define SMB_FID_OPENDELETE 0x10 /* open for deletion (NT) */
340 #define SMB_FID_DELONCLOSE 0x20 /* marked for deletion */
342 * Now some special flags to work around a bug in NT Client
344 #define SMB_FID_LENGTHSETDONE 0x40 /* have done 0-length write */
345 #define SMB_FID_MTIMESETDONE 0x80 /* have set modtime via Tr2 */
346 #define SMB_FID_LOOKSLIKECOPY (SMB_FID_LENGTHSETDONE | SMB_FID_MTIMESETDONE)
347 #define SMB_FID_NTOPEN 0x100 /* have dscp and pathp */
349 #define SMB_FID_SHARE_READ 0x1000
350 #define SMB_FID_SHARE_WRITE 0x2000
352 #define SMB_FID_QLOCK_HIGH 0x0fe00000
353 #define SMB_FID_QLOCK_LOW 0x00000000
354 #define SMB_FID_QLOCK_LENGTH 1
355 #define SMB_FID_QLOCK_PID 0
358 * SMB file attributes (32-bit)
360 #define SMB_ATTR_READONLY 0x0001
361 #define SMB_ATTR_HIDDEN 0x0002 /* hidden file for the purpose of dir listings */
362 #define SMB_ATTR_SYSTEM 0x0004
363 #define SMB_ATTR_VOLUMEID 0x0008 /* obsolete */
364 #define SMB_ATTR_DIRECTORY 0x0010
365 #define SMB_ATTR_ARCHIVE 0x0020
366 #define SMB_ATTR_DEVICE 0x0040
367 #define SMB_ATTR_NORMAL 0x0080 /* normal file. Only valid if used alone */
368 #define SMB_ATTR_TEMPORARY 0x0100
369 #define SMB_ATTR_SPARSE_FILE 0x0200 /* used with dfs links */
370 #define SMB_ATTR_REPARSE_POINT 0x0400
371 #define SMB_ATTR_COMPRESSED 0x0800 /* file or dir is compressed */
372 #define SMB_ATTR_OFFLINE 0x1000
373 #define SMB_ATTR_NOT_CONTENT_INDEXED 0x2000
374 #define SMB_ATTR_ENCRYPTED 0x4000
376 #define LOCKING_ANDX_SHARED_LOCK 0x01 /* Read-only lock */
377 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02 /* Oplock break notification */
378 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04 /* Change lock type */
379 #define LOCKING_ANDX_CANCEL_LOCK 0x08 /* Cancel outstanding request */
380 #define LOCKING_ANDX_LARGE_FILES 0x10 /* Large file locking format */
382 /* for tracking in-progress directory searches */
383 typedef struct smb_dirSearch {
384 osi_queue_t q; /* queue of all outstanding cookies */
385 osi_mutex_t mx; /* just in case the caller screws up */
386 unsigned long refCount; /* reference count */
387 long cookie; /* value returned to the caller */
388 struct cm_scache *scp; /* vnode of the dir we're searching */
389 time_t lastTime; /* last time we used this (osi_Time) */
390 long flags; /* flags (see below);
391 * locked by smb_globalLock */
392 unsigned short attribute; /* search attribute
393 * (used for extended protocol) */
394 char mask[256]; /* search mask for V3 */
397 #define SMB_DIRSEARCH_DELETE 1 /* delete struct when ref count zero */
398 #define SMB_DIRSEARCH_HITEOF 2 /* perhaps useful for advisory later */
399 #define SMB_DIRSEARCH_SMALLID 4 /* cookie can only be 8 bits, not 16 */
400 #define SMB_DIRSEARCH_BULKST 8 /* get bulk stat info */
402 /* type for patching directory listings */
403 typedef struct smb_dirListPatch {
405 char *dptr; /* ptr to attr, time, data, sizel, sizeh */
406 long flags; /* flags. See below */
408 cm_dirEntry_t *dep; /* temp */
409 } smb_dirListPatch_t;
411 /* dirListPatch Flags */
412 #define SMB_DIRLISTPATCH_DOTFILE 1
413 /* the file referenced is a dot file
414 * Note: will not be set if smb_hideDotFiles is false
417 /* individual lock on a waiting lock request */
418 typedef struct smb_waitingLock {
421 LARGE_INTEGER LOffset;
422 LARGE_INTEGER LLength;
423 cm_file_lock_t * lockp;
427 #define SMB_WAITINGLOCKSTATE_WAITING 0
428 #define SMB_WAITINGLOCKSTATE_DONE 1
429 #define SMB_WAITINGLOCKSTATE_ERROR 2
431 /* waiting lock request */
432 typedef struct smb_waitingLockRequest {
439 time_t timeRemaining;
440 smb_waitingLock_t * locks;
441 } smb_waitingLockRequest_t;
443 extern smb_waitingLockRequest_t *smb_allWaitingLocks;
445 typedef long (smb_proc_t)(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
447 typedef struct smb_dispatch {
448 smb_proc_t *procp; /* proc to call */
449 int flags; /* flags describing function */
452 #define SMB_DISPATCHFLAG_CHAINED 1 /* this is an _AND_X function */
453 #define SMB_DISPATCHFLAG_NORESPONSE 2 /* don't send the response
454 * packet, typically because
455 * the response was already
458 #define SMB_MAX_PATH 256 /* max path length */
462 extern void smb_Init(osi_log_t *logp, char *smbNamep, int useV3, int LANadapt,
469 extern void smb_LargeSearchTimeFromUnixTime(FILETIME *largeTimep, time_t unixTime);
471 extern void smb_UnixTimeFromLargeSearchTime(time_t *unixTimep, FILETIME *largeTimep);
473 extern void smb_SearchTimeFromUnixTime(afs_uint32 *searchTimep, time_t unixTime);
475 extern void smb_UnixTimeFromSearchTime(time_t *unixTimep, afs_uint32 searchTime);
477 extern void smb_DosUTimeFromUnixTime(afs_uint32 *dosUTimep, time_t unixTime);
479 extern void smb_UnixTimeFromDosUTime(time_t *unixTimep, afs_uint32 dosUTime);
481 extern void CompensateForSmbClientLastWriteTimeBugs(afs_uint32 *dosTimep);
483 extern smb_vc_t *smb_FindVC(unsigned short lsn, int flags, int lana);
485 extern void smb_ReleaseVC(smb_vc_t *vcp);
487 extern void smb_ReleaseVCNoLock(smb_vc_t *vcp);
489 extern smb_tid_t *smb_FindTID(smb_vc_t *vcp, unsigned short tid, int flags);
491 extern void smb_ReleaseTID(smb_tid_t *tidp);
493 extern smb_user_t *smb_FindUID(smb_vc_t *vcp, unsigned short uid, int flags);
495 extern smb_username_t *smb_FindUserByName(char *usern, char *machine, int flags);
497 extern smb_user_t *smb_FindUserByNameThisSession(smb_vc_t *vcp, char *usern);
499 extern smb_username_t *smb_FindUserByName(char *usern, char *machine, int flags);
501 extern smb_user_t *smb_FindUserByNameThisSession(smb_vc_t *vcp, char *usern);
503 extern void smb_ReleaseUID(smb_user_t *uidp);
505 extern cm_user_t *smb_GetUser(smb_vc_t *vcp, smb_packet_t *inp);
507 extern long smb_LookupTIDPath(smb_vc_t *vcp, unsigned short tid, char ** tidPathp);
509 extern smb_fid_t *smb_FindFID(smb_vc_t *vcp, unsigned short fid, int flags);
511 extern void smb_ReleaseFID(smb_fid_t *fidp);
513 extern int smb_FindShare(smb_vc_t *vcp, smb_user_t *uidp, char *shareName, char **pathNamep);
515 extern int smb_FindShareCSCPolicy(char *shareName);
517 extern smb_dirSearch_t *smb_FindDirSearchNL(long cookie);
519 extern void smb_DeleteDirSearch(smb_dirSearch_t *dsp);
521 extern void smb_ReleaseDirSearch(smb_dirSearch_t *dsp);
523 extern smb_dirSearch_t *smb_FindDirSearch(long cookie);
525 extern smb_dirSearch_t *smb_NewDirSearch(int isV3);
527 extern smb_packet_t *smb_CopyPacket(smb_packet_t *packetp);
529 extern void smb_FreePacket(smb_packet_t *packetp);
531 extern unsigned char *smb_GetSMBData(smb_packet_t *smbp, int *nbytesp);
533 extern void smb_SetSMBDataLength(smb_packet_t *smbp, unsigned int dsize);
535 extern unsigned int smb_GetSMBParm(smb_packet_t *smbp, int parm);
537 extern unsigned int smb_GetSMBOffsetParm(smb_packet_t *smbp, int parm, int offset);
539 extern void smb_SetSMBParm(smb_packet_t *smbp, int slot, unsigned int parmValue);
541 extern void smb_SetSMBParmLong(smb_packet_t *smbp, int slot, unsigned int parmValue);
543 extern void smb_SetSMBParmDouble(smb_packet_t *smbp, int slot, char *parmValuep);
545 extern void smb_SetSMBParmByte(smb_packet_t *smbp, int slot, unsigned int parmValue);
547 extern void smb_StripLastComponent(char *outPathp, char **lastComponentp,
550 extern unsigned char *smb_ParseASCIIBlock(unsigned char *inp, char **chainpp);
552 extern unsigned char *smb_ParseVblBlock(unsigned char *inp, char **chainpp,
555 extern smb_packet_t *smb_GetResponsePacket(smb_vc_t *vcp, smb_packet_t *inp);
557 extern void smb_SendPacket(smb_vc_t *vcp, smb_packet_t *inp);
559 extern void smb_MapCoreError(long code, smb_vc_t *vcp, unsigned short *scodep,
560 unsigned char *classp);
562 extern void smb_MapNTError(long code, unsigned long *NTStatusp);
564 extern void smb_HoldVC(smb_vc_t *vcp);
566 extern void smb_HoldVCNoLock(smb_vc_t *vcp);
568 /* some globals, too */
569 extern char *smb_localNamep;
570 extern int loggedOut;
571 extern time_t loggedOutTime;
572 extern char *loggedOutName;
573 extern smb_user_t *loggedOutUserp;
575 extern osi_log_t *smb_logp;
577 extern osi_rwlock_t smb_globalLock;
579 extern osi_rwlock_t smb_rctLock;
581 extern int smb_LogoffTokenTransfer;
582 extern time_t smb_LogoffTransferTimeout;
584 extern int smb_maxVCPerServer; /* max # of VCs per server */
585 extern int smb_maxMpxRequests; /* max # of mpx requests */
587 extern int smb_StoreAnsiFilenames;
588 extern int smb_hideDotFiles;
589 extern unsigned int smb_IsDotFile(char *lastComp);
591 /* the following are used for smb auth */
592 extern int smb_authType; /* Type of SMB authentication to be used. One from below. */
594 #define SMB_AUTH_NONE 0
595 #define SMB_AUTH_NTLM 1
596 #define SMB_AUTH_EXTENDED 2
598 extern HANDLE smb_lsaHandle; /* LSA handle obtained during smb_init if using SMB auth */
599 extern ULONG smb_lsaSecPackage; /* LSA security package id. Set during smb_init */
600 extern char smb_ServerDomainName[];
601 extern int smb_ServerDomainNameLength;
602 extern char smb_ServerOS[];
603 extern int smb_ServerOSLength;
604 extern char smb_ServerLanManager[];
605 extern int smb_ServerLanManagerLength;
606 extern GUID smb_ServerGUID;
607 extern LSA_STRING smb_lsaLogonOrigin;
609 /* used for getting a challenge for SMB auth */
610 typedef struct _MSV1_0_LM20_CHALLENGE_REQUEST {
611 MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
612 } MSV1_0_LM20_CHALLENGE_REQUEST, *PMSV1_0_LM20_CHALLENGE_REQUEST;
614 typedef struct _MSV1_0_LM20_CHALLENGE_RESPONSE {
615 MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
616 UCHAR ChallengeToClient[MSV1_0_CHALLENGE_LENGTH];
617 } MSV1_0_LM20_CHALLENGE_RESPONSE, *PMSV1_0_LM20_CHALLENGE_RESPONSE;
620 extern long smb_AuthenticateUserLM(smb_vc_t *vcp, char * accountName, char * primaryDomain, char * ciPwd, unsigned ciPwdLength, char * csPwd, unsigned csPwdLength);
622 extern long smb_GetNormalizedUsername(char * usern, const char * accountName, const char * domainName);
624 extern void smb_FormatResponsePacket(smb_vc_t *vcp, smb_packet_t *inp,
627 extern char *myCrt_Dispatch(int i);
629 extern char *myCrt_2Dispatch(int i);
631 extern char *myCrt_RapDispatch(int i);
633 extern unsigned int smb_Attributes(cm_scache_t *scp);
635 extern int smb_ChainFID(int fid, smb_packet_t *inp);
637 extern smb_fid_t *smb_FindFID(smb_vc_t *vcp, unsigned short fid, int flags);
639 extern void smb_ReleaseFID(smb_fid_t *fidp);
641 extern unsigned char *smb_ParseDataBlock(unsigned char *inp, char **chainpp, int *lengthp);
643 extern unsigned char *smb_ParseASCIIBlock(unsigned char *inp, char **chainpp);
645 extern unsigned char *smb_ParseVblBlock(unsigned char *inp, char **chainpp, int *lengthp);
647 extern int smb_SUser(cm_user_t *userp);
650 extern long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count,
651 char *op, cm_user_t *userp, long *readp);
653 extern long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count,
654 char *op, cm_user_t *userp, long *readp, int dosflag);
657 extern long smb_Rename(smb_vc_t *vcp, smb_packet_t *inp, char *oldPathp, char *newPathp, int attrs);
659 extern long smb_Link(smb_vc_t *vcp, smb_packet_t *inp, char *oldPathp, char *newPathp);
661 extern BOOL smb_IsLegalFilename(char *filename);
663 extern char *smb_GetSharename(void);
665 extern DWORD smb_ServerExceptionFilter(void);
667 /* include other include files */
669 #include "smb_ioctl.h"
670 #include "smb_iocons.h"
672 cm_user_t *smb_FindOrCreateUser(smb_vc_t *vcp, char *usern);
675 extern void smb_LogPacket(smb_packet_t *packet);
676 #endif /* NOTSERVICE */
678 #ifndef MSV1_0_OPTION_ALLOW_BLANK_PASSWORD
679 #define MSV1_0_OPTION_ALLOW_BLANK_PASSWORD 0x1
680 #define MSV1_0_OPTION_DISABLE_ADMIN_LOCKOUT 0x2
681 #define MSV1_0_OPTION_DISABLE_FORCE_GUEST 0x4
682 #define MSV1_0_OPTION_TRY_CACHE_FIRST 0x10
684 typedef struct _MSV1_0_SETPROCESSOPTION_REQUEST {
685 MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
686 ULONG ProcessOptions;
687 BOOLEAN DisableOptions;
688 } MSV1_0_SETPROCESSOPTION_REQUEST, *PMSV1_0_SETPROCESSOPTION_REQUEST;
691 #endif /* whole file */