/** @file\r
Help functions to access UDP service, it is used by both the DHCP and MTFTP.\r
- \r
+\r
Copyright (c) 2005 - 2009, Intel Corporation.<BR>\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
} else {\r
ASSERT (FALSE);\r
}\r
- \r
+\r
FreePool (TxToken);\r
}\r
\r
gBS->CloseEvent (RxToken->Token.Udp6.Event);\r
} else {\r
ASSERT (FALSE);\r
- } \r
+ }\r
\r
FreePool (RxToken);\r
}\r
\r
/**\r
The callback function when the packet is sent by UDP.\r
- \r
+\r
It will remove the packet from the local list then call\r
the packet owner's callback function set by UdpIoSendDatagram.\r
\r
ASSERT (TxToken->Signature == UDP_IO_TX_SIGNATURE);\r
ASSERT ((TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||\r
(TxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));\r
- \r
+\r
RemoveEntryList (&TxToken->Link);\r
\r
if (TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {\r
\r
/**\r
Request UdpIoOnDgramSentDpc as a DPC at TPL_CALLBACK.\r
- \r
+\r
@param[in] Event The event signaled.\r
@param[in] Context The UDP TX Token.\r
\r
UdpIoRecycleDgram (\r
IN VOID *Context\r
)\r
-{ \r
+{\r
UDP_RX_TOKEN *RxToken;\r
\r
RxToken = (UDP_RX_TOKEN *) Context;\r
\r
/**\r
The event handle for UDP receive request.\r
- \r
+\r
It will build a NET_BUF from the recieved UDP data, then deliver it\r
to the receiver.\r
\r
\r
ZeroMem (&EndPoint, sizeof(UDP_END_POINT));\r
\r
- ASSERT ((RxToken->Signature == UDP_IO_RX_SIGNATURE) && \r
+ ASSERT ((RxToken->Signature == UDP_IO_RX_SIGNATURE) &&\r
(RxToken == RxToken->UdpIo->RecvRequest));\r
\r
ASSERT ((RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||\r
// Build a NET_BUF from the UDP receive data, then deliver it up.\r
//\r
if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {\r
- \r
+\r
Netbuf = NetbufFromExt (\r
(NET_FRAGMENT *)((EFI_UDP4_RECEIVE_DATA *) RxData)->FragmentTable,\r
((EFI_UDP4_RECEIVE_DATA *) RxData)->FragmentCount,\r
EndPoint.LocalAddr.Addr[0] = NTOHL (EndPoint.LocalAddr.Addr[0]);\r
EndPoint.RemoteAddr.Addr[0] = NTOHL (EndPoint.RemoteAddr.Addr[0]);\r
} else {\r
- \r
+\r
Netbuf = NetbufFromExt (\r
(NET_FRAGMENT *)((EFI_UDP6_RECEIVE_DATA *) RxData)->FragmentTable,\r
((EFI_UDP6_RECEIVE_DATA *) RxData)->FragmentCount,\r
UdpIoRecycleDgram,\r
RxToken\r
);\r
- \r
+\r
if (Netbuf == NULL) {\r
gBS->SignalEvent (((EFI_UDP6_RECEIVE_DATA *) RxData)->RecycleSignal);\r
RxToken->CallBack (NULL, NULL, EFI_OUT_OF_RESOURCES, RxToken->Context);\r
- \r
+\r
UdpIoFreeRxToken (RxToken);\r
return;\r
}\r
- \r
+\r
Session = &((EFI_UDP6_RECEIVE_DATA *) RxData)->UdpSession;\r
EndPoint.LocalPort = ((EFI_UDP6_SESSION_DATA *) Session)->DestinationPort;\r
EndPoint.RemotePort = ((EFI_UDP6_SESSION_DATA *) Session)->SourcePort;\r
- \r
+\r
CopyMem (\r
&EndPoint.LocalAddr,\r
&((EFI_UDP6_SESSION_DATA *) Session)->DestinationAddress,\r
&Token->Token.Udp4.Event\r
);\r
} else {\r
- \r
+\r
Token->Token.Udp6.Status = EFI_NOT_READY;\r
Token->Token.Udp6.Packet.RxData = NULL;\r
\r
Token,\r
&Token->Token.Udp6.Event\r
);\r
- } \r
+ }\r
\r
\r
if (EFI_ERROR (Status)) {\r
@param[in] CallBack The function to call when transmission completed.\r
@param[in] Context The opaque parameter to the call back.\r
\r
- @return The wrapped transmission request or NULL if failed to allocate resources \r
+ @return The wrapped transmission request or NULL if failed to allocate resources\r
or for some errors.\r
\r
**/\r
EFI_STATUS Status;\r
UINT32 Count;\r
UINTN Size;\r
- IP4_ADDR Ip; \r
+ IP4_ADDR Ip;\r
\r
ASSERT (Packet != NULL);\r
ASSERT ((UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||\r
if (EndPoint != NULL) {\r
Ip = HTONL (EndPoint->LocalAddr.Addr[0]);\r
CopyMem (\r
- &TxToken->Session.Udp4.SourceAddress, \r
- &Ip, \r
+ &TxToken->Session.Udp4.SourceAddress,\r
+ &Ip,\r
sizeof (EFI_IPv4_ADDRESS)\r
);\r
\r
Ip = HTONL (EndPoint->RemoteAddr.Addr[0]);\r
CopyMem (\r
- &TxToken->Session.Udp4.DestinationAddress, \r
- &Ip, \r
+ &TxToken->Session.Udp4.DestinationAddress,\r
+ &Ip,\r
sizeof (EFI_IPv4_ADDRESS)\r
);\r
\r
if (Gateway != NULL && (Gateway->Addr[0] != 0)) {\r
Ip = HTONL (Gateway->Addr[0]);\r
CopyMem (&TxToken->Gateway, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
- ((EFI_UDP4_TRANSMIT_DATA *) Data)->GatewayAddress = &TxToken->Gateway; \r
+ ((EFI_UDP4_TRANSMIT_DATA *) Data)->GatewayAddress = &TxToken->Gateway;\r
}\r
\r
} else {\r
- \r
+\r
((EFI_UDP6_COMPLETION_TOKEN *) Token)->Status = EFI_NOT_READY;\r
- \r
+\r
Status = gBS->CreateEvent (\r
EVT_NOTIFY_SIGNAL,\r
TPL_NOTIFY,\r
FreePool (TxToken);\r
return NULL;\r
}\r
- \r
+\r
Data = &(TxToken->Data.Udp6);\r
((EFI_UDP6_COMPLETION_TOKEN *) Token)->Packet.TxData = Data;\r
((EFI_UDP6_TRANSMIT_DATA *) Data)->UdpSessionData = NULL;\r
\r
if (EndPoint != NULL) {\r
CopyMem (\r
- &TxToken->Session.Udp6.SourceAddress, \r
- &EndPoint->LocalAddr.v6, \r
+ &TxToken->Session.Udp6.SourceAddress,\r
+ &EndPoint->LocalAddr.v6,\r
sizeof(EFI_IPv6_ADDRESS)\r
);\r
\r
CopyMem (\r
- &TxToken->Session.Udp6.DestinationAddress, \r
- &EndPoint->RemoteAddr.v6, \r
+ &TxToken->Session.Udp6.DestinationAddress,\r
+ &EndPoint->RemoteAddr.v6,\r
sizeof(EFI_IPv6_ADDRESS)\r
);\r
\r
TxToken->Session.Udp6.SourcePort = EndPoint->LocalPort;\r
TxToken->Session.Udp6.DestinationPort = EndPoint->RemotePort;\r
((EFI_UDP6_TRANSMIT_DATA *) Data)->UdpSessionData = &(TxToken->Session.Udp6);\r
- } \r
+ }\r
}\r
\r
return TxToken;\r
/**\r
Creates a UDP_IO to access the UDP service. It creates and configures\r
a UDP child.\r
- \r
- This function:\r
- # locates the UDP service binding prototype on the Controller parameter\r
- # uses the UDP service binding prototype to create a UDP child (also known as a UDP instance)\r
- # configures the UDP child by calling Configure function prototype. \r
- Any failures in creating or configuring the UDP child return NULL for failure. \r
+\r
+ It locates the UDP service binding prototype on the Controller parameter\r
+ uses the UDP service binding prototype to create a UDP child (also known as\r
+ a UDP instance) configures the UDP child by calling Configure function prototype.\r
+ Any failures in creating or configuring the UDP child return NULL for failure.\r
\r
@param[in] Controller The controller that has the UDP service binding.\r
protocol installed.\r
&gEfiUdp4ServiceBindingProtocolGuid,\r
&UdpIo->UdpHandle\r
);\r
- \r
+\r
if (EFI_ERROR (Status)) {\r
goto FREE_MEM;\r
}\r
if (EFI_ERROR (Configure (UdpIo, Context))) {\r
goto CLOSE_PROTOCOL;\r
}\r
- \r
+\r
Status = UdpIo->Protocol.Udp4->GetModeData (\r
- UdpIo->Protocol.Udp4, \r
- NULL, \r
- NULL, \r
- NULL, \r
+ UdpIo->Protocol.Udp4,\r
+ NULL,\r
+ NULL,\r
+ NULL,\r
&UdpIo->SnpMode\r
);\r
- \r
+\r
if (EFI_ERROR (Status)) {\r
goto CLOSE_PROTOCOL;\r
}\r
\r
} else {\r
- \r
+\r
Status = NetLibCreateServiceChild (\r
Controller,\r
ImageHandle,\r
&gEfiUdp6ServiceBindingProtocolGuid,\r
&UdpIo->UdpHandle\r
);\r
- \r
+\r
if (EFI_ERROR (Status)) {\r
goto FREE_MEM;\r
}\r
- \r
+\r
Status = gBS->OpenProtocol (\r
UdpIo->UdpHandle,\r
&gEfiUdp6ProtocolGuid,\r
Controller,\r
EFI_OPEN_PROTOCOL_BY_DRIVER\r
);\r
- \r
+\r
if (EFI_ERROR (Status)) {\r
goto FREE_CHILD;\r
}\r
- \r
+\r
if (EFI_ERROR (Configure (UdpIo, Context))) {\r
goto CLOSE_PROTOCOL;\r
}\r
- \r
+\r
Status = UdpIo->Protocol.Udp6->GetModeData (\r
- UdpIo->Protocol.Udp6, \r
- NULL, \r
- NULL, \r
- NULL, \r
+ UdpIo->Protocol.Udp6,\r
+ NULL,\r
+ NULL,\r
+ NULL,\r
&UdpIo->SnpMode\r
);\r
- \r
+\r
if (EFI_ERROR (Status)) {\r
goto CLOSE_PROTOCOL;\r
}\r
UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &TxToken->Token.Udp6);\r
}\r
}\r
- } \r
+ }\r
}\r
\r
/**\r
Free the UDP_IO and all its related resources.\r
- \r
+\r
The function will cancel all sent datagram and receive request.\r
\r
@param[in] UdpIo The UDP_IO to free.\r
if ((RxToken = UdpIo->RecvRequest) != NULL) {\r
UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &RxToken->Token.Udp6);\r
}\r
- \r
+\r
//\r
// Close then destory the Udp6 child\r
//\r
UdpIo->Image,\r
UdpIo->Controller\r
);\r
- \r
+\r
NetLibDestroyServiceChild (\r
UdpIo->Controller,\r
UdpIo->Image,\r
/**\r
Clean up the UDP_IO without freeing it. The function is called when\r
user wants to re-use the UDP_IO later.\r
- \r
+\r
It will release all the transmitted datagrams and receive request. It will\r
also configure NULL for the UDP instance.\r
\r
\r
/**\r
Send a packet through the UDP_IO.\r
- \r
+\r
The packet will be wrapped in UDP_TX_TOKEN. Function Callback will be called\r
when the packet is sent. The optional parameter EndPoint overrides the default\r
address pair if specified.\r
@param[in] Packet The packet to send.\r
@param[in] EndPoint The local and remote access point. Override the\r
default address pair set during configuration.\r
- @param[in] Gateway The gateway to use. \r
+ @param[in] Gateway The gateway to use.\r
@param[in] CallBack The function being called when packet is\r
transmitted or failed.\r
@param[in] Context The opaque parameter passed to CallBack.\r
\r
/**\r
Issue a receive request to the UDP_IO.\r
- \r
+\r
This function is called when upper-layer needs packet from UDP for processing.\r
Only one receive request is acceptable at a time so a common usage model is\r
to invoke this function inside its Callback function when the former packet\r