/* This function should be called after finishing the process of mIpSec->ProcessExt() for outbound traffic. The (EFI_IPSEC2_PROTOCOL)->ProcessExt() allocates a new buffer for the ESP, so there needs a function to free the old net buffer. */
VOID NetIpSecNetbufFree(NET_BUF *Nbuf)
/* This function should be called after finishing the process of mIpSec->ProcessExt() for outbound traffic. The (EFI_IPSEC2_PROTOCOL)->ProcessExt() allocates a new buffer for the ESP, so there needs a function to free the old net buffer. */
VOID NetIpSecNetbufFree(NET_BUF *Nbuf)
{
  NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
  ASSERT (Nbuf->RefCnt > 0);
  Nbuf->RefCnt--;
  if (Nbuf->RefCnt == 0) {
    NET_CHECK_SIGNATURE (Nbuf->Vector, NET_VECTOR_SIGNATURE);
    ASSERT (Nbuf->Vector->RefCnt > 0);
    Nbuf->Vector->RefCnt--;
    if (Nbuf->Vector->RefCnt > 0) {
      return;
    }
    if ((Nbuf->Vector->Flag & NET_VECTOR_OWN_FIRST) != 0) {
      FreePool (Nbuf->Vector->Block[0].Bulk);
    }
    FreePool (Nbuf->Vector);
    FreePool (Nbuf);
  }
}