/* Adjust the send queue or the retransmit queue. */
INTN TcpAdjustSndQue(IN TCP_CB *Tcb, IN TCP_SEQNO Ack)
/* Adjust the send queue or the retransmit queue. */
INTN TcpAdjustSndQue(IN TCP_CB *Tcb, IN TCP_SEQNO Ack)
{
  LIST_ENTRY  *Head;
  LIST_ENTRY  *Cur;
  NET_BUF     *Node;
  TCP_SEG     *Seg;
  Head = &Tcb->SndQue;
  Cur  = Head->ForwardLink;
  while (Cur != Head) {
    Node = NET_LIST_USER_STRUCT (Cur, NET_BUF, List);
    Seg  = TCPSEG_NETBUF (Node);
    if (TCP_SEQ_GEQ (Seg->Seq, Ack)) {
      break;
    }
    if (TCP_SEQ_LEQ (Seg->End, Ack)) {
      Cur = Cur->ForwardLink;
      RemoveEntryList (&Node->List);
      NetbufFree (Node);
      continue;
    }
    return TcpTrimSegment (Node, Ack, Seg->End);
  }
  return 1;
}