Hi,

Thanks for reporting this. We will check whether we can reproduce the issue.

Best Regards,
Ye Ting

From: Thomas Rognon [mailto:tcrog...@gmail.com]
Sent: Sunday, August 17, 2014 8:21 AM
To: edk2-devel
Subject: [edk2] TcpIoReceive question

I'm receiving a packet of unknown length and it is less than 1024 bytes. I'm 
using TcpIoReceive. I'm expecting it to receive the packet and then update the 
NET_FRAGMENT.Len to the number of bytes received. Instead, it times out.

I know the packet is being sent (I can see it on wireshark). Also, if the 
actual packet size and my buffer size match, then everything works fine. It 
only times out when the actual packet size is smaller than my buffer.

Here is example code. What am I doing wrong?

EFI_STATUS
ExampleReceive (
  IN     EXAMPLE_PRIVATE  *Private,
  IN OUT UINT32           *DataSize,
  IN OUT UINT8            *Data
  )
{
  EFI_STATUS    Status;
  NET_FRAGMENT  Fragment;
  NET_BUF       *Packet;

  Fragment.Len = *DataSize;
  Fragment.Bulk = Data;
  Packet = NetbufFromExt (
             &Fragment,
             1,
             0,
             0,
             ExampleNbufExtFree,
             NULL
             );
  if (Packet == NULL) {
    return EFI_OUT_OF_RESOURCES;
  }

  Status = gBS->SetTimer (
                  Private->RxTimeoutEvent,
                  TimerRelative,
                  5 * TICKS_PER_SECOND
                  );
  if (EFI_ERROR (Status)) {
    NetbufFree (Packet);
    return Status;
  }

  Status = TcpIoReceive (
             &Private->TcpIo,
             Packet,
             FALSE,
             Private->RxTimeoutEvent
             );

  gBS->SetTimer (Private->RxTimeoutEvent, TimerCancel, 0);
  NetbufFree (Packet);

  if (!EFI_ERROR (Status)) {
    *DataSize = Fragment.Len;
  }

  return Status;
}

If the incoming packet is 1024 bytes, then the following code will work as 
expected. If the incoming packet is less than 1024 bytes, then it will return 
EFI_TIMEOUT after 5 seconds.

DataSize = 1024; // this number is arbitrary
Data = AllocatePool (DataSize);
ExampleReceive (Private, &DataSize, Data);

If I'm doing something wrong, then how would I receive a packet where I know 
the maximum size, but I don't know the exact size? I'm using 
UDK2010.SR1.UP1.P1. Thank you for any insight.

Thomas Rognon
------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to