/** @file\r
The header files of the driver binding and service binding protocol for HttpDxe driver.\r
\r
- Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
#include <Protocol/Ip6Config.h>\r
#include <Protocol/Tls.h>\r
#include <Protocol/TlsConfig.h>\r
+#include <Protocol/HttpCallback.h>\r
\r
#include <Guid/ImageAuthentication.h>\r
//\r
gEfiTlsServiceBindingProtocolGuid ## SOMETIMES_CONSUMES\r
gEfiTlsProtocolGuid ## SOMETIMES_CONSUMES\r
gEfiTlsConfigurationProtocolGuid ## SOMETIMES_CONSUMES\r
+ gEdkiiHttpCallbackProtocolGuid ## SOMETIMES_CONSUMES\r
\r
[Guids]\r
gEfiTlsCaCertificateGuid ## SOMETIMES_CONSUMES ## Variable:L"TlsCaCertificate"\r
} else {\r
Status = HttpDns6 (HttpInstance, HostNameStr, &HttpInstance->RemoteIpv6Addr);\r
}\r
+ HttpNotify (HttpEventDns, Status);\r
\r
FreePool (HostNameStr);\r
if (EFI_ERROR (Status)) {\r
Configure || ReConfigure,\r
TlsConfigure\r
);\r
+ HttpNotify (HttpEventInitSession, Status);\r
if (EFI_ERROR (Status)) {\r
goto Error2;\r
}\r
/** @file\r
Miscellaneous routines for HttpDxe driver.\r
\r
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
HttpInstance->IsTcp4ConnDone = FALSE;\r
HttpInstance->Tcp4ConnToken.CompletionToken.Status = EFI_NOT_READY;\r
Status = HttpInstance->Tcp4->Connect (HttpInstance->Tcp4, &HttpInstance->Tcp4ConnToken);\r
+ HttpNotify (HttpEventConnectTcp, Status);\r
if (EFI_ERROR (Status)) {\r
DEBUG ((EFI_D_ERROR, "HttpCreateConnection: Tcp4->Connect() = %r\n", Status));\r
return Status;\r
HttpInstance->IsTcp6ConnDone = FALSE;\r
HttpInstance->Tcp6ConnToken.CompletionToken.Status = EFI_NOT_READY;\r
Status = HttpInstance->Tcp6->Connect (HttpInstance->Tcp6, &HttpInstance->Tcp6ConnToken);\r
+ HttpNotify (HttpEventConnectTcp, Status);\r
if (EFI_ERROR (Status)) {\r
DEBUG ((EFI_D_ERROR, "HttpCreateConnection: Tcp6->Connect() = %r\n", Status));\r
return Status;\r
}\r
\r
Status = TlsConnectSession (HttpInstance, HttpInstance->TimeoutEvent);\r
+ HttpNotify (HttpEventTlsConnectSession, Status);\r
\r
gBS->SetTimer (HttpInstance->TimeoutEvent, TimerCancel, 0);\r
\r
}\r
\r
Status = TlsConnectSession (HttpInstance, HttpInstance->TimeoutEvent);\r
+ HttpNotify (HttpEventTlsConnectSession, Status);\r
\r
gBS->SetTimer (HttpInstance->TimeoutEvent, TimerCancel, 0);\r
\r
}\r
\r
}\r
+\r
+/**\r
+ Send Events via EDKII_HTTP_CALLBACK_PROTOCOL.\r
+\r
+ @param[in] Event The event that occurs in the current state.\r
+ @param[in] EventStatus The Status of Event, EFI_SUCCESS or other errors.\r
+\r
+**/\r
+VOID\r
+HttpNotify (\r
+ IN EDKII_HTTP_CALLBACK_EVENT Event,\r
+ IN EFI_STATUS EventStatus\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE *Handles;\r
+ UINTN Index;\r
+ UINTN HandleCount;\r
+ EFI_HANDLE Handle;\r
+ EDKII_HTTP_CALLBACK_PROTOCOL *HttpCallback;\r
+\r
+ DEBUG ((DEBUG_INFO, "HttpNotify: Event - %d, EventStatus - %r\n", Event, EventStatus));\r
+\r
+ Handles = NULL;\r
+ HandleCount = 0;\r
+ Status = gBS->LocateHandleBuffer (\r
+ ByProtocol,\r
+ &gEdkiiHttpCallbackProtocolGuid,\r
+ NULL,\r
+ &HandleCount,\r
+ &Handles\r
+ );\r
+ if (Status == EFI_SUCCESS) {\r
+ for (Index = 0; Index < HandleCount; Index++) {\r
+ Handle = Handles[Index];\r
+ Status = gBS->HandleProtocol (\r
+ Handle,\r
+ &gEdkiiHttpCallbackProtocolGuid,\r
+ (VOID **) &HttpCallback\r
+ );\r
+ if (Status == EFI_SUCCESS) {\r
+ DEBUG ((DEBUG_INFO, "HttpNotify: Notifying %p\n", HttpCallback));\r
+ HttpCallback->Callback (\r
+ HttpCallback,\r
+ Event,\r
+ EventStatus\r
+ );\r
+ }\r
+ }\r
+ FreePool (Handles);\r
+ }\r
+}\r
IN HTTP_TOKEN_WRAP *Wrap\r
);\r
\r
+/**\r
+ Send Events via EDKII_HTTP_CALLBACK_PROTOCOL.\r
+\r
+ @param[in] Event The event that occurs in the current state.\r
+ @param[in] EventStatus The Status of Event, EFI_SUCCESS or other errors.\r
+\r
+**/\r
+VOID\r
+HttpNotify (\r
+ IN EDKII_HTTP_CALLBACK_EVENT Event,\r
+ IN EFI_STATUS EventStatus\r
+ );\r
+\r
#endif\r
--- /dev/null
+/** @file\r
+ This file defines the EDKII HTTP Callback Protocol interface.\r
+\r
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#ifndef EDKII_HTTP_CALLBACK_H_\r
+#define EDKII_HTTP_CALLBACK_H_\r
+\r
+#define EDKII_HTTP_CALLBACK_PROTOCOL_GUID \\r
+ { \\r
+ 0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40} \\r
+ }\r
+\r
+typedef struct _EDKII_HTTP_CALLBACK_PROTOCOL EDKII_HTTP_CALLBACK_PROTOCOL;\r
+\r
+///\r
+/// EDKII_HTTP_CALLBACK_EVENT\r
+///\r
+typedef enum {\r
+ ///\r
+ /// The Status of DNS Event to retrieve the host address.\r
+ /// EventStatus:\r
+ /// EFI_SUCCESS Operation succeeded.\r
+ /// EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
+ /// EFI_DEVICE_ERROR An unexpected network error occurred.\r
+ /// Others Other errors as indicated.\r
+ ///\r
+ HttpEventDns,\r
+\r
+ ///\r
+ /// The Status of Event to initiate a nonblocking TCP connection request.\r
+ /// EventStatus:\r
+ /// EFI_SUCCESS The connection request is successfully initiated.\r
+ /// EFI_NOT_STARTED This EFI TCP Protocol instance has not been configured.\r
+ /// EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+ /// Others Other errors as indicated.\r
+ ///\r
+ HttpEventConnectTcp,\r
+\r
+ ///\r
+ /// The Status of Event to connect one TLS session by finishing the TLS handshake process.\r
+ /// EventStatus:\r
+ /// EFI_SUCCESS The TLS session is established.\r
+ /// EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
+ /// EFI_ABORTED TLS session state is incorrect.\r
+ /// Others Other error as indicated.\r
+ ///\r
+ HttpEventTlsConnectSession,\r
+\r
+ ///\r
+ /// The Status of Event to initialize Http session\r
+ /// EventStatus:\r
+ /// EFI_SUCCESS The initialization of session is done.\r
+ /// Others Other error as indicated.\r
+ ///\r
+ HttpEventInitSession\r
+} EDKII_HTTP_CALLBACK_EVENT;\r
+\r
+/**\r
+ Callback function that is invoked when HTTP event occurs.\r
+\r
+ @param[in] This Pointer to the EDKII_HTTP_CALLBACK_PROTOCOL instance.\r
+ @param[in] Event The event that occurs in the current state.\r
+ @param[in] EventStatus The Status of Event, EFI_SUCCESS or other errors.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI * EDKII_HTTP_CALLBACK) (\r
+ IN EDKII_HTTP_CALLBACK_PROTOCOL *This,\r
+ IN EDKII_HTTP_CALLBACK_EVENT Event,\r
+ IN EFI_STATUS EventStatus\r
+ );\r
+\r
+///\r
+/// EFI HTTP Callback Protocol is invoked when HTTP event occurs.\r
+///\r
+struct _EDKII_HTTP_CALLBACK_PROTOCOL {\r
+ EDKII_HTTP_CALLBACK Callback;\r
+};\r
+\r
+extern EFI_GUID gEdkiiHttpCallbackProtocolGuid;\r
+\r
+#endif /* EDKII_HTTP_CALLBACK_H_ */\r
## Include/Protocol/Dpc.h\r
gEfiDpcProtocolGuid = {0x480f8ae9, 0xc46, 0x4aa9, { 0xbc, 0x89, 0xdb, 0x9f, 0xba, 0x61, 0x98, 0x6 }}\r
\r
+ ## Include/Protocol/HttpCallback.h\r
+ gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}}\r
+\r
[PcdsFixedAtBuild]\r
## The max attempt number will be created by iSCSI driver.\r
# @Prompt Max attempt number.\r