#define KNOWS_LONG_NAMES(inp) ((((smb_t *)inp)->flg2 & SMB_FLAGS2_KNOWS_LONG_NAMES)?1:0)
#define WANTS_DFS_PATHNAMES(inp) ((((smb_t *)inp)->flg2 & SMB_FLAGS2_DFS_PATHNAMES)?1:0)
+#define WANTS_UNICODE(inp) ((((smb_t *)inp)->flg2 & SMB_FLAGS2_UNICODE)?1:0)
/* Information Levels */
#define SMB_INFO_STANDARD 1
#define SMB_PACKETSIZE 32768 /* was 8400 */
/* raw mode is considered obsolete and cannot be used with message signing */
#define SMB_MAXRAWSIZE 65536
+/* max STRING characters per packet per request */
+#define SMB_STRINGBUFSIZE 4096
/* Negotiate protocol constants */
/* Security */
unsigned char oddByte;
unsigned short ncb_length;
unsigned char flags;
+ cm_space_t *stringsp; /* decoded strings from this packet */
} smb_packet_t;
/* smb_packet flags */
typedef struct smb_vc {
struct smb_vc *nextp; /* not used */
afs_uint32 magic; /* a magic value to detect bad entries */
- unsigned long refCount; /* the reference count */
- long flags; /* the flags, if any; locked by mx */
+ afs_int32 refCount; /* the reference count */
+ afs_uint32 flags; /* the flags, if any; locked by mx */
osi_mutex_t mx; /* the mutex */
- long vcID; /* VC id */
+ afs_uint32 vcID; /* VC id */
unsigned short lsn; /* the NCB LSN associated with this */
unsigned short uidCounter; /* session ID counter */
unsigned short tidCounter; /* tree ID counter */
#define SMB_VCFLAG_SESSX_RCVD 0x40 /* we received at least one session setups on this vc */
#define SMB_VCFLAG_AUTH_IN_PROGRESS 0x80 /* a SMB NT extended authentication is in progress */
#define SMB_VCFLAG_CLEAN_IN_PROGRESS 0x100
+#define SMB_VCFLAG_USEUNICODE 0x200 /* une UNICODE for STRING fields (NTLM 0.12 or later) */
/* one per user session */
typedef struct smb_user {
struct smb_user *nextp; /* next sibling */
- unsigned long refCount; /* ref count */
+ afs_int32 refCount; /* ref count */
afs_uint32 flags; /* flags; locked by mx */
osi_mutex_t mx;
unsigned short userID; /* the session identifier */
struct smb_vc *vcp; /* back ptr to virtual circuit */
struct smb_username *unp; /* user name struct */
- afs_uint32 delete; /* ok to del: locked by smb_rctLock */
+ afs_uint32 deleteOk; /* ok to del: locked by smb_rctLock */
} smb_user_t;
#define SMB_USERFLAG_DELETE 1 /* delete struct when ref count zero */
typedef struct smb_username {
struct smb_username *nextp; /* next sibling */
- unsigned long refCount; /* ref count */
+ afs_int32 refCount; /* ref count */
long flags; /* flags; locked by mx */
osi_mutex_t mx;
struct cm_user *userp; /* CM user structure */
/* one per tree-connect */
typedef struct smb_tid {
struct smb_tid *nextp; /* next sibling */
- unsigned long refCount;
+ afs_int32 refCount;
afs_uint32 flags; /* protected by mx */
osi_mutex_t mx; /* for non-tree-related stuff */
unsigned short tid; /* the tid */
struct cm_user *userp; /* user logged in at the
* tree connect level (base) */
char *pathname; /* pathname derived from sharename */
- afs_uint32 delete; /* ok to del: locked by smb_rctLock */
+ afs_uint32 deleteOk; /* ok to del: locked by smb_rctLock */
} smb_tid_t;
#define SMB_TIDFLAG_IPC 1 /* IPC$ */
/* one per process ID */
typedef struct smb_pid {
struct smb_pid *nextp; /* next sibling */
- unsigned long refCount;
+ afs_int32 refCount;
long flags;
osi_mutex_t mx; /* for non-tree-related stuff */
unsigned short pid; /* the pid */
/* uid pointer */
smb_user_t *uidp;
+
} smb_ioctl_t;
/* flags for smb_ioctl_t */
#define SMB_IOCTLFLAG_DATAIN 1 /* reading data from client to server */
#define SMB_IOCTLFLAG_LOGON 2 /* got tokens from integrated logon */
+#define SMB_IOCTLFLAG_USEUTF8 4 /* this request is using UTF-8 strings */
/* one per file ID; these are really file descriptors */
typedef struct smb_fid {
osi_queue_t q;
- unsigned long refCount;
+ afs_int32 refCount;
afs_uint32 flags; /* protected by mx */
osi_mutex_t mx; /* for non-tree-related stuff */
unsigned short fid; /* the file ID */
int prev_chunk; /* previous chunk read */
int raw_writers; /* pending async raw writes */
EVENT_HANDLE raw_write_event; /* signal this when raw_writers zero */
- afs_uint32 delete; /* ok to del: locked by smb_rctLock */
+ afs_uint32 deleteOk; /* ok to del: locked by smb_rctLock */
} smb_fid_t;
#define SMB_FID_OPENREAD_LISTDIR 1 /* open for reading / listing directory */
typedef struct smb_dirSearch {
osi_queue_t q; /* queue of all outstanding cookies */
osi_mutex_t mx; /* just in case the caller screws up */
- unsigned long refCount; /* reference count */
+ afs_int32 refCount; /* reference count */
long cookie; /* value returned to the caller */
struct cm_scache *scp; /* vnode of the dir we're searching */
time_t lastTime; /* last time we used this (osi_Time) */
int state;
} smb_waitingLock_t;
-#define SMB_WAITINGLOCKSTATE_WAITING 0
-#define SMB_WAITINGLOCKSTATE_DONE 1
-#define SMB_WAITINGLOCKSTATE_ERROR 2
+#define SMB_WAITINGLOCKSTATE_WAITING 0
+#define SMB_WAITINGLOCKSTATE_DONE 1
+#define SMB_WAITINGLOCKSTATE_ERROR 2
+#define SMB_WAITINGLOCKSTATE_CANCELLED 3
/* waiting lock request */
typedef struct smb_waitingLockRequest {
smb_packet_t *inp;
smb_packet_t *outp;
int lockType;
- time_t timeRemaining;
+ time_t start_t; /* osi_Time */
+ afs_uint32 msTimeout; /* msecs, 0xFFFFFFFF = wait forever */
smb_waitingLock_t * locks;
} smb_waitingLockRequest_t;
extern void smb_HoldTIDNoLock(smb_tid_t *tidp);
-extern void smb_ReleaseTID(smb_tid_t *tidp);
+extern void smb_ReleaseTID(smb_tid_t *tidp, afs_uint32 locked);
extern smb_user_t *smb_FindUID(smb_vc_t *vcp, unsigned short uid, int flags);
extern void smb_StripLastComponent(char *outPathp, char **lastComponentp,
char *inPathp);
-extern unsigned char *smb_ParseASCIIBlock(unsigned char *inp, char **chainpp);
+#define SMB_STRF_FORCEASCII (1<<0)
+#define SMB_STRF_ANSIPATH (1<<1)
+#define SMB_STRF_IGNORENULL (1<<2)
+
+extern unsigned char *smb_ParseASCIIBlock(smb_packet_t * pktp, unsigned char *inp,
+ char **chainpp, int flags);
+
+extern unsigned char *smb_ParseString(smb_packet_t * pktp, unsigned char * inp,
+ char ** chainpp, int flags);
+
+extern unsigned char *smb_ParseStringBuf(const unsigned char * bufbase,
+ cm_space_t ** stringspp,
+ unsigned char *inp, size_t *pcb_max,
+ char **chainpp, int flags);
+
+extern unsigned char *smb_ParseStringCb(smb_packet_t * pktp, unsigned char * inp,
+ size_t cb, char ** chainpp, int flags);
+
+extern unsigned char *smb_ParseStringCch(smb_packet_t * pktp, unsigned char * inp,
+ size_t cch, char ** chainpp, int flags);
+
+extern unsigned char * smb_UnparseString(smb_packet_t * pktp, unsigned char * outp,
+ unsigned char * str,
+ size_t * plen, int flags);
extern unsigned char *smb_ParseVblBlock(unsigned char *inp, char **chainpp,
int *lengthp);
extern int smb_StoreAnsiFilenames;
extern int smb_hideDotFiles;
extern unsigned int smb_IsDotFile(char *lastComp);
+extern afs_uint32 smb_AsyncStore;
+extern afs_uint32 smb_AsyncStoreSize;
/* the following are used for smb auth */
extern int smb_authType; /* Type of SMB authentication to be used. One from below. */
extern int smb_ServerLanManagerLength;
extern GUID smb_ServerGUID;
extern LSA_STRING smb_lsaLogonOrigin;
+extern LONG smb_UseUnicode;
/* used for getting a challenge for SMB auth */
typedef struct _MSV1_0_LM20_CHALLENGE_REQUEST {
extern unsigned char *smb_ParseDataBlock(unsigned char *inp, char **chainpp, int *lengthp);
-extern unsigned char *smb_ParseASCIIBlock(unsigned char *inp, char **chainpp);
-
extern unsigned char *smb_ParseVblBlock(unsigned char *inp, char **chainpp, int *lengthp);
extern int smb_SUser(cm_user_t *userp);
-long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
+long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, afs_uint32 count, char *op,
cm_user_t *userp, long *writtenp);
-extern long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count,
+extern long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, afs_uint32 count,
char *op, cm_user_t *userp, long *readp);
extern long smb_Rename(smb_vc_t *vcp, smb_packet_t *inp, char *oldPathp, char *newPathp, int attrs);
extern void smb_UpdateServerPriority(void);
extern void smb_SetRequestStartTime(void);
extern void smb_ResetServerPriority(void);
-extern void smb_RestartListeners(void);
-extern void smb_StopListeners(void);
-extern void smb_StopListener(NCB *ncbp, int lana);
+extern void smb_RestartListeners(int);
+extern void smb_StopListeners(int);
+extern void smb_StopListener(NCB *ncbp, int lana, int wait);
extern long smb_IsNetworkStarted(void);
+extern void smb_LanAdapterChange(int);
+extern void smb_SetLanAdapterChangeDetected(void);
+
#define SMB_LISTENER_UNINITIALIZED -1
#define SMB_LISTENER_STOPPED 0