32 if (TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
33 gBS->CloseEvent (TxToken->Token.Udp4.Event);
34 }
else if (TxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION) {
35 gBS->CloseEvent (TxToken->Token.Udp6.Event);
54 if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
55 gBS->CloseEvent (RxToken->Token.Udp4.Event);
56 }
else if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION) {
57 gBS->CloseEvent (RxToken->Token.Udp6.Event);
83 ASSERT (TxToken->Signature == UDP_IO_TX_SIGNATURE);
85 (TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
86 (TxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
91 if (TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
92 TxToken->CallBack (TxToken->Packet,
NULL, TxToken->Token.Udp4.Status, TxToken->Context);
94 TxToken->CallBack (TxToken->Packet,
NULL, TxToken->Token.Udp6.
Status, TxToken->Context);
136 if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
137 gBS->SignalEvent (RxToken->Token.Udp4.Packet.RxData->RecycleSignal);
138 }
else if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION) {
176 (RxToken == RxToken->UdpIo->RecvRequest)
180 (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
181 (RxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
188 RxToken->UdpIo->RecvRequest =
NULL;
190 if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
191 Token = &RxToken->Token.Udp4;
195 Token = &RxToken->Token.Udp6;
200 if (EFI_ERROR (Status) || (RxData ==
NULL)) {
201 if (Status != EFI_ABORTED) {
205 RxToken->CallBack (
NULL,
NULL, Status, RxToken->Context);
215 if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
227 (UINT32)RxToken->HeadLen,
232 if (Netbuf ==
NULL) {
234 RxToken->CallBack (
NULL,
NULL, EFI_OUT_OF_RESOURCES, RxToken->Context);
251 &EndPoint.RemoteAddr,
256 EndPoint.LocalAddr.Addr[0] = NTOHL (EndPoint.LocalAddr.Addr[0]);
257 EndPoint.RemoteAddr.Addr[0] = NTOHL (EndPoint.RemoteAddr.Addr[0]);
270 (UINT32)RxToken->HeadLen,
275 if (Netbuf ==
NULL) {
277 RxToken->CallBack (
NULL,
NULL, EFI_OUT_OF_RESOURCES, RxToken->Context);
294 &EndPoint.RemoteAddr,
303 RxToken->CallBack (Netbuf, &EndPoint,
EFI_SUCCESS, RxToken->Context);
307 if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
309 RxToken->UdpIo->Protocol.Udp4->Receive (RxToken->UdpIo->Protocol.Udp4, &RxToken->Token.Udp4);
312 RxToken->UdpIo->Protocol.Udp6->Receive (RxToken->UdpIo->Protocol.Udp6, &RxToken->Token.Udp6);
359 (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
360 (UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
370 Token->UdpIo = UdpIo;
371 Token->CallBack = CallBack;
372 Token->Context = Context;
373 Token->HeadLen = HeadLen;
375 if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
376 Token->Token.Udp4.Status = EFI_NOT_READY;
377 Token->Token.Udp4.Packet.RxData =
NULL;
379 Status =
gBS->CreateEvent (
384 &Token->Token.Udp4.Event
387 Token->Token.Udp6.
Status = EFI_NOT_READY;
390 Status =
gBS->CreateEvent (
395 &Token->Token.Udp6.
Event
399 if (EFI_ERROR (Status)) {
442 ASSERT (Packet !=
NULL);
444 (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
445 (UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
448 if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
456 if (TxToken ==
NULL) {
460 TxToken->Signature = UDP_IO_TX_SIGNATURE;
463 TxToken->UdpIo = UdpIo;
464 TxToken->CallBack = CallBack;
465 TxToken->Packet = Packet;
466 TxToken->Context = Context;
468 Token = &(TxToken->Token);
469 Count = Packet->BlockOpNum;
471 if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
474 Status =
gBS->CreateEvent (
482 if (EFI_ERROR (Status)) {
487 Data = &(TxToken->Data.Udp4);
502 if (EndPoint !=
NULL) {
503 Ip = HTONL (EndPoint->LocalAddr.Addr[0]);
505 &TxToken->Session.Udp4.SourceAddress,
510 Ip = HTONL (EndPoint->RemoteAddr.Addr[0]);
512 &TxToken->Session.Udp4.DestinationAddress,
517 TxToken->Session.Udp4.SourcePort = EndPoint->LocalPort;
518 TxToken->Session.Udp4.DestinationPort = EndPoint->RemotePort;
522 if ((Gateway !=
NULL) && (Gateway->Addr[0] != 0)) {
523 Ip = HTONL (Gateway->Addr[0]);
530 Status =
gBS->CreateEvent (
538 if (EFI_ERROR (Status)) {
543 Data = &(TxToken->Data.Udp6);
556 if (EndPoint !=
NULL) {
559 &EndPoint->LocalAddr.v6,
565 &EndPoint->RemoteAddr.v6,
569 TxToken->Session.Udp6.
SourcePort = EndPoint->LocalPort;
613 ASSERT (Configure !=
NULL);
614 ASSERT ((UdpVersion == UDP_IO_UDP4_VERSION) || (UdpVersion == UDP_IO_UDP6_VERSION));
622 UdpIo->UdpVersion = UdpVersion;
623 UdpIo->Signature = UDP_IO_SIGNATURE;
627 UdpIo->Controller = Controller;
628 UdpIo->Image = ImageHandle;
631 UdpIo->RecvRequest =
NULL;
632 UdpIo->UdpHandle =
NULL;
634 if (UdpVersion == UDP_IO_UDP4_VERSION) {
641 &gEfiUdp4ServiceBindingProtocolGuid,
645 if (EFI_ERROR (Status)) {
649 Status =
gBS->OpenProtocol (
651 &gEfiUdp4ProtocolGuid,
652 (VOID **)&UdpIo->Protocol.Udp4,
655 EFI_OPEN_PROTOCOL_BY_DRIVER
658 if (EFI_ERROR (Status)) {
662 if (EFI_ERROR (Configure (UdpIo, Context))) {
666 Status = UdpIo->Protocol.Udp4->GetModeData (
667 UdpIo->Protocol.Udp4,
674 if (EFI_ERROR (Status)) {
681 &gEfiUdp6ServiceBindingProtocolGuid,
685 if (EFI_ERROR (Status)) {
689 Status =
gBS->OpenProtocol (
691 &gEfiUdp6ProtocolGuid,
692 (VOID **)&UdpIo->Protocol.Udp6,
695 EFI_OPEN_PROTOCOL_BY_DRIVER
698 if (EFI_ERROR (Status)) {
702 if (EFI_ERROR (Configure (UdpIo, Context))) {
706 Status = UdpIo->Protocol.Udp6->GetModeData (
707 UdpIo->Protocol.Udp6,
714 if (EFI_ERROR (Status)) {
722 if (UdpVersion == UDP_IO_UDP4_VERSION) {
723 gBS->CloseProtocol (UdpIo->UdpHandle, &gEfiUdp4ProtocolGuid, ImageHandle, Controller);
725 gBS->CloseProtocol (UdpIo->UdpHandle, &gEfiUdp6ProtocolGuid, ImageHandle, Controller);
729 if (UdpVersion == UDP_IO_UDP4_VERSION) {
733 &gEfiUdp4ServiceBindingProtocolGuid,
740 &gEfiUdp6ServiceBindingProtocolGuid,
769 IN VOID *Context OPTIONAL
777 (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
778 (UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
781 NET_LIST_FOR_EACH_SAFE (Entry, Next, &UdpIo->SentDatagram) {
782 TxToken = NET_LIST_USER_STRUCT (Entry,
UDP_TX_TOKEN, Link);
784 if ((ToCancel ==
NULL) || (ToCancel (TxToken, Context))) {
785 if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
786 UdpIo->Protocol.Udp4->Cancel (UdpIo->Protocol.Udp4, &TxToken->Token.Udp4);
788 UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &TxToken->Token.Udp6);
817 (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
818 (UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
831 if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
832 if ((RxToken = UdpIo->RecvRequest) !=
NULL) {
833 Status = UdpIo->Protocol.Udp4->Cancel (UdpIo->Protocol.Udp4, &RxToken->Token.Udp4);
834 if (EFI_ERROR (Status)) {
842 Status =
gBS->CloseProtocol (
844 &gEfiUdp4ProtocolGuid,
848 if (EFI_ERROR (Status)) {
855 &gEfiUdp4ServiceBindingProtocolGuid,
858 if (EFI_ERROR (Status)) {
862 if ((RxToken = UdpIo->RecvRequest) !=
NULL) {
863 Status = UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &RxToken->Token.Udp6);
864 if (EFI_ERROR (Status)) {
872 Status =
gBS->CloseProtocol (
874 &gEfiUdp6ProtocolGuid,
878 if (EFI_ERROR (Status)) {
885 &gEfiUdp6ServiceBindingProtocolGuid,
888 if (EFI_ERROR (Status)) {
922 (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
923 (UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
931 if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
932 if ((RxToken = UdpIo->RecvRequest) !=
NULL) {
933 UdpIo->Protocol.Udp4->Cancel (UdpIo->Protocol.Udp4, &RxToken->Token.Udp4);
936 UdpIo->Protocol.Udp4->Configure (UdpIo->Protocol.Udp4,
NULL);
938 if ((RxToken = UdpIo->RecvRequest) !=
NULL) {
939 UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &RxToken->Token.Udp6);
942 UdpIo->Protocol.Udp6->Configure (UdpIo->Protocol.Udp6,
NULL);
984 (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
985 (UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
990 if (TxToken ==
NULL) {
991 return EFI_OUT_OF_RESOURCES;
1000 if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
1001 Status = UdpIo->Protocol.Udp4->Transmit (UdpIo->Protocol.Udp4, &TxToken->Token.Udp4);
1003 Status = UdpIo->Protocol.Udp6->Transmit (UdpIo->Protocol.Udp6, &TxToken->Token.Udp6);
1006 if (EFI_ERROR (Status)) {
1035 if (Token->Packet == Packet) {
1095 (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
1096 (UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
1099 if (UdpIo->RecvRequest !=
NULL) {
1100 return EFI_ALREADY_STARTED;
1105 if (RxToken ==
NULL) {
1106 return EFI_OUT_OF_RESOURCES;
1109 UdpIo->RecvRequest = RxToken;
1110 if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
1111 Status = UdpIo->Protocol.Udp4->Receive (UdpIo->Protocol.Udp4, &RxToken->Token.Udp4);
1113 Status = UdpIo->Protocol.Udp6->Receive (UdpIo->Protocol.Udp6, &RxToken->Token.Udp6);
1116 if (EFI_ERROR (Status)) {
1117 UdpIo->RecvRequest =
NULL;
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertHeadList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS EFIAPI QueueDpc(IN EFI_TPL DpcTpl, IN EFI_DPC_PROCEDURE DpcProcedure, IN VOID *DpcContext OPTIONAL)
VOID EFIAPI UdpIoRecycleDgram(IN VOID *Context)
UDP_RX_TOKEN * UdpIoCreateRxToken(IN UDP_IO *UdpIo, IN UDP_IO_CALLBACK CallBack, IN VOID *Context, IN UINT32 HeadLen)
VOID UdpIoFreeTxToken(IN UDP_TX_TOKEN *TxToken)
VOID UdpIoFreeRxToken(IN UDP_RX_TOKEN *RxToken)
VOID EFIAPI UdpIoOnDgramRcvdDpc(IN VOID *Context)
VOID EFIAPI UdpIoCancelSentDatagram(IN UDP_IO *UdpIo, IN NET_BUF *Packet)
VOID EFIAPI UdpIoOnDgramRcvd(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI UdpIoCleanIo(IN UDP_IO *UdpIo)
VOID EFIAPI UdpIoCancelDgrams(IN UDP_IO *UdpIo, IN EFI_STATUS IoStatus, IN UDP_IO_TO_CANCEL ToCancel OPTIONAL, IN VOID *Context OPTIONAL)
BOOLEAN EFIAPI UdpIoCancelSingleDgram(IN UDP_TX_TOKEN *Token, IN VOID *Context)
EFI_STATUS EFIAPI UdpIoRecvDatagram(IN UDP_IO *UdpIo, IN UDP_IO_CALLBACK CallBack, IN VOID *Context, IN UINT32 HeadLen)
EFI_STATUS EFIAPI UdpIoSendDatagram(IN UDP_IO *UdpIo, IN NET_BUF *Packet, IN UDP_END_POINT *EndPoint OPTIONAL, IN EFI_IP_ADDRESS *Gateway OPTIONAL, IN UDP_IO_CALLBACK CallBack, IN VOID *Context)
VOID EFIAPI UdpIoOnDgramSentDpc(IN VOID *Context)
VOID EFIAPI UdpIoOnDgramSent(IN EFI_EVENT Event, IN VOID *Context)
UDP_TX_TOKEN * UdpIoCreateTxToken(IN UDP_IO *UdpIo, IN NET_BUF *Packet, IN UDP_END_POINT *EndPoint OPTIONAL, IN EFI_IP_ADDRESS *Gateway OPTIONAL, IN UDP_IO_CALLBACK CallBack, IN VOID *Context)
EFI_STATUS EFIAPI UdpIoFreeIo(IN UDP_IO *UdpIo)
UDP_IO *EFIAPI UdpIoCreateIo(IN EFI_HANDLE Controller, IN EFI_HANDLE ImageHandle, IN UDP_IO_CONFIG Configure, IN UINT8 UdpVersion, IN VOID *Context)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI NetbufBuildExt(IN NET_BUF *Nbuf, IN OUT NET_FRAGMENT *ExtFragment, IN OUT UINT32 *ExtNum)
EFI_STATUS EFIAPI NetLibCreateServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN OUT EFI_HANDLE *ChildHandle)
EFI_IPv6_ADDRESS *EFIAPI Ip6Swap128(EFI_IPv6_ADDRESS *Ip6)
EFI_STATUS EFIAPI NetLibDestroyServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN EFI_HANDLE ChildHandle)
NET_BUF *EFIAPI NetbufFromExt(IN NET_FRAGMENT *ExtFragment, IN UINT32 ExtNum, IN UINT32 HeadSpace, IN UINT32 HeadLen, IN NET_VECTOR_EXT_FREE ExtFree, IN VOID *Arg OPTIONAL)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
#define UDP_IO_RX_SIGNATURE
EFI_STATUS(EFIAPI * UDP_IO_CONFIG)(IN UDP_IO *UdpIo, IN VOID *Context)
BOOLEAN(EFIAPI * UDP_IO_TO_CANCEL)(IN UDP_TX_TOKEN *Token, IN VOID *Context)
VOID(EFIAPI * UDP_IO_CALLBACK)(IN NET_BUF *Packet, IN UDP_END_POINT *EndPoint, IN EFI_STATUS IoStatus, IN VOID *Context)
LIST_ENTRY SentDatagram
A list of UDP_TX_TOKEN.
EFI_UDP6_RECEIVE_DATA * RxData
EFI_IPv6_ADDRESS DestinationAddress
EFI_IPv6_ADDRESS SourceAddress