/// <summary> /// Create TransWriteNamedPipe request for client to write data to named pipe. /// </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 = "fileId">the valid file id to operation on, response by server. </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 = "writeData">The data to write to named pipe. </param> /// <returns>a write named pipe request packet </returns> private SmbTransWriteNmpipeRequestPacket CreateTransWriteNamedPipeRequest( ushort messageId, ushort sessionUid, ushort treeId, SmbHeader_Flags_Values flags, SmbHeader_Flags2_Values flags2, ushort fileId, TransSmbParametersFlags transactOptions, uint timeOut, byte[] writeData) { return new SmbTransWriteNmpipeRequestPacket( this.cifsClient.CreateTransWriteNmpipeRequest( messageId, sessionUid, treeId, (SmbFlags)flags, (SmbFlags2)flags2, this.capability.MaxParameterCount, this.capability.MaxDataCount, this.capability.MaxSetupCount, transactOptions, timeOut, fileId, writeData, "")); }
/// <summary> /// Create TransQueryNamedPipeInfo request for client to query the information of named pipe. /// </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 = "fileId">the valid file id to operation on, response by server. </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"> /// A USHORT value (as specified in [MS-DTYP] section 2.2.54) that describes the information level being /// queried for the pipe. The only supported value is 0x0001. /// </param> /// <returns>a query named pipe information request packet </returns> /// <exception cref="ArgumentException">The only supported value is 0x0001.</exception> private SmbTransQueryNmpipeInfoRequestPacket CreateTransQueryNamedPipeInfoRequest( ushort messageId, ushort sessionUid, ushort treeId, SmbHeader_Flags_Values flags, SmbHeader_Flags2_Values flags2, ushort fileId, TransSmbParametersFlags transactOptions, uint timeOut, NamedPipeInformationLevel informationLevel) { if (informationLevel != NamedPipeInformationLevel.VALID) { throw new ArgumentException("The only supported value is 0x0001.", "informationLevel"); } return new SmbTransQueryNmpipeInfoRequestPacket( this.cifsClient.CreateTransQueryNmpipeInfoRequest( messageId, sessionUid, treeId, (SmbFlags)flags, (SmbFlags2)flags2, this.capability.MaxParameterCount, this.capability.MaxDataCount, this.capability.MaxSetupCount, transactOptions, timeOut, fileId, "")); }
/// <summary> /// Create TransWaitNamedPipe request for client to wait named pipe 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 = "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 = "priority"> /// This field MUST be in the range of 0 to 9. The larger value being the higher priority. /// </param> /// <param name = "name"> /// The pathname of the mailslot or named pipe to which the transaction subcommand applies or a client /// supplied identifier that provides a name for the transaction. /// </param> /// <returns>a wait named pipe request packet </returns> private SmbTransWaitNmpipeRequestPacket CreateTransWaitNamedPipeRequest( ushort messageId, ushort sessionUid, ushort treeId, SmbHeader_Flags_Values flags, SmbHeader_Flags2_Values flags2, TransSmbParametersFlags transactOptions, uint timeOut, ushort priority, string name) { return new SmbTransWaitNmpipeRequestPacket( this.cifsClient.CreateTransWaitNmpipeRequest( messageId, sessionUid, treeId, (SmbFlags)flags, (SmbFlags2)flags2, this.capability.MaxParameterCount, this.capability.MaxDataCount, this.capability.MaxSetupCount, transactOptions, timeOut, priority, name)); }
/// <summary> /// Create TransMailslotWrite request for client to write data to mailslot 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 = "mailslotName">The name of maislot to write to. </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 = "writeData">The data to write to mailslot. </param> /// <param name = "priority"> /// This field MUST be in the range of 0 to 9. The larger value being the higher priority. /// </param> /// <param name = "className"> /// The third setup word and the class of the mailslot request. This value MUST be set to one of the following /// values. /// </param> /// <returns>a write mailslot request packet </returns> private SmbTransMailslotWriteRequestPacket CreateTransMailslotWriteRequest( ushort messageId, ushort sessionUid, ushort treeId, SmbHeader_Flags_Values flags, SmbHeader_Flags2_Values flags2, string mailslotName, TransSmbParametersFlags transactOptions, uint timeOut, byte[] writeData, ushort priority, SmbTransMailslotClass className) { if (mailslotName == null) { mailslotName = string.Empty; } SmbTransMailslotWriteRequestPacket packet = new SmbTransMailslotWriteRequestPacket(); packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_TRANSACTION, messageId, sessionUid, treeId, (SmbFlags)flags, (SmbFlags2)flags2); // Set Smb Parameters SMB_COM_TRANSACTION_Request_SMB_Parameters smbParameters = new SMB_COM_TRANSACTION_Request_SMB_Parameters(); smbParameters.MaxParameterCount = this.capability.MaxParameterCount; smbParameters.MaxDataCount = this.capability.MaxDataCount; smbParameters.MaxSetupCount = this.capability.MaxSetupCount; smbParameters.Flags = transactOptions; smbParameters.Timeout = timeOut; smbParameters.SetupCount = 3; // the correct count in word of the Setup is always 3. smbParameters.Setup = new ushort[3]; smbParameters.Setup[0] = (ushort)TransSubCommand.TRANS_MAILSLOT_WRITE; smbParameters.Setup[1] = (ushort)priority; smbParameters.Setup[2] = (ushort)className; smbParameters.WordCount = (byte)(CifsMessageUtils.GetSize<SMB_COM_TRANSACTION_Request_SMB_Parameters>( smbParameters) / SmbCapability.NUM_BYTES_OF_WORD); // Set Smb Data SMB_COM_TRANSACTION_Request_SMB_Data smbData = new SMB_COM_TRANSACTION_Request_SMB_Data(); smbData.Name = CifsMessageUtils.ToSmbStringBytes(mailslotName, this.capability.IsUnicode); smbData.Trans_Data = writeData; packet.SmbParameters = smbParameters; packet.SmbData = smbData; packet.UpdateCountAndOffset(); // update TransactionSubCommand in SmbGlobalContext, record the transact action this.capability.TransactionSubCommand = TransSubCommandExtended.TRANS_EXT_MAILSLOT_WRITE; return packet; }
/// <summary> /// Create TransNamedRap request for client to send a rap request to 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 = "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="rapOPCode"> /// The operation code for the particular operation. For more information on valid operation codes, see 2.5.4. /// </param> /// <param name="paramDesc"> /// This value MUST be a null-terminated ASCII descriptor string. The server SHOULD validate that the ParamDesc /// value passed by the client matches what is specified by the RAPOpcode. The following table specifies the /// descriptor character and the notation for each data type. /// </param> /// <param name="dataDesc"> /// (Optional) If this value is specified, it MUST be a null-terminated ASCII descriptor string that describes /// the contents of the data returned to the client. Certain RAPOpcodes specify a DataDesc field; for a list /// of Remote Administration Protocol commands that specify a DataDesc field, see section 2.5.5. /// </param> /// <param name="rapParamsAndAuxDesc"> /// This field combines the following fields, because each of their length is unknown:<para/> /// RAPParams: Remote Administration Protocol command-specific parameters, as specified in sections 2.5.5, 2.5.6, 2.5.7, /// 2.5.8, and 2.5.9.<para/> /// AuxDesc: (Optional) If this value is specified, it MUST be a null-terminated ASCII descriptor string that describes /// auxiliary data returned to the client. If no AuxDesc field is specified for the Remote Administration /// Protocol command, this field MUST NOT be present. For the origin of the descriptor string values, see /// section 4.2. /// </param> /// <param name="rapInData"> /// Additional data for the Remote Administration Protocol request. This field MUST be present in the /// NetPrintJobSetInfoRequest command. This field cannot be present in any other command. /// </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> /// <returns>a named rap request packet </returns> private SmbTransRapRequestPacket CreateTransNamedRapRequest( ushort messageId, ushort sessionUid, ushort treeId, SmbHeader_Flags_Values flags, SmbHeader_Flags2_Values flags2, TransSmbParametersFlags transactOptions, ushort rapOPCode, byte[] paramDesc, byte[] dataDesc, byte[] rapParamsAndAuxDesc, byte[] rapInData, uint timeOut) { SmbTransRapRequestPacket packet = new SmbTransRapRequestPacket(); packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_TRANSACTION, messageId, sessionUid, treeId, (SmbFlags)flags, (SmbFlags2)flags2); // Set Smb Parameters SMB_COM_TRANSACTION_Request_SMB_Parameters smbParameters = new SMB_COM_TRANSACTION_Request_SMB_Parameters(); smbParameters.MaxParameterCount = this.capability.MaxParameterCount; smbParameters.MaxDataCount = this.capability.MaxDataCount; smbParameters.MaxSetupCount = this.capability.MaxSetupCount; smbParameters.Flags = transactOptions; smbParameters.Timeout = timeOut; smbParameters.SetupCount = 0; // the correct count in word of the Setup is always 0. smbParameters.Setup = new ushort[0]; smbParameters.WordCount = (byte)(CifsMessageUtils.GetSize<SMB_COM_TRANSACTION_Request_SMB_Parameters>( smbParameters) / SmbCapability.NUM_BYTES_OF_WORD); // Set Smb Data SMB_COM_TRANSACTION_Request_SMB_Data smbData = new SMB_COM_TRANSACTION_Request_SMB_Data(); smbData.Name = CifsMessageUtils.ToSmbStringBytes("", this.capability.IsUnicode); // Set Transaction Parameters TRANSACTION_Rap_Request_Trans_Parameters transParameters = new TRANSACTION_Rap_Request_Trans_Parameters(); transParameters.RapOPCode = rapOPCode; transParameters.ParamDesc = paramDesc; transParameters.DataDesc = dataDesc; transParameters.RAPParamsAndAuxDesc = rapParamsAndAuxDesc; // Set Transaction Data TRANSACTION_Rap_Request_Trans_Data transData = new TRANSACTION_Rap_Request_Trans_Data(); transData.RAPInData = rapInData; packet.SmbParameters = smbParameters; packet.SmbData = smbData; packet.TransParameters = transParameters; packet.TransData = transData; packet.UpdateCountAndOffset(); // update TransactionSubCommand in SmbGlobalContext, record the transact action this.capability.TransactionSubCommand = TransSubCommandExtended.TRANS_EXT_RAP; return packet; }
/// <summary> /// Create TransWaitNamedPipe request for client to wait named pipe on server. /// </summary> /// <param name = "treeId">the valid tree connect id, must be response by server of the tree connect. </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 = "priority"> /// This field MUST be in the range of 0 to 9. The larger value being the higher priority. /// </param> /// <param name = "name"> /// The pathname of the mailslot or named pipe to which the transaction subcommand applies or a client /// supplied identifier that provides a name for the transaction. /// </param> /// <returns>a wait named pipe request packet </returns> public virtual SmbTransWaitNmpipeRequestPacket CreateTransWaitNamedPipeRequest( ushort treeId, TransSmbParametersFlags transactOptions, ushort priority, string name) { return CreateTransWaitNamedPipeRequest( this.MessageId, this.GetSessionIdByTreeId(treeId), treeId, this.capability.Flag, this.capability.Flags2, transactOptions, this.capability.Timeout, priority, name); }
/// <summary> /// Create TransWriteNamedPipe request for client to write data to named pipe. /// </summary> /// <param name = "fileId">the valid file id to operation on, response by server. </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 = "writeData">The data to write to named pipe. </param> /// <returns>a write named pipe request packet </returns> public virtual SmbTransWriteNmpipeRequestPacket CreateTransWriteNamedPipeRequest( ushort fileId, TransSmbParametersFlags transactOptions, byte[] writeData) { return CreateTransWriteNamedPipeRequest( this.MessageId, this.GetSessionIdByFileId(fileId), this.GetTreeIdByFileId(fileId), this.capability.Flag, this.capability.Flags2, fileId, transactOptions, 0, writeData); }
/// <summary> /// Create TransReadNamedPipe request for client to read data from named pipe. /// </summary> /// <param name = "fileId">the valid file id to operation on, response by server. </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 = "maxReadDataCount">The max read data size. </param> /// <returns>a read named pipe request packet </returns> public virtual SmbTransReadNmpipeRequestPacket CreateTransReadNamedPipeRequest( ushort fileId, TransSmbParametersFlags transactOptions, ushort maxReadDataCount) { return CreateTransReadNamedPipeRequest( this.MessageId, this.GetSessionIdByFileId(fileId), this.GetTreeIdByFileId(fileId), this.capability.Flag, this.capability.Flags2, fileId, transactOptions, 0, maxReadDataCount); }
/// <summary> /// Create TransSetNamedPipeState request packet for client to set the state of named pipe. /// </summary> /// <param name = "fileId">the valid file id to operation on, response by server. </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 = "pipeState"> /// This field contains the value that defines the state being set on the pipe. Any combination of the /// following flags MUST be valid for the set operation. All other flags are considered unused and SHOULD be /// set to 0 when this message is sent. The server MUST ignore the unused bits when the message is received /// </param> /// <returns>a set named pipe state request packet. </returns> public virtual SmbTransSetNmpipeStateRequestPacket CreateTransSetNamedPipeStateRequest( ushort fileId, TransSmbParametersFlags transactOptions, PipeState pipeState) { return CreateTransSetNamedPipeStateRequest( this.MessageId, this.GetSessionIdByFileId(fileId), this.GetTreeIdByFileId(fileId), this.capability.Flag, this.capability.Flags2, fileId, transactOptions, this.capability.Timeout, pipeState); }
/// <summary> /// Create TransQueryNamedPipeInfo request for client to query the information of named pipe. /// </summary> /// <param name = "fileId">the valid file id to operation on, response by server. </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 = "informationLevel"> /// A USHORT value (as specified in [MS-DTYP] section 2.2.54) that describes the information level being /// queried for the pipe. The only supported value is 0x0001. /// </param> /// <returns>a query named pipe information request packet </returns> public virtual SmbTransQueryNmpipeInfoRequestPacket CreateTransQueryNamedPipeInfoRequest( ushort fileId, TransSmbParametersFlags transactOptions, NamedPipeInformationLevel informationLevel) { return CreateTransQueryNamedPipeInfoRequest( this.MessageId, this.GetSessionIdByFileId(fileId), this.GetTreeIdByFileId(fileId), this.capability.Flag, this.capability.Flags2, fileId, transactOptions, 0, informationLevel); }
/// <summary> /// Create TransNamedRap request for client to send a rap request to server. /// </summary> /// <param name = "treeId">the valid tree connect id, must be response by server of the tree connect. </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="rapOPCode"> /// The operation code for the particular operation. For more information on valid operation codes, see 2.5.4. /// </param> /// <param name="paramDesc"> /// This value MUST be a null-terminated ASCII descriptor string. The server SHOULD validate that the ParamDesc /// value passed by the client matches what is specified by the RAPOpcode. The following table specifies the /// descriptor character and the notation for each data type. /// </param> /// <param name="dataDesc"> /// (Optional) If this value is specified, it MUST be a null-terminated ASCII descriptor string that describes /// the contents of the data returned to the client. Certain RAPOpcodes specify a DataDesc field; for a list /// of Remote Administration Protocol commands that specify a DataDesc field, see section 2.5.5. /// </param> /// <param name="rapParamsAndAuxDesc"> /// This field combines the following fields, because each of their length is unknown:<para/> /// RAPParams: Remote Administration Protocol command-specific parameters, as specified in sections 2.5.5, 2.5.6, 2.5.7, /// 2.5.8, and 2.5.9.<para/> /// AuxDesc: (Optional) If this value is specified, it MUST be a null-terminated ASCII descriptor string that describes /// auxiliary data returned to the client. If no AuxDesc field is specified for the Remote Administration /// Protocol command, this field MUST NOT be present. For the origin of the descriptor string values, see /// section 4.2. /// </param> /// <param name="rapInData"> /// Additional data for the Remote Administration Protocol request. This field MUST be present in the /// NetPrintJobSetInfoRequest command. This field cannot be present in any other command. /// </param> /// <returns>a named rap request packet </returns> public virtual SmbTransRapRequestPacket CreateTransNamedRapRequest( ushort treeId, TransSmbParametersFlags transactOptions, ushort rapOPCode, byte[] paramDesc, byte[] dataDesc, byte[] rapParamsAndAuxDesc, byte[] rapInData) { return CreateTransNamedRapRequest( this.MessageId, this.GetSessionIdByTreeId(treeId), treeId, this.capability.Flag, this.capability.Flags2, transactOptions, rapOPCode, paramDesc, dataDesc, rapParamsAndAuxDesc, rapInData, this.capability.Timeout); }
/// <summary> /// Create TransMailslotWrite request for client to write data to mailslot on server. /// </summary> /// <param name = "treeId">the valid tree connect id, must be response by server of the tree connect. </param> /// <param name = "mailslotName">The name of maislot to write to. </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 = "writeData">The data to write to mailslot. </param> /// <param name = "priority"> /// This field MUST be in the range of 0 to 9. The larger value being the higher priority. /// </param> /// <param name = "className"> /// The third setup word and the class of the mailslot request. This value MUST be set to one of the following /// values. /// </param> /// <returns>a write mailslot request packet </returns> public virtual SmbTransMailslotWriteRequestPacket CreateTransMailslotWriteRequest( ushort treeId, string mailslotName, TransSmbParametersFlags transactOptions, byte[] writeData, ushort priority, SmbTransMailslotClass className) { return CreateTransMailslotWriteRequest( this.MessageId, this.GetSessionIdByTreeId(treeId), treeId, this.capability.Flag, this.capability.Flags2, mailslotName, transactOptions, this.capability.Timeout, writeData, priority, className); }
/// <summary> /// Create TransCallNamedPipe request for client to call named pipe on server. /// </summary> /// <param name = "treeId">the valid tree connect id, must be response by server of the tree connect. </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 = "writeData">Data buffer that contains the data to write to the named pipe. </param> /// <param name = "maxReadDataCount">The max read data size to call named pipe. </param> /// <param name = "priority"> /// This field MUST be in the range of 0 to 9. The larger value being the higher priority. /// </param> /// <param name = "name"> /// The pathname of the mailslot or named pipe to which the transaction subcommand applies or a client /// supplied identifier that provides a name for the transaction. /// </param> /// <returns>a call named pipe request packet </returns> public virtual SmbTransCallNmpipeRequestPacket CreateTransCallNamedPipeRequest( ushort treeId, TransSmbParametersFlags transactOptions, ushort maxReadDataCount, byte[] writeData, ushort priority, string name) { return CreateTransCallNamedPipeRequest( this.MessageId, this.GetSessionIdByTreeId(treeId), treeId, this.capability.Flag, this.capability.Flags2, transactOptions, this.capability.Timeout, maxReadDataCount, writeData, priority, name); }
/// <summary> /// to create a TransWriteNmpipe 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="maxParameterCount">The maximum number of parameter bytes that the client will accept in the /// transaction reply. The server MUST NOT return more than this number of parameter bytes.</param> /// <param name="maxDataCount">The maximum number of data bytes that the client will accept in the transaction /// reply. The server MUST NOT return more than this number of data bytes.</param> /// <param name="maxSetupCount">Maximum number of setup bytes that the client will accept in the transaction /// reply. The server MUST NOT return more than this number of setup bytes</param> /// <param name="smbParametersflags">A set of bit flags that alter the behavior of the requested /// operation</param> /// <param name="timeout">The value of this field MUST be the maximum number of milliseconds the server SHOULD /// wait for completion of the transaction before generating a timeout and returning a response to the /// client. </param> /// <param name="fid">MUST contain a valid FID obtained from a previously successful SMB open command.</param> /// <param name="writeData">This field MUST contain the bytes to be written to the named pipe as part of the /// transacted operation.</param> /// <param name="name">The pathname of the mailslot or named pipe to which the transaction subcommand applies /// or a client supplied identifier that provides a name for the transaction.</param> /// <returns>a TransWriteNmpipe request packet</returns> public SmbTransWriteNmpipeRequestPacket CreateTransWriteNmpipeRequest( ushort messageId, ushort uid, ushort treeId, SmbFlags flags, SmbFlags2 flags2, ushort maxParameterCount, ushort maxDataCount, byte maxSetupCount, TransSmbParametersFlags smbParametersflags, uint timeout, ushort fid, byte[] writeData, string name) { if (writeData == null) { writeData = new byte[0]; } if (name == null) { name = string.Empty; } SmbTransWriteNmpipeRequestPacket packet = new SmbTransWriteNmpipeRequestPacket(); packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_TRANSACTION, messageId, uid, treeId, flags, flags2); // Set Smb Parameters SMB_COM_TRANSACTION_Request_SMB_Parameters smbParameters = new SMB_COM_TRANSACTION_Request_SMB_Parameters(); smbParameters.MaxParameterCount = maxParameterCount; smbParameters.MaxDataCount = maxDataCount; smbParameters.MaxSetupCount = maxSetupCount; smbParameters.Flags = smbParametersflags; smbParameters.Timeout = timeout; smbParameters.SetupCount = 2; // the correct count in word of the Setup is always 2. smbParameters.Setup = new ushort[2]; smbParameters.Setup[0] = (ushort)TransSubCommand.TRANS_WRITE_NMPIPE; smbParameters.Setup[1] = fid; smbParameters.WordCount = (byte)(CifsMessageUtils.GetSize<SMB_COM_TRANSACTION_Request_SMB_Parameters>( smbParameters) / NumBytesOfWord); // Set Smb Data SMB_COM_TRANSACTION_Request_SMB_Data smbData = new SMB_COM_TRANSACTION_Request_SMB_Data(); smbData.Name = CifsMessageUtils.ToSmbStringBytes(name, (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE); // Set Trans_Data TRANS_WRITE_NMPIPE_Request_Trans_Data transData = new TRANS_WRITE_NMPIPE_Request_Trans_Data(); transData.WriteData = writeData; packet.SmbParameters = smbParameters; packet.SmbData = smbData; packet.TransData = transData; packet.UpdateCountAndOffset(); return packet; }