本文整理汇总了C#中Smb2FunctionalClient.SendAndReceiveCompoundPacket方法的典型用法代码示例。如果您正苦于以下问题:C# Smb2FunctionalClient.SendAndReceiveCompoundPacket方法的具体用法?C# Smb2FunctionalClient.SendAndReceiveCompoundPacket怎么用?C# Smb2FunctionalClient.SendAndReceiveCompoundPacket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smb2FunctionalClient
的用法示例。
在下文中一共展示了Smb2FunctionalClient.SendAndReceiveCompoundPacket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compound_RelatedRequests
private void Compound_RelatedRequests(string fileName, bool isEncrypted)
{
BaseTestSite.Log.Add(LogEntryKind.TestStep, "Initialize the test client.");
Smb2FunctionalClient client = new Smb2FunctionalClient(TestConfig.Timeout, TestConfig, BaseTestSite);
uint treeId;
BaseTestSite.Log.Add(LogEntryKind.TestStep, "Connect to the SMB2 basic share by sending the following requests: NEGOTIATE; SESSION_SETUP; TREE_CONNECT.");
ConnectToShare(client, out treeId);
BaseTestSite.Log.Add(LogEntryKind.TestStep, "Construct Create packet.");
Smb2CreateRequestPacket createPacket = ConstructCreatePacket(client.SessionId, treeId, fileName);
BaseTestSite.Log.Add(LogEntryKind.TestStep, "Construct Write packet, flag FLAGS_RELATED_OPERATIONS is set.");
Smb2WriteRequestPacket writePacket = ConstructRelatedWritePacket();
BaseTestSite.Log.Add(LogEntryKind.TestStep, "Construct Close packet, flag FLAGS_RELATED_OPERATIONS is set.");
Smb2CloseRequestPacket closePacket = ConstructRelatedClosePacket();
BaseTestSite.Log.Add(LogEntryKind.TestStep, "Send {0}compounded Create, Write and Close requests to SUT.", isEncrypted ? "encrypted " : "");
List<Smb2SinglePacket> requestPackets = new List<Smb2SinglePacket>();
requestPackets.Add(createPacket);
requestPackets.Add(writePacket);
requestPackets.Add(closePacket);
if (isEncrypted)
{
// Enable encryption
client.EnableSessionSigningAndEncryption(enableSigning: testConfig.SendSignedRequest, enableEncryption: true);
}
List<Smb2SinglePacket> responsePackets = client.SendAndReceiveCompoundPacket(requestPackets);
BaseTestSite.Log.Add(LogEntryKind.TestStep, "Verify responses to the compounded request.");
foreach (var responsePacket in responsePackets)
{
if (TestConfig.Platform == Platform.WindowsServer2016 && responsePacket.Header.Status != Smb2Status.STATUS_SUCCESS)
{
}
else
{
BaseTestSite.Assert.AreEqual(
Smb2Status.STATUS_SUCCESS,
responsePacket.Header.Status,
"{0} should succeed, actual status is {1}", responsePacket.Header.Command, Smb2Status.GetStatusCode(responsePacket.Header.Status));
}
}
client.TreeDisconnect(treeId);
client.LogOff();
client.Disconnect();
}