Beispiel #1
0
        public Bytes ExtractHead(out uint startOffset, out uint length)
        {
            if (this.Empty)
            {
                startOffset = 0;
                length      = 0;
                return(null);
            }
            TcpVectorNode candidate = this.listHead.next;
            Bytes         data      = candidate.Unlink();

            count--;
            if (data != null)
            {
                size -= candidate.length;
            }
            else
            {
                DebugStub.WriteLine("Extracthead no data??\n");
                DebugStub.Break();
                VTable.Assert(false);
            }
            startOffset = candidate.startOffset;
            length      = candidate.length;
            return(data);
        }
Beispiel #2
0
        public Bytes ExtractTail(out uint startOffset, out uint length)
        {
            if (this.Empty)
            {
                startOffset = 0;
                length      = 0;
                return(null);
            }
            TcpVectorNode candidate = this.listTail.prev;

            Bytes data = candidate.Unlink();

            count--;
            if (data != null)
            {
                size -= candidate.length;
            }
            startOffset = candidate.startOffset;
            length      = candidate.length;
            return(data);
        }
Beispiel #3
0
        public bool ReleaseDataFromTxBuffer(uint bytes)
        {
            uint totalBytes = bytes;

            if (this.Empty)
            {
                DebugStub.Print("Attempting to release {0} bytes on an empty list? size {1}\n",
                                DebugStub.ArgList(bytes, this.size));
                DebugStub.Break();
                return(false);
            }
            else if (bytes > this.size)
            {
                DebugStub.Print("Ack! attempting to release {0} bytes size {1} bytes\n", DebugStub.ArgList(bytes, this.size));
                bytes = this.size;
            }
            if (bytes > this.currentTxTotalOffset)
            {
                DebugStub.Print("ack! trying to release more than total offset??\n");
                DebugStub.Break();
            }

            TcpVectorNode candidate = this.listHead.next;

            while (bytes != 0)
            {
                if (candidate.length <= bytes)
                {
                    TcpVectorNode toFree = candidate;
                    candidate  = candidate.next;
                    bytes      = bytes - toFree.length;
                    this.size -= toFree.length;
                    if (this.currentTxBuff == toFree)
                    {
                        this.currentTxBuff         = null;
                        this.currentTxBufferOffset = 0;
                    }
                    Bytes data = toFree.Unlink();
                    this.count--;
                    if (data != null)
                    {
                        //delete data;
                    }
                }
                else
                {
                    candidate.TrimStart(bytes);
                    //this happens when some packets being retransmitted are
                    //acknowledged during retransmission.
                    if ((candidate == this.currentTxBuff) &&
                        (candidate.startOffset > this.currentTxBufferOffset))
                    {
                        DebugStub.WriteLine("startoffset was {0} now {1} current offset {2} totalBytes to Free {3}\n",
                                            DebugStub.ArgList((candidate.startOffset - bytes), candidate.startOffset,
                                                              this.currentTxBufferOffset, totalBytes));
                        this.currentTxBufferOffset = candidate.startOffset;
                    }

                    this.size -= bytes;
                    bytes      = 0;
                }
            }
            if (this.Empty)
            {
                return(false);
            }
            return(true);
        }