]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Rrq.c
index 665114c7f8a3e2b415dfb9377fd900cab88d8a32..93780fb87f7aff7b31f5708880bc0b54135903db 100644 (file)
@@ -172,7 +172,7 @@ Mtftp4RrqSaveBlock (
       Mtftp4SendError (\r
         Instance,\r
         EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION,\r
-        "User aborted download"\r
+        (UINT8 *) "User aborted download"\r
         );\r
 \r
       return EFI_ABORTED;\r
@@ -183,7 +183,7 @@ Mtftp4RrqSaveBlock (
     Start = MultU64x32 (Block - 1, Instance->BlkSize);\r
 \r
     if (Start + DataLen <= Token->BufferSize) {\r
-      NetCopyMem ((UINT8 *) Token->Buffer + Start, Packet->Data.Data, DataLen);\r
+      CopyMem ((UINT8 *) Token->Buffer + Start, Packet->Data.Data, DataLen);\r
 \r
       //\r
       // Update the file size when received the last block\r
@@ -203,7 +203,7 @@ Mtftp4RrqSaveBlock (
       Mtftp4SendError (\r
         Instance,\r
         EFI_MTFTP4_ERRORCODE_DISK_FULL,\r
-        "User provided memory block is too small"\r
+        (UINT8 *) "User provided memory block is too small"\r
         );\r
 \r
       return EFI_BUFFER_TOO_SMALL;\r
@@ -371,7 +371,6 @@ Mtftp4RrqOackValid (
   @retval Others                Failed to configure the UDP child.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 Mtftp4RrqConfigMcastPort (\r
   IN UDP_IO_PORT            *McastIo,\r
@@ -404,7 +403,7 @@ Mtftp4RrqConfigMcastPort (
   UdpConfig.RemotePort         = 0;\r
 \r
   Ip = HTONL (Instance->ServerIp);\r
-  NetCopyMem (&UdpConfig.RemoteAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&UdpConfig.RemoteAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
 \r
   Status = McastIo->Udp->Configure (McastIo->Udp, &UdpConfig);\r
 \r
@@ -412,11 +411,23 @@ Mtftp4RrqConfigMcastPort (
     return Status;\r
   }\r
 \r
+  if (!Config->UseDefaultSetting && !EFI_IP4_EQUAL (&mZeroIp4Addr, &Config->GatewayIp)) {\r
+    //\r
+    // The station IP address is manually configured and the Gateway IP is not 0.\r
+    // Add the default route for this UDP instance.\r
+    //\r
+    Status = McastIo->Udp->Routes (McastIo->Udp, FALSE, &mZeroIp4Addr, &mZeroIp4Addr, &Config->GatewayIp);\r
+    if (EFI_ERROR (Status)) {\r
+      McastIo->Udp->Configure (McastIo->Udp, NULL);\r
+      return Status;\r
+    }\r
+  }\r
+\r
   //\r
   // join the multicast group\r
   //\r
   Ip = HTONL (Instance->McastIp);\r
-  NetCopyMem (&Group, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
+  CopyMem (&Group, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
 \r
   return McastIo->Udp->Groups (McastIo->Udp, TRUE, &Group);\r
 }\r
@@ -467,7 +478,7 @@ Mtftp4RrqHandleOack (
   //\r
   // Parse and validate the options from server\r
   //\r
-  NetZeroMem (&Reply, sizeof (MTFTP4_OPTION));\r
+  ZeroMem (&Reply, sizeof (MTFTP4_OPTION));\r
 \r
   Status = Mtftp4ParseOptionOack (Packet, Len, &Reply);\r
 \r
@@ -480,7 +491,7 @@ Mtftp4RrqHandleOack (
       Mtftp4SendError (\r
         Instance,\r
         EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION,\r
-        "Mal-formated OACK packet"\r
+        (UINT8 *) "Mal-formated OACK packet"\r
         );\r
     }\r
 \r
@@ -501,7 +512,7 @@ Mtftp4RrqHandleOack (
         Mtftp4SendError (\r
           Instance,\r
           EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION,\r
-          "Illegal multicast setting"\r
+          (UINT8 *) "Illegal multicast setting"\r
           );\r
 \r
         return EFI_TFTP_ERROR;\r
@@ -529,27 +540,27 @@ Mtftp4RrqHandleOack (
         Mtftp4SendError (\r
           Instance,\r
           EFI_MTFTP4_ERRORCODE_ACCESS_VIOLATION,\r
-          "Failed to create socket to receive multicast packet"\r
+          (UINT8 *) "Failed to create socket to receive multicast packet"\r
           );\r
 \r
         return Status;\r
       }\r
-\r
+    \r
       //\r
       // Update the parameters used.\r
       //\r
       if (Reply.BlkSize != 0) {\r
         Instance->BlkSize = Reply.BlkSize;\r
       }\r
-\r
+      \r
       if (Reply.Timeout != 0) {\r
         Instance->Timeout = Reply.Timeout;\r
-      }\r
-    }\r
-\r
+      }  \r
+    }    \r
+    \r
   } else {\r
     Instance->Master = TRUE;\r
-\r
+    \r
     if (Reply.BlkSize != 0) {\r
       Instance->BlkSize = Reply.BlkSize;\r
     }\r
@@ -558,7 +569,7 @@ Mtftp4RrqHandleOack (
       Instance->Timeout = Reply.Timeout;\r
     }\r
   }\r
-\r
+  \r
   //\r
   // Send an ACK to (Expected - 1) which is 0 for unicast download,\r
   // or tell the server we want to receive the Expected block.\r
@@ -638,7 +649,7 @@ Mtftp4RrqInput (
   Len = UdpPacket->TotalSize;\r
 \r
   if (UdpPacket->BlockOpNum > 1) {\r
-    Packet = NetAllocatePool (Len);\r
+    Packet = AllocatePool (Len);\r
 \r
     if (Packet == NULL) {\r
       Status = EFI_OUT_OF_RESOURCES;\r
@@ -675,7 +686,7 @@ Mtftp4RrqInput (
         Mtftp4SendError (\r
           Instance,\r
           EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,\r
-          "User aborted the transfer"\r
+          (UINT8 *) "User aborted the transfer"\r
           );\r
       }\r
 \r
@@ -714,7 +725,7 @@ ON_EXIT:
   // receive, otherwise end the session.\r
   //\r
   if ((Packet != NULL) && (UdpPacket->BlockOpNum > 1)) {\r
-    NetFreePool (Packet);\r
+    gBS->FreePool (Packet);\r
   }\r
 \r
   if (UdpPacket != NULL) {\r