コード例 #1
0
ファイル: SelectiveAckChunk.cs プロジェクト: sipsorcery/SCTP
 /// <summary>
 /// Adds a Gap Ack Block.
 /// </summary>
 /// <param name="block">The gap ack block.</param>
 public void AddGapAckBlock(GapAckBlock block)
 {
     if (this.GapAckBlocks == null)
     {
         this.GapAckBlocks = new List <GapAckBlock>();
     }
     this.GapAckBlocks.Add(block);
 }
コード例 #2
0
ファイル: SelectiveAckChunk.cs プロジェクト: sipsorcery/SCTP
        /// <summary>
        /// Reads the chunk from a byte array.
        /// </summary>
        /// <param name="buffer">The byte array.</param>
        /// <param name="offset">The offset at which to start reading the chunk.</param>
        /// <param name="length">The number of bytes that make up the chunk..</param>
        /// <returns>The number of bytes read.</returns>
        protected override int FromBuffer(byte[] buffer, int offset, int length)
        {
            int start = offset;

            this.CumulativeTSNAck = NetworkHelpers.ToUInt32(buffer, offset);
            offset += 4;
            this.AdvertisedReceiverWindowCredit = NetworkHelpers.ToUInt32(buffer, offset);
            offset += 4;
            int numberOfGapAckBlocks = (int)NetworkHelpers.ToUInt16(buffer, offset);

            offset += 2;
            int numberOfDuplicateTSNs = (int)NetworkHelpers.ToUInt16(buffer, offset);

            offset += 2;

            for (int i = 0; i < numberOfGapAckBlocks; i++)
            {
                if (this.GapAckBlocks == null)
                {
                    this.GapAckBlocks = new List <GapAckBlock>(numberOfGapAckBlocks);
                }

                GapAckBlock block = new GapAckBlock();
                block.GapAckBlockStart = NetworkHelpers.ToUInt16(buffer, offset);
                offset += 2;
                block.GapAckBlockEnd = NetworkHelpers.ToUInt16(buffer, offset);
                offset += 2;

                this.AddGapAckBlock(block);
            }

            for (int i = 0; i < numberOfDuplicateTSNs; i++)
            {
                if (this.DuplicateTSNs == null)
                {
                    this.DuplicateTSNs = new List <uint>(numberOfDuplicateTSNs);
                }

                this.DuplicateTSNs.Add(NetworkHelpers.ToUInt32(buffer, offset));
                offset += 4;
            }

            return(offset - start);
        }