]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/HttpDxe/HttpDriver.c
NetworkPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / NetworkPkg / HttpDxe / HttpDriver.c
index bd1d04e78cc430acbba194d78f2e5eb9e9b8a5a3..7c64d421511977c24c6b143d74cc2dbcde3ffefb 100644 (file)
@@ -1,15 +1,10 @@
 /** @file\r
   The driver binding and service binding protocol for HttpDxe driver.\r
 \r
-  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
@@ -20,21 +15,30 @@ EFI_HTTP_UTILITIES_PROTOCOL *mHttpUtilities = NULL;
 ///\r
 /// Driver Binding Protocol instance\r
 ///\r
-EFI_DRIVER_BINDING_PROTOCOL gHttpDxeDriverBinding = {\r
-  HttpDxeDriverBindingSupported,\r
-  HttpDxeDriverBindingStart,\r
-  HttpDxeDriverBindingStop,\r
+EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp4DriverBinding = {\r
+  HttpDxeIp4DriverBindingSupported,\r
+  HttpDxeIp4DriverBindingStart,\r
+  HttpDxeIp4DriverBindingStop,\r
+  HTTP_DRIVER_VERSION,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp6DriverBinding = {\r
+  HttpDxeIp6DriverBindingSupported,\r
+  HttpDxeIp6DriverBindingStart,\r
+  HttpDxeIp6DriverBindingStop,\r
   HTTP_DRIVER_VERSION,\r
   NULL,\r
   NULL\r
 };\r
 \r
+\r
 /**\r
   Create a HTTP driver service binding private instance.\r
 \r
   @param[in]  Controller         The controller that has TCP4 service binding\r
                                  installed.\r
-  @param[in]  ImageHandle        The HTTP driver's image handle.\r
   @param[out] ServiceData        Point to HTTP driver private instance.\r
 \r
   @retval EFI_OUT_OF_RESOURCES   Failed to allocate some resources.\r
@@ -44,7 +48,6 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpDxeDriverBinding = {
 EFI_STATUS\r
 HttpCreateService (\r
   IN  EFI_HANDLE            Controller,\r
-  IN  EFI_HANDLE            ImageHandle,\r
   OUT HTTP_SERVICE          **ServiceData\r
   )\r
 {\r
@@ -61,11 +64,10 @@ HttpCreateService (
   HttpService->Signature = HTTP_SERVICE_SIGNATURE;\r
   HttpService->ServiceBinding.CreateChild = HttpServiceBindingCreateChild;\r
   HttpService->ServiceBinding.DestroyChild = HttpServiceBindingDestroyChild;\r
-  HttpService->ImageHandle = ImageHandle;\r
   HttpService->ControllerHandle = Controller;\r
   HttpService->ChildrenNumber = 0;\r
   InitializeListHead (&HttpService->ChildrenList);\r
-  \r
+\r
   *ServiceData = HttpService;\r
   return EFI_SUCCESS;\r
 }\r
@@ -73,33 +75,59 @@ HttpCreateService (
 /**\r
   Release all the resource used the HTTP service binding instance.\r
 \r
-  @param  HttpService        The HTTP private instance.\r
-\r
+  @param[in]  HttpService        The HTTP private instance.\r
+  @param[in]  UsingIpv6          Indicate use TCP4 protocol or TCP6 protocol.\r
+                                 if TRUE, use Tcp6 protocol.\r
+                                 if FALSE, use Tcp4 protocl.\r
 **/\r
 VOID\r
 HttpCleanService (\r
-  IN HTTP_SERVICE     *HttpService\r
+  IN HTTP_SERVICE     *HttpService,\r
+  IN BOOLEAN          UsingIpv6\r
   )\r
 {\r
+\r
   if (HttpService == NULL) {\r
     return ;\r
   }\r
+  if (!UsingIpv6) {\r
+    if (HttpService->Tcp4ChildHandle != NULL) {\r
+      gBS->CloseProtocol (\r
+             HttpService->Tcp4ChildHandle,\r
+             &gEfiTcp4ProtocolGuid,\r
+             HttpService->Ip4DriverBindingHandle,\r
+             HttpService->ControllerHandle\r
+             );\r
 \r
-  if (HttpService->TcpChildHandle != NULL) {\r
-    gBS->CloseProtocol (\r
-           HttpService->TcpChildHandle,\r
-           &gEfiTcp4ProtocolGuid,\r
-           HttpService->ImageHandle,\r
-           HttpService->ControllerHandle\r
-           );\r
+      NetLibDestroyServiceChild (\r
+        HttpService->ControllerHandle,\r
+        HttpService->Ip4DriverBindingHandle,\r
+        &gEfiTcp4ServiceBindingProtocolGuid,\r
+        HttpService->Tcp4ChildHandle\r
+        );\r
+\r
+      HttpService->Tcp4ChildHandle = NULL;\r
+    }\r
+  } else {\r
+    if (HttpService->Tcp6ChildHandle != NULL) {\r
+      gBS->CloseProtocol (\r
+             HttpService->Tcp6ChildHandle,\r
+             &gEfiTcp6ProtocolGuid,\r
+             HttpService->Ip6DriverBindingHandle,\r
+             HttpService->ControllerHandle\r
+             );\r
 \r
-    NetLibDestroyServiceChild (\r
-      HttpService->ControllerHandle,\r
-      HttpService->ImageHandle,\r
-      &gEfiTcp4ServiceBindingProtocolGuid,\r
-      HttpService->TcpChildHandle\r
-      );\r
+      NetLibDestroyServiceChild (\r
+        HttpService->ControllerHandle,\r
+        HttpService->Ip6DriverBindingHandle,\r
+        &gEfiTcp6ServiceBindingProtocolGuid,\r
+        HttpService->Tcp6ChildHandle\r
+        );\r
+\r
+      HttpService->Tcp6ChildHandle = NULL;\r
+    }\r
   }\r
+\r
 }\r
 \r
 /**\r
@@ -107,7 +135,7 @@ HttpCleanService (
   in the system.\r
 \r
   @param[in]     Event         Not used.\r
-  @param[in]     Context       The pointer to the IP4 config2 instance data.\r
+  @param[in]     Context       The pointer to the IP4 config2 instance data or IP6 Config instance data.\r
 \r
 **/\r
 VOID\r
@@ -118,11 +146,11 @@ HttpUtilitiesInstalledCallback (
   )\r
 {\r
   gBS->LocateProtocol (\r
-         &gEfiHttpUtilitiesProtocolGuid, \r
-         NULL, \r
+         &gEfiHttpUtilitiesProtocolGuid,\r
+         NULL,\r
          (VOID **) &mHttpUtilities\r
          );\r
-                \r
+\r
   //\r
   // Close the event if Http utilities protocol is loacted.\r
   //\r
@@ -149,12 +177,13 @@ HttpDxeDriverEntryPoint (
   IN EFI_HANDLE        ImageHandle,\r
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
-{ \r
+{\r
+  EFI_STATUS     Status;\r
   VOID           *Registration;\r
 \r
   gBS->LocateProtocol (\r
-         &gEfiHttpUtilitiesProtocolGuid, \r
-         NULL, \r
+         &gEfiHttpUtilitiesProtocolGuid,\r
+         NULL,\r
          (VOID **) &mHttpUtilities\r
          );\r
 \r
@@ -174,19 +203,39 @@ HttpDxeDriverEntryPoint (
   //\r
   // Install UEFI Driver Model protocol(s).\r
   //\r
-  return EfiLibInstallDriverBindingComponentName2 (\r
-           ImageHandle,\r
-           SystemTable,\r
-           &gHttpDxeDriverBinding,\r
-           ImageHandle,\r
-           &gHttpDxeComponentName,\r
-           &gHttpDxeComponentName2\r
-           );\r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gHttpDxeIp4DriverBinding,\r
+             ImageHandle,\r
+             &gHttpDxeComponentName,\r
+             &gHttpDxeComponentName2\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gHttpDxeIp6DriverBinding,\r
+             NULL,\r
+             &gHttpDxeComponentName,\r
+             &gHttpDxeComponentName2\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    EfiLibUninstallDriverBindingComponentName2 (\r
+      &gHttpDxeIp4DriverBinding,\r
+      &gHttpDxeComponentName,\r
+      &gHttpDxeComponentName2\r
+      );\r
+  }\r
+  return Status;\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
@@ -224,196 +273,194 @@ HttpDestroyChildEntryInHandleBuffer (
 }\r
 \r
 /**\r
-  Tests to see if this driver supports a given controller. If a child device is provided, \r
-  it further tests to see if this driver supports creating a handle for the specified child device.\r
+  Test to see if this driver supports ControllerHandle. This is the worker function for\r
+  HttpDxeIp4(6)DriverBindingSupported.\r
 \r
-  This function checks to see if the driver specified by This supports the device specified by \r
-  ControllerHandle. Drivers will typically use the device path attached to \r
-  ControllerHandle and/or the services from the bus I/O abstraction attached to \r
-  ControllerHandle to determine if the driver supports ControllerHandle. This function \r
-  may be called many times during platform initialization. In order to reduce boot times, the tests \r
-  performed by this function must be very small, and take as little time as possible to execute. This \r
-  function must not change the state of any hardware devices, and this function must be aware that the \r
-  device specified by ControllerHandle may already be managed by the same driver or a \r
-  different driver. This function must match its calls to AllocatePages() with FreePages(), \r
-  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().  \r
-  Because ControllerHandle may have been previously started by the same driver, if a protocol is \r
-  already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
-  to guarantee the state of ControllerHandle is not modified by this function.\r
+  @param[in]  This                The pointer to the driver binding protocol.\r
+  @param[in]  ControllerHandle    The handle of device to be tested.\r
+  @param[in]  RemainingDevicePath Optional parameter used to pick a specific child\r
+                                  device to be started.\r
+  @param[in]  IpVersion           IP_VERSION_4 or IP_VERSION_6.\r
 \r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to test. This handle \r
-                                   must support a protocol interface that supplies \r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
-                                   parameter is ignored by device drivers, and is optional for bus \r
-                                   drivers. For bus drivers, if this parameter is not NULL, then \r
-                                   the bus driver must determine if the bus controller specified \r
-                                   by ControllerHandle and the child controller specified \r
-                                   by RemainingDevicePath are both supported by this \r
-                                   bus driver.\r
+  @retval EFI_SUCCESS         This driver supports this device.\r
+  @retval EFI_UNSUPPORTED     This driver does not support this device.\r
 \r
-  @retval EFI_SUCCESS              The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is supported by the driver specified by This.\r
-  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is already being managed by the driver\r
-                                   specified by This.\r
-  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is already being managed by a different\r
-                                   driver or an application that requires exclusive access.\r
-                                   Currently not implemented.\r
-  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is not supported by the driver specified by This.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-HttpDxeDriverBindingSupported (\r
+HttpDxeSupported (\r
   IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN EFI_HANDLE                   ControllerHandle,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL,\r
+  IN UINT8                        IpVersion\r
   )\r
 {\r
-  EFI_STATUS       Status;\r
+  EFI_STATUS                      Status;\r
+  EFI_GUID                        *TcpServiceBindingProtocolGuid;\r
 \r
-  //\r
-  // Test for the HttpServiceBinding protocol.\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiHttpServiceBindingProtocolGuid,\r
-                  NULL,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    return EFI_ALREADY_STARTED;\r
+  if (IpVersion == IP_VERSION_4) {\r
+    TcpServiceBindingProtocolGuid = &gEfiTcp4ServiceBindingProtocolGuid;\r
+  } else {\r
+    TcpServiceBindingProtocolGuid = &gEfiTcp6ServiceBindingProtocolGuid;\r
   }\r
 \r
-  //\r
-  // Test for the Tcp4 Protocol\r
-  //\r
-  return gBS->OpenProtocol (\r
+  Status = gBS->OpenProtocol (\r
                 ControllerHandle,\r
-                &gEfiTcp4ServiceBindingProtocolGuid,\r
+                TcpServiceBindingProtocolGuid,\r
                 NULL,\r
                 This->DriverBindingHandle,\r
                 ControllerHandle,\r
                 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
                 );\r
-  \r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
-  Starts a device controller or a bus controller.\r
+  Start this driver on ControllerHandle. This is the worker function for\r
+  HttpDxeIp4(6)DriverBindingStart.\r
 \r
-  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
-  As a result, much of the error checking on the parameters to Start() has been moved into this \r
-  common boot service. It is legal to call Start() from other locations, \r
-  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE.\r
-  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
-     EFI_DEVICE_PATH_PROTOCOL.\r
-  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
-     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.  \r
+  @param[in]  This                 The pointer to the driver binding protocol.\r
+  @param[in]  ControllerHandle     The handle of device to be started.\r
+  @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child\r
+                                   device to be started.\r
+  @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.\r
 \r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to start. This handle \r
-                                   must support a protocol interface that supplies \r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
-                                   parameter is ignored by device drivers, and is optional for bus \r
-                                   drivers. For a bus driver, if this parameter is NULL, then handles \r
-                                   for all the children of Controller are created by this driver.  \r
-                                   If this parameter is not NULL and the first Device Path Node is \r
-                                   not the End of Device Path Node, then only the handle for the \r
-                                   child device specified by the first Device Path Node of \r
-                                   RemainingDevicePath is created by this driver.\r
-                                   If the first Device Path Node of RemainingDevicePath is \r
-                                   the End of Device Path Node, no child handle is created by this\r
-                                   driver.\r
 \r
-  @retval EFI_SUCCESS              The device was started.\r
-  @retval EFI_ALREADY_STARTED      This device is already running on ControllerHandle.\r
-  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.\r
-  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
-  @retval Others                   The driver failded to start the device.\r
+  @retval EFI_SUCCESS          This driver is installed to ControllerHandle.\r
+  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle.\r
+  @retval other                This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-HttpDxeDriverBindingStart (\r
+HttpDxeStart (\r
   IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN EFI_HANDLE                   ControllerHandle,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL,\r
+  IN UINT8                        IpVersion\r
   )\r
 {\r
   EFI_STATUS                      Status;\r
+  EFI_SERVICE_BINDING_PROTOCOL    *ServiceBinding;\r
   HTTP_SERVICE                    *HttpService;\r
   VOID                            *Interface;\r
-  \r
+  BOOLEAN                         UsingIpv6;\r
+\r
+  UsingIpv6 = FALSE;\r
+\r
   //\r
   // Test for the Http service binding protocol\r
   //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
                   &gEfiHttpServiceBindingProtocolGuid,\r
-                  NULL,\r
+                  (VOID **) &ServiceBinding,\r
                   This->DriverBindingHandle,\r
                   ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                   );\r
 \r
-  if (Status == EFI_SUCCESS) {\r
-    return EFI_ALREADY_STARTED;\r
-  }\r
-\r
-  Status = HttpCreateService (ControllerHandle, This->DriverBindingHandle, &HttpService);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  ASSERT (HttpService != NULL);\r
-\r
-  //\r
-  // Create a TCP child instance, but do not configure it. This will establish the parent-child relationship.\r
-  //\r
-  Status = NetLibCreateServiceChild (\r
-             ControllerHandle,\r
-             This->DriverBindingHandle,\r
-             &gEfiTcp4ServiceBindingProtocolGuid,\r
-             &HttpService->TcpChildHandle\r
-             );\r
+  if (!EFI_ERROR (Status)) {\r
+    HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);\r
+  } else {\r
+    Status = HttpCreateService (ControllerHandle, &HttpService);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
 \r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_ERROR;\r
-  }\r
+    ASSERT (HttpService != NULL);\r
 \r
-  Status = gBS->OpenProtocol (\r
-                  HttpService->TcpChildHandle,\r
-                  &gEfiTcp4ProtocolGuid,\r
-                  &Interface,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-                  \r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_ERROR;\r
+    //\r
+    // Install the HttpServiceBinding Protocol onto Controller\r
+    //\r
+    Status = gBS->InstallMultipleProtocolInterfaces (\r
+                    &ControllerHandle,\r
+                    &gEfiHttpServiceBindingProtocolGuid,\r
+                    &HttpService->ServiceBinding,\r
+                    NULL\r
+                    );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      goto ON_ERROR;\r
+    }\r
   }\r
 \r
-  //\r
-  // Install the HttpServiceBinding Protocol onto Controller\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &ControllerHandle,\r
-                  &gEfiHttpServiceBindingProtocolGuid,\r
-                  &HttpService->ServiceBinding,\r
-                  NULL\r
-                  );\r
+  if (IpVersion == IP_VERSION_4) {\r
+    HttpService->Ip4DriverBindingHandle = This->DriverBindingHandle;\r
+\r
+    if (HttpService->Tcp4ChildHandle == NULL) {\r
+      //\r
+      // Create a TCP4 child instance, but do not configure it. This will establish the parent-child relationship.\r
+      //\r
+      Status = NetLibCreateServiceChild (\r
+                 ControllerHandle,\r
+                 This->DriverBindingHandle,\r
+                 &gEfiTcp4ServiceBindingProtocolGuid,\r
+                 &HttpService->Tcp4ChildHandle\r
+                 );\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        goto ON_ERROR;\r
+      }\r
+\r
+      Status = gBS->OpenProtocol (\r
+                      HttpService->Tcp4ChildHandle,\r
+                      &gEfiTcp4ProtocolGuid,\r
+                      &Interface,\r
+                      This->DriverBindingHandle,\r
+                      ControllerHandle,\r
+                      EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                      );\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        goto ON_ERROR;\r
+      }\r
+\r
+    } else {\r
+      return EFI_ALREADY_STARTED;\r
+    }\r
+\r
+  } else {\r
+    UsingIpv6 = TRUE;\r
+    HttpService->Ip6DriverBindingHandle = This->DriverBindingHandle;\r
+\r
+    if (HttpService->Tcp6ChildHandle == NULL) {\r
+      //\r
+      // Create a TCP6 child instance, but do not configure it. This will establish the parent-child relationship.\r
+      //\r
+      Status = NetLibCreateServiceChild (\r
+                 ControllerHandle,\r
+                 This->DriverBindingHandle,\r
+                 &gEfiTcp6ServiceBindingProtocolGuid,\r
+                 &HttpService->Tcp6ChildHandle\r
+                 );\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        goto ON_ERROR;\r
+      }\r
+\r
+      Status = gBS->OpenProtocol (\r
+                      HttpService->Tcp6ChildHandle,\r
+                      &gEfiTcp6ProtocolGuid,\r
+                      &Interface,\r
+                      This->DriverBindingHandle,\r
+                      ControllerHandle,\r
+                      EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                      );\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        goto ON_ERROR;\r
+      }\r
+\r
+    } else {\r
+      return EFI_ALREADY_STARTED;\r
+    }\r
 \r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_ERROR;\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -421,46 +468,41 @@ HttpDxeDriverBindingStart (
 ON_ERROR:\r
 \r
   if (HttpService != NULL) {\r
-    HttpCleanService (HttpService);\r
-    FreePool (HttpService);\r
+    HttpCleanService (HttpService, UsingIpv6);\r
+    if (HttpService->Tcp4ChildHandle == NULL && HttpService->Tcp6ChildHandle == NULL) {\r
+      FreePool (HttpService);\r
+    }\r
   }\r
-  \r
+\r
   return Status;\r
+\r
+\r
 }\r
 \r
 /**\r
-  Stops a device controller or a bus controller.\r
-  \r
-  The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
-  As a result, much of the error checking on the parameters to Stop() has been moved \r
-  into this common boot service. It is legal to call Stop() from other locations, \r
-  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
-     same driver's Start() function.\r
-  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
-     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
-     Start() function, and the Start() function must have called OpenProtocol() on\r
-     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
-  \r
-  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must \r
-                                support a bus specific I/O protocol for the driver \r
-                                to use to stop the device.\r
-  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL \r
-                                if NumberOfChildren is 0.\r
+  Stop this driver on ControllerHandle. This is the worker function for\r
+  HttpDxeIp4(6)DriverBindingStop.\r
 \r
-  @retval EFI_SUCCESS           The device was stopped.\r
-  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
+  @param[in]  This              Protocol instance pointer.\r
+  @param[in]  ControllerHandle  Handle of device to stop driver on.\r
+  @param[in]  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
+                                children is zero stop the entire bus driver.\r
+  @param[in]  ChildHandleBuffer List of Child Handles to Stop.\r
+  @param[in]  IpVersion         IP_VERSION_4 or IP_VERSION_6.\r
+\r
+  @retval EFI_SUCCESS           This driver was removed ControllerHandle.\r
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.\r
+  @retval Others                This driver was not removed from this device\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-HttpDxeDriverBindingStop (\r
+HttpDxeStop (\r
   IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN EFI_HANDLE                   ControllerHandle,\r
   IN UINTN                        NumberOfChildren,\r
-  IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL\r
+  IN EFI_HANDLE                   *ChildHandleBuffer,\r
+  IN UINT8                        IpVersion\r
   )\r
 {\r
   EFI_HANDLE                                 NicHandle;\r
@@ -469,13 +511,21 @@ HttpDxeDriverBindingStop (
   HTTP_SERVICE                               *HttpService;\r
   LIST_ENTRY                                 *List;\r
   HTTP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT   Context;\r
-  \r
+  BOOLEAN                                    UsingIpv6;\r
+\r
   //\r
-  // HTTP driver opens TCP child, So, Controller is a TCP\r
+  // HTTP driver opens TCP4(6) child, So, Controller is a TCP4(6)\r
   // child handle. Locate the Nic handle first. Then get the\r
   // HTTP private data back.\r
   //\r
-  NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid);\r
+  if (IpVersion == IP_VERSION_4) {\r
+    UsingIpv6 = FALSE;\r
+    NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid);\r
+  } else {\r
+    UsingIpv6 = TRUE;\r
+    NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiTcp6ProtocolGuid);\r
+  }\r
+\r
   if (NicHandle == NULL) {\r
     return EFI_SUCCESS;\r
   }\r
@@ -489,45 +539,352 @@ HttpDxeDriverBindingStop (
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                   );\r
 \r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);\r
+  if (!EFI_ERROR (Status)) {\r
 \r
-  if (!IsListEmpty (&HttpService->ChildrenList)) {\r
-    //\r
-    // Destroy the HTTP child instance in ChildHandleBuffer.\r
-    //\r
-    List = &HttpService->ChildrenList;\r
-    Context.ServiceBinding    = ServiceBinding;\r
-    Context.NumberOfChildren  = NumberOfChildren;\r
-    Context.ChildHandleBuffer = ChildHandleBuffer;\r
-    Status = NetDestroyLinkList (\r
-               List,\r
-               HttpDestroyChildEntryInHandleBuffer,\r
-               &Context,\r
-               NULL\r
+    HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);\r
+\r
+    if (NumberOfChildren != 0) {\r
+      //\r
+      // Destroy the HTTP child instance in ChildHandleBuffer.\r
+      //\r
+      List = &HttpService->ChildrenList;\r
+      Context.ServiceBinding    = ServiceBinding;\r
+      Context.NumberOfChildren  = NumberOfChildren;\r
+      Context.ChildHandleBuffer = ChildHandleBuffer;\r
+      Status = NetDestroyLinkList (\r
+                 List,\r
+                 HttpDestroyChildEntryInHandleBuffer,\r
+                 &Context,\r
+                 NULL\r
+                 );\r
+    } else {\r
+\r
+      HttpCleanService (HttpService, UsingIpv6);\r
+\r
+      if (HttpService->Tcp4ChildHandle == NULL && HttpService->Tcp6ChildHandle == NULL) {\r
+        gBS->UninstallProtocolInterface (\r
+               NicHandle,\r
+               &gEfiHttpServiceBindingProtocolGuid,\r
+               ServiceBinding\r
                );\r
+        FreePool (HttpService);\r
+      }\r
+      Status = EFI_SUCCESS;\r
+    }\r
   }\r
 \r
-  if (NumberOfChildren == 0 && IsListEmpty (&HttpService->ChildrenList)) {\r
-    gBS->UninstallProtocolInterface (\r
-           NicHandle,\r
-           &gEfiHttpServiceBindingProtocolGuid,\r
-           ServiceBinding\r
+  return Status;\r
+\r
+}\r
+\r
+/**\r
+  Tests to see if this driver supports a given controller. If a child device is provided,\r
+  it further tests to see if this driver supports creating a handle for the specified child device.\r
+\r
+  This function checks to see if the driver specified by This supports the device specified by\r
+  ControllerHandle. Drivers will typically use the device path attached to\r
+  ControllerHandle and/or the services from the bus I/O abstraction attached to\r
+  ControllerHandle to determine if the driver supports ControllerHandle. This function\r
+  may be called many times during platform initialization. In order to reduce boot times, the tests\r
+  performed by this function must be very small, and take as little time as possible to execute. This\r
+  function must not change the state of any hardware devices, and this function must be aware that the\r
+  device specified by ControllerHandle may already be managed by the same driver or a\r
+  different driver. This function must match its calls to AllocatePages() with FreePages(),\r
+  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r
+  Because ControllerHandle may have been previously started by the same driver, if a protocol is\r
+  already in the opened state, then it must not be closed with CloseProtocol(). This is required\r
+  to guarantee the state of ControllerHandle is not modified by this function.\r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to test. This handle\r
+                                   must support a protocol interface that supplies\r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This\r
+                                   parameter is ignored by device drivers, and is optional for bus\r
+                                   drivers. For bus drivers, if this parameter is not NULL, then\r
+                                   the bus driver must determine if the bus controller specified\r
+                                   by ControllerHandle and the child controller specified\r
+                                   by RemainingDevicePath are both supported by this\r
+                                   bus driver.\r
+\r
+  @retval EFI_SUCCESS              The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is supported by the driver specified by This.\r
+  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is already being managed by the driver\r
+                                   specified by This.\r
+  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is already being managed by a different\r
+                                   driver or an application that requires exclusive access.\r
+                                   Currently not implemented.\r
+  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is not supported by the driver specified by This.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpDxeIp4DriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
+  )\r
+{\r
+  return HttpDxeSupported (\r
+           This,\r
+           ControllerHandle,\r
+           RemainingDevicePath,\r
+           IP_VERSION_4\r
            );\r
+}\r
 \r
-    HttpCleanService (HttpService);\r
-   \r
-    FreePool (HttpService);\r
+/**\r
+  Starts a device controller or a bus controller.\r
 \r
-    Status = EFI_SUCCESS;\r
-  }\r
+  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
+  As a result, much of the error checking on the parameters to Start() has been moved into this\r
+  common boot service. It is legal to call Start() from other locations,\r
+  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE.\r
+  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
+     EFI_DEVICE_PATH_PROTOCOL.\r
+  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
+     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to start. This handle\r
+                                   must support a protocol interface that supplies\r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This\r
+                                   parameter is ignored by device drivers, and is optional for bus\r
+                                   drivers. For a bus driver, if this parameter is NULL, then handles\r
+                                   for all the children of Controller are created by this driver.\r
+                                   If this parameter is not NULL and the first Device Path Node is\r
+                                   not the End of Device Path Node, then only the handle for the\r
+                                   child device specified by the first Device Path Node of\r
+                                   RemainingDevicePath is created by this driver.\r
+                                   If the first Device Path Node of RemainingDevicePath is\r
+                                   the End of Device Path Node, no child handle is created by this\r
+                                   driver.\r
+\r
+  @retval EFI_SUCCESS              The device was started.\r
+  @retval EFI_ALREADY_STARTED      This device is already running on ControllerHandle.\r
+  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.\r
+  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
+  @retval Others                   The driver failded to start the device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpDxeIp4DriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
+  )\r
+{\r
+  return HttpDxeStart (\r
+           This,\r
+           ControllerHandle,\r
+           RemainingDevicePath,\r
+           IP_VERSION_4\r
+           );\r
+}\r
+\r
+/**\r
+  Stops a device controller or a bus controller.\r
+\r
+  The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
+  As a result, much of the error checking on the parameters to Stop() has been moved\r
+  into this common boot service. It is legal to call Stop() from other locations,\r
+  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
+     same driver's Start() function.\r
+  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
+     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
+     Start() function, and the Start() function must have called OpenProtocol() on\r
+     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+\r
+  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must\r
+                                support a bus specific I/O protocol for the driver\r
+                                to use to stop the device.\r
+  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
+  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL\r
+                                if NumberOfChildren is 0.\r
+\r
+  @retval EFI_SUCCESS           The device was stopped.\r
+  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpDxeIp4DriverBindingStop (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN UINTN                        NumberOfChildren,\r
+  IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL\r
+  )\r
+{\r
+  return HttpDxeStop (\r
+           This,\r
+           ControllerHandle,\r
+           NumberOfChildren,\r
+           ChildHandleBuffer,\r
+           IP_VERSION_4\r
+           );\r
+}\r
+\r
+/**\r
+  Tests to see if this driver supports a given controller. If a child device is provided,\r
+  it further tests to see if this driver supports creating a handle for the specified child device.\r
+\r
+  This function checks to see if the driver specified by This supports the device specified by\r
+  ControllerHandle. Drivers will typically use the device path attached to\r
+  ControllerHandle and/or the services from the bus I/O abstraction attached to\r
+  ControllerHandle to determine if the driver supports ControllerHandle. This function\r
+  may be called many times during platform initialization. In order to reduce boot times, the tests\r
+  performed by this function must be very small, and take as little time as possible to execute. This\r
+  function must not change the state of any hardware devices, and this function must be aware that the\r
+  device specified by ControllerHandle may already be managed by the same driver or a\r
+  different driver. This function must match its calls to AllocatePages() with FreePages(),\r
+  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r
+  Because ControllerHandle may have been previously started by the same driver, if a protocol is\r
+  already in the opened state, then it must not be closed with CloseProtocol(). This is required\r
+  to guarantee the state of ControllerHandle is not modified by this function.\r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to test. This handle\r
+                                   must support a protocol interface that supplies\r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This\r
+                                   parameter is ignored by device drivers, and is optional for bus\r
+                                   drivers. For bus drivers, if this parameter is not NULL, then\r
+                                   the bus driver must determine if the bus controller specified\r
+                                   by ControllerHandle and the child controller specified\r
+                                   by RemainingDevicePath are both supported by this\r
+                                   bus driver.\r
+\r
+  @retval EFI_SUCCESS              The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is supported by the driver specified by This.\r
+  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is already being managed by the driver\r
+                                   specified by This.\r
+  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is already being managed by a different\r
+                                   driver or an application that requires exclusive access.\r
+                                   Currently not implemented.\r
+  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is not supported by the driver specified by This.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpDxeIp6DriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
+  )\r
+{\r
+  return HttpDxeSupported (\r
+           This,\r
+           ControllerHandle,\r
+           RemainingDevicePath,\r
+           IP_VERSION_6\r
+           );\r
 \r
-  return Status;\r
 }\r
 \r
+/**\r
+  Starts a device controller or a bus controller.\r
+\r
+  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
+  As a result, much of the error checking on the parameters to Start() has been moved into this\r
+  common boot service. It is legal to call Start() from other locations,\r
+  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE.\r
+  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
+     EFI_DEVICE_PATH_PROTOCOL.\r
+  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
+     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to start. This handle\r
+                                   must support a protocol interface that supplies\r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This\r
+                                   parameter is ignored by device drivers, and is optional for bus\r
+                                   drivers. For a bus driver, if this parameter is NULL, then handles\r
+                                   for all the children of Controller are created by this driver.\r
+                                   If this parameter is not NULL and the first Device Path Node is\r
+                                   not the End of Device Path Node, then only the handle for the\r
+                                   child device specified by the first Device Path Node of\r
+                                   RemainingDevicePath is created by this driver.\r
+                                   If the first Device Path Node of RemainingDevicePath is\r
+                                   the End of Device Path Node, no child handle is created by this\r
+                                   driver.\r
+\r
+  @retval EFI_SUCCESS              The device was started.\r
+  @retval EFI_ALREADY_STARTED      This device is already running on ControllerHandle.\r
+  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.\r
+  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
+  @retval Others                   The driver failded to start the device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpDxeIp6DriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
+  )\r
+{\r
+  return HttpDxeStart (\r
+           This,\r
+           ControllerHandle,\r
+           RemainingDevicePath,\r
+           IP_VERSION_6\r
+           );\r
+}\r
+\r
+/**\r
+  Stops a device controller or a bus controller.\r
+\r
+  The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
+  As a result, much of the error checking on the parameters to Stop() has been moved\r
+  into this common boot service. It is legal to call Stop() from other locations,\r
+  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
+     same driver's Start() function.\r
+  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
+     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
+     Start() function, and the Start() function must have called OpenProtocol() on\r
+     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+\r
+  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must\r
+                                support a bus specific I/O protocol for the driver\r
+                                to use to stop the device.\r
+  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
+  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL\r
+                                if NumberOfChildren is 0.\r
+\r
+  @retval EFI_SUCCESS           The device was stopped.\r
+  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpDxeIp6DriverBindingStop (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN UINTN                        NumberOfChildren,\r
+  IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL\r
+  )\r
+{\r
+  return HttpDxeStop (\r
+           This,\r
+           ControllerHandle,\r
+           NumberOfChildren,\r
+           ChildHandleBuffer,\r
+           IP_VERSION_6\r
+           );\r
+}\r
 /**\r
   Creates a child handle and installs a protocol.\r
 \r
@@ -542,7 +899,7 @@ HttpDxeDriverBindingStop (
 \r
   @retval EFI_SUCCES            The protocol was added to ChildHandle.\r
   @retval EFI_INVALID_PARAMETER This is NULL, or ChildHandle is NULL.\r
-  @retval EFI_OUT_OF_RESOURCES  There are not enough resources availabe to create\r
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resources available to create\r
                                 the child.\r
   @retval other                 The child handle was not created.\r
 \r
@@ -557,7 +914,6 @@ HttpServiceBindingCreateChild (
   HTTP_SERVICE         *HttpService;\r
   HTTP_PROTOCOL        *HttpInstance;\r
   EFI_STATUS           Status;\r
-  VOID                 *Interface;\r
   EFI_TPL              OldTpl;\r
 \r
   if ((This == NULL) || (ChildHandle == NULL)) {\r
@@ -570,6 +926,14 @@ HttpServiceBindingCreateChild (
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
+  HttpInstance->Signature = HTTP_PROTOCOL_SIGNATURE;\r
+  HttpInstance->Service   = HttpService;\r
+  HttpInstance->Method = HttpMethodMax;\r
+\r
+  CopyMem (&HttpInstance->Http, &mEfiHttpTemplate, sizeof (HttpInstance->Http));\r
+  NetMapInit (&HttpInstance->TxTokens);\r
+  NetMapInit (&HttpInstance->RxTokens);\r
+\r
   //\r
   // Install HTTP protocol onto ChildHandle\r
   //\r
@@ -584,27 +948,7 @@ HttpServiceBindingCreateChild (
     goto ON_ERROR;\r
   }\r
 \r
-  HttpInstance->Handle = *ChildHandle;\r
-\r
-  Status = HttpInitProtocol (HttpService, HttpInstance);\r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_ERROR;\r
-  }\r
-\r
-  //\r
-  // Open the default Tcp4 protocol by child.\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  HttpService->TcpChildHandle,\r
-                  &gEfiTcp4ProtocolGuid,\r
-                  (VOID **) &Interface,\r
-                  gHttpDxeDriverBinding.DriverBindingHandle,\r
-                  HttpInstance->Handle,\r
-                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_ERROR;\r
-  }\r
+  HttpInstance->Handle    = *ChildHandle;\r
 \r
   //\r
   // Add it to the HTTP service's child list.\r
@@ -617,10 +961,11 @@ HttpServiceBindingCreateChild (
   gBS->RestoreTPL (OldTpl);\r
 \r
   return EFI_SUCCESS;\r
-  \r
+\r
 ON_ERROR:\r
 \r
-  HttpCleanProtocol (HttpInstance);\r
+  NetMapClean (&HttpInstance->TxTokens);\r
+  NetMapClean (&HttpInstance->RxTokens);\r
   FreePool (HttpInstance);\r
 \r
   return Status;\r
@@ -654,7 +999,7 @@ HttpServiceBindingDestroyChild (
   EFI_HTTP_PROTOCOL        *Http;\r
   EFI_STATUS                Status;\r
   EFI_TPL                   OldTpl;\r
-  \r
+\r
   if ((This == NULL) || (ChildHandle == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -664,14 +1009,14 @@ HttpServiceBindingDestroyChild (
                   ChildHandle,\r
                   &gEfiHttpProtocolGuid,\r
                   (VOID **) &Http,\r
-                  gHttpDxeDriverBinding.DriverBindingHandle,\r
-                  ChildHandle,\r
+                  NULL,\r
+                  NULL,\r
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
-  \r
+\r
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (Http);\r
   if (HttpInstance->Service != HttpService) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -681,16 +1026,6 @@ HttpServiceBindingDestroyChild (
     return EFI_SUCCESS;\r
   }\r
 \r
-  //\r
-  // Close the Tcp4 protocol.\r
-  //\r
-  gBS->CloseProtocol (\r
-         HttpService->TcpChildHandle,\r
-         &gEfiTcp4ProtocolGuid,\r
-         gHttpDxeDriverBinding.DriverBindingHandle,\r
-         ChildHandle\r
-         );\r
-  \r
   HttpInstance->InDestroy = TRUE;\r
 \r
   //\r
@@ -707,15 +1042,15 @@ HttpServiceBindingDestroyChild (
     return Status;\r
   }\r
 \r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
   HttpCleanProtocol (HttpInstance);\r
 \r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
   RemoveEntryList (&HttpInstance->Link);\r
   HttpService->ChildrenNumber--;\r
 \r
   gBS->RestoreTPL (OldTpl);\r
-  \r
+\r
   FreePool (HttpInstance);\r
   return EFI_SUCCESS;\r
 }\r