]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
Use Mde library and definition instead of some native definitions in NetLib, to simpl...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Udp4Dxe / Udp4Impl.c
index e5576820a66a436811a4822c74d47d9c2e2f0a73..c190a1df80f1a758a152f7c87ed6439bf5c8cc3a 100644 (file)
@@ -36,7 +36,7 @@ Udp4CheckTimeout (
 STATIC\r
 BOOLEAN\r
 Udp4FindInstanceByPort (\r
-  IN NET_LIST_ENTRY    *InstanceList,\r
+  IN LIST_ENTRY        *InstanceList,\r
   IN EFI_IPv4_ADDRESS  *Address,\r
   IN UINT16            Port\r
   );\r
@@ -153,13 +153,15 @@ Udp4CreateService (
   EFI_STATUS       Status;\r
   IP_IO_OPEN_DATA  OpenData;\r
 \r
+  ZeroMem (Udp4Service, sizeof (UDP4_SERVICE_DATA));\r
+\r
   Udp4Service->Signature        = UDP4_SERVICE_DATA_SIGNATURE;\r
   Udp4Service->ServiceBinding   = mUdp4ServiceBinding;\r
   Udp4Service->ImageHandle      = ImageHandle;\r
   Udp4Service->ControllerHandle = ControllerHandle;\r
   Udp4Service->ChildrenNumber   = 0;\r
 \r
-  NetListInit (&Udp4Service->ChildrenList);\r
+  InitializeListHead (&Udp4Service->ChildrenList);\r
 \r
   //\r
   // Create the IpIo for this service context.\r
@@ -172,7 +174,7 @@ Udp4CreateService (
   //\r
   // Set the OpenData used to open the IpIo.\r
   //\r
-  CopyMem (&OpenData.IpConfigData, &mIpIoDefaultIpConfigData, sizeof (EFI_IP4_CONFIG_DATA));\r
+  CopyMem (&OpenData.IpConfigData, &mIpIoDefaultIpConfigData, sizeof (OpenData.IpConfigData));\r
   OpenData.IpConfigData.AcceptBroadcast = TRUE;\r
   OpenData.RcvdContext                  = (VOID *) Udp4Service;\r
   OpenData.SndContext                   = NULL;\r
@@ -184,7 +186,7 @@ Udp4CreateService (
   //\r
   Status = IpIoOpen (Udp4Service->IpIo, &OpenData);\r
   if (EFI_ERROR (Status)) {\r
-    goto RELEASE_IPIO;\r
+    goto ON_ERROR;\r
   }\r
 \r
   //\r
@@ -192,13 +194,13 @@ Udp4CreateService (
   //\r
   Status = gBS->CreateEvent (\r
                   EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
-                  NET_TPL_FAST_TIMER,\r
+                  TPL_CALLBACK,\r
                   Udp4CheckTimeout,\r
                   Udp4Service,\r
                   &Udp4Service->TimeoutEvent\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    goto RELEASE_IPIO;\r
+    goto ON_ERROR;\r
   }\r
 \r
   //\r
@@ -210,18 +212,16 @@ Udp4CreateService (
                   UDP4_TIMEOUT_INTERVAL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    goto RELEASE_ALL;\r
+    goto ON_ERROR;\r
   }\r
 \r
-  Udp4Service->MacString = NULL;\r
-\r
   return EFI_SUCCESS;\r
 \r
-RELEASE_ALL:\r
-\r
-  gBS->CloseEvent (Udp4Service->TimeoutEvent);\r
+ON_ERROR:\r
 \r
-RELEASE_IPIO:\r
+  if (Udp4Service->TimeoutEvent != NULL) {\r
+    gBS->CloseEvent (Udp4Service->TimeoutEvent);\r
+  }\r
 \r
   IpIoDestroy (Udp4Service->IpIo);\r
 \r
@@ -279,10 +279,10 @@ Udp4CheckTimeout (
   )\r
 {\r
   UDP4_SERVICE_DATA   *Udp4Service;\r
-  NET_LIST_ENTRY      *Entry;\r
+  LIST_ENTRY          *Entry;\r
   UDP4_INSTANCE_DATA  *Instance;\r
-  NET_LIST_ENTRY      *WrapEntry;\r
-  NET_LIST_ENTRY      *NextEntry;\r
+  LIST_ENTRY          *WrapEntry;\r
+  LIST_ENTRY          *NextEntry;\r
   UDP4_RXDATA_WRAP    *Wrap;\r
 \r
   Udp4Service = (UDP4_SERVICE_DATA *) Context;\r
@@ -344,9 +344,9 @@ Udp4InitInstance (
   //\r
   // Init the lists.\r
   //\r
-  NetListInit (&Instance->Link);\r
-  NetListInit (&Instance->RcvdDgramQue);\r
-  NetListInit (&Instance->DeliveredDgramQue);\r
+  InitializeListHead (&Instance->Link);\r
+  InitializeListHead (&Instance->RcvdDgramQue);\r
+  InitializeListHead (&Instance->DeliveredDgramQue);\r
 \r
   //\r
   // Init the NET_MAPs.\r
@@ -359,7 +359,7 @@ Udp4InitInstance (
   // Save the pointer to the UDP4_SERVICE_DATA, and initialize other members.\r
   //\r
   Instance->Udp4Service = Udp4Service;\r
-  CopyMem (&Instance->Udp4Proto, &mUdp4Protocol, sizeof (EFI_UDP4_PROTOCOL));\r
+  CopyMem (&Instance->Udp4Proto, &mUdp4Protocol, sizeof (Instance->Udp4Proto));\r
   Instance->IcmpError   = EFI_SUCCESS;\r
   Instance->Configured  = FALSE;\r
   Instance->IsNoMapping = FALSE;\r
@@ -400,12 +400,12 @@ Udp4CleanInstance (
 STATIC\r
 BOOLEAN\r
 Udp4FindInstanceByPort (\r
-  IN NET_LIST_ENTRY    *InstanceList,\r
+  IN LIST_ENTRY        *InstanceList,\r
   IN EFI_IPv4_ADDRESS  *Address,\r
   IN UINT16            Port\r
   )\r
 {\r
-  NET_LIST_ENTRY        *Entry;\r
+  LIST_ENTRY            *Entry;\r
   UDP4_INSTANCE_DATA    *Instance;\r
   EFI_UDP4_CONFIG_DATA  *ConfigData;\r
 \r
@@ -424,7 +424,7 @@ Udp4FindInstanceByPort (
       continue;\r
     }\r
 \r
-    if (EFI_IP4_EQUAL (ConfigData->StationAddress, *Address) &&\r
+    if (EFI_IP4_EQUAL (&ConfigData->StationAddress, Address) &&\r
       (ConfigData->StationPort == Port)) {\r
       //\r
       // if both the address and the port are the same, return TRUE.\r
@@ -457,7 +457,7 @@ Udp4FindInstanceByPort (
 **/\r
 EFI_STATUS\r
 Udp4Bind (\r
-  IN NET_LIST_ENTRY        *InstanceList,\r
+  IN LIST_ENTRY            *InstanceList,\r
   IN EFI_UDP4_CONFIG_DATA  *ConfigData\r
   )\r
 {\r
@@ -566,8 +566,8 @@ Udp4IsReconfigurable (
     }\r
 \r
     if (!NewConfigData->UseDefaultAddress &&\r
-      (!EFI_IP4_EQUAL (NewConfigData->StationAddress, OldConfigData->StationAddress) ||\r
-      !EFI_IP4_EQUAL (NewConfigData->SubnetMask, OldConfigData->SubnetMask))) {\r
+      (!EFI_IP4_EQUAL (&NewConfigData->StationAddress, &OldConfigData->StationAddress) ||\r
+      !EFI_IP4_EQUAL (&NewConfigData->SubnetMask, &OldConfigData->SubnetMask))) {\r
       //\r
       // If the instance doesn't use the default address, and the new address or\r
       // new subnet mask is different from the old values.\r
@@ -576,14 +576,14 @@ Udp4IsReconfigurable (
     }\r
   }\r
 \r
-  if (!EFI_IP4_EQUAL (NewConfigData->RemoteAddress, OldConfigData->RemoteAddress)) {\r
+  if (!EFI_IP4_EQUAL (&NewConfigData->RemoteAddress, &OldConfigData->RemoteAddress)) {\r
     //\r
     // The remoteaddress is not the same.\r
     //\r
     return FALSE;\r
   }\r
 \r
-  if (!EFI_IP4_EQUAL (NewConfigData->RemoteAddress, mZeroIp4Addr) && (NewConfigData->RemotePort != OldConfigData->RemotePort)) {\r
+  if (!EFI_IP4_EQUAL (&NewConfigData->RemoteAddress, &mZeroIp4Addr) && (NewConfigData->RemotePort != OldConfigData->RemotePort)) {\r
     //\r
     // The RemotePort differs if it's designated in the configdata.\r
     //\r
@@ -612,14 +612,14 @@ Udp4BuildIp4ConfigData (
   IN EFI_IP4_CONFIG_DATA   *Ip4ConfigData\r
   )\r
 {\r
-  CopyMem (Ip4ConfigData, &mIpIoDefaultIpConfigData, sizeof (EFI_IP4_CONFIG_DATA));\r
+  CopyMem (Ip4ConfigData, &mIpIoDefaultIpConfigData, sizeof (*Ip4ConfigData));\r
 \r
   Ip4ConfigData->DefaultProtocol   = EFI_IP_PROTO_UDP;\r
   Ip4ConfigData->AcceptBroadcast   = Udp4ConfigData->AcceptBroadcast;\r
   Ip4ConfigData->AcceptPromiscuous = Udp4ConfigData->AcceptPromiscuous;\r
   Ip4ConfigData->UseDefaultAddress = Udp4ConfigData->UseDefaultAddress;\r
-  Ip4ConfigData->StationAddress    = Udp4ConfigData->StationAddress;\r
-  Ip4ConfigData->SubnetMask        = Udp4ConfigData->SubnetMask;\r
+  CopyMem (&Ip4ConfigData->StationAddress, &Udp4ConfigData->StationAddress, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&Ip4ConfigData->SubnetMask, &Udp4ConfigData->SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r
 \r
   //\r
   // use the -1 magic number to disable the receiving process of the ip instance.\r
@@ -701,7 +701,7 @@ Udp4ValidateTxToken (
   }\r
 \r
   if (TxData->GatewayAddress != NULL) {\r
-    NetCopyMem (&GatewayAddress, TxData->GatewayAddress, sizeof (IP4_ADDR));\r
+    CopyMem (&GatewayAddress, TxData->GatewayAddress, sizeof (IP4_ADDR));\r
 \r
     if (!Ip4IsUnicast (NTOHL (GatewayAddress), 0)) {\r
       //\r
@@ -716,7 +716,7 @@ Udp4ValidateTxToken (
 \r
   if (UdpSessionData != NULL) {\r
 \r
-    NetCopyMem (&SourceAddress, &UdpSessionData->SourceAddress, sizeof (IP4_ADDR));\r
+    CopyMem (&SourceAddress, &UdpSessionData->SourceAddress, sizeof (IP4_ADDR));\r
 \r
     if ((SourceAddress != 0) && !Ip4IsUnicast (HTONL (SourceAddress), 0)) {\r
       //\r
@@ -733,13 +733,13 @@ Udp4ValidateTxToken (
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
-    if (EFI_IP4_EQUAL (UdpSessionData->DestinationAddress, mZeroIp4Addr)) {\r
+    if (EFI_IP4_EQUAL (&UdpSessionData->DestinationAddress, &mZeroIp4Addr)) {\r
       //\r
       // The DestinationAddress specified in the UdpSessionData is 0.\r
       //\r
       return EFI_INVALID_PARAMETER;\r
     }\r
-  } else if (EFI_IP4_EQUAL (ConfigData->RemoteAddress, mZeroIp4Addr)) {\r
+  } else if (EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &mZeroIp4Addr)) {\r
     //\r
     // the configured RemoteAddress is all zero, and the user doens't override the\r
     // destination address.\r
@@ -817,7 +817,7 @@ Udp4Checksum (
 \r
   Checksum  = NetAddChecksum (Checksum, HTONS ((UINT16) Packet->TotalSize));\r
 \r
-  return ~Checksum;\r
+  return (UINT16) ~Checksum;\r
 }\r
 \r
 \r
@@ -891,6 +891,7 @@ Udp4DgramSent (
     //\r
     Token->Status = Status;\r
     gBS->SignalEvent (Token->Event);\r
+    NetLibDispatchDpc ();\r
   }\r
 }\r
 \r
@@ -935,6 +936,12 @@ Udp4DgramRcvd (
     //\r
     Udp4IcmpHandler ((UDP4_SERVICE_DATA *) Context, IcmpError, NetSession, Packet);\r
   }\r
+\r
+  //\r
+  // Dispatch the DPC queued by the NotifyFunction of the rx token's events\r
+  // which are signaled with received data.\r
+  //\r
+  NetLibDispatchDpc ();\r
 }\r
 \r
 \r
@@ -962,9 +969,9 @@ Udp4LeaveGroup (
 \r
   McastIp = Arg;\r
 \r
-  if ((McastIp != NULL) && (!EFI_IP4_EQUAL (*McastIp, (UINTN) Item->Key))) {\r
+  if ((McastIp != NULL) && (!EFI_IP4_EQUAL (McastIp, &(Item->Key)))) {\r
     //\r
-    // McastIp is not NULL and the multicast address contained in the Item \r
+    // McastIp is not NULL and the multicast address contained in the Item\r
     // is not the same as McastIp.\r
     //\r
     return EFI_SUCCESS;\r
@@ -1033,11 +1040,10 @@ Udp4CancelTokens (
     // The token is a receive token. Abort it and remove it from the Map.\r
     //\r
     TokenToCancel = (EFI_UDP4_COMPLETION_TOKEN *) Item->Key;\r
+    NetMapRemoveItem (Map, Item, NULL);\r
 \r
     TokenToCancel->Status = EFI_ABORTED;\r
     gBS->SignalEvent (TokenToCancel->Event);\r
-\r
-    NetMapRemoveItem (Map, Item, NULL);\r
   }\r
 \r
   if (Arg != NULL) {\r
@@ -1057,28 +1063,23 @@ Udp4CancelTokens (
 \r
 **/\r
 VOID\r
-Udp4FlushRxData (\r
-  IN NET_LIST_ENTRY  *RcvdDgramQue\r
+Udp4FlushRcvdDgram (\r
+  IN UDP4_INSTANCE_DATA  *Instance\r
   )\r
 {\r
   UDP4_RXDATA_WRAP  *Wrap;\r
-  EFI_TPL           OldTpl;\r
-\r
-  OldTpl = NET_RAISE_TPL (NET_TPL_RECYCLE);\r
 \r
-  while (!NetListIsEmpty (RcvdDgramQue)) {\r
+  while (!IsListEmpty (&Instance->RcvdDgramQue)) {\r
     //\r
     // Iterate all the Wraps in the RcvdDgramQue.\r
     //\r
-    Wrap = NET_LIST_HEAD (RcvdDgramQue, UDP4_RXDATA_WRAP, Link);\r
+    Wrap = NET_LIST_HEAD (&Instance->RcvdDgramQue, UDP4_RXDATA_WRAP, Link);\r
 \r
     //\r
     // The Wrap will be removed from the RcvdDgramQue by this function call.\r
     //\r
     Udp4RecycleRxDataWrap (NULL, (VOID *) Wrap);\r
   }\r
-\r
-  NET_RESTORE_TPL (OldTpl);\r
 }\r
 \r
 \r
@@ -1172,16 +1173,16 @@ Udp4MatchDgram (
     return FALSE;\r
   }\r
 \r
-  if (!EFI_IP4_EQUAL (ConfigData->RemoteAddress, mZeroIp4Addr) &&\r
-    !EFI_IP4_EQUAL (ConfigData->RemoteAddress, Udp4Session->SourceAddress)) {\r
+  if (!EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &mZeroIp4Addr) &&\r
+    !EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &Udp4Session->SourceAddress)) {\r
     //\r
     // This datagram doesn't come from the instance's specified sender.\r
     //\r
     return FALSE;\r
   }\r
 \r
-  if (EFI_IP4_EQUAL (ConfigData->StationAddress, mZeroIp4Addr) ||\r
-    EFI_IP4_EQUAL (Udp4Session->DestinationAddress, ConfigData->StationAddress)) {\r
+  if (EFI_IP4_EQUAL (&ConfigData->StationAddress, &mZeroIp4Addr) ||\r
+    EFI_IP4_EQUAL (&Udp4Session->DestinationAddress, &ConfigData->StationAddress)) {\r
     //\r
     // The instance is configured to receive datagrams destinated to any station IP or\r
     // the destination address of this datagram matches the configured station IP.\r
@@ -1189,7 +1190,7 @@ Udp4MatchDgram (
     return TRUE;\r
   }\r
 \r
-  NetCopyMem (&Destination, &Udp4Session->DestinationAddress, sizeof (IP4_ADDR));\r
+  CopyMem (&Destination, &Udp4Session->DestinationAddress, sizeof (IP4_ADDR));\r
 \r
   if (IP4_IS_LOCAL_BROADCAST (Destination) && ConfigData->AcceptBroadcast) {\r
     //\r
@@ -1234,7 +1235,7 @@ Udp4RecycleRxDataWrap (
   //\r
   // Remove the Wrap from the list it belongs to.\r
   //\r
-  NetListRemoveEntry (&Wrap->Link);\r
+  RemoveEntryList (&Wrap->Link);\r
 \r
   //\r
   // Free the Packet associated with this Wrap.\r
@@ -1246,7 +1247,7 @@ Udp4RecycleRxDataWrap (
   //\r
   gBS->CloseEvent (Wrap->RxData.RecycleSignal);\r
 \r
-  NetFreePool (Wrap);\r
+  gBS->FreePool (Wrap);\r
 }\r
 \r
 \r
@@ -1276,28 +1277,28 @@ Udp4WrapRxData (
   //\r
   // Allocate buffer for the Wrap.\r
   //\r
-  Wrap = NetAllocatePool (sizeof (UDP4_RXDATA_WRAP) +\r
+  Wrap = AllocatePool (sizeof (UDP4_RXDATA_WRAP) +\r
          (Packet->BlockOpNum - 1) * sizeof (EFI_UDP4_FRAGMENT_DATA));\r
   if (Wrap == NULL) {\r
     return NULL;\r
   }\r
 \r
-  NetListInit (&Wrap->Link);\r
+  InitializeListHead (&Wrap->Link);\r
 \r
-  CopyMem (&Wrap->RxData, RxData, sizeof (EFI_UDP4_RECEIVE_DATA));\r
+  CopyMem (&Wrap->RxData, RxData, sizeof (Wrap->RxData));\r
 \r
   //\r
   // Create the Recycle event.\r
   //\r
   Status = gBS->CreateEvent (\r
                   EVT_NOTIFY_SIGNAL,\r
-                  NET_TPL_RECYCLE,\r
+                  TPL_NOTIFY,\r
                   Udp4RecycleRxDataWrap,\r
                   Wrap,\r
                   &Wrap->RxData.RecycleSignal\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    NetFreePool (Wrap);\r
+    gBS->FreePool (Wrap);\r
     return NULL;\r
   }\r
 \r
@@ -1328,7 +1329,7 @@ Udp4EnqueueDgram (
   IN EFI_UDP4_RECEIVE_DATA  *RxData\r
   )\r
 {\r
-  NET_LIST_ENTRY      *Entry;\r
+  LIST_ENTRY          *Entry;\r
   UDP4_INSTANCE_DATA  *Instance;\r
   UDP4_RXDATA_WRAP    *Wrap;\r
   UINTN               Enqueued;\r
@@ -1349,14 +1350,14 @@ Udp4EnqueueDgram (
       //\r
       // Wrap the RxData and put this Wrap into the instances RcvdDgramQue.\r
       //\r
-      CopyMem (&Wrap, Udp4WrapRxData (Instance, Packet, RxData), sizeof (UDP4_RXDATA_WRAP));\r
+      Wrap = Udp4WrapRxData (Instance, Packet, RxData);\r
       if (Wrap == NULL) {\r
         continue;\r
       }\r
 \r
       NET_GET_REF (Packet);\r
 \r
-      NetListInsertTail (&Instance->RcvdDgramQue, &Wrap->Link);\r
+      InsertTailList (&Instance->RcvdDgramQue, &Wrap->Link);\r
 \r
       Enqueued++;\r
     }\r
@@ -1383,8 +1384,9 @@ Udp4InstanceDeliverDgram (
   EFI_UDP4_COMPLETION_TOKEN  *Token;\r
   NET_BUF                    *Dup;\r
   EFI_UDP4_RECEIVE_DATA      *RxData;\r
+  EFI_TPL                    OldTpl;\r
 \r
-  if (!NetListIsEmpty (&Instance->RcvdDgramQue) &&\r
+  if (!IsListEmpty (&Instance->RcvdDgramQue) &&\r
     !NetMapIsEmpty (&Instance->RxTokens)) {\r
 \r
     Wrap = NET_LIST_HEAD (&Instance->RcvdDgramQue, UDP4_RXDATA_WRAP, Link);\r
@@ -1401,7 +1403,7 @@ Udp4InstanceDeliverDgram (
       NetbufFree (Wrap->Packet);\r
 \r
       Wrap->Packet = Dup;\r
-    }\r
+    } \r
 \r
     NetListRemoveHead (&Instance->RcvdDgramQue);\r
 \r
@@ -1422,9 +1424,11 @@ Udp4InstanceDeliverDgram (
     Token->Status        = EFI_SUCCESS;\r
     Token->Packet.RxData = &Wrap->RxData;\r
 \r
-    gBS->SignalEvent (Token->Event);\r
+    OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+    InsertTailList (&Instance->DeliveredDgramQue, &Wrap->Link);\r
+    gBS->RestoreTPL (OldTpl);\r
 \r
-    NetListInsertTail (&Instance->DeliveredDgramQue, &Wrap->Link);\r
+    gBS->SignalEvent (Token->Event);\r
   }\r
 }\r
 \r
@@ -1443,7 +1447,7 @@ Udp4DeliverDgram (
   IN UDP4_SERVICE_DATA  *Udp4Service\r
   )\r
 {\r
-  NET_LIST_ENTRY      *Entry;\r
+  LIST_ENTRY          *Entry;\r
   UDP4_INSTANCE_DATA  *Instance;\r
 \r
   NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) {\r
@@ -1520,8 +1524,8 @@ Udp4Demultiplex (
   Udp4Session->SourcePort      = NTOHS (Udp4Header->SrcPort);\r
   Udp4Session->DestinationPort = NTOHS (Udp4Header->DstPort);\r
 \r
-  NetCopyMem (&Udp4Session->SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS));\r
-  NetCopyMem (&Udp4Session->DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&Udp4Session->SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&Udp4Session->DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));\r
 \r
   //\r
   // Trim the UDP header.\r
@@ -1625,18 +1629,18 @@ Udp4SendPortUnreach (
   //\r
   // Copy the IP header of the datagram tragged the error.\r
   //\r
-  NetCopyMem (&IcmpErrHdr->IpHead, IpHdr, EFI_IP4_HEADER_LEN (IpHdr));\r
+  CopyMem (&IcmpErrHdr->IpHead, IpHdr, EFI_IP4_HEADER_LEN (IpHdr));\r
 \r
   //\r
   // Copy the UDP header.\r
   //\r
   Ptr = (UINT8 *) &IcmpErrHdr->IpHead + EFI_IP4_HEADER_LEN (IpHdr);\r
-  NetCopyMem (Ptr, Udp4Header, ICMP_ERROR_PACKET_LENGTH);\r
+  CopyMem (Ptr, Udp4Header, ICMP_ERROR_PACKET_LENGTH);\r
 \r
   //\r
   // Calculate the checksum.\r
   //\r
-  IcmpErrHdr->Head.Checksum = ~(NetbufChecksum (Packet));\r
+  IcmpErrHdr->Head.Checksum = (UINT16) ~(NetbufChecksum (Packet));\r
 \r
   //\r
   // Fill the override data.\r
@@ -1646,8 +1650,8 @@ Udp4SendPortUnreach (
   Override.TimeToLive    = 255;\r
   Override.Protocol      = EFI_IP_PROTO_ICMP;\r
 \r
-  NetCopyMem (&Override.SourceAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));\r
-  NetZeroMem (&Override.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&Override.SourceAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));\r
+  ZeroMem (&Override.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
 \r
   //\r
   // Send out this icmp packet.\r
@@ -1682,13 +1686,13 @@ Udp4IcmpHandler (
 {\r
   EFI_UDP4_HEADER        *Udp4Header;\r
   EFI_UDP4_SESSION_DATA  Udp4Session;\r
-  NET_LIST_ENTRY         *Entry;\r
+  LIST_ENTRY             *Entry;\r
   UDP4_INSTANCE_DATA     *Instance;\r
 \r
   Udp4Header = (EFI_UDP4_HEADER *) NetbufGetByte (Packet, 0, NULL);\r
 \r
-  NetCopyMem (&Udp4Session.SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS));\r
-  NetCopyMem (&Udp4Session.DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&Udp4Session.SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&Udp4Session.DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));\r
 \r
   Udp4Session.SourcePort      = NTOHS (Udp4Header->DstPort);\r
   Udp4Session.DestinationPort = NTOHS (Udp4Header->SrcPort);\r
@@ -1702,7 +1706,7 @@ Udp4IcmpHandler (
     if (!Instance->Configured ||\r
       Instance->ConfigData.AcceptPromiscuous ||\r
       Instance->ConfigData.AcceptAnyPort ||\r
-      EFI_IP4_EQUAL (Instance->ConfigData.StationAddress, mZeroIp4Addr)) {\r
+      EFI_IP4_EQUAL (&Instance->ConfigData.StationAddress, &mZeroIp4Addr)) {\r
       //\r
       // Don't try to deliver the ICMP error to this instance if it is not configured,\r
       // or it's configured to be promiscuous or accept any port or accept all the\r
@@ -1811,7 +1815,7 @@ Udp4SetVariableData (
   )\r
 {\r
   UINT32                  NumConfiguredInstance;\r
-  NET_LIST_ENTRY          *Entry;\r
+  LIST_ENTRY              *Entry;\r
   UINTN                   VariableDataSize;\r
   EFI_UDP4_VARIABLE_DATA  *Udp4VariableData;\r
   EFI_UDP4_SERVICE_POINT  *Udp4ServicePoint;\r
@@ -1848,7 +1852,7 @@ Udp4SetVariableData (
     VariableDataSize += sizeof (EFI_UDP4_SERVICE_POINT) * (NumConfiguredInstance - 1);\r
   }\r
 \r
-  Udp4VariableData = NetAllocatePool (VariableDataSize);\r
+  Udp4VariableData = AllocatePool (VariableDataSize);\r
   if (Udp4VariableData == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -1909,7 +1913,7 @@ Udp4SetVariableData (
              );\r
     }\r
 \r
-    NetFreePool (Udp4Service->MacString);\r
+    gBS->FreePool (Udp4Service->MacString);\r
   }\r
 \r
   Udp4Service->MacString = NewMacString;\r
@@ -1924,7 +1928,7 @@ Udp4SetVariableData (
 \r
 ON_ERROR:\r
 \r
-  NetFreePool (Udp4VariableData);\r
+  gBS->FreePool (Udp4VariableData);\r
 \r
   return Status;\r
 }\r
@@ -1953,6 +1957,6 @@ Udp4ClearVariableData (
          NULL\r
          );\r
 \r
-  NetFreePool (Udp4Service->MacString);\r
+  gBS->FreePool (Udp4Service->MacString);\r
   Udp4Service->MacString = NULL;\r
 }\r