Ejemplo n.º 1
0
        /// <summary>
        /// Verify the received message from client.
        /// </summary>
        /// <param name="remoteAddr">The remote address.</param>
        /// <param name="pccrrPacket">The pccrrPacket.</param>
        private void RetrievalTransport_Receive(IPEndPoint remoteAddr, PccrrPacket pccrrPacket)
        {
            PccrrGETBLKSRequestPacket pccrrGETBLKSRequestPacket = pccrrPacket as PccrrGETBLKSRequestPacket;

            if (pccrrGETBLKSRequestPacket != null)
            {
                MSG_GETBLKS    msgGETBLKS    = pccrrGETBLKSRequestPacket.MsgGetBLKS;
                MESSAGE_HEADER messageHEADER = pccrrGETBLKSRequestPacket.MessageHeader;
                this.sid = msgGETBLKS.SegmentID;
                REQUEST_MESSAGE requestMESSAGE = new REQUEST_MESSAGE();
                requestMESSAGE.MESSAGEBODY   = msgGETBLKS;
                requestMESSAGE.MESSAGEHEADER = messageHEADER;
                this.uiPayload = Marshal.SizeOf(messageHEADER) + Marshal.SizeOf(msgGETBLKS) + 24;

                PccrrBothRoleCaptureCode.CaptureBlockRangeRequirements(msgGETBLKS.ReqBlockRanges[0]);
                PccrrBothRoleCaptureCode.CaptureMessageHeaderRequirements(messageHEADER, this.uiPayload);
                this.VerifyGetBlocks(msgGETBLKS);
                this.VerifyRequestMessage(requestMESSAGE);
                PccrrBothRoleCaptureCode.CaptureSegmentIdRequirements(msgGETBLKS.SegmentID);
                PccrrBothRoleCaptureCode.CaptureHttpRequirements();
                PccrrBothRoleCaptureCode.CaptureMessageRequirements();

                this.ReceiveMsgGetBlk(msgGETBLKS.ReqBlockRanges[0].Index);
            }
            else
            {
                PccrrGETBLKLISTRequestPacket pccrrGETBLKLISTRequestPacket = pccrrPacket as PccrrGETBLKLISTRequestPacket;

                if (pccrrGETBLKLISTRequestPacket != null)
                {
                    MSG_GETBLKLIST msgGETBLKLIST = pccrrGETBLKLISTRequestPacket.MsgGetBLKLIST;
                    this.sid = msgGETBLKLIST.SegmentID;

                    this.VerifyGetBlkList(msgGETBLKLIST);
                    PccrrBothRoleCaptureCode.CaptureCommonDataTypesRequirements(msgGETBLKLIST);
                    _BLOCKRANGE[] blockRanges = ClientHelper.ConvertFromStackBLOCKRANGEArray(msgGETBLKLIST.NeededBlockRanges);

                    this.ReceiveMsgGetBlkList(blockRanges);
                }
                else
                {
                    this.ReceiveMsgNegoReq();
                }
            }
        }
        /// <summary>
        /// REQUEST_MESSAGE structure capture
        /// </summary>
        /// <param name="requestMessage">RequestMessage object</param>
        private void VerifyRequestMessage(REQUEST_MESSAGE requestMessage)
        {
            //
            // Add the debug information
            //
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R74");

            // Verify MS-PCCRR requirement: MS-PCCRR_R74
            Site.CaptureRequirementIfAreEqual <int>(
                16,
                Marshal.SizeOf(requestMessage.MESSAGEHEADER),
                74,
                @"[In Request Message]MESSAGE_HEADER (16 bytes):  Message header.");

            //
            // Add the debug information
            //
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R75");

            // Verify MS-PCCRR requirement: MS-PCCRR_R75
            bool isVerifyR75 = requestMessage.MESSAGEBODY is MSG_GETBLKLIST ||
                               requestMessage.MESSAGEBODY is MSG_GETBLKS;

            Site.CaptureRequirementIfIsTrue(
                isVerifyR75,
                75,
                @"[In Request Message]MESSAGE_BODY (variable):  Message body, which contains either a GetBlockList 
                (MSG_GETBLKLIST) or GetBlocks (MSG_GETBLKS) request message.");

            // MS-PCCRR_R74 and MS-PCCRR_R75 have been verified it successfully, so capture it directly.
            Site.CaptureRequirement(
                73,
                @"[In Request Message]The complete layout of a request-type Peer Content Caching and Retrieval: 
                Retrieval Protocol message is as follows [MESSAGE_HEADER,MESSAGE_BODY (variable)].");

            //
            // Add the debug information
            //
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R13");

            // Since the request parsed by stack layer properly, capture the requirement directly.
            Site.CaptureRequirement(
                13,
                @"[In Peer Download Transport]The initiating/client-role peer P1 at IP address A1 initiates 
                the transport of a given request-type Peer Retrieval Protocol message to peer P2 at 
                IP address A2, by sending an HTTP POST request to the root path of 
                {116B50EB-ECE2-41ac-8429-9F9E963361B7}/.");

            //
            // Add the debug information
            //
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R225");

            // Since the message parsed by stack layer properly, capture the requirement directly.
            Site.CaptureRequirement(
                225,
                @"[In MSG_NEGO_RESP Received][The rules for determining compatibility and selecting a version 
                are listed below:1.]In both cases[MSG_NEGO_REQ and MSG_NEGO_RESP messages], 
                they[MSG_NEGO_REQ and MSG_NEGO_RESP messages] are defined as the inclusive range between 
                the major version from the MinSupportedProtocolVersion field and the major version from 
                the MaxSupportedProtocolVersion field.");
        }