RedfishPkg/RedfishRestExDxe: Implement EDKII_HTTP_CALLBACK_PROTOCOL

Implement EDKII_HTTP_CALLBACK_PROTOCOL that listens to
HttpEventTlsConfigured event for reconfiguring TLS configuration
data.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
This commit is contained in:
Abner Chang
2024-01-05 09:39:41 +08:00
committed by mergify[bot]
parent 8466480965
commit 0a12d8bd55
3 changed files with 95 additions and 10 deletions

View File

@@ -4,6 +4,7 @@
Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -585,6 +586,53 @@ RedfishRestExDriverBindingStop (
return Status;
}
/**
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.
**/
VOID
EFIAPI
RestExHttpCallback (
IN EDKII_HTTP_CALLBACK_PROTOCOL *This,
IN EDKII_HTTP_CALLBACK_EVENT Event,
IN EFI_STATUS EventStatus
)
{
EFI_STATUS Status;
EFI_TLS_PROTOCOL *TlsProtocol;
RESTEX_INSTANCE *Instance;
EFI_TLS_VERIFY TlsVerifyMethod;
if ((Event == HttpEventTlsConfigured) && (EventStatus == EFI_SUCCESS)) {
// Reconfigure TLS configuration data.
Instance = RESTEX_INSTANCE_FROM_HTTP_CALLBACK (This);
Status = gBS->HandleProtocol (
Instance->HttpIo.Handle,
&gEfiTlsProtocolGuid,
(VOID **)&TlsProtocol
);
if (EFI_ERROR (Status)) {
return;
}
TlsVerifyMethod = EFI_TLS_VERIFY_NONE;
Status = TlsProtocol->SetSessionData (
TlsProtocol,
EfiTlsVerifyMethod,
&TlsVerifyMethod,
sizeof (EFI_TLS_VERIFY)
);
if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_MANAGEABILITY, "%a: REST EX reconfigures TLS verify method.\n", __func__));
}
}
return;
}
/**
Creates a child handle and installs a protocol.
@@ -699,6 +747,19 @@ RedfishRestExServiceBindingCreateChild (
goto ON_ERROR;
}
// Initial HTTP callback funciton on this REST EX instance
Instance->HttpCallbakFunction.Callback = RestExHttpCallback;
Status = gBS->InstallProtocolInterface (
&Instance->HttpIo.Handle,
&gEdkiiHttpCallbackProtocolGuid,
EFI_NATIVE_INTERFACE,
&Instance->HttpCallbakFunction
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Fail to install HttpCallbakFunction.\n", __func__));
goto ON_ERROR;
}
//
// Add it to the parent's child list.
//
@@ -812,6 +873,15 @@ RedfishRestExServiceBindingDestroyChild (
RestEx
);
//
// Uninstall the HTTP callback protocol.
//
Status = gBS->UninstallProtocolInterface (
Instance->HttpIo.Handle,
&gEdkiiHttpCallbackProtocolGuid,
&Instance->HttpCallbakFunction
);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (EFI_ERROR (Status)) {