[edk2-devel] [Patch V2] NetworkPkg: Add HTTP Additional Event Notifications

2021-07-22 Thread Heng Luo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3496

Add new EDKII_HTTP_CALLBACK_PROTOCOL in NetworkPkg,
Send HTTP Events via EDKII_HTTP_CALLBACK_PROTOCOL
when Dns/ConnectTcp/TlsConnectSession/InitSession
occurs.

Signed-off-by: Heng Luo 
Cc: Maciej Rabeda 
Cc: Jiaxin Wu 
Cc: Siyuan Fu 
---
 NetworkPkg/HttpDxe/HttpDriver.h|  3 ++-
 NetworkPkg/HttpDxe/HttpDxe.inf |  3 ++-
 NetworkPkg/HttpDxe/HttpImpl.c  |  4 +++-
 NetworkPkg/HttpDxe/HttpProto.c | 58 
+-
 NetworkPkg/HttpDxe/HttpProto.h | 15 ++-
 NetworkPkg/Include/Protocol/HttpCallback.h | 85 
+
 NetworkPkg/NetworkPkg.dec  |  3 +++
 7 files changed, 166 insertions(+), 5 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpDriver.h b/NetworkPkg/HttpDxe/HttpDriver.h
index 5fe8c5b5e9..b701b80858 100644
--- a/NetworkPkg/HttpDxe/HttpDriver.h
+++ b/NetworkPkg/HttpDxe/HttpDriver.h
@@ -1,7 +1,7 @@
 /** @file
   The header files of the driver binding and service binding protocol for 
HttpDxe driver.
 
-  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 //
diff --git a/NetworkPkg/HttpDxe/HttpDxe.inf b/NetworkPkg/HttpDxe/HttpDxe.inf
index 35fe31af18..23fb9ec394 100644
--- a/NetworkPkg/HttpDxe/HttpDxe.inf
+++ b/NetworkPkg/HttpDxe/HttpDxe.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Implementation of EFI HTTP protocol interfaces.
 #
-#  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -65,6 +65,7 @@
   gEfiTlsServiceBindingProtocolGuid## SOMETIMES_CONSUMES
   gEfiTlsProtocolGuid  ## SOMETIMES_CONSUMES
   gEfiTlsConfigurationProtocolGuid ## SOMETIMES_CONSUMES
+  gEdkiiHttpCallbackProtocolGuid   ## SOMETIMES_CONSUMES
 
 [Guids]
   gEfiTlsCaCertificateGuid ## SOMETIMES_CONSUMES  ## 
Variable:L"TlsCaCertificate"
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 5a6ecbc9d9..97f15d229f 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation of EFI_HTTP_PROTOCOL protocol interfaces.
 
-  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -527,6 +527,7 @@ EfiHttpRequest (
   } else {
 Status = HttpDns6 (HttpInstance, HostNameStr, 
>RemoteIpv6Addr);
   }
+  HttpNotify (HttpEventDns, Status);
 
   FreePool (HostNameStr);
   if (EFI_ERROR (Status)) {
@@ -588,6 +589,7 @@ EfiHttpRequest (
  Configure || ReConfigure,
  TlsConfigure
  );
+  HttpNotify (HttpEventInitSession, Status);
   if (EFI_ERROR (Status)) {
 goto Error2;
   }
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
index afc7db5a72..affa916bd6 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -1,7 +1,7 @@
 /** @file
   Miscellaneous routines for HttpDxe driver.
 
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -966,6 +966,7 @@ HttpCreateConnection (
 HttpInstance->IsTcp4ConnDone = FALSE;
 HttpInstance->Tcp4ConnToken.CompletionToken.Status = EFI_NOT_READY;
 Status = HttpInstance->Tcp4->Connect (HttpInstance->Tcp4, 
>Tcp4ConnToken);
+HttpNotify (HttpEventConnectTcp, Status);
 if (EFI_ERROR (Status)) {
   DEBUG ((EFI_D_ERROR, "HttpCreateConnection: Tcp4->Connect() = %r\n", 
Status));
   return Status;
@@ -981,6 +982,7 @@ HttpCreateConnection (
 HttpInstance->IsTcp6ConnDone = FALSE;
 HttpInstance->Tcp6ConnToken.CompletionToken.Status = EFI_NOT_READY;
 Status = HttpInstance->Tcp6->Connect (HttpInstance->Tcp6, 
>Tcp6ConnToken);
+HttpNotify (HttpEventConnectTcp, Status);
 if (EFI_ERROR (Status)) {
   DEBUG ((EFI_D_ERROR, "HttpCreateConnection: Tcp6->Connect() = %r\n", 
Status));
   return Status;
@@ -1277,6 +1279,7 @@ HttpConnectTcp4 (
 }
 
 Status = TlsConnectSession (HttpInstance, HttpInstance->TimeoutEvent);
+HttpNotify (HttpEventTlsConnectSession, Status);
 
 gBS->SetTimer 

Re: [edk2-devel] [Patch V2] NetworkPkg: Add HTTP Additional Event Notifications

2021-07-19 Thread Wu, Jiaxin
Reviewed-by: Jiaxin Wu 



Thanks,
Jiaxin

> -Original Message-
> From: Luo, Heng 
> Sent: Tuesday, July 20, 2021 10:18 AM
> To: devel@edk2.groups.io
> Cc: Maciej Rabeda ; Wu, Jiaxin
> ; Fu, Siyuan 
> Subject: [Patch V2] NetworkPkg: Add HTTP Additional Event Notifications
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3496
> 
> Add new EDKII_HTTP_CALLBACK_PROTOCOL in NetworkPkg,
> Send HTTP Events via EDKII_HTTP_CALLBACK_PROTOCOL
> when Dns/ConnectTcp/TlsConnectSession/InitSession
> occurs.
> 
> Signed-off-by: Heng Luo 
> Cc: Maciej Rabeda 
> Cc: Jiaxin Wu 
> Cc: Siyuan Fu 
> ---
>  NetworkPkg/HttpDxe/HttpDriver.h|  3 ++-
>  NetworkPkg/HttpDxe/HttpDxe.inf |  3 ++-
>  NetworkPkg/HttpDxe/HttpImpl.c  |  4 +++-
>  NetworkPkg/HttpDxe/HttpProto.c | 58
> +-
>  NetworkPkg/HttpDxe/HttpProto.h | 15 ++-
>  NetworkPkg/Include/Protocol/HttpCallback.h | 85
> ++
> +++
>  NetworkPkg/NetworkPkg.dec  |  3 +++
>  7 files changed, 166 insertions(+), 5 deletions(-)
> 
> diff --git a/NetworkPkg/HttpDxe/HttpDriver.h
> b/NetworkPkg/HttpDxe/HttpDriver.h
> index 5fe8c5b5e9..b701b80858 100644
> --- a/NetworkPkg/HttpDxe/HttpDriver.h
> +++ b/NetworkPkg/HttpDxe/HttpDriver.h
> @@ -1,7 +1,7 @@
>  /** @file
> 
>The header files of the driver binding and service binding protocol for
> HttpDxe driver.
> 
> 
> 
> -  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
> 
> +  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
> 
>(C) Copyright 2016 Hewlett Packard Enterprise Development LP
> 
> 
> 
>SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -47,6 +47,7 @@
>  #include 
> 
>  #include 
> 
>  #include 
> 
> +#include 
> 
> 
> 
>  #include 
> 
>  //
> 
> diff --git a/NetworkPkg/HttpDxe/HttpDxe.inf
> b/NetworkPkg/HttpDxe/HttpDxe.inf
> index 35fe31af18..23fb9ec394 100644
> --- a/NetworkPkg/HttpDxe/HttpDxe.inf
> +++ b/NetworkPkg/HttpDxe/HttpDxe.inf
> @@ -1,7 +1,7 @@
>  ## @file
> 
>  #  Implementation of EFI HTTP protocol interfaces.
> 
>  #
> 
> -#  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
> 
> +#  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
> 
>  #
> 
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  #
> 
> @@ -65,6 +65,7 @@
>gEfiTlsServiceBindingProtocolGuid## SOMETIMES_CONSUMES
> 
>gEfiTlsProtocolGuid  ## SOMETIMES_CONSUMES
> 
>gEfiTlsConfigurationProtocolGuid ## SOMETIMES_CONSUMES
> 
> +  gEdkiiHttpCallbackProtocolGuid   ## SOMETIMES_CONSUMES
> 
> 
> 
>  [Guids]
> 
>gEfiTlsCaCertificateGuid ## SOMETIMES_CONSUMES  ##
> Variable:L"TlsCaCertificate"
> 
> diff --git a/NetworkPkg/HttpDxe/HttpImpl.c
> b/NetworkPkg/HttpDxe/HttpImpl.c
> index 5a6ecbc9d9..97f15d229f 100644
> --- a/NetworkPkg/HttpDxe/HttpImpl.c
> +++ b/NetworkPkg/HttpDxe/HttpImpl.c
> @@ -1,7 +1,7 @@
>  /** @file
> 
>Implementation of EFI_HTTP_PROTOCOL protocol interfaces.
> 
> 
> 
> -  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
> 
> +  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
> 
>(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
> 
> 
> 
>SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -527,6 +527,7 @@ EfiHttpRequest (
>} else {
> 
>  Status = HttpDns6 (HttpInstance, HostNameStr, 
> >RemoteIpv6Addr);
> 
>}
> 
> +  HttpNotify (HttpEventDns, Status);
> 
> 
> 
>FreePool (HostNameStr);
> 
>if (EFI_ERROR (Status)) {
> 
> @@ -588,6 +589,7 @@ EfiHttpRequest (
>   Configure || ReConfigure,
> 
>   TlsConfigure
> 
>   );
> 
> +  HttpNotify (HttpEventInitSession, Status);
> 
>if (EFI_ERROR (Status)) {
> 
>  goto Error2;
> 
>}
> 
> diff --git a/NetworkPkg/HttpDxe/HttpProto.c
> b/NetworkPkg/HttpDxe/HttpProto.c
> index afc7db5a72..affa916bd6 100644
> --- a/NetworkPkg/HttpDxe/HttpProto.c
> +++ b/NetworkPkg/HttpDxe/HttpProto.c
> @@ -1,7 +1,7 @@
>  /** @file
> 
>Miscellaneous routines for HttpDxe driver.
> 
> 
> 
> -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
> 
> +Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
> 
>  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> 
> 
> @@ -966,6 +966,7 @@ HttpCreateConnection (
>  HttpInstance->IsTcp4ConnDone = FALSE;
> 
>  HttpInstance->Tcp4ConnToken.CompletionToken.Status =
> EFI_NOT_READY;
> 
>  Status = HttpInstance->Tcp4->Connect (HttpInstance->Tcp4,
> >Tcp4ConnToken);
> 
> +HttpNotify (HttpEventConnectTcp, Status);
> 
>  if (EFI_ERROR (Status)) {
> 
>DEBUG ((EFI_D_ERROR, 

[edk2-devel] [Patch V2] NetworkPkg: Add HTTP Additional Event Notifications

2021-07-19 Thread Heng Luo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3496

Add new EDKII_HTTP_CALLBACK_PROTOCOL in NetworkPkg,
Send HTTP Events via EDKII_HTTP_CALLBACK_PROTOCOL
when Dns/ConnectTcp/TlsConnectSession/InitSession
occurs.

Signed-off-by: Heng Luo 
Cc: Maciej Rabeda 
Cc: Jiaxin Wu 
Cc: Siyuan Fu 
---
 NetworkPkg/HttpDxe/HttpDriver.h|  3 ++-
 NetworkPkg/HttpDxe/HttpDxe.inf |  3 ++-
 NetworkPkg/HttpDxe/HttpImpl.c  |  4 +++-
 NetworkPkg/HttpDxe/HttpProto.c | 58 
+-
 NetworkPkg/HttpDxe/HttpProto.h | 15 ++-
 NetworkPkg/Include/Protocol/HttpCallback.h | 85 
+
 NetworkPkg/NetworkPkg.dec  |  3 +++
 7 files changed, 166 insertions(+), 5 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpDriver.h b/NetworkPkg/HttpDxe/HttpDriver.h
index 5fe8c5b5e9..b701b80858 100644
--- a/NetworkPkg/HttpDxe/HttpDriver.h
+++ b/NetworkPkg/HttpDxe/HttpDriver.h
@@ -1,7 +1,7 @@
 /** @file
   The header files of the driver binding and service binding protocol for 
HttpDxe driver.
 
-  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 //
diff --git a/NetworkPkg/HttpDxe/HttpDxe.inf b/NetworkPkg/HttpDxe/HttpDxe.inf
index 35fe31af18..23fb9ec394 100644
--- a/NetworkPkg/HttpDxe/HttpDxe.inf
+++ b/NetworkPkg/HttpDxe/HttpDxe.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Implementation of EFI HTTP protocol interfaces.
 #
-#  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -65,6 +65,7 @@
   gEfiTlsServiceBindingProtocolGuid## SOMETIMES_CONSUMES
   gEfiTlsProtocolGuid  ## SOMETIMES_CONSUMES
   gEfiTlsConfigurationProtocolGuid ## SOMETIMES_CONSUMES
+  gEdkiiHttpCallbackProtocolGuid   ## SOMETIMES_CONSUMES
 
 [Guids]
   gEfiTlsCaCertificateGuid ## SOMETIMES_CONSUMES  ## 
Variable:L"TlsCaCertificate"
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 5a6ecbc9d9..97f15d229f 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation of EFI_HTTP_PROTOCOL protocol interfaces.
 
-  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -527,6 +527,7 @@ EfiHttpRequest (
   } else {
 Status = HttpDns6 (HttpInstance, HostNameStr, 
>RemoteIpv6Addr);
   }
+  HttpNotify (HttpEventDns, Status);
 
   FreePool (HostNameStr);
   if (EFI_ERROR (Status)) {
@@ -588,6 +589,7 @@ EfiHttpRequest (
  Configure || ReConfigure,
  TlsConfigure
  );
+  HttpNotify (HttpEventInitSession, Status);
   if (EFI_ERROR (Status)) {
 goto Error2;
   }
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
index afc7db5a72..affa916bd6 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -1,7 +1,7 @@
 /** @file
   Miscellaneous routines for HttpDxe driver.
 
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -966,6 +966,7 @@ HttpCreateConnection (
 HttpInstance->IsTcp4ConnDone = FALSE;
 HttpInstance->Tcp4ConnToken.CompletionToken.Status = EFI_NOT_READY;
 Status = HttpInstance->Tcp4->Connect (HttpInstance->Tcp4, 
>Tcp4ConnToken);
+HttpNotify (HttpEventConnectTcp, Status);
 if (EFI_ERROR (Status)) {
   DEBUG ((EFI_D_ERROR, "HttpCreateConnection: Tcp4->Connect() = %r\n", 
Status));
   return Status;
@@ -981,6 +982,7 @@ HttpCreateConnection (
 HttpInstance->IsTcp6ConnDone = FALSE;
 HttpInstance->Tcp6ConnToken.CompletionToken.Status = EFI_NOT_READY;
 Status = HttpInstance->Tcp6->Connect (HttpInstance->Tcp6, 
>Tcp6ConnToken);
+HttpNotify (HttpEventConnectTcp, Status);
 if (EFI_ERROR (Status)) {
   DEBUG ((EFI_D_ERROR, "HttpCreateConnection: Tcp6->Connect() = %r\n", 
Status));
   return Status;
@@ -1277,6 +1279,7 @@ HttpConnectTcp4 (
 }
 
 Status = TlsConnectSession (HttpInstance, HttpInstance->TimeoutEvent);
+HttpNotify (HttpEventTlsConnectSession, Status);
 
 gBS->SetTimer