]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
BaseTools:Change the path of the file that Binary Cache
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Driver.c
index 03ba458a96f5fb244bb61be27398309fdb8b1fbf..ebd4dec1dfe4290452b7e4041c626323679a587c 100644 (file)
@@ -1,16 +1,10 @@
 /** @file\r
   The driver binding and service binding protocol for IP4 driver.\r
 \r
-Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
 \r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -46,7 +40,7 @@ IpSec2InstalledCallback (
   // Test if protocol was even found.\r
   // Notification function will be called at least once.\r
   //\r
-  Status = gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, &mIpSec);\r
+  Status = gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **)&mIpSec);\r
   if (Status == EFI_SUCCESS && mIpSec != NULL) {\r
     //\r
     // Close the event so it does not get called again.\r
@@ -253,11 +247,12 @@ Ip4CreateService (
   ZeroMem (&IpSb->SnpMode, sizeof (EFI_SIMPLE_NETWORK_MODE));\r
 \r
   IpSb->Timer = NULL;\r
+  IpSb->ReconfigCheckTimer = NULL;\r
 \r
   IpSb->ReconfigEvent = NULL;\r
 \r
   IpSb->Reconfig = FALSE;\r
-  \r
+\r
   IpSb->MediaPresent = TRUE;\r
 \r
   //\r
@@ -284,6 +279,18 @@ Ip4CreateService (
     goto ON_ERROR;\r
   }\r
 \r
+  Status = gBS->CreateEvent (\r
+                  EVT_NOTIFY_SIGNAL | EVT_TIMER,\r
+                  TPL_CALLBACK,\r
+                  Ip4TimerReconfigChecking,\r
+                  IpSb,\r
+                  &IpSb->ReconfigCheckTimer\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\r
+  }\r
+\r
   Status = gBS->CreateEvent (\r
                   EVT_NOTIFY_SIGNAL,\r
                   TPL_NOTIFY,\r
@@ -339,7 +346,7 @@ Ip4CreateService (
 \r
   IpSb->MacString = NULL;\r
   Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString);\r
-  \r
+\r
   if (EFI_ERROR (Status)) {\r
     goto ON_ERROR;\r
   }\r
@@ -354,7 +361,7 @@ Ip4CreateService (
   InsertHeadList (&IpSb->Interfaces, &IpSb->DefaultInterface->Link);\r
 \r
   ZeroMem (&IpSb->Ip4Config2Instance, sizeof (IP4_CONFIG2_INSTANCE));\r
-  \r
+\r
   Status = Ip4Config2InitInstance (&IpSb->Ip4Config2Instance);\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -410,6 +417,13 @@ Ip4CleanService (
     IpSb->Timer = NULL;\r
   }\r
 \r
+  if (IpSb->ReconfigCheckTimer != NULL) {\r
+    gBS->SetTimer (IpSb->ReconfigCheckTimer, TimerCancel, 0);\r
+    gBS->CloseEvent (IpSb->ReconfigCheckTimer);\r
+\r
+    IpSb->ReconfigCheckTimer = NULL;\r
+  }\r
+\r
   if (IpSb->DefaultInterface != NULL) {\r
     Status = Ip4FreeInterface (IpSb->DefaultInterface, NULL);\r
 \r
@@ -468,7 +482,7 @@ Ip4CleanService (
 \r
 /**\r
   Callback function which provided by user to remove one node in NetDestroyLinkList process.\r
-  \r
+\r
   @param[in]    Entry           The entry to be removed.\r
   @param[in]    Context         Pointer to the callback context corresponds to the Context in NetDestroyLinkList.\r
 \r
@@ -529,7 +543,7 @@ Ip4DriverBindingStart (
   IN EFI_HANDLE                   ControllerHandle,\r
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
   )\r
-{ \r
+{\r
   EFI_STATUS                    Status;\r
   IP4_SERVICE                   *IpSb;\r
   EFI_IP4_CONFIG2_PROTOCOL      *Ip4Cfg2;\r
@@ -555,13 +569,13 @@ Ip4DriverBindingStart (
   if (Status == EFI_SUCCESS) {\r
     return EFI_ALREADY_STARTED;\r
   }\r
-  \r
+\r
   Status = Ip4CreateService (ControllerHandle, This->DriverBindingHandle, &IpSb);\r
-  \r
+\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  \r
+\r
   ASSERT (IpSb != NULL);\r
 \r
   Ip4Cfg2  = &IpSb->Ip4Config2Instance.Ip4Config2;\r
@@ -583,16 +597,16 @@ Ip4DriverBindingStart (
   }\r
 \r
   //\r
-  // Read the config data from NV variable again. \r
+  // Read the config data from NV variable again.\r
   // The default data can be changed by other drivers.\r
   //\r
   Status = Ip4Config2ReadConfigData (IpSb->MacString, &IpSb->Ip4Config2Instance);\r
   if (EFI_ERROR (Status)) {\r
     goto UNINSTALL_PROTOCOL;\r
   }\r
-  \r
+\r
   //\r
-  // Consume the installed EFI_IP4_CONFIG2_PROTOCOL to set the default data items. \r
+  // Consume the installed EFI_IP4_CONFIG2_PROTOCOL to set the default data items.\r
   //\r
   for (Index = Ip4Config2DataTypePolicy; Index < Ip4Config2DataTypeMaximum; Index++) {\r
     DataItem = &IpSb->Ip4Config2Instance.DataItem[Index];\r
@@ -606,13 +620,13 @@ Ip4DriverBindingStart (
       if (EFI_ERROR(Status)) {\r
         goto UNINSTALL_PROTOCOL;\r
       }\r
-      \r
+\r
       if (Index == Ip4Config2DataTypePolicy && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) {\r
         break;\r
-      } \r
+      }\r
     }\r
   }\r
\r
+\r
   //\r
   // Ready to go: start the receiving and timer.\r
   // Ip4Config2SetPolicy maybe call Ip4ReceiveFrame() to set the default interface's RecvRequest first after\r
@@ -630,6 +644,12 @@ Ip4DriverBindingStart (
     goto UNINSTALL_PROTOCOL;\r
   }\r
 \r
+  Status = gBS->SetTimer (IpSb->ReconfigCheckTimer, TimerPeriodic, 500 * TICKS_PER_MS);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto UNINSTALL_PROTOCOL;\r
+  }\r
+\r
   //\r
   // Initialize the IP4 ID\r
   //\r
@@ -638,10 +658,13 @@ Ip4DriverBindingStart (
   return Status;\r
 \r
 UNINSTALL_PROTOCOL:\r
-  gBS->UninstallProtocolInterface (\r
+  gBS->UninstallMultipleProtocolInterfaces (\r
          ControllerHandle,\r
          &gEfiIp4ServiceBindingProtocolGuid,\r
-         &IpSb->ServiceBinding\r
+         &IpSb->ServiceBinding,\r
+         &gEfiIp4Config2ProtocolGuid,\r
+         Ip4Cfg2,\r
+         NULL\r
          );\r
 \r
 FREE_SERVICE:\r
@@ -679,9 +702,9 @@ Ip4DriverBindingStop (
   )\r
 {\r
   EFI_SERVICE_BINDING_PROTOCOL             *ServiceBinding;\r
-  IP4_SERVICE                              *IpSb; \r
+  IP4_SERVICE                              *IpSb;\r
   EFI_HANDLE                               NicHandle;\r
-  EFI_STATUS                               Status; \r
+  EFI_STATUS                               Status;\r
   INTN                                     State;\r
   LIST_ENTRY                               *List;\r
   IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT  Context;\r
@@ -691,20 +714,20 @@ Ip4DriverBindingStop (
   BOOLEAN                                  IsDhcp4;\r
 \r
   IsDhcp4   = FALSE;\r
-   \r
+\r
   NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);\r
   if (NicHandle == NULL) {\r
     NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid);\r
     if (NicHandle == NULL) {\r
       NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp4ProtocolGuid);\r
       if (NicHandle != NULL) {\r
-        IsDhcp4 = TRUE;  \r
+        IsDhcp4 = TRUE;\r
       } else {\r
         return EFI_SUCCESS;\r
       }\r
     }\r
   }\r
-   \r
+\r
   Status = gBS->OpenProtocol (\r
                   NicHandle,\r
                   &gEfiIp4ServiceBindingProtocolGuid,\r
@@ -716,7 +739,7 @@ Ip4DriverBindingStop (
   if (EFI_ERROR (Status)) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
-  \r
+\r
   IpSb = IP4_SERVICE_FROM_PROTOCOL (ServiceBinding);\r
 \r
   if (IsDhcp4) {\r
@@ -735,7 +758,7 @@ Ip4DriverBindingStop (
                NULL\r
                );\r
   } else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) {\r
-  \r
+\r
     //\r
     // The ARP protocol for the default interface is being uninstalled and all\r
     // its IP child handles should have been destroyed before. So, release the\r
@@ -744,7 +767,7 @@ Ip4DriverBindingStop (
     Ip4CancelReceive (IpSb->DefaultInterface);\r
     Ip4FreeInterface (IpSb->DefaultInterface, NULL);\r
     Ip4FreeRouteTable (IpSb->DefaultRouteTable);\r
-    \r
+\r
     IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);\r
     if (IpIf == NULL) {\r
       goto ON_ERROR;\r
@@ -754,7 +777,7 @@ Ip4DriverBindingStop (
       Ip4FreeInterface (IpIf, NULL);\r
       goto ON_ERROR;;\r
     }\r
-    \r
+\r
     IpSb->DefaultInterface  = IpIf;\r
     InsertHeadList (&IpSb->Interfaces, &IpIf->Link);\r
     IpSb->DefaultRouteTable = RouteTable;\r
@@ -781,7 +804,7 @@ Ip4DriverBindingStop (
            &IpSb->Ip4Config2Instance.Ip4Config2,\r
            NULL\r
            );\r
-    \r
+\r
     if (gIp4ControllerNameTable != NULL) {\r
       FreeUnicodeStringTable (gIp4ControllerNameTable);\r
       gIp4ControllerNameTable = NULL;\r