]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
MdeModulePkg: INF/DEC file updates to EDK II packages
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Driver.c
index 4a3d342711ca7d257f3cbc91be191a1f6a16e988..4944113e468deaaa747464c24b6ce893aadea83d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The driver binding and service binding protocol for IP4 driver.\r
 \r
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2014, 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\r
@@ -297,8 +297,6 @@ Ip4CreateService (
     IpSb->MaxPacketSize -= NET_VLAN_TAG_LEN;\r
   }\r
   IpSb->OldMaxPacketSize = IpSb->MaxPacketSize;\r
-  IpSb->MacString = NULL;\r
-\r
   *Service = IpSb;\r
   return EFI_SUCCESS;\r
 \r
@@ -519,8 +517,6 @@ Ip4DriverBindingStart (
   //\r
   mIp4Id = (UINT16)NET_RANDOM (NetRandomInitSeed ());\r
 \r
-  Ip4SetVariableData (IpSb);\r
-\r
   return Status;\r
 \r
 UNINSTALL_PROTOCOL:\r
@@ -572,6 +568,8 @@ Ip4DriverBindingStop (
   INTN                                     State;\r
   LIST_ENTRY                               *List;\r
   IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT  Context;\r
+  IP4_INTERFACE                            *IpIf;\r
+  IP4_ROUTE_TABLE                          *RouteTable;\r
 \r
   //\r
   // IP4 driver opens the MNP child, ARP children or the IP4_CONFIG protocol\r
@@ -681,15 +679,39 @@ Ip4DriverBindingStop (
                &Context,\r
                NULL\r
                );\r
+  } else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) {\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
+    // default interface and route table, create a new one and mark it as not started.\r
+    //\r
+    Ip4CancelReceive (IpSb->DefaultInterface);\r
+    Ip4FreeInterface (IpSb->DefaultInterface, NULL);\r
+    Ip4FreeRouteTable (IpSb->DefaultRouteTable);\r
+    \r
+    IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);\r
+    if (IpIf == NULL) {\r
+      goto ON_ERROR;\r
+    }\r
+    RouteTable = Ip4CreateRouteTable ();\r
+    if (RouteTable == NULL) {\r
+      Ip4FreeInterface (IpIf, NULL);\r
+      goto ON_ERROR;;\r
+    }\r
+    \r
+    IpSb->DefaultInterface  = IpIf;\r
+    InsertHeadList (&IpSb->Interfaces, &IpIf->Link);\r
+    IpSb->DefaultRouteTable = RouteTable;\r
+    Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);\r
+\r
+    if (IpSb->Ip4Config != NULL && IpSb->State != IP4_SERVICE_DESTROY) {\r
+      IpSb->Ip4Config->Stop (IpSb->Ip4Config);\r
+    }\r
+    IpSb->State = IP4_SERVICE_UNSTARTED;\r
   } else if (IsListEmpty (&IpSb->Children)) {\r
     State           = IpSb->State;\r
     IpSb->State     = IP4_SERVICE_DESTROY;\r
 \r
-    //\r
-    // Clear the variable data.\r
-    //\r
-    Ip4ClearVariableData (IpSb);\r
-\r
     //\r
     // OK, clean other resources then uninstall the service binding protocol.\r
     //\r
@@ -944,9 +966,6 @@ Ip4ServiceBindingDestroyChild (
   }\r
 \r
   Status = Ip4CleanProtocol (IpInstance);\r
-\r
-  Ip4SetVariableData (IpSb);\r
-\r
   if (EFI_ERROR (Status)) {\r
     gBS->InstallMultipleProtocolInterfaces (\r
            &ChildHandle,\r