/// <summary> /// to create a LockingAndx request packet. /// </summary> /// <param name="uid">This field SHOULD identify the authenticated instance of the user.</param> /// <param name="treeId">This field identifies the subdirectory (or tree) on the server that the client is /// accessing.</param> /// <param name="fid">This field MUST be a valid 16-bit signed integer indicating the file from which the data /// SHOULD be read</param> /// <param name="typeOfLock">This field is a 8-bit unsigned integer bit mask indicating the nature of the lock /// request and the format of the LOCKING_ANDX_RANGE data</param> /// <param name="newOplockLevel">This field is valid only in SMB_COM_LOCKING_ANDX SMB requests sent from the /// server to the client in response to a change in the existing Oplock's state</param> /// <param name="unlocks">An array of byte ranges to be unlocked. If 32-bit offsets are being used, this field /// uses LOCKING_ANDX_RANGE32 (see below) and is (10 * NumberOfRequestedUnlocks) bytes in length. If 64-bit /// offsets are being used, this field uses LOCKING_ANDX_RANGE64 (see below) and is (20 * /// NumberOfRequestedUnlocks) bytes in length.</param> /// <param name="locks">An array of byte ranges to be locked. If 32-bit offsets are being used, this field uses /// LOCKING_ANDX_RANGE32 (see below) and is (10 * NumberOfRequestedUnlocks) bytes in length. If 64-bit offsets /// are being used, this field uses LOCKING_ANDX_RANGE64 (see below) and is (20 * NumberOfRequestedUnlocks) /// bytes in length</param> /// <param name="andxPacket">the andx packet.</param> /// <returns>a LockingAndx request packet</returns> /// <exception cref="System.NullReferenceException">There is no connection in context. </exception> public SmbLockingAndxRequestPacket CreateLockingAndxRequest( ushort uid, ushort treeId, ushort fid, LockingAndxTypeOfLock typeOfLock, NewOplockLevelValue newOplockLevel, Object[] unlocks, Object[] locks, SmbPacket andxPacket) { return this.CreateLockingAndxRequest(this.Context.GetMessageId(this.connectionId), uid, treeId, this.defaultParameters.Flag, this.defaultParameters.Flag2, fid, typeOfLock, newOplockLevel, this.defaultParameters.Timeout, unlocks, locks, andxPacket); }
/// <summary> /// to create a LockingAndx request packet. /// </summary> /// <param name="messageId">This field SHOULD be the multiplex ID that is used to associate a response with a /// request.</param> /// <param name="uid">This field SHOULD identify the authenticated instance of the user.</param> /// <param name="treeId">This field identifies the subdirectory (or tree) on the server that the client is /// accessing.</param> /// <param name="flags">An 8-bit field of 1-bit flags describing various features in effect for the /// message</param> /// <param name="flags2">A 16-bit field of 1-bit flags that represent various features in effect for the /// message. Unspecified bits are reserved and MUST be zero.</param> /// <param name="fid">This field MUST be a valid 16-bit signed integer indicating the file from which the data /// SHOULD be read</param> /// <param name="typeOfLock">This field is a 8-bit unsigned integer bit mask indicating the nature of the lock /// request and the format of the LOCKING_ANDX_RANGE data</param> /// <param name="newOplockLevel">This field is valid only in SMB_COM_LOCKING_ANDX SMB requests sent from the /// server to the client in response to a change in the existing Oplock's state</param> /// <param name="timeout">This field is a 32-bit unsigned integer value</param> /// <param name="unlocks">An array of byte ranges to be unlocked. If 32-bit offsets are being used, this field /// uses LOCKING_ANDX_RANGE32 (see below) and is (10 * NumberOfRequestedUnlocks) bytes in length. If 64-bit /// offsets are being used, this field uses LOCKING_ANDX_RANGE64 (see below) and is (20 * /// NumberOfRequestedUnlocks) bytes in length.</param> /// <param name="locks">An array of byte ranges to be locked. If 32-bit offsets are being used, this field uses /// LOCKING_ANDX_RANGE32 (see below) and is (10 * NumberOfRequestedUnlocks) bytes in length. If 64-bit offsets /// are being used, this field uses LOCKING_ANDX_RANGE64 (see below) and is (20 * NumberOfRequestedUnlocks) /// bytes in length</param> /// <param name="andxPacket">the andx packet.</param> /// <returns>a LockingAndx request packet</returns> public SmbLockingAndxRequestPacket CreateLockingAndxRequest( ushort messageId, ushort uid, ushort treeId, SmbFlags flags, SmbFlags2 flags2, ushort fid, LockingAndxTypeOfLock typeOfLock, NewOplockLevelValue newOplockLevel, uint timeout, Object[] unlocks, Object[] locks, SmbPacket andxPacket) { if (unlocks == null) { unlocks = new Object[0]; } if (locks == null) { locks = new Object[0]; } SmbLockingAndxRequestPacket packet = new SmbLockingAndxRequestPacket(); packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_LOCKING_ANDX, messageId, uid, treeId, flags, flags2); SMB_COM_LOCKING_ANDX_Request_SMB_Parameters smbParameters = new SMB_COM_LOCKING_ANDX_Request_SMB_Parameters(); if (andxPacket == null) { smbParameters.AndXCommand = SmbCommand.SMB_COM_NO_ANDX_COMMAND; } else { smbParameters.AndXCommand = andxPacket.SmbHeader.Command; } smbParameters.AndXReserved = 0; smbParameters.FID = fid; smbParameters.TypeOfLock = typeOfLock; smbParameters.NewOplockLevel = newOplockLevel; smbParameters.Timeout = timeout; smbParameters.NumberOfRequestedUnlocks = (ushort)unlocks.Length; smbParameters.NumberOfRequestedLocks = (ushort)locks.Length; smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord); SMB_COM_LOCKING_ANDX_Request_SMB_Data smbData = new SMB_COM_LOCKING_ANDX_Request_SMB_Data(); smbData.Locks = locks; smbData.Unlocks = unlocks; smbData.ByteCount = 0; foreach (object lockItem in unlocks) { smbData.ByteCount += (ushort)Marshal.SizeOf(lockItem); } foreach (object lockItem in locks) { smbData.ByteCount += (ushort)Marshal.SizeOf(lockItem); } packet.SmbParameters = smbParameters; packet.SmbData = smbData; packet.AndxPacket = andxPacket; return packet; }