]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c
1. Fixed one bug in Undi driver.
[mirror_edk2.git] / MdeModulePkg / Library / DxeUdpIoLib / DxeUdpIoLib.c
index b66348c284c9c7401e5f725c99c52fc7cd79cc5e..d56456afb20e59aabde2f1643e6d7c7e729dd1af 100644 (file)
@@ -30,6 +30,7 @@ Abstract:
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
+#include <library/BaseMemoryLib.h>\r
 \r
 STATIC\r
 VOID\r
@@ -77,6 +78,7 @@ UdpIoWrapTx (
   EFI_UDP4_TRANSMIT_DATA    *UdpTxData;\r
   EFI_STATUS                Status;\r
   UINT32                    Count;\r
+  IP4_ADDR                  Ip;\r
 \r
   Token = NetAllocatePool (sizeof (UDP_TX_TOKEN) +\r
                            sizeof (EFI_UDP4_FRAGMENT_DATA) * (Packet->BlockOpNum - 1));\r
@@ -116,15 +118,21 @@ UdpIoWrapTx (
   UdpTxData->GatewayAddress = NULL;\r
 \r
   if (EndPoint != NULL) {\r
-    EFI_IP4 (Token->UdpSession.SourceAddress)      = HTONL (EndPoint->LocalAddr);\r
-    EFI_IP4 (Token->UdpSession.DestinationAddress) = HTONL (EndPoint->RemoteAddr);\r
-    Token->UdpSession.SourcePort                   = EndPoint->LocalPort;\r
-    Token->UdpSession.DestinationPort              = EndPoint->RemotePort;\r
-    UdpTxData->UdpSessionData                      = &Token->UdpSession;\r
+    Ip = HTONL (EndPoint->LocalAddr);\r
+    NetCopyMem (&Token->UdpSession.SourceAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
+\r
+    Ip = HTONL (EndPoint->RemoteAddr);\r
+    NetCopyMem (&Token->UdpSession.DestinationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
+\r
+    Token->UdpSession.SourcePort      = EndPoint->LocalPort;\r
+    Token->UdpSession.DestinationPort = EndPoint->RemotePort;\r
+    UdpTxData->UdpSessionData         = &Token->UdpSession;\r
   }\r
 \r
   if (Gateway != 0) {\r
-    EFI_IP4 (Token->Gateway)  = HTONL (Gateway);\r
+    Ip = HTONL (Gateway);\r
+    NetCopyMem (&Token->Gateway, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
+\r
     UdpTxData->GatewayAddress = &Token->Gateway;\r
   }\r
 \r
@@ -670,11 +678,14 @@ UdpIoOnDgramRcvd (
   }\r
 \r
   UdpSession        = &UdpRxData->UdpSession;\r
-  Points.LocalAddr  = EFI_NTOHL (UdpSession->DestinationAddress);\r
   Points.LocalPort  = UdpSession->DestinationPort;\r
-  Points.RemoteAddr = EFI_NTOHL (UdpSession->SourceAddress);\r
   Points.RemotePort = UdpSession->SourcePort;\r
 \r
+  NetCopyMem (&Points.LocalAddr, &UdpSession->DestinationAddress, sizeof (IP4_ADDR));\r
+  NetCopyMem (&Points.RemoteAddr, &UdpSession->SourceAddress, sizeof (IP4_ADDR));\r
+  Points.LocalAddr  = NTOHL (Points.LocalAddr);\r
+  Points.RemoteAddr = NTOHL (Points.RemoteAddr);\r
+\r
   Token->CallBack (Netbuf, &Points, EFI_SUCCESS, Token->Context);\r
 \r
 ON_EXIT:\r