summaryrefslogtreecommitdiffstats
path: root/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c')
-rw-r--r--RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c124
1 files changed, 66 insertions, 58 deletions
diff --git a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c b/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
index 05c70c213f..d9acad24de 100644
--- a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
+++ b/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
@@ -15,7 +15,7 @@
#include <Protocol/Http.h>
#include <Protocol/RestEx.h>
-#define REST_EX_CONFIG_DATA_LEN_UNKNOWN 0xff
+#define REST_EX_CONFIG_DATA_LEN_UNKNOWN 0xff
/**
This function allows the caller to create child handle for specific
@@ -33,27 +33,28 @@
**/
EFI_STATUS
RestExLibCreateChild (
- IN EFI_HANDLE Image,
+ IN EFI_HANDLE Image,
IN EFI_REST_EX_SERVICE_ACCESS_MODE AccessMode,
- IN EFI_REST_EX_CONFIG_TYPE ConfigType,
- IN EFI_REST_EX_SERVICE_TYPE ServiceType,
- OUT EFI_HANDLE *ChildInstanceHandle
-)
+ IN EFI_REST_EX_CONFIG_TYPE ConfigType,
+ IN EFI_REST_EX_SERVICE_TYPE ServiceType,
+ OUT EFI_HANDLE *ChildInstanceHandle
+ )
{
- EFI_STATUS Status;
- UINTN NoBuffer;
- EFI_HANDLE *Handle;
- EFI_HANDLE ChildHandle;
- EFI_REST_EX_PROTOCOL *RestEx;
- EFI_REST_EX_SERVICE_INFO *RestExServiceInfo;
- UINT8 LenOfConfig;
-
- if (Image == NULL ||
- AccessMode >= EfiRestExServiceModeMax ||
- ConfigType >= EfiRestExConfigTypeMax ||
- ServiceType >= EfiRestExServiceTypeMax ||
- ChildInstanceHandle == NULL
- ) {
+ EFI_STATUS Status;
+ UINTN NoBuffer;
+ EFI_HANDLE *Handle;
+ EFI_HANDLE ChildHandle;
+ EFI_REST_EX_PROTOCOL *RestEx;
+ EFI_REST_EX_SERVICE_INFO *RestExServiceInfo;
+ UINT8 LenOfConfig;
+
+ if ((Image == NULL) ||
+ (AccessMode >= EfiRestExServiceModeMax) ||
+ (ConfigType >= EfiRestExConfigTypeMax) ||
+ (ServiceType >= EfiRestExServiceTypeMax) ||
+ (ChildInstanceHandle == NULL)
+ )
+ {
return EFI_INVALID_PARAMETER;
}
@@ -61,29 +62,31 @@ RestExLibCreateChild (
//
// Locate all REST EX binding service.
//
- Handle = NULL;
+ Handle = NULL;
NoBuffer = 0;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiRestExServiceBindingProtocolGuid,
- NULL,
- &NoBuffer,
- &Handle
- );
- if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiRestExServiceBindingProtocolGuid,
+ NULL,
+ &NoBuffer,
+ &Handle
+ );
+ if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
return Status;
}
- Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof(EFI_HANDLE) * NoBuffer);
+
+ Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof (EFI_HANDLE) * NoBuffer);
if (Handle == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiRestExServiceBindingProtocolGuid,
- NULL,
- &NoBuffer,
- &Handle
- );
+ ByProtocol,
+ &gEfiRestExServiceBindingProtocolGuid,
+ NULL,
+ &NoBuffer,
+ &Handle
+ );
if (EFI_ERROR (Status)) {
FreePool (Handle);
return Status;
@@ -94,21 +97,21 @@ RestExLibCreateChild (
//
while (NoBuffer != 0) {
ChildHandle = NULL;
- Status = NetLibCreateServiceChild (
- *(Handle + (NoBuffer - 1)),
- Image,
- &gEfiRestExServiceBindingProtocolGuid,
- &ChildHandle
- );
+ Status = NetLibCreateServiceChild (
+ *(Handle + (NoBuffer - 1)),
+ Image,
+ &gEfiRestExServiceBindingProtocolGuid,
+ &ChildHandle
+ );
if (!EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
- ChildHandle,
- &gEfiRestExProtocolGuid,
- (VOID **)&RestEx,
- Image,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ ChildHandle,
+ &gEfiRestExProtocolGuid,
+ (VOID **)&RestEx,
+ Image,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
@@ -117,12 +120,13 @@ RestExLibCreateChild (
// Get the information of REST service provided by this EFI REST EX driver
//
Status = RestEx->GetService (
- RestEx,
- &RestExServiceInfo
- );
+ RestEx,
+ &RestExServiceInfo
+ );
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
+
//
// Check REST EX property.
//
@@ -138,13 +142,16 @@ RestExLibCreateChild (
default:
goto ON_ERROR;
}
- if (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode ||
- RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType ||
- RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType ||
- ((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig))) {
+
+ if ((RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode) ||
+ (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType) ||
+ (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType) ||
+ ((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig)))
+ {
goto ON_ERROR;
}
}
+
//
// This is proper REST EX instance.
//
@@ -159,8 +166,9 @@ ON_ERROR:;
&gEfiRestExServiceBindingProtocolGuid,
ChildHandle
);
- NoBuffer --;
- };
+ NoBuffer--;
+ }
+
FreePool (Handle);
return EFI_NOT_FOUND;
}