/* The duplicated net buffer will allocate its own memory to hold the data of the source net buffer. */
NET_BUF* EFIAPI NetbufDuplicate(IN NET_BUF *Nbuf, IN OUT NET_BUF *Duplicate OPTIONAL, IN UINT32 HeadSpace)
/* The duplicated net buffer will allocate its own memory to hold the data of the source net buffer. */
NET_BUF* EFIAPI NetbufDuplicate(IN NET_BUF *Nbuf, IN OUT NET_BUF *Duplicate OPTIONAL, IN UINT32 HeadSpace)
{
  UINT8  *Dst;
  NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
  if (Duplicate == NULL) {
    Duplicate = NetbufAlloc (Nbuf->TotalSize + HeadSpace);
  }
  if (Duplicate == NULL) {
    return NULL;
  }
  CopyMem (Duplicate->ProtoData, Nbuf->ProtoData, NET_PROTO_DATA);
  NetbufReserve (Duplicate, HeadSpace);
  Dst = NetbufAllocSpace (Duplicate, Nbuf->TotalSize, NET_BUF_TAIL);
  NetbufCopy (Nbuf, 0, Nbuf->TotalSize, Dst);
  return Duplicate;
}