/* Verify that the segment is in good shape. */
INTN TcpVerifySegment(IN NET_BUF *Nbuf)
/* Verify that the segment is in good shape. */
INTN TcpVerifySegment(IN NET_BUF *Nbuf)
{
  TCP_HEAD  *Head;
  TCP_SEG   *Seg;
  UINT32    Len;
  if (Nbuf == NULL) {
    return 1;
  }
  NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
  Seg  = TCPSEG_NETBUF (Nbuf);
  Len  = Nbuf->TotalSize;
  Head = Nbuf->Tcp;
  if (Head != NULL) {
    if (Head->Flag != Seg->Flag) {
      return 0;
    }
    Len -= (Head->HeadLen << 2);
  }
  if (TCP_FLG_ON (Seg->Flag, TCP_FLG_SYN)) {
    Len++;
  }
  if (TCP_FLG_ON (Seg->Flag, TCP_FLG_FIN)) {
    Len++;
  }
  if (Seg->Seq + Len != Seg->End) {
    return 0;
  }
  return 1;
}