]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
Fix issue that node is still reachable after executing ifconfig –c.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4ConfigDxe / Ip4ConfigDriver.c
index c620abd70b4141f19bbb506a869fba74b15cfb93..2a9fcb94e5b573344d81fee407ccf619799b576c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The driver binding for IP4 CONFIG protocol.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\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<BR>\r
@@ -51,13 +51,19 @@ IP4_CONFIG_INSTANCE        mIp4ConfigTemplate = {
     FALSE,\r
     FALSE,\r
     {\r
-      0\r
+      {\r
+        0\r
+      }\r
     },\r
     {\r
-      0\r
+      {\r
+        0\r
+      }\r
     },\r
     {\r
-      0\r
+      {\r
+        0\r
+      }\r
     }\r
   },\r
   0,\r
@@ -70,14 +76,19 @@ IP4_CONFIG_INSTANCE        mIp4ConfigTemplate = {
     0,\r
     0,\r
     {\r
-      0\r
+      {\r
+        0\r
+      }\r
     }\r
   },\r
   (CHAR16 *) NULL,\r
   (NIC_IP4_CONFIG_INFO *) NULL,\r
   (EFI_DHCP4_PROTOCOL *) NULL,\r
   NULL,\r
-  NULL\r
+  NULL,\r
+  NULL,\r
+  TRUE,\r
+  FALSE\r
 };\r
 \r
 /**\r
@@ -285,25 +296,28 @@ Ip4ConfigDriverBindingStart (
     goto ON_ERROR;\r
   }\r
 \r
+  //\r
+  // A dedicated timer is used to poll underlying media status.\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EVT_NOTIFY_SIGNAL | EVT_TIMER,\r
+                  TPL_CALLBACK,\r
+                  MediaChangeDetect,\r
+                  Instance,\r
+                  &Instance->Timer\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\r
+  }\r
+\r
   //\r
   // Get the previous configure parameters. If an error happend here,\r
   // just ignore it because the driver should be able to operate.\r
   //\r
   NicConfig = Ip4ConfigReadVariable (Instance);\r
   if (NicConfig != NULL) {\r
-    if (NicConfig->Perment) {\r
-      if (NicConfig->Source == IP4_CONFIG_SOURCE_STATIC) {\r
-        //\r
-        // Don't modify the permanent static configuration.\r
-        //\r
-      } else if (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP) {\r
-        //\r
-        // Remove the previous acquired DHCP parameters.\r
-        //\r
-        ZeroMem (&NicConfig->Ip4Info, sizeof (EFI_IP4_IPCONFIG_DATA));\r
-        Ip4ConfigWriteVariable (Instance, NicConfig);\r
-      }\r
-    } else {\r
+    if (!NicConfig->Perment) {\r
       //\r
       // Delete the non-permanent configuration.\r
       //\r
@@ -332,7 +346,7 @@ ON_ERROR:
   NetLibDestroyServiceChild (\r
     ControllerHandle,\r
     This->DriverBindingHandle,\r
-    &gEfiManagedNetworkProtocolGuid,\r
+    &gEfiManagedNetworkServiceBindingProtocolGuid,\r
     MnpHandle\r
     );\r
 \r
@@ -476,6 +490,12 @@ Ip4ConfigDriverBindingStop (
     FreePool (Instance->MacString);\r
   }\r
 \r
+  if (Instance->Timer != NULL) {\r
+    gBS->SetTimer (Instance->Timer, TimerCancel, 0);\r
+    gBS->CloseEvent (Instance->Timer);\r
+    Instance->Timer = NULL;\r
+  }\r
+  \r
   Ip4ConfigCleanConfig (Instance);\r
   FreePool (Instance);\r
 \r