Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pchc.PCHCClient.CreateSegmentInfoMessage C# (CSharp) Method

CreateSegmentInfoMessage() public method

Create SEGMENT_INFO_MESSAGE package.
public CreateSegmentInfoMessage ( int connectionInfoPort, Content_Information_Data_Structure segmentInformation ) : SEGMENT_INFO_MESSAGE
connectionInfoPort int /// A 16-bit unsigned integer that MUST be set by the client to the port /// on which it is listening as a server-role peer, for use with the retrieval protocol. ///
segmentInformation Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrc.Content_Information_Data_Structure A Content Information data structure.
return SEGMENT_INFO_MESSAGE
        public SEGMENT_INFO_MESSAGE CreateSegmentInfoMessage(
            int connectionInfoPort,
            Content_Information_Data_Structure segmentInformation)
        {
            MESSAGE_HEADER messageHeader;

            // MajorVersion (1 byte):  The major part of the version, which MUST be 0x01.
            // MinorVersion (1 byte):  The minor part of the version, which MUST be 0x00.
            // Padding (4 bytes):  The value of this field is indeterminate and MUST be ignored on processing
            messageHeader.MajorVersion = 1;
            messageHeader.MinorVersion = 0;
            messageHeader.MsgType = PCHC_MESSAGE_TYPE.SEGMENT_INFO_MESSAGE;
            messageHeader.Padding = new byte[4];
            Content_Information_Data_Structure segmentInfomation = segmentInformation;

            CONNECTION_INFORMATION connectionInfo;

            // Padding (6 bytes):  The value of this field is indeterminated and MUST be ignored on processing.
            // Port (2 bytes): A 16-bit unsigned integer that MUST be set by the client to the port on
            // which it is listening as a server-role peer, for use with the retrieval protocol.
            connectionInfo.Padding = new byte[6];
            connectionInfo.Port = (ushort)connectionInfoPort;

            // ContentTag (16 bytes):  A structure consisting of 16 bytes of opaque data.
            byte[] contentTag = new byte[16];

            SEGMENT_INFO_MESSAGE segmentInfoMessage;
            segmentInfoMessage.ConnectionInfo = connectionInfo;
            segmentInfoMessage.ContentTag = contentTag;
            segmentInfoMessage.MsgHeader = messageHeader;
            segmentInfoMessage.SegmentInfo = segmentInfomation;

            return segmentInfoMessage;
        }

Same methods

PCHCClient::CreateSegmentInfoMessage ( int connectionInfoPort, Content_Information_Data_Structure contentInformation, int segmentIndex ) : SEGMENT_INFO_MESSAGE

Usage Example

        public void HostedCacheServer_PchcServer_SegmentInfo_HashAlgoInvalid()
        {
            CheckApplicability();

            var contentInformation = contentInformationUtility.CreateContentInformationV1();

            using (var pccrrServer = new PccrrServer(testConfig.ClientContentRetrievalListenPort))
            {
                pccrrServer.StartListening();

                pccrrServer.MessageArrived += new MessageArrivedEventArgs(delegate(IPEndPoint sender, PccrrPacket pccrrPacket)
                {
                    BaseTestSite.Assert.Fail("Hosted cache server should not retrieve content information with invalid hash algorithm");
                });

                PCHCClient pchcClient = new PCHCClient(
                    TransferProtocol.HTTPS,
                    testConfig.HostedCacheServerComputerName,
                    testConfig.HostedCacheServerHTTPSListenPort,
                    PchcConsts.HttpsUrl,
                    testConfig.DomainName,
                    testConfig.UserName,
                    testConfig.UserPassword);

                var segmentInfo = pchcClient.CreateSegmentInfoMessage(
                    testConfig.ClientContentRetrievalListenPort,
                    contentInformation,
                    0);

                segmentInfo.SegmentInfo.dwHashAlgo = (dwHashAlgo_Values)0xFEFE;

                var segmentInfoResponse = pchcClient.SendSegmentInfoMessage(segmentInfo);

                BaseTestSite.Assert.AreEqual(
                    RESPONSE_CODE.OK,
                    segmentInfoResponse.ResponseCode,
                    "Hosted cache server should return OK to segment info message");

                Thread.Sleep(testConfig.NegativeTestTimeout);
            }
        }
All Usage Examples Of Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pchc.PCHCClient::CreateSegmentInfoMessage