The PccrrBLKLISTResponsePacket is sent by the server.
Inheritance: PccrrPacket
        /// <summary>
        /// Decode pack.
        /// </summary>
        /// <param name="rawdata">The rawdata.</param>
        /// <returns>The PccrrPacket.</returns>
        public override PccrrPacket Decode(byte[] rawdata)
        {
            if (rawdata == null)
            {
                throw new ArgumentNullException("rawdata");
            }

            if (rawdata.Length == 0)
            {
                throw new ArgumentException("The raw data should not be empty.");
            }

            PccrrBLKLISTResponsePacket packet = new PccrrBLKLISTResponsePacket();

            return(packet);
        }
示例#2
0
        /// <summary>
        /// Create a MsgBlkList response.
        /// </summary>
        /// <param name="segmentId">The segmentId.</param>
        /// <param name="blockRanges">The blockRanges.</param>
        /// <param name="nextBlockIndex">The nextBlockIndex.</param>
        /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param>
        /// <param name="msgTypeValues">The msgType.</param>
        /// <returns>The MsgBlkList response.</returns>
        public PccrrBLKLISTResponsePacket CreateMsgBlkListResponse(
            byte[] segmentId,
            BLOCK_RANGE[] blockRanges,
            uint nextBlockIndex,
            CryptoAlgoId_Values cryptoAlgoIdValues,
            MsgType_Values msgTypeValues)
        {
            if (segmentId == null)
            {
                segmentId = new byte[0];
            }

            if (blockRanges == null)
            {
                blockRanges = new BLOCK_RANGE[0];
            }

            PccrrBLKLISTResponsePacket packet = new PccrrBLKLISTResponsePacket();

            MSG_BLKLIST msgBlkListResp = new MSG_BLKLIST();

            byte[] zeroPad = new byte[0] {
            };
            msgBlkListResp.ZeroPad         = zeroPad;
            msgBlkListResp.SizeOfSegmentId = (uint)segmentId.Length;
            msgBlkListResp.SegmentId       = segmentId;
            msgBlkListResp.BlockRanges     = blockRanges;
            msgBlkListResp.BlockRangeCount = (uint)blockRanges.Length;
            msgBlkListResp.NextBlockIndex  = nextBlockIndex;
            MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion {
                MajorVersion = 1, MinorVersion = 0
            });

            packet.MsgBLKLIST    = msgBlkListResp;
            packet.MessageHeader = messageHeader;

            return(packet);
        }
示例#3
0
        /// <summary>
        /// Decode response message.
        /// </summary>
        /// <param name="rawdata">The raw data.</param>
        /// <returns>The PccrrPacket.</returns>
        public PccrrPacket DecodeResponseMessage(byte[] rawdata)
        {
            if (rawdata == null)
            {
                throw new ArgumentNullException("rawdata");
            }

            if (rawdata.Length == 0)
            {
                throw new ArgumentException("The raw data should not be empty.");
            }

            int messageLength = 0;

            messageLength = rawdata.Length;

            PccrrPacket packet = null;

            if (messageLength > 0)
            {
                int index = 0;

                RESPONSE_MESSAGE ret = new RESPONSE_MESSAGE();
                ret.TRANSPORTRESPONSEHEADER.Size = MarshalHelper.GetUInt32(rawdata, ref index, false);
                ret.MESSAGEHEADER = this.DecodeMessageHeader(rawdata, ref index);

                switch (ret.MESSAGEHEADER.MsgType)
                {
                case MsgType_Values.MSG_BLKLIST:
                    PccrrBLKLISTResponsePacket pccrrBLKLISTResponsePacket = new PccrrBLKLISTResponsePacket();

                    MSG_BLKLIST msgBLKLIST = this.DecodeMSG_BLKLIST(rawdata, ref index);
                    pccrrBLKLISTResponsePacket.TransportResponseHeader = ret.TRANSPORTRESPONSEHEADER;
                    pccrrBLKLISTResponsePacket.MsgBLKLIST    = msgBLKLIST;
                    pccrrBLKLISTResponsePacket.MessageHeader = ret.MESSAGEHEADER;
                    packet = pccrrBLKLISTResponsePacket;
                    break;

                case MsgType_Values.MSG_BLK:
                    PccrrBLKResponsePacket pccrrBLKResponsePacket = new PccrrBLKResponsePacket();

                    MSG_BLK msgBLK = this.DecodeMSG_BLK(rawdata, ref index);
                    pccrrBLKResponsePacket.TransportResponseHeader = ret.TRANSPORTRESPONSEHEADER;
                    pccrrBLKResponsePacket.MsgBLK        = msgBLK;
                    pccrrBLKResponsePacket.MessageHeader = ret.MESSAGEHEADER;
                    packet = pccrrBLKResponsePacket;
                    break;

                case MsgType_Values.MSG_NEGO_RESP:
                    PccrrNegoResponsePacket pccrrNegoResponsePacket = new PccrrNegoResponsePacket();

                    MSG_NEGO_RESP msgNEGORESP = this.DecodeMSG_NEGO_RESP(rawdata, ref index);
                    pccrrNegoResponsePacket.TransportResponseHeader = ret.TRANSPORTRESPONSEHEADER;
                    pccrrNegoResponsePacket.MsgNegoResp             = msgNEGORESP;
                    pccrrNegoResponsePacket.MessageHeader           = ret.MESSAGEHEADER;
                    packet = pccrrNegoResponsePacket;
                    break;

                case MsgType_Values.MSG_SEGLIST:
                    PccrrSegListResponsePacket pccrrSegListResponsePacket = new PccrrSegListResponsePacket();
                    pccrrSegListResponsePacket.MsgSegList = TypeMarshal.ToStruct <MSG_SEGLIST>(rawdata, ref index);
                    pccrrSegListResponsePacket.TransportResponseHeader = ret.TRANSPORTRESPONSEHEADER;
                    pccrrSegListResponsePacket.MessageHeader           = ret.MESSAGEHEADER;
                    packet = pccrrSegListResponsePacket;
                    break;
                }
            }

            return(packet);
        }
        /// <summary>
        /// Decode response message.
        /// </summary>
        /// <param name="rawdata">The raw data.</param>
        /// <returns>The PccrrPacket.</returns>
        public PccrrPacket DecodeResponseMessage(byte[] rawdata)
        {
            if (rawdata == null)
            {
                throw new ArgumentNullException("rawdata");
            }

            if (rawdata.Length == 0)
            {
                throw new ArgumentException("The raw data should not be empty.");
            }

            int messageLength = 0;

            messageLength = rawdata.Length;

            PccrrPacket packet = null;

            if (messageLength > 0)
            {
                int index = 0;

                RESPONSE_MESSAGE ret = new RESPONSE_MESSAGE();
                ret.TRANSPORTRESPONSEHEADER.Size = MarshalHelper.GetUInt32(rawdata, ref index, false);
                ret.MESSAGEHEADER = this.DecodeMessageHeader(rawdata, ref index);

                switch (ret.MESSAGEHEADER.MsgType)
                {
                    case MsgType_Values.MSG_BLKLIST:
                        PccrrBLKLISTResponsePacket pccrrBLKLISTResponsePacket = new PccrrBLKLISTResponsePacket();

                        MSG_BLKLIST msgBLKLIST = this.DecodeMSG_BLKLIST(rawdata, ref index);
                        pccrrBLKLISTResponsePacket.TransportResponseHeader = ret.TRANSPORTRESPONSEHEADER;
                        pccrrBLKLISTResponsePacket.MsgBLKLIST = msgBLKLIST;
                        pccrrBLKLISTResponsePacket.MessageHeader = ret.MESSAGEHEADER;
                        packet = pccrrBLKLISTResponsePacket;
                        break;
                    case MsgType_Values.MSG_BLK:
                        PccrrBLKResponsePacket pccrrBLKResponsePacket = new PccrrBLKResponsePacket();

                        MSG_BLK msgBLK = this.DecodeMSG_BLK(rawdata, ref index);
                        pccrrBLKResponsePacket.TransportResponseHeader = ret.TRANSPORTRESPONSEHEADER;
                        pccrrBLKResponsePacket.MsgBLK = msgBLK;
                        pccrrBLKResponsePacket.MessageHeader = ret.MESSAGEHEADER;
                        packet = pccrrBLKResponsePacket;
                        break;
                    case MsgType_Values.MSG_NEGO_RESP:
                        PccrrNegoResponsePacket pccrrNegoResponsePacket = new PccrrNegoResponsePacket();

                        MSG_NEGO_RESP msgNEGORESP = this.DecodeMSG_NEGO_RESP(rawdata, ref index);
                        pccrrNegoResponsePacket.TransportResponseHeader = ret.TRANSPORTRESPONSEHEADER;
                        pccrrNegoResponsePacket.MsgNegoResp = msgNEGORESP;
                        pccrrNegoResponsePacket.MessageHeader = ret.MESSAGEHEADER;
                        packet = pccrrNegoResponsePacket;
                        break;

                    case MsgType_Values.MSG_SEGLIST:
                        PccrrSegListResponsePacket pccrrSegListResponsePacket = new PccrrSegListResponsePacket();
                        pccrrSegListResponsePacket.MsgSegList = TypeMarshal.ToStruct<MSG_SEGLIST>(rawdata, ref index);
                        pccrrSegListResponsePacket.TransportResponseHeader = ret.TRANSPORTRESPONSEHEADER;
                        pccrrSegListResponsePacket.MessageHeader = ret.MESSAGEHEADER;
                        packet = pccrrSegListResponsePacket;
                        break;
                }
            }

            return packet;
        }
        /// <summary>
        /// Create a MsgBlkList response.
        /// </summary>
        /// <param name="segmentId">The segmentId.</param>
        /// <param name="blockRanges">The blockRanges.</param>
        /// <param name="nextBlockIndex">The nextBlockIndex.</param>
        /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param>
        /// <param name="msgTypeValues">The msgType.</param>
        /// <returns>The MsgBlkList response.</returns>
        public PccrrBLKLISTResponsePacket CreateMsgBlkListResponse(
            byte[] segmentId,
            BLOCK_RANGE[] blockRanges,
            uint nextBlockIndex,
            CryptoAlgoId_Values cryptoAlgoIdValues,
            MsgType_Values msgTypeValues)
        {
            if (segmentId == null)
            {
                segmentId = new byte[0];
            }

            if (blockRanges == null)
            {
                blockRanges = new BLOCK_RANGE[0];
            }

            PccrrBLKLISTResponsePacket packet = new PccrrBLKLISTResponsePacket();

            MSG_BLKLIST msgBlkListResp = new MSG_BLKLIST();
            byte[] zeroPad = new byte[0] { };
            msgBlkListResp.ZeroPad = zeroPad;
            msgBlkListResp.SizeOfSegmentId = (uint)segmentId.Length;
            msgBlkListResp.SegmentId = segmentId;
            msgBlkListResp.BlockRanges = blockRanges;
            msgBlkListResp.BlockRangeCount = (uint)blockRanges.Length;
            msgBlkListResp.NextBlockIndex = nextBlockIndex;
            MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion { MajorVersion = 1, MinorVersion = 0 });
            packet.MsgBLKLIST = msgBlkListResp;
            packet.MessageHeader = messageHeader;

            return packet;
        }
        /// <summary>
        /// Decode pack.
        /// </summary>
        /// <param name="rawdata">The rawdata.</param>
        /// <returns>The PccrrPacket.</returns>
        public override PccrrPacket Decode(byte[] rawdata)
        {
            if (rawdata == null)
            {
                throw new ArgumentNullException("rawdata");
            }

            if (rawdata.Length == 0)
            {
                throw new ArgumentException("The raw data should not be empty.");
            }

            PccrrBLKLISTResponsePacket packet = new PccrrBLKLISTResponsePacket();

            return packet;
        }