/// <summary> /// Expect rap response payLoadPacket from server /// </summary> /// <param name="timeout">timeout</param> /// <returns>The rap response packet</returns> /// <exception cref="System.InvalidOperationException">Thrown if there is any error occurred</exception> public virtual FsRapResponse ExpectRapPayload(TimeSpan timeout) { this.internalTimeout = timeout; SmbPacket packet = smbClient.ExpectPacket(timeout); if (packet is SmbErrorResponsePacket) { throw new InvalidOperationException(string.Format( "The server returns error, the error code is 0x{0:x}", packet.SmbHeader.Status)); } SmbTransRapResponsePacket transResponse = packet as SmbTransRapResponsePacket; FsRapResponse responsePacket = new FsRapResponse(); responsePacket.messageId = transResponse.SmbHeader.Mid; responsePacket.TransParameters = new RapResponseParam(); responsePacket.TransParameters.Converter = transResponse.TransParameters.Converter; responsePacket.TransParameters.RAPOutParams = transResponse.TransParameters.RAPOutParams; responsePacket.TransParameters.Win32ErrorCode = transResponse.TransParameters.Win32ErrorCode; responsePacket.TransData = new RapResponseData(); responsePacket.TransData.RAPOutData = transResponse.TransData.RAPOutData; return(responsePacket); }
/// <summary> /// createt the transactions packet /// </summary> /// <param name="request">the request packet</param> /// <param name="smbHeader">the smb header of response packet</param> /// <param name="channel">the channel contains the packet bytes</param> /// <returns>the response packet</returns> private SmbPacket CreateTransactionResponsePacket(SmbPacket request, SmbHeader smbHeader, Channel channel) { SmbPacket smbPacket = null; if (smbHeader.Status == 0 && channel.Peek <byte>(0) == 0 && channel.Peek <ushort>(1) == 0) { return(smbPacket); } SmbTransactionRequestPacket transactionRequest = request as SmbTransactionRequestPacket; if (transactionRequest == null) { return(smbPacket); } switch (smbClient.Capability.TransactionSubCommand) { case TransSubCommandExtended.TRANS_EXT_MAILSLOT_WRITE: smbPacket = new SmbTransMailslotWriteResponsePacket(); break; case TransSubCommandExtended.TRANS_EXT_RAP: smbPacket = new SmbTransRapResponsePacket(); break; default: break; } // the packet is find if (smbPacket != null) { return(smbPacket); } // if no setup command. break if (transactionRequest.SmbParameters.SetupCount == 0) { return(smbPacket); } // decode packet using the setup command switch ((TransSubCommand)transactionRequest.SmbParameters.Setup[0]) { case TransSubCommand.TRANS_SET_NMPIPE_STATE: smbPacket = new SmbTransSetNmpipeStateResponsePacket(); break; case TransSubCommand.TRANS_QUERY_NMPIPE_STATE: smbPacket = new SmbTransQueryNmpipeStateResponsePacket(); break; case TransSubCommand.TRANS_RAW_READ_NMPIPE: smbPacket = new SmbTransRawReadNmpipeResponsePacket(); break; case TransSubCommand.TRANS_QUERY_NMPIPE_INFO: smbPacket = new SmbTransQueryNmpipeInfoResponsePacket(); break; case TransSubCommand.TRANS_PEEK_NMPIPE: smbPacket = new SmbTransPeekNmpipeResponsePacket(); break; case TransSubCommand.TRANS_TRANSACT_NMPIPE: smbPacket = new SmbTransTransactNmpipeResponsePacket(); break; case TransSubCommand.TRANS_READ_NMPIPE: smbPacket = new SmbTransReadNmpipeResponsePacket(); break; case TransSubCommand.TRANS_WRITE_NMPIPE: smbPacket = new SmbTransWriteNmpipeResponsePacket(); break; case TransSubCommand.TRANS_WAIT_NMPIPE: smbPacket = new SmbTransWaitNmpipeResponsePacket(); break; case TransSubCommand.TRANS_CALL_NMPIPE: smbPacket = new SmbTransCallNmpipeResponsePacket(); break; default: break; } return(smbPacket); }
/// <summary> /// Deep copy constructor. /// </summary> public SmbTransRapResponsePacket(SmbTransRapResponsePacket packet) : base(packet) { }