public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] MdeModulePkg/Ip4Dxe: Trigger Ip4Config2 to retrieve the default address.
@ 2017-10-20  6:50 Jiaxin Wu
  2017-10-25  9:07 ` Fu, Siyuan
  0 siblings, 1 reply; 2+ messages in thread
From: Jiaxin Wu @ 2017-10-20  6:50 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin

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>
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
index 3cdf8ec..fc5812e 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
@@ -594,13 +594,17 @@ Ip4ConfigProtocol (
   IP4_INTERFACE             *IpIf;
   EFI_STATUS                Status;
   IP4_ADDR                  Ip;
   IP4_ADDR                  Netmask;
   EFI_ARP_PROTOCOL          *Arp;
+  EFI_IP4_CONFIG2_PROTOCOL  *Ip4Config2;
+  EFI_IP4_CONFIG2_POLICY    Policy;
 
   IpSb = IpInstance->Service;
 
+  Ip4Config2  = NULL;
+
   //
   // User is changing packet filters. It must be stopped
   // before the station address can be changed.
   //
   if (IpInstance->State == IP4_STATE_CONFIGED) {
@@ -675,14 +679,27 @@ Ip4ConfigProtocol (
   } else {
     //
     // Use the default address. Check the state.
     //
     if (IpSb->State == IP4_SERVICE_UNSTARTED) {
-      Status = Ip4StartAutoConfig (&IpSb->Ip4Config2Instance);
-
-      if (EFI_ERROR (Status)) {
-        goto ON_ERROR;
+      //
+      // Trigger the EFI_IP4_CONFIG2_PROTOCOL to retrieve the 
+      // default IPv4 address if it is not available yet.
+      //
+      Policy = IpSb->Ip4Config2Instance.Policy;
+      if (Policy != Ip4Config2PolicyDhcp) {
+        Ip4Config2 = &IpSb->Ip4Config2Instance.Ip4Config2;
+        Policy = Ip4Config2PolicyDhcp;
+        Status= Ip4Config2->SetData (
+                              Ip4Config2,
+                              Ip4Config2DataTypePolicy,
+                              sizeof (EFI_IP4_CONFIG2_POLICY),
+                              &Policy
+                              );
+        if (EFI_ERROR (Status)) {
+          goto ON_ERROR;
+        }
       }
     }
 
     IpIf = IpSb->DefaultInterface;
     NET_GET_REF (IpSb->DefaultInterface);
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] MdeModulePkg/Ip4Dxe: Trigger Ip4Config2 to retrieve the default address.
  2017-10-20  6:50 [Patch] MdeModulePkg/Ip4Dxe: Trigger Ip4Config2 to retrieve the default address Jiaxin Wu
@ 2017-10-25  9:07 ` Fu, Siyuan
  0 siblings, 0 replies; 2+ messages in thread
From: Fu, Siyuan @ 2017-10-25  9:07 UTC (permalink / raw)
  To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Ye, Ting, Wu, Jiaxin

Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Jiaxin Wu
> Sent: Friday, October 20, 2017 2:51 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu,
> Jiaxin <jiaxin.wu@intel.com>
> Subject: [edk2] [Patch] MdeModulePkg/Ip4Dxe: Trigger Ip4Config2 to
> retrieve the default address.
> 
> 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>
> ---
>  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c | 25
> +++++++++++++++++++++----
>  1 file changed, 21 insertions(+), 4 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> index 3cdf8ec..fc5812e 100644
> --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
> @@ -594,13 +594,17 @@ Ip4ConfigProtocol (
>    IP4_INTERFACE             *IpIf;
>    EFI_STATUS                Status;
>    IP4_ADDR                  Ip;
>    IP4_ADDR                  Netmask;
>    EFI_ARP_PROTOCOL          *Arp;
> +  EFI_IP4_CONFIG2_PROTOCOL  *Ip4Config2;
> +  EFI_IP4_CONFIG2_POLICY    Policy;
> 
>    IpSb = IpInstance->Service;
> 
> +  Ip4Config2  = NULL;
> +
>    //
>    // User is changing packet filters. It must be stopped
>    // before the station address can be changed.
>    //
>    if (IpInstance->State == IP4_STATE_CONFIGED) {
> @@ -675,14 +679,27 @@ Ip4ConfigProtocol (
>    } else {
>      //
>      // Use the default address. Check the state.
>      //
>      if (IpSb->State == IP4_SERVICE_UNSTARTED) {
> -      Status = Ip4StartAutoConfig (&IpSb->Ip4Config2Instance);
> -
> -      if (EFI_ERROR (Status)) {
> -        goto ON_ERROR;
> +      //
> +      // Trigger the EFI_IP4_CONFIG2_PROTOCOL to retrieve the
> +      // default IPv4 address if it is not available yet.
> +      //
> +      Policy = IpSb->Ip4Config2Instance.Policy;
> +      if (Policy != Ip4Config2PolicyDhcp) {
> +        Ip4Config2 = &IpSb->Ip4Config2Instance.Ip4Config2;
> +        Policy = Ip4Config2PolicyDhcp;
> +        Status= Ip4Config2->SetData (
> +                              Ip4Config2,
> +                              Ip4Config2DataTypePolicy,
> +                              sizeof (EFI_IP4_CONFIG2_POLICY),
> +                              &Policy
> +                              );
> +        if (EFI_ERROR (Status)) {
> +          goto ON_ERROR;
> +        }
>        }
>      }
> 
>      IpIf = IpSb->DefaultInterface;
>      NET_GET_REF (IpSb->DefaultInterface);
> --
> 1.9.5.msysgit.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-25  9:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-20  6:50 [Patch] MdeModulePkg/Ip4Dxe: Trigger Ip4Config2 to retrieve the default address Jiaxin Wu
2017-10-25  9:07 ` Fu, Siyuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox