예제 #1
0
파일: SCTPPacket.cs 프로젝트: sgf/SCTP
        /// <summary>
        /// Checks the CRC of the incomming packet
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="offset"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        private static bool CheckCRC(byte[] buffer, int offset, int count)
        {
            uint packetCrc = BitConverter.ToUInt32(buffer, offset + 8);

            for (int i = offset + 8; i < offset + 12; i++)
            {
                buffer[i] = 0;
            }

            uint crc = CRC32c.GetCRC(buffer, offset, count);

            return(packetCrc == crc);
        }
예제 #2
0
파일: SCTPPacket.cs 프로젝트: sgf/SCTP
        /// <summary>
        /// Updates the packets CRC.
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="offset"></param>
        /// <param name="count"></param>
        private void UpdateCRC(byte[] buffer, int offset, int count)
        {
            uint crc = CRC32c.GetCRC(buffer, offset, count);

            Buffer.BlockCopy(BitConverter.GetBytes(crc), 0, buffer, offset + 8, 4);
        }