]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Ip4Dxe: Trigger Ip4Config2 to retrieve the default address.
authorJiaxin Wu <jiaxin.wu@intel.com>
Fri, 20 Oct 2017 06:46:31 +0000 (14:46 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Thu, 26 Oct 2017 08:22:14 +0000 (16:22 +0800)
According the UEFI spec 2.7 A:
In section 28.3.2 for the IpConfigData.UseDefaultAddress, "While set to
TRUE, Configure() will trigger the EFI_IP4_CONFIG2_PROTOCOL to retrieve
the default IPv4 address if it is not available yet."
In section 28.5 for the Ip4Config2PolicyDhcp, "...All of these configurations
are retrieved from DHCP server or other auto-configuration mechanism."

This patch is to align with the above description. When the default IPv4
address is not available and IpConfigData.UseDefaultAddress is set to TRUE,
Ip4Config2 protocol will be called to retrieve the default address by setting
the policy to Ip4Config2PolicyDhcp.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c

index 3cdf8ecaad06f033a2e5381d0f73ef90e6ba2d35..fc5812e4ab55e180f8a21ff35fc4ecaec63a0455 100644 (file)
@@ -596,9 +596,13 @@ Ip4ConfigProtocol (
   IP4_ADDR                  Ip;\r
   IP4_ADDR                  Netmask;\r
   EFI_ARP_PROTOCOL          *Arp;\r
   IP4_ADDR                  Ip;\r
   IP4_ADDR                  Netmask;\r
   EFI_ARP_PROTOCOL          *Arp;\r
+  EFI_IP4_CONFIG2_PROTOCOL  *Ip4Config2;\r
+  EFI_IP4_CONFIG2_POLICY    Policy;\r
 \r
   IpSb = IpInstance->Service;\r
 \r
 \r
   IpSb = IpInstance->Service;\r
 \r
+  Ip4Config2  = NULL;\r
+\r
   //\r
   // User is changing packet filters. It must be stopped\r
   // before the station address can be changed.\r
   //\r
   // User is changing packet filters. It must be stopped\r
   // before the station address can be changed.\r
@@ -677,10 +681,23 @@ Ip4ConfigProtocol (
     // Use the default address. Check the state.\r
     //\r
     if (IpSb->State == IP4_SERVICE_UNSTARTED) {\r
     // Use the default address. Check the state.\r
     //\r
     if (IpSb->State == IP4_SERVICE_UNSTARTED) {\r
-      Status = Ip4StartAutoConfig (&IpSb->Ip4Config2Instance);\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        goto ON_ERROR;\r
+      //\r
+      // Trigger the EFI_IP4_CONFIG2_PROTOCOL to retrieve the \r
+      // default IPv4 address if it is not available yet.\r
+      //\r
+      Policy = IpSb->Ip4Config2Instance.Policy;\r
+      if (Policy != Ip4Config2PolicyDhcp) {\r
+        Ip4Config2 = &IpSb->Ip4Config2Instance.Ip4Config2;\r
+        Policy = Ip4Config2PolicyDhcp;\r
+        Status= Ip4Config2->SetData (\r
+                              Ip4Config2,\r
+                              Ip4Config2DataTypePolicy,\r
+                              sizeof (EFI_IP4_CONFIG2_POLICY),\r
+                              &Policy\r
+                              );\r
+        if (EFI_ERROR (Status)) {\r
+          goto ON_ERROR;\r
+        }\r
       }\r
     }\r
 \r
       }\r
     }\r
 \r