/// <summary> /// TRANS2_SET_PATH_INFORMATION Request. /// </summary> /// <param name="messageId">This is used to associate a response with a request.</param> /// <param name="sessionId"> /// Set this value to 0 to request a new session setup, or set this value to a previously established session /// identifier to request reauthenticate to an existing session. /// </param> /// <param name="treeId"> /// This field identifies the subdirectory (or tree) (also referred as a share in this document) on the /// server that the client is accessing. /// </param> /// <param name="isSigned"> /// Indicate whether the SUT has message signing enabled or required. /// </param> /// <param name="isUsePassthrough"> /// Indicate whether adding SMB_INFO_PASSTHROUGH in InformationLevel field of the request. /// </param> /// <param name="isReparse">Indicate whether it is reparsed or not.</param> /// <param name="informationLevel">This can be used to query information from the server.</param> /// <param name="gmtTokenIndex">The index of the GMT token configured by CheckPreviousVersion action.</param> public void Trans2SetPathInfoRequest( int messageId, int sessionId, int treeId, bool isSigned, bool isUsePassthrough, bool isReparse, [Domain("InfoLevelSetByPath")] InformationLevel informationLevel, int gmtTokenIndex) { #region Create Packet SmbTrans2SetPathInformationRequestPacket smbPacket = new SmbTrans2SetPathInformationRequestPacket(); ushort uid = (ushort)this.uId[(uint)sessionId]; ushort requestedTid = (ushort)this.tId[(uint)treeId]; NamespaceCifs.Trans2SmbParametersFlags transactOptions = NamespaceCifs.Trans2SmbParametersFlags.NONE; string fileName = string.Empty; if (gmtTokenIndex < (int)uint.MinValue) { fileName = Site.Properties["SmbTestCaseBadGmt"].ToString(); } else { fileName = this.openedFileName; } ushort level = this.informationLevelBytes[(ushort)informationLevel]; byte[] data = new byte[SizeOfInfoData]; this.smbClientStack.Capability.IsUsePathThrough = isUsePassthrough; smbPacket = this.smbClientStack.CreateTrans2SetPathInformationRequest( requestedTid, fileName, transactOptions, (NamespaceCifs.SetInformationLevel)level, isReparse, data); if (isSigned) { NamespaceCifs.CifsClientPerConnection connection = this.smbClientStack.Context.GetConnection(ConnectionId); NamespaceCifs.CifsClientPerSession session = this.smbClientStack.Context.GetSession(ConnectionId, uid); smbPacket.Sign(connection.ClientNextSendSequenceNumber, session.SessionKey); } #endregion #region Send and Receive ExpectPacket this.smbClientStack.SendPacket(smbPacket); StackPacket response = this.smbClientStack.ExpectPacket(this.timeout); NamespaceCifs.SmbPacket smbPacketResponse = (NamespaceCifs.SmbPacket)response; this.QueryUidTable(smbPacketResponse); this.QueryTidTable(smbPacketResponse); VerifyTransport(smbPacketResponse); VerifyCommonMessageSyntax(smbPacketResponse); if (response.GetType() == typeof(SmbErrorResponsePacket)) { SmbErrorResponsePacket smbErrorResponsePacket = response as SmbErrorResponsePacket; NamespaceCifs.SmbHeader smbErrorHeader = smbErrorResponsePacket.SmbHeader; if (smbErrorHeader.Status == (uint)MessageStatus.StatusInvalidInfoClass) { smbErrorHeader.Status = (uint)MessageStatus.NotSupported; } this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status); } else { SmbTrans2SetPathInformationResponsePacket smbTrans2SetPathInformationPacket = response as SmbTrans2SetPathInformationResponsePacket; NamespaceCifs.SmbHeader trans2SetPathInformationResponseHeader = smbTrans2SetPathInformationPacket.SmbHeader; this.Trans2SetPathInfoResponse( trans2SetPathInformationResponseHeader.Mid + this.addMidMark, this.QueryUidTable(smbPacketResponse), this.QueryTidTable(smbPacketResponse), (smbPacketResponse).IsSignRequired, (MessageStatus)trans2SetPathInformationResponseHeader.Status); } #endregion }
/// <summary> /// Create Trans2SetPathInformation request for client to set the path information on server. /// </summary> /// <param name = "messageId">the id of message, used to identity the request and the server response. </param> /// <param name = "sessionUid">the valid session id, must be response by server of the session setup request. </param> /// <param name = "treeId">the valid tree connect id, must be response by server of the tree connect. </param> /// <param name = "flags"> /// The Flags field contains individual flags, as specified in [CIFS] sections 2.4.2 and 3.1.1. /// </param> /// <param name = "flags2"> /// The Flags2 field contains individual bit flags that, depending on the negotiated SMB dialect, indicate /// various client and server capabilities. /// </param> /// <param name = "fileName">The name of path to set the information on server. </param> /// <param name = "isUsePathThrough"> /// Indicates that the client is requesting a native Microsoft Windows® NT operating system information level, /// as specified in section 3.2.4.7 and in [MS-FSCC] section 2.4. /// </param> /// <param name = "transactOptions"> /// A set of bit flags that alter the behavior of the requested operation. Unused bit fields MUST be set to /// zero by the client sending the request, and MUST be ignored by the server receiving the request. The /// client MAY set either or both of the following bit flags /// </param> /// <param name = "timeOut"> /// The maximum amount of time in milliseconds to wait for the operation to complete. The client SHOULD set /// this to 0 to indicate that no time-out is given. If the operation does not complete within the specified /// time, the server MAY abort the request and send a failure response. /// </param> /// <param name = "informationLevel"> /// Indicates that client specifies the information it is requesting. Server return different data based on /// the client's request. /// </param> /// <param name = "data">the information data to be set. </param> /// <returns>a set path information request packet </returns> private SmbTrans2SetPathInformationRequestPacket CreateTrans2SetPathInformationRequest( ushort messageId, ushort sessionUid, ushort treeId, SmbHeader_Flags_Values flags, SmbHeader_Flags2_Values flags2, string fileName, bool isUsePathThrough, Trans2SmbParametersFlags transactOptions, uint timeOut, SetInformationLevel informationLevel, byte[] data) { if (isUsePathThrough) { informationLevel = (SetInformationLevel) (informationLevel + SmbCapability.CONST_SMB_INFO_PASSTHROUGH); } SmbTrans2SetPathInformationRequestPacket packet = new SmbTrans2SetPathInformationRequestPacket( this.cifsClient.CreateTrans2SetPathInformationRequest( messageId, sessionUid, treeId, (SmbFlags)flags, (SmbFlags2)flags2, this.capability.MaxParameterCount, this.capability.MaxDataCount, this.capability.MaxSetupCount, transactOptions, timeOut, informationLevel, fileName, data)); packet.UpdateCountAndOffset(); return packet; }
/// <summary> /// find the transaction2 packet. /// </summary> /// <param name="command">the command of transaction2 packet.</param> /// <returns>the target transaction2 packet</returns> private static SmbPacket FindTheTrans2Packet(Trans2SubCommand command) { SmbPacket smbPacket = null; switch ((Trans2SubCommand)command) { case Trans2SubCommand.TRANS2_FIND_FIRST2: smbPacket = new SmbTrans2FindFirst2RequestPacket(); break; case Trans2SubCommand.TRANS2_FIND_NEXT2: smbPacket = new SmbTrans2FindNext2RequestPacket(); break; case Trans2SubCommand.TRANS2_QUERY_FS_INFORMATION: smbPacket = new SmbTrans2QueryFsInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_SET_FS_INFORMATION: smbPacket = new SmbTrans2SetFsInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_QUERY_PATH_INFORMATION: smbPacket = new SmbTrans2QueryPathInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_SET_PATH_INFORMATION: smbPacket = new SmbTrans2SetPathInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_QUERY_FILE_INFORMATION: smbPacket = new SmbTrans2QueryFileInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_SET_FILE_INFORMATION: smbPacket = new SmbTrans2SetFileInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_GET_DFS_REFERRAL: smbPacket = new SmbTrans2GetDfsReferralRequestPacket(); break; default: break; } return smbPacket; }