예제 #1
0
        internal static GranularLogDataMsg ReadFromNet(NetworkChannel ch, byte[] workingBuf, int startOffset)
        {
            int len = 52;

            ch.Read(workingBuf, startOffset, len);
            GranularLogDataMsg granularLogDataMsg = new GranularLogDataMsg();
            BufDeserializer    bufDeserializer    = new BufDeserializer(workingBuf, startOffset);

            granularLogDataMsg.FlagsUsed         = (GranularLogDataMsg.Flags)bufDeserializer.ExtractInt64();
            granularLogDataMsg.RequestAckCounter = bufDeserializer.ExtractInt64();
            granularLogDataMsg.LogDataLength     = bufDeserializer.ExtractInt32();
            if (granularLogDataMsg.LogDataLength > 1048576)
            {
                throw new NetworkCorruptDataException(ch.PartnerNodeName);
            }
            granularLogDataMsg.EmitContext                       = new JET_EMITDATACTX();
            granularLogDataMsg.EmitContext.cbLogData             = (long)granularLogDataMsg.LogDataLength;
            granularLogDataMsg.EmitContext.dwVersion             = bufDeserializer.ExtractInt32();
            granularLogDataMsg.EmitContext.qwSequenceNum         = bufDeserializer.ExtractUInt64();
            granularLogDataMsg.EmitContext.grbitOperationalFlags = (ShadowLogEmitGrbit)bufDeserializer.ExtractUInt32();
            granularLogDataMsg.EmitContext.logtimeEmit           = bufDeserializer.ExtractDateTime();
            JET_LGPOS lgposLogData = default(JET_LGPOS);

            lgposLogData.lGeneration = bufDeserializer.ExtractInt32();
            lgposLogData.isec        = (int)bufDeserializer.ExtractUInt16();
            lgposLogData.ib          = (int)bufDeserializer.ExtractUInt16();
            granularLogDataMsg.EmitContext.lgposLogData = lgposLogData;
            return(granularLogDataMsg);
        }
        internal static BlockModeCompressedDataMsg ReadFromNet(NetworkChannel ch, byte[] workingBuf, int startOffset)
        {
            int len = 52;

            ch.Read(workingBuf, startOffset, len);
            BlockModeCompressedDataMsg blockModeCompressedDataMsg = new BlockModeCompressedDataMsg();
            BufDeserializer            bufDeserializer            = new BufDeserializer(workingBuf, startOffset);

            blockModeCompressedDataMsg.FlagsUsed         = (BlockModeCompressedDataMsg.Flags)bufDeserializer.ExtractInt64();
            blockModeCompressedDataMsg.RequestAckCounter = bufDeserializer.ExtractInt64();
            blockModeCompressedDataMsg.LogDataLength     = bufDeserializer.ExtractInt32();
            if (blockModeCompressedDataMsg.LogDataLength > 1048576)
            {
                throw new NetworkCorruptDataException(ch.PartnerNodeName);
            }
            blockModeCompressedDataMsg.EmitContext                       = new JET_EMITDATACTX();
            blockModeCompressedDataMsg.EmitContext.cbLogData             = (long)blockModeCompressedDataMsg.LogDataLength;
            blockModeCompressedDataMsg.EmitContext.dwVersion             = bufDeserializer.ExtractInt32();
            blockModeCompressedDataMsg.EmitContext.qwSequenceNum         = bufDeserializer.ExtractUInt64();
            blockModeCompressedDataMsg.EmitContext.grbitOperationalFlags = (ShadowLogEmitGrbit)bufDeserializer.ExtractUInt32();
            blockModeCompressedDataMsg.EmitContext.logtimeEmit           = bufDeserializer.ExtractDateTime();
            JET_LGPOS lgposLogData = default(JET_LGPOS);

            lgposLogData.lGeneration = bufDeserializer.ExtractInt32();
            lgposLogData.isec        = (int)bufDeserializer.ExtractUInt16();
            lgposLogData.ib          = (int)bufDeserializer.ExtractUInt16();
            blockModeCompressedDataMsg.EmitContext.lgposLogData = lgposLogData;
            if (blockModeCompressedDataMsg.LogDataLength > 0)
            {
                int num = BlockModeCompressedDataMsg.CalculateBlockCount(blockModeCompressedDataMsg.LogDataLength);
                blockModeCompressedDataMsg.CompressedLengths = new int[num];
                len = num * 4;
                ch.Read(workingBuf, startOffset, len);
                bufDeserializer.Reset(workingBuf, startOffset);
                for (int i = 0; i < num; i++)
                {
                    int num2 = bufDeserializer.ExtractInt32();
                    if (num2 <= 0 || num2 > 65536)
                    {
                        throw new NetworkCorruptDataException(ch.PartnerNodeName);
                    }
                    blockModeCompressedDataMsg.CompressedLengths[i] = num2;
                }
            }
            return(blockModeCompressedDataMsg);
        }