protected virtual void HandlePccrrGETBLKLISTRequestPacket(PccrrGETBLKLISTRequestPacket pccrrGetBlkListRequest)
        {
            var pccrrBLKLISTResponsePacket = pccrrServer.CreateMsgBlkListResponse(
                pccrrGetBlkListRequest.MsgGetBLKLIST.SegmentID,
                pccrrGetBlkListRequest.MsgGetBLKLIST.NeededBlockRanges,
                0,
                cryptoAlgoId,
                MsgType_Values.MSG_BLKLIST);

            pccrrServer.SendPacket(pccrrBLKLISTResponsePacket);
        }
Esempio n. 2
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>
        /// The handle of MessageArrivedEventArgs happened.
        /// </summary>
        /// <param name="remoteAddr">Represents the remote endpoint address</param>
        /// <param name="pccrrPacket">The received pccrrPacket, used to judge whether
        /// it is a PccrrGETBLKLISTRequestPacket</param>
        private void RetrievalTransport_Receive(IPEndPoint remoteAddr, PccrrPacket pccrrPacket)
        {
            if (pccrrPacket.PacketType == MsgType_Values.MSG_GETBLKLIST)
            {
                PccrrGETBLKLISTRequestPacket package = (PccrrGETBLKLISTRequestPacket)pccrrPacket;

                int    port      = package.Uri.Port;
                byte[] segmentID = package.MsgGetBLKLIST.SegmentID;
                this.ReceivePccrrRequestHandler(this, new ReceivedPccrrRequestEventArg(port, segmentID));
            }
            else if (pccrrPacket.PacketType == MsgType_Values.MSG_GETBLKS)
            {
                PccrrGETBLKSRequestPacket package = (PccrrGETBLKSRequestPacket)pccrrPacket;

                int    port      = package.Uri.Port;
                byte[] segmentID = package.MsgGetBLKS.SegmentID;
                this.ReceivePccrrRequestHandler(this, new ReceivedPccrrRequestEventArg(port, segmentID));
            }
        }