]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Fix protocol handler service in HttpDxe.
authorZhang, Lubo <lubo.zhang@intel.com>
Sun, 22 Jan 2017 01:40:30 +0000 (09:40 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Mon, 23 Jan 2017 07:19:05 +0000 (15:19 +0800)
When we create a HTTP driver service binding private
instance, there may be different DriverBindingHandle
for Ipv4 or Ipv6, so it is essential to distinguish
the HttpService image which will be used in open
protocol or close protocol.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Sriram Subramanian <sriram-s@hpe.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
NetworkPkg/HttpDxe/HttpDns.c
NetworkPkg/HttpDxe/HttpDriver.c
NetworkPkg/HttpDxe/HttpImpl.c
NetworkPkg/HttpDxe/HttpProto.c
NetworkPkg/HttpDxe/HttpProto.h

index 0f5fe180727025d475f7a535bf43b1639260caac..59cd7b325189b4c777812c38426a4c87d38e1a85 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Routines for HttpDxe driver to perform DNS resolution based on UEFI DNS protocols.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2017, 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
@@ -88,7 +88,7 @@ HttpDns4 (
   //\r
   Status = NetLibCreateServiceChild (\r
              Service->ControllerHandle,\r
-             Service->ImageHandle,\r
+             Service->Ip4DriverBindingHandle,\r
              &gEfiDns4ServiceBindingProtocolGuid,\r
              &Dns4Handle\r
              );\r
@@ -100,7 +100,7 @@ HttpDns4 (
                   Dns4Handle,\r
                   &gEfiDns4ProtocolGuid,\r
                   (VOID **) &Dns4,\r
-                  Service->ImageHandle,\r
+                  Service->Ip4DriverBindingHandle,\r
                   Service->ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
                   );\r
@@ -196,7 +196,7 @@ Exit:
     gBS->CloseProtocol (\r
            Dns4Handle,\r
            &gEfiDns4ProtocolGuid,\r
-           Service->ImageHandle,\r
+           Service->Ip4DriverBindingHandle,\r
            Service->ControllerHandle\r
            );\r
   }\r
@@ -204,7 +204,7 @@ Exit:
   if (Dns4Handle != NULL) {\r
     NetLibDestroyServiceChild (\r
       Service->ControllerHandle,\r
-      Service->ImageHandle,\r
+      Service->Ip4DriverBindingHandle,\r
       &gEfiDns4ServiceBindingProtocolGuid,\r
       Dns4Handle\r
       );\r
@@ -290,7 +290,7 @@ HttpDns6 (
   //\r
   Status = NetLibCreateServiceChild (\r
              Service->ControllerHandle,\r
-             Service->ImageHandle,\r
+             Service->Ip6DriverBindingHandle,\r
              &gEfiDns6ServiceBindingProtocolGuid,\r
              &Dns6Handle\r
              );\r
@@ -302,7 +302,7 @@ HttpDns6 (
                   Dns6Handle,\r
                   &gEfiDns6ProtocolGuid,\r
                   (VOID **) &Dns6,\r
-                  Service->ImageHandle,\r
+                  Service->Ip6DriverBindingHandle,\r
                   Service->ControllerHandle,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
                   );\r
@@ -393,7 +393,7 @@ Exit:
     gBS->CloseProtocol (\r
            Dns6Handle,\r
            &gEfiDns6ProtocolGuid,\r
-           Service->ImageHandle,\r
+           Service->Ip6DriverBindingHandle,\r
            Service->ControllerHandle\r
            );\r
   }\r
@@ -401,7 +401,7 @@ Exit:
   if (Dns6Handle != NULL) {\r
     NetLibDestroyServiceChild (\r
       Service->ControllerHandle,\r
-      Service->ImageHandle,\r
+      Service->Ip6DriverBindingHandle,\r
       &gEfiDns6ServiceBindingProtocolGuid,\r
       Dns6Handle\r
       );\r
index de2763517326ea3e501b24f9d1fc5377ff959efd..5727526273c3e54151f073ebcfda3d672c2350a7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The driver binding and service binding protocol for HttpDxe driver.\r
 \r
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2017, 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
@@ -45,7 +45,6 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp6DriverBinding = {
 \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
@@ -55,7 +54,6 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpDxeIp6DriverBinding = {
 EFI_STATUS\r
 HttpCreateService (\r
   IN  EFI_HANDLE            Controller,\r
-  IN  EFI_HANDLE            ImageHandle,\r
   OUT HTTP_SERVICE          **ServiceData\r
   )\r
 {\r
@@ -72,7 +70,6 @@ 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
@@ -104,13 +101,13 @@ HttpCleanService (
       gBS->CloseProtocol (\r
              HttpService->Tcp4ChildHandle,\r
              &gEfiTcp4ProtocolGuid,\r
-             HttpService->ImageHandle,\r
+             HttpService->Ip4DriverBindingHandle,\r
              HttpService->ControllerHandle\r
              );\r
     \r
       NetLibDestroyServiceChild (\r
         HttpService->ControllerHandle,\r
-        HttpService->ImageHandle,\r
+        HttpService->Ip4DriverBindingHandle,\r
         &gEfiTcp4ServiceBindingProtocolGuid,\r
         HttpService->Tcp4ChildHandle\r
         );\r
@@ -122,13 +119,13 @@ HttpCleanService (
       gBS->CloseProtocol (\r
              HttpService->Tcp6ChildHandle,\r
              &gEfiTcp6ProtocolGuid,\r
-             HttpService->ImageHandle,\r
+             HttpService->Ip6DriverBindingHandle,\r
              HttpService->ControllerHandle\r
              );\r
     \r
       NetLibDestroyServiceChild (\r
         HttpService->ControllerHandle,\r
-        HttpService->ImageHandle,\r
+        HttpService->Ip6DriverBindingHandle,\r
         &gEfiTcp6ServiceBindingProtocolGuid,\r
         HttpService->Tcp6ChildHandle\r
         );\r
@@ -382,7 +379,7 @@ HttpDxeStart (
   if (!EFI_ERROR (Status)) {\r
     HttpService = HTTP_SERVICE_FROM_PROTOCOL (ServiceBinding);\r
   } else {\r
-    Status = HttpCreateService (ControllerHandle, This->DriverBindingHandle, &HttpService);\r
+    Status = HttpCreateService (ControllerHandle, &HttpService);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
@@ -405,7 +402,8 @@ HttpDxeStart (
   }\r
 \r
   if (IpVersion == IP_VERSION_4) {\r
-    \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
@@ -440,7 +438,8 @@ HttpDxeStart (
 \r
   } else {\r
     UsingIpv6 = TRUE;\r
-    \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
index 85b00833492e52ebbaabb7bf520d3bff2325e30a..745832b9d0bc15f85d802a4e0ad9dc381f4d7099 100644 (file)
@@ -249,6 +249,7 @@ EfiHttpRequest (
   HTTP_TOKEN_WRAP               *Wrap;\r
   CHAR8                         *FileUrl;\r
   UINTN                         RequestMsgSize;\r
+  EFI_HANDLE                    ImageHandle;\r
 \r
   //\r
   // Initializations\r
@@ -371,8 +372,14 @@ EfiHttpRequest (
       //\r
       // Use TlsSb to create Tls child and open the TLS protocol.\r
       //\r
+      if (HttpInstance->LocalAddressIsIPv6) {\r
+        ImageHandle = HttpInstance->Service->Ip6DriverBindingHandle;\r
+      } else {\r
+        ImageHandle = HttpInstance->Service->Ip4DriverBindingHandle;\r
+      }\r
+\r
       HttpInstance->TlsChildHandle = TlsCreateChild (\r
-                                       HttpInstance->Service->ImageHandle,\r
+                                       ImageHandle,\r
                                        &(HttpInstance->Tls),\r
                                        &(HttpInstance->TlsConfiguration)\r
                                        );\r
index 2e8c42e62999154ed62cd1ff4ce5bca1f5bb15a8..3d61ba2ae122b49ed5f8f6424557f37332c466e5 100644 (file)
@@ -642,7 +642,7 @@ HttpInitProtocol (
     //\r
     Status = NetLibCreateServiceChild (\r
                HttpInstance->Service->ControllerHandle,\r
-               HttpInstance->Service->ImageHandle,\r
+               HttpInstance->Service->Ip4DriverBindingHandle,\r
                &gEfiTcp4ServiceBindingProtocolGuid,\r
                &HttpInstance->Tcp4ChildHandle\r
                );\r
@@ -655,7 +655,7 @@ HttpInitProtocol (
                     HttpInstance->Tcp4ChildHandle,\r
                     &gEfiTcp4ProtocolGuid,\r
                     (VOID **) &Interface,\r
-                    HttpInstance->Service->ImageHandle,\r
+                    HttpInstance->Service->Ip4DriverBindingHandle,\r
                     HttpInstance->Service->ControllerHandle,\r
                     EFI_OPEN_PROTOCOL_BY_DRIVER\r
                     );\r
@@ -668,7 +668,7 @@ HttpInitProtocol (
                     HttpInstance->Tcp4ChildHandle,\r
                     &gEfiTcp4ProtocolGuid,\r
                     (VOID **) &HttpInstance->Tcp4,\r
-                    HttpInstance->Service->ImageHandle,\r
+                    HttpInstance->Service->Ip4DriverBindingHandle,\r
                     HttpInstance->Handle,\r
                     EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
                     );\r
@@ -680,7 +680,7 @@ HttpInitProtocol (
                     HttpInstance->Service->Tcp4ChildHandle,\r
                     &gEfiTcp4ProtocolGuid,\r
                     (VOID **) &Interface,\r
-                    HttpInstance->Service->ImageHandle,\r
+                    HttpInstance->Service->Ip4DriverBindingHandle,\r
                     HttpInstance->Handle,\r
                     EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
                     );\r
@@ -693,7 +693,7 @@ HttpInitProtocol (
     //\r
     Status = NetLibCreateServiceChild (\r
                HttpInstance->Service->ControllerHandle,\r
-               HttpInstance->Service->ImageHandle,\r
+               HttpInstance->Service->Ip6DriverBindingHandle,\r
                &gEfiTcp6ServiceBindingProtocolGuid,\r
                &HttpInstance->Tcp6ChildHandle\r
                );\r
@@ -706,7 +706,7 @@ HttpInitProtocol (
                     HttpInstance->Tcp6ChildHandle,\r
                     &gEfiTcp6ProtocolGuid,\r
                     (VOID **) &Interface,\r
-                    HttpInstance->Service->ImageHandle,\r
+                    HttpInstance->Service->Ip6DriverBindingHandle,\r
                     HttpInstance->Service->ControllerHandle,\r
                     EFI_OPEN_PROTOCOL_BY_DRIVER\r
                     );\r
@@ -719,7 +719,7 @@ HttpInitProtocol (
                     HttpInstance->Tcp6ChildHandle,\r
                     &gEfiTcp6ProtocolGuid,\r
                     (VOID **) &HttpInstance->Tcp6,\r
-                    HttpInstance->Service->ImageHandle,\r
+                    HttpInstance->Service->Ip6DriverBindingHandle,\r
                     HttpInstance->Handle,\r
                     EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
                     );\r
@@ -732,7 +732,7 @@ HttpInitProtocol (
                     HttpInstance->Service->Tcp6ChildHandle,\r
                     &gEfiTcp6ProtocolGuid,\r
                     (VOID **) &Interface,\r
-                    HttpInstance->Service->ImageHandle,\r
+                    HttpInstance->Service->Ip6DriverBindingHandle,\r
                     HttpInstance->Handle,\r
                     EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
                     );\r
@@ -756,20 +756,20 @@ ON_ERROR:
     gBS->CloseProtocol (\r
            HttpInstance->Tcp4ChildHandle,\r
            &gEfiTcp4ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip4DriverBindingHandle,\r
            HttpInstance->Service->ControllerHandle\r
            );\r
 \r
     gBS->CloseProtocol (\r
            HttpInstance->Tcp4ChildHandle,\r
            &gEfiTcp4ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip4DriverBindingHandle,\r
            HttpInstance->Handle\r
            );    \r
     \r
     NetLibDestroyServiceChild (\r
       HttpInstance->Service->ControllerHandle,\r
-      HttpInstance->Service->ImageHandle,\r
+      HttpInstance->Service->Ip4DriverBindingHandle,\r
       &gEfiTcp4ServiceBindingProtocolGuid,\r
       HttpInstance->Tcp4ChildHandle\r
       );\r
@@ -779,7 +779,7 @@ ON_ERROR:
     gBS->CloseProtocol (\r
            HttpInstance->Service->Tcp4ChildHandle,\r
            &gEfiTcp4ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip4DriverBindingHandle,\r
            HttpInstance->Handle\r
            );\r
   }\r
@@ -788,20 +788,20 @@ ON_ERROR:
     gBS->CloseProtocol (\r
            HttpInstance->Tcp6ChildHandle,\r
            &gEfiTcp6ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip6DriverBindingHandle,\r
            HttpInstance->Service->ControllerHandle\r
            );\r
 \r
     gBS->CloseProtocol (\r
            HttpInstance->Tcp6ChildHandle,\r
            &gEfiTcp6ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip6DriverBindingHandle,\r
            HttpInstance->Handle\r
            );\r
     \r
     NetLibDestroyServiceChild (\r
       HttpInstance->Service->ControllerHandle,\r
-      HttpInstance->Service->ImageHandle,\r
+      HttpInstance->Service->Ip6DriverBindingHandle,\r
       &gEfiTcp6ServiceBindingProtocolGuid,\r
       HttpInstance->Tcp6ChildHandle\r
       );\r
@@ -811,7 +811,7 @@ ON_ERROR:
     gBS->CloseProtocol (\r
            HttpInstance->Service->Tcp6ChildHandle,\r
            &gEfiTcp6ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip6DriverBindingHandle,\r
            HttpInstance->Handle\r
            );\r
   }\r
@@ -868,20 +868,20 @@ HttpCleanProtocol (
     gBS->CloseProtocol (\r
            HttpInstance->Tcp4ChildHandle,\r
            &gEfiTcp4ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip4DriverBindingHandle,\r
            HttpInstance->Service->ControllerHandle\r
            );\r
 \r
     gBS->CloseProtocol (\r
            HttpInstance->Tcp4ChildHandle,\r
            &gEfiTcp4ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip4DriverBindingHandle,\r
            HttpInstance->Handle\r
            );\r
     \r
     NetLibDestroyServiceChild (\r
       HttpInstance->Service->ControllerHandle,\r
-      HttpInstance->Service->ImageHandle,\r
+      HttpInstance->Service->Ip4DriverBindingHandle,\r
       &gEfiTcp4ServiceBindingProtocolGuid,\r
       HttpInstance->Tcp4ChildHandle\r
       );\r
@@ -891,7 +891,7 @@ HttpCleanProtocol (
     gBS->CloseProtocol (\r
            HttpInstance->Service->Tcp4ChildHandle,\r
            &gEfiTcp4ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip4DriverBindingHandle,\r
            HttpInstance->Handle\r
            );\r
   }  \r
@@ -900,20 +900,20 @@ HttpCleanProtocol (
     gBS->CloseProtocol (\r
            HttpInstance->Tcp6ChildHandle,\r
            &gEfiTcp6ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip6DriverBindingHandle,\r
            HttpInstance->Service->ControllerHandle\r
            );\r
 \r
     gBS->CloseProtocol (\r
            HttpInstance->Tcp6ChildHandle,\r
            &gEfiTcp6ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip6DriverBindingHandle,\r
            HttpInstance->Handle\r
            );\r
     \r
     NetLibDestroyServiceChild (\r
       HttpInstance->Service->ControllerHandle,\r
-      HttpInstance->Service->ImageHandle,\r
+      HttpInstance->Service->Ip6DriverBindingHandle,\r
       &gEfiTcp6ServiceBindingProtocolGuid,\r
       HttpInstance->Tcp6ChildHandle\r
       );\r
@@ -923,7 +923,7 @@ HttpCleanProtocol (
     gBS->CloseProtocol (\r
            HttpInstance->Service->Tcp6ChildHandle,\r
            &gEfiTcp6ProtocolGuid,\r
-           HttpInstance->Service->ImageHandle,\r
+           HttpInstance->Service->Ip6DriverBindingHandle,\r
            HttpInstance->Handle\r
            );\r
   }\r
index ced8acac367c200f2d1e775cd27f2c33fe3d48ad..95fb4843ce32ae4be44acde2f89687ae7772768b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The header files of miscellaneous routines for HttpDxe driver.\r
 \r
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -59,7 +59,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 typedef struct _HTTP_SERVICE {\r
   UINT32                        Signature;\r
   EFI_SERVICE_BINDING_PROTOCOL  ServiceBinding;\r
-  EFI_HANDLE                    ImageHandle;\r
+  EFI_HANDLE                    Ip4DriverBindingHandle;\r
+  EFI_HANDLE                    Ip6DriverBindingHandle;\r
   EFI_HANDLE                    ControllerHandle;\r
   EFI_HANDLE                    Tcp4ChildHandle;\r
   EFI_HANDLE                    Tcp6ChildHandle;\r