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> Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com> Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
This commit is contained in:
@@ -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>
|
||||
//
|
||||
|
@@ -65,6 +65,7 @@
|
||||
gEfiTlsServiceBindingProtocolGuid ## SOMETIMES_CONSUMES
|
||||
gEfiTlsProtocolGuid ## SOMETIMES_CONSUMES
|
||||
gEfiTlsConfigurationProtocolGuid ## SOMETIMES_CONSUMES
|
||||
gEdkiiHttpCallbackProtocolGuid ## SOMETIMES_CONSUMES
|
||||
|
||||
[Guids]
|
||||
gEfiTlsCaCertificateGuid ## SOMETIMES_CONSUMES ## Variable:L"TlsCaCertificate"
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -608,4 +608,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
|
||||
|
Reference in New Issue
Block a user