public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch V2] NetworkPkg: Add HTTP Additional Event Notifications
@ 2021-07-20  2:17 Heng Luo
  2021-07-20  2:53 ` Wu, Jiaxin
  0 siblings, 1 reply; 3+ messages in thread
From: Heng Luo @ 2021-07-20  2:17 UTC (permalink / raw)
  To: devel; +Cc: Maciej Rabeda, Jiaxin Wu, Siyuan Fu

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 <heng.luo@intel.com>
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
---
 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.<BR>
+  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -47,6 +47,7 @@
 #include <Protocol/Ip6Config.h>
 #include <Protocol/Tls.h>
 #include <Protocol/TlsConfig.h>
+#include <Protocol/HttpCallback.h>
 
 #include <Guid/ImageAuthentication.h>
 //
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.<BR>
+#  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 #  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.<BR>
+  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -527,6 +527,7 @@ EfiHttpRequest (
       } else {
         Status = HttpDns6 (HttpInstance, HostNameStr, &HttpInstance->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.<BR>
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 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, &HttpInstance->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, &HttpInstance->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 (HttpInstance->TimeoutEvent, TimerCancel, 0);
 
@@ -1369,6 +1372,7 @@ HttpConnectTcp6 (
     }
 
     Status = TlsConnectSession (HttpInstance, HttpInstance->TimeoutEvent);
+    HttpNotify (HttpEventTlsConnectSession, Status);
 
     gBS->SetTimer (HttpInstance->TimeoutEvent, TimerCancel, 0);
 
@@ -2195,3 +2199,55 @@ HttpTcpTokenCleanup (
   }
 
 }
+
+/**
+  Send Events via EDKII_HTTP_CALLBACK_PROTOCOL.
+
+  @param[in]  Event               The event that occurs in the current state.
+  @param[in]  EventStatus         The Status of Event, EFI_SUCCESS or other errors.
+
+**/
+VOID
+HttpNotify (
+  IN  EDKII_HTTP_CALLBACK_EVENT         Event,
+  IN  EFI_STATUS                        EventStatus
+  )
+{
+  EFI_STATUS                      Status;
+  EFI_HANDLE                      *Handles;
+  UINTN                           Index;
+  UINTN                           HandleCount;
+  EFI_HANDLE                      Handle;
+  EDKII_HTTP_CALLBACK_PROTOCOL    *HttpCallback;
+
+  DEBUG ((DEBUG_INFO, "HttpNotify: Event - %d, EventStatus - %r\n", Event, EventStatus));
+
+  Handles = NULL;
+  HandleCount = 0;
+  Status = gBS->LocateHandleBuffer (
+                  ByProtocol,
+                  &gEdkiiHttpCallbackProtocolGuid,
+                  NULL,
+                  &HandleCount,
+                  &Handles
+                  );
+  if (Status == EFI_SUCCESS) {
+    for (Index = 0; Index < HandleCount; Index++) {
+      Handle = Handles[Index];
+      Status = gBS->HandleProtocol (
+                      Handle,
+                      &gEdkiiHttpCallbackProtocolGuid,
+                      (VOID **) &HttpCallback
+                      );
+      if (Status == EFI_SUCCESS) {
+        DEBUG ((DEBUG_INFO, "HttpNotify: Notifying %p\n", HttpCallback));
+        HttpCallback->Callback (
+                HttpCallback,
+                Event,
+                EventStatus
+                );
+      }
+    }
+    FreePool (Handles);
+  }
+}
diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h
index 00ba26aca4..5b90a6b074 100644
--- a/NetworkPkg/HttpDxe/HttpProto.h
+++ b/NetworkPkg/HttpDxe/HttpProto.h
@@ -1,7 +1,7 @@
 /** @file
   The header files of miscellaneous routines for HttpDxe driver.
 
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -609,4 +609,17 @@ HttpResponseWorker (
   IN  HTTP_TOKEN_WRAP           *Wrap
   );
 
+/**
+  Send Events via EDKII_HTTP_CALLBACK_PROTOCOL.
+
+  @param[in]  Event               The event that occurs in the current state.
+  @param[in]  EventStatus         The Status of Event, EFI_SUCCESS or other errors.
+
+**/
+VOID
+HttpNotify (
+  IN  EDKII_HTTP_CALLBACK_EVENT         Event,
+  IN  EFI_STATUS                        EventStatus
+  );
+
 #endif
diff --git a/NetworkPkg/Include/Protocol/HttpCallback.h b/NetworkPkg/Include/Protocol/HttpCallback.h
new file mode 100644
index 0000000000..d036a8a4be
--- /dev/null
+++ b/NetworkPkg/Include/Protocol/HttpCallback.h
@@ -0,0 +1,85 @@
+/** @file
+  This file defines the EDKII HTTP Callback Protocol interface.
+
+  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef __EDKII_HTTP_CALLBACK_H__
+#define __EDKII_HTTP_CALLBACK_H__
+
+#define EDKII_HTTP_CALLBACK_PROTOCOL_GUID \
+  { \
+    0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40} \
+  }
+
+typedef struct _EDKII_HTTP_CALLBACK_PROTOCOL  EDKII_HTTP_CALLBACK_PROTOCOL;
+
+///
+/// EDKII_HTTP_CALLBACK_EVENT
+///
+typedef enum {
+  ///
+  /// The Status of DNS Event to retrieve the host address.
+  /// EventStatus:
+  /// EFI_SUCCESS             Operation succeeded.
+  /// EFI_OUT_OF_RESOURCES    Failed to allocate needed resources.
+  /// EFI_DEVICE_ERROR        An unexpected network error occurred.
+  /// Others                  Other errors as indicated.
+  ///
+  HttpEventDns,
+
+  ///
+  /// The Status of Event to initiate a nonblocking TCP connection request.
+  /// EventStatus:
+  /// EFI_SUCCESS            The connection request is successfully initiated.
+  /// EFI_NOT_STARTED        This EFI TCP Protocol instance has not been configured.
+  /// EFI_DEVICE_ERROR       An unexpected system or network error occurred.
+  /// Others                 Other errors as indicated.
+  ///
+  HttpEventConnectTcp,
+
+  ///
+  /// The Status of Event to connect one TLS session by finishing the TLS handshake process.
+  /// EventStatus:
+  /// EFI_SUCCESS            The TLS session is established.
+  /// EFI_OUT_OF_RESOURCES   Can't allocate memory resources.
+  /// EFI_ABORTED            TLS session state is incorrect.
+  /// Others                 Other error as indicated.
+  ///
+  HttpEventTlsConnectSession,
+
+  ///
+  /// The Status of Event to initialize Http session
+  /// EventStatus:
+  /// EFI_SUCCESS            The initialization of session is done.
+  /// Others                 Other error as indicated.
+  ///
+  HttpEventInitSession
+} EDKII_HTTP_CALLBACK_EVENT;
+
+/**
+  Callback function that is invoked when HTTP event occurs.
+
+  @param[in]  This                Pointer to the EDKII_HTTP_CALLBACK_PROTOCOL instance.
+  @param[in]  Event               The event that occurs in the current state.
+  @param[in]  EventStatus         The Status of Event, EFI_SUCCESS or other errors.
+**/
+typedef
+VOID
+(EFIAPI * EDKII_HTTP_CALLBACK) (
+  IN EDKII_HTTP_CALLBACK_PROTOCOL     *This,
+  IN EDKII_HTTP_CALLBACK_EVENT        Event,
+  IN EFI_STATUS                       EventStatus
+ );
+
+///
+/// EFI HTTP Callback Protocol is invoked when HTTP event occurs.
+///
+struct _EDKII_HTTP_CALLBACK_PROTOCOL {
+  EDKII_HTTP_CALLBACK Callback;
+};
+
+extern EFI_GUID gEdkiiHttpCallbackProtocolGuid;
+
+#endif
diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec
index b81f10ef6e..0f9f7bb15e 100644
--- a/NetworkPkg/NetworkPkg.dec
+++ b/NetworkPkg/NetworkPkg.dec
@@ -88,6 +88,9 @@
   ## Include/Protocol/Dpc.h
   gEfiDpcProtocolGuid           = {0x480f8ae9, 0xc46, 0x4aa9,  { 0xbc, 0x89, 0xdb, 0x9f, 0xba, 0x61, 0x98, 0x6 }}
 
+  ## Include/Protocol/HttpCallback.h
+  gEdkiiHttpCallbackProtocolGuid  = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}}
+
 [PcdsFixedAtBuild]
   ## The max attempt number will be created by iSCSI driver.
   # @Prompt Max attempt number.
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch V2] NetworkPkg: Add HTTP Additional Event Notifications
  2021-07-20  2:17 [Patch V2] NetworkPkg: Add HTTP Additional Event Notifications Heng Luo
@ 2021-07-20  2:53 ` Wu, Jiaxin
  0 siblings, 0 replies; 3+ messages in thread
From: Wu, Jiaxin @ 2021-07-20  2:53 UTC (permalink / raw)
  To: Luo, Heng, devel@edk2.groups.io; +Cc: Maciej Rabeda, Fu, Siyuan

Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>



Thanks,
Jiaxin

> -----Original Message-----
> From: Luo, Heng <heng.luo@intel.com>
> Sent: Tuesday, July 20, 2021 10:18 AM
> To: devel@edk2.groups.io
> Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>; Wu, Jiaxin
> <jiaxin.wu@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>
> 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 <heng.luo@intel.com>
> Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> ---
>  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.<BR>
> 
> +  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
> 
>    (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
> 
> 
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -47,6 +47,7 @@
>  #include <Protocol/Ip6Config.h>
> 
>  #include <Protocol/Tls.h>
> 
>  #include <Protocol/TlsConfig.h>
> 
> +#include <Protocol/HttpCallback.h>
> 
> 
> 
>  #include <Guid/ImageAuthentication.h>
> 
>  //
> 
> 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.<BR>
> 
> +#  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
> 
>  #
> 
>  #  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.<BR>
> 
> +  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
> 
>    (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
> 
> 
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -527,6 +527,7 @@ EfiHttpRequest (
>        } else {
> 
>          Status = HttpDns6 (HttpInstance, HostNameStr, &HttpInstance-
> >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.<BR>
> 
> +Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
> 
>  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
> 
>  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,
> &HttpInstance->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,
> &HttpInstance->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 (HttpInstance->TimeoutEvent, TimerCancel, 0);
> 
> 
> 
> @@ -1369,6 +1372,7 @@ HttpConnectTcp6 (
>      }
> 
> 
> 
>      Status = TlsConnectSession (HttpInstance, HttpInstance->TimeoutEvent);
> 
> +    HttpNotify (HttpEventTlsConnectSession, Status);
> 
> 
> 
>      gBS->SetTimer (HttpInstance->TimeoutEvent, TimerCancel, 0);
> 
> 
> 
> @@ -2195,3 +2199,55 @@ HttpTcpTokenCleanup (
>    }
> 
> 
> 
>  }
> 
> +
> 
> +/**
> 
> +  Send Events via EDKII_HTTP_CALLBACK_PROTOCOL.
> 
> +
> 
> +  @param[in]  Event               The event that occurs in the current state.
> 
> +  @param[in]  EventStatus         The Status of Event, EFI_SUCCESS or other
> errors.
> 
> +
> 
> +**/
> 
> +VOID
> 
> +HttpNotify (
> 
> +  IN  EDKII_HTTP_CALLBACK_EVENT         Event,
> 
> +  IN  EFI_STATUS                        EventStatus
> 
> +  )
> 
> +{
> 
> +  EFI_STATUS                      Status;
> 
> +  EFI_HANDLE                      *Handles;
> 
> +  UINTN                           Index;
> 
> +  UINTN                           HandleCount;
> 
> +  EFI_HANDLE                      Handle;
> 
> +  EDKII_HTTP_CALLBACK_PROTOCOL    *HttpCallback;
> 
> +
> 
> +  DEBUG ((DEBUG_INFO, "HttpNotify: Event - %d, EventStatus - %r\n",
> Event, EventStatus));
> 
> +
> 
> +  Handles = NULL;
> 
> +  HandleCount = 0;
> 
> +  Status = gBS->LocateHandleBuffer (
> 
> +                  ByProtocol,
> 
> +                  &gEdkiiHttpCallbackProtocolGuid,
> 
> +                  NULL,
> 
> +                  &HandleCount,
> 
> +                  &Handles
> 
> +                  );
> 
> +  if (Status == EFI_SUCCESS) {
> 
> +    for (Index = 0; Index < HandleCount; Index++) {
> 
> +      Handle = Handles[Index];
> 
> +      Status = gBS->HandleProtocol (
> 
> +                      Handle,
> 
> +                      &gEdkiiHttpCallbackProtocolGuid,
> 
> +                      (VOID **) &HttpCallback
> 
> +                      );
> 
> +      if (Status == EFI_SUCCESS) {
> 
> +        DEBUG ((DEBUG_INFO, "HttpNotify: Notifying %p\n", HttpCallback));
> 
> +        HttpCallback->Callback (
> 
> +                HttpCallback,
> 
> +                Event,
> 
> +                EventStatus
> 
> +                );
> 
> +      }
> 
> +    }
> 
> +    FreePool (Handles);
> 
> +  }
> 
> +}
> 
> diff --git a/NetworkPkg/HttpDxe/HttpProto.h
> b/NetworkPkg/HttpDxe/HttpProto.h
> index 00ba26aca4..5b90a6b074 100644
> --- a/NetworkPkg/HttpDxe/HttpProto.h
> +++ b/NetworkPkg/HttpDxe/HttpProto.h
> @@ -1,7 +1,7 @@
>  /** @file
> 
>    The header files of miscellaneous routines for HttpDxe driver.
> 
> 
> 
> -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
> 
> +Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
> 
>  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> 
> 
> @@ -609,4 +609,17 @@ HttpResponseWorker (
>    IN  HTTP_TOKEN_WRAP           *Wrap
> 
>    );
> 
> 
> 
> +/**
> 
> +  Send Events via EDKII_HTTP_CALLBACK_PROTOCOL.
> 
> +
> 
> +  @param[in]  Event               The event that occurs in the current state.
> 
> +  @param[in]  EventStatus         The Status of Event, EFI_SUCCESS or other
> errors.
> 
> +
> 
> +**/
> 
> +VOID
> 
> +HttpNotify (
> 
> +  IN  EDKII_HTTP_CALLBACK_EVENT         Event,
> 
> +  IN  EFI_STATUS                        EventStatus
> 
> +  );
> 
> +
> 
>  #endif
> 
> diff --git a/NetworkPkg/Include/Protocol/HttpCallback.h
> b/NetworkPkg/Include/Protocol/HttpCallback.h
> new file mode 100644
> index 0000000000..d036a8a4be
> --- /dev/null
> +++ b/NetworkPkg/Include/Protocol/HttpCallback.h
> @@ -0,0 +1,85 @@
> +/** @file
> 
> +  This file defines the EDKII HTTP Callback Protocol interface.
> 
> +
> 
> +  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
> 
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +**/
> 
> +
> 
> +#ifndef __EDKII_HTTP_CALLBACK_H__
> 
> +#define __EDKII_HTTP_CALLBACK_H__
> 
> +
> 
> +#define EDKII_HTTP_CALLBACK_PROTOCOL_GUID \
> 
> +  { \
> 
> +    0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2,
> 0x40} \
> 
> +  }
> 
> +
> 
> +typedef struct _EDKII_HTTP_CALLBACK_PROTOCOL
> EDKII_HTTP_CALLBACK_PROTOCOL;
> 
> +
> 
> +///
> 
> +/// EDKII_HTTP_CALLBACK_EVENT
> 
> +///
> 
> +typedef enum {
> 
> +  ///
> 
> +  /// The Status of DNS Event to retrieve the host address.
> 
> +  /// EventStatus:
> 
> +  /// EFI_SUCCESS             Operation succeeded.
> 
> +  /// EFI_OUT_OF_RESOURCES    Failed to allocate needed resources.
> 
> +  /// EFI_DEVICE_ERROR        An unexpected network error occurred.
> 
> +  /// Others                  Other errors as indicated.
> 
> +  ///
> 
> +  HttpEventDns,
> 
> +
> 
> +  ///
> 
> +  /// The Status of Event to initiate a nonblocking TCP connection request.
> 
> +  /// EventStatus:
> 
> +  /// EFI_SUCCESS            The connection request is successfully initiated.
> 
> +  /// EFI_NOT_STARTED        This EFI TCP Protocol instance has not been
> configured.
> 
> +  /// EFI_DEVICE_ERROR       An unexpected system or network error
> occurred.
> 
> +  /// Others                 Other errors as indicated.
> 
> +  ///
> 
> +  HttpEventConnectTcp,
> 
> +
> 
> +  ///
> 
> +  /// The Status of Event to connect one TLS session by finishing the TLS
> handshake process.
> 
> +  /// EventStatus:
> 
> +  /// EFI_SUCCESS            The TLS session is established.
> 
> +  /// EFI_OUT_OF_RESOURCES   Can't allocate memory resources.
> 
> +  /// EFI_ABORTED            TLS session state is incorrect.
> 
> +  /// Others                 Other error as indicated.
> 
> +  ///
> 
> +  HttpEventTlsConnectSession,
> 
> +
> 
> +  ///
> 
> +  /// The Status of Event to initialize Http session
> 
> +  /// EventStatus:
> 
> +  /// EFI_SUCCESS            The initialization of session is done.
> 
> +  /// Others                 Other error as indicated.
> 
> +  ///
> 
> +  HttpEventInitSession
> 
> +} EDKII_HTTP_CALLBACK_EVENT;
> 
> +
> 
> +/**
> 
> +  Callback function that is invoked when HTTP event occurs.
> 
> +
> 
> +  @param[in]  This                Pointer to the EDKII_HTTP_CALLBACK_PROTOCOL
> instance.
> 
> +  @param[in]  Event               The event that occurs in the current state.
> 
> +  @param[in]  EventStatus         The Status of Event, EFI_SUCCESS or other
> errors.
> 
> +**/
> 
> +typedef
> 
> +VOID
> 
> +(EFIAPI * EDKII_HTTP_CALLBACK) (
> 
> +  IN EDKII_HTTP_CALLBACK_PROTOCOL     *This,
> 
> +  IN EDKII_HTTP_CALLBACK_EVENT        Event,
> 
> +  IN EFI_STATUS                       EventStatus
> 
> + );
> 
> +
> 
> +///
> 
> +/// EFI HTTP Callback Protocol is invoked when HTTP event occurs.
> 
> +///
> 
> +struct _EDKII_HTTP_CALLBACK_PROTOCOL {
> 
> +  EDKII_HTTP_CALLBACK Callback;
> 
> +};
> 
> +
> 
> +extern EFI_GUID gEdkiiHttpCallbackProtocolGuid;
> 
> +
> 
> +#endif
> 
> diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec
> index b81f10ef6e..0f9f7bb15e 100644
> --- a/NetworkPkg/NetworkPkg.dec
> +++ b/NetworkPkg/NetworkPkg.dec
> @@ -88,6 +88,9 @@
>    ## Include/Protocol/Dpc.h
> 
>    gEfiDpcProtocolGuid           = {0x480f8ae9, 0xc46, 0x4aa9,  { 0xbc, 0x89, 0xdb,
> 0x9f, 0xba, 0x61, 0x98, 0x6 }}
> 
> 
> 
> +  ## Include/Protocol/HttpCallback.h
> 
> +  gEdkiiHttpCallbackProtocolGuid  = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36,
> 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}}
> 
> +
> 
>  [PcdsFixedAtBuild]
> 
>    ## The max attempt number will be created by iSCSI driver.
> 
>    # @Prompt Max attempt number.
> 
> --
> 2.31.1.windows.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Patch V2] NetworkPkg: Add HTTP Additional Event Notifications
@ 2021-07-22  7:38 Heng Luo
  0 siblings, 0 replies; 3+ messages in thread
From: Heng Luo @ 2021-07-22  7:38 UTC (permalink / raw)
  To: devel; +Cc: Maciej Rabeda, Jiaxin Wu, Siyuan Fu

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 <heng.luo@intel.com>
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
---
 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.<BR>
+  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -47,6 +47,7 @@
 #include <Protocol/Ip6Config.h>
 #include <Protocol/Tls.h>
 #include <Protocol/TlsConfig.h>
+#include <Protocol/HttpCallback.h>
 
 #include <Guid/ImageAuthentication.h>
 //
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.<BR>
+#  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 #  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.<BR>
+  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -527,6 +527,7 @@ EfiHttpRequest (
       } else {
         Status = HttpDns6 (HttpInstance, HostNameStr, &HttpInstance->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.<BR>
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 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, &HttpInstance->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, &HttpInstance->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 (HttpInstance->TimeoutEvent, TimerCancel, 0);
 
@@ -1369,6 +1372,7 @@ HttpConnectTcp6 (
     }
 
     Status = TlsConnectSession (HttpInstance, HttpInstance->TimeoutEvent);
+    HttpNotify (HttpEventTlsConnectSession, Status);
 
     gBS->SetTimer (HttpInstance->TimeoutEvent, TimerCancel, 0);
 
@@ -2195,3 +2199,55 @@ HttpTcpTokenCleanup (
   }
 
 }
+
+/**
+  Send Events via EDKII_HTTP_CALLBACK_PROTOCOL.
+
+  @param[in]  Event               The event that occurs in the current state.
+  @param[in]  EventStatus         The Status of Event, EFI_SUCCESS or other errors.
+
+**/
+VOID
+HttpNotify (
+  IN  EDKII_HTTP_CALLBACK_EVENT         Event,
+  IN  EFI_STATUS                        EventStatus
+  )
+{
+  EFI_STATUS                      Status;
+  EFI_HANDLE                      *Handles;
+  UINTN                           Index;
+  UINTN                           HandleCount;
+  EFI_HANDLE                      Handle;
+  EDKII_HTTP_CALLBACK_PROTOCOL    *HttpCallback;
+
+  DEBUG ((DEBUG_INFO, "HttpNotify: Event - %d, EventStatus - %r\n", Event, EventStatus));
+
+  Handles = NULL;
+  HandleCount = 0;
+  Status = gBS->LocateHandleBuffer (
+                  ByProtocol,
+                  &gEdkiiHttpCallbackProtocolGuid,
+                  NULL,
+                  &HandleCount,
+                  &Handles
+                  );
+  if (Status == EFI_SUCCESS) {
+    for (Index = 0; Index < HandleCount; Index++) {
+      Handle = Handles[Index];
+      Status = gBS->HandleProtocol (
+                      Handle,
+                      &gEdkiiHttpCallbackProtocolGuid,
+                      (VOID **) &HttpCallback
+                      );
+      if (Status == EFI_SUCCESS) {
+        DEBUG ((DEBUG_INFO, "HttpNotify: Notifying %p\n", HttpCallback));
+        HttpCallback->Callback (
+                HttpCallback,
+                Event,
+                EventStatus
+                );
+      }
+    }
+    FreePool (Handles);
+  }
+}
diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h
index 00ba26aca4..5b90a6b074 100644
--- a/NetworkPkg/HttpDxe/HttpProto.h
+++ b/NetworkPkg/HttpDxe/HttpProto.h
@@ -1,7 +1,7 @@
 /** @file
   The header files of miscellaneous routines for HttpDxe driver.
 
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -609,4 +609,17 @@ HttpResponseWorker (
   IN  HTTP_TOKEN_WRAP           *Wrap
   );
 
+/**
+  Send Events via EDKII_HTTP_CALLBACK_PROTOCOL.
+
+  @param[in]  Event               The event that occurs in the current state.
+  @param[in]  EventStatus         The Status of Event, EFI_SUCCESS or other errors.
+
+**/
+VOID
+HttpNotify (
+  IN  EDKII_HTTP_CALLBACK_EVENT         Event,
+  IN  EFI_STATUS                        EventStatus
+  );
+
 #endif
diff --git a/NetworkPkg/Include/Protocol/HttpCallback.h b/NetworkPkg/Include/Protocol/HttpCallback.h
new file mode 100644
index 0000000000..d036a8a4be
--- /dev/null
+++ b/NetworkPkg/Include/Protocol/HttpCallback.h
@@ -0,0 +1,85 @@
+/** @file
+  This file defines the EDKII HTTP Callback Protocol interface.
+
+  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef __EDKII_HTTP_CALLBACK_H__
+#define __EDKII_HTTP_CALLBACK_H__
+
+#define EDKII_HTTP_CALLBACK_PROTOCOL_GUID \
+  { \
+    0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40} \
+  }
+
+typedef struct _EDKII_HTTP_CALLBACK_PROTOCOL  EDKII_HTTP_CALLBACK_PROTOCOL;
+
+///
+/// EDKII_HTTP_CALLBACK_EVENT
+///
+typedef enum {
+  ///
+  /// The Status of DNS Event to retrieve the host address.
+  /// EventStatus:
+  /// EFI_SUCCESS             Operation succeeded.
+  /// EFI_OUT_OF_RESOURCES    Failed to allocate needed resources.
+  /// EFI_DEVICE_ERROR        An unexpected network error occurred.
+  /// Others                  Other errors as indicated.
+  ///
+  HttpEventDns,
+
+  ///
+  /// The Status of Event to initiate a nonblocking TCP connection request.
+  /// EventStatus:
+  /// EFI_SUCCESS            The connection request is successfully initiated.
+  /// EFI_NOT_STARTED        This EFI TCP Protocol instance has not been configured.
+  /// EFI_DEVICE_ERROR       An unexpected system or network error occurred.
+  /// Others                 Other errors as indicated.
+  ///
+  HttpEventConnectTcp,
+
+  ///
+  /// The Status of Event to connect one TLS session by finishing the TLS handshake process.
+  /// EventStatus:
+  /// EFI_SUCCESS            The TLS session is established.
+  /// EFI_OUT_OF_RESOURCES   Can't allocate memory resources.
+  /// EFI_ABORTED            TLS session state is incorrect.
+  /// Others                 Other error as indicated.
+  ///
+  HttpEventTlsConnectSession,
+
+  ///
+  /// The Status of Event to initialize Http session
+  /// EventStatus:
+  /// EFI_SUCCESS            The initialization of session is done.
+  /// Others                 Other error as indicated.
+  ///
+  HttpEventInitSession
+} EDKII_HTTP_CALLBACK_EVENT;
+
+/**
+  Callback function that is invoked when HTTP event occurs.
+
+  @param[in]  This                Pointer to the EDKII_HTTP_CALLBACK_PROTOCOL instance.
+  @param[in]  Event               The event that occurs in the current state.
+  @param[in]  EventStatus         The Status of Event, EFI_SUCCESS or other errors.
+**/
+typedef
+VOID
+(EFIAPI * EDKII_HTTP_CALLBACK) (
+  IN EDKII_HTTP_CALLBACK_PROTOCOL     *This,
+  IN EDKII_HTTP_CALLBACK_EVENT        Event,
+  IN EFI_STATUS                       EventStatus
+ );
+
+///
+/// EFI HTTP Callback Protocol is invoked when HTTP event occurs.
+///
+struct _EDKII_HTTP_CALLBACK_PROTOCOL {
+  EDKII_HTTP_CALLBACK Callback;
+};
+
+extern EFI_GUID gEdkiiHttpCallbackProtocolGuid;
+
+#endif
diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec
index b81f10ef6e..0f9f7bb15e 100644
--- a/NetworkPkg/NetworkPkg.dec
+++ b/NetworkPkg/NetworkPkg.dec
@@ -88,6 +88,9 @@
   ## Include/Protocol/Dpc.h
   gEfiDpcProtocolGuid           = {0x480f8ae9, 0xc46, 0x4aa9,  { 0xbc, 0x89, 0xdb, 0x9f, 0xba, 0x61, 0x98, 0x6 }}
 
+  ## Include/Protocol/HttpCallback.h
+  gEdkiiHttpCallbackProtocolGuid  = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}}
+
 [PcdsFixedAtBuild]
   ## The max attempt number will be created by iSCSI driver.
   # @Prompt Max attempt number.
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-22  7:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-20  2:17 [Patch V2] NetworkPkg: Add HTTP Additional Event Notifications Heng Luo
2021-07-20  2:53 ` Wu, Jiaxin
  -- strict thread matches above, loose matches on Subject: below --
2021-07-22  7:38 Heng Luo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox