/** @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
// 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
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
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
\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
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
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
\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
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
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
}\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
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
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
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
)\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
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
if (EFI_ERROR (Status)) {\r
return EFI_DEVICE_ERROR;\r
}\r
- \r
+\r
IpSb = IP4_SERVICE_FROM_PROTOCOL (ServiceBinding);\r
\r
if (IsDhcp4) {\r
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
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
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
&IpSb->Ip4Config2Instance.Ip4Config2,\r
NULL\r
);\r
- \r
+\r
if (gIp4ControllerNameTable != NULL) {\r
FreeUnicodeStringTable (gIp4ControllerNameTable);\r
gIp4ControllerNameTable = NULL;\r