RedfishPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the RedfishPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Abner Chang <abner.chang@hpe.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:11 -08:00
committed by mergify[bot]
parent 5220bd211d
commit 39de741e2d
56 changed files with 6067 additions and 4616 deletions

View File

@ -45,7 +45,7 @@ typedef struct {
///< iSerialNumber.bDescriptorType field of the USB ///< iSerialNumber.bDescriptorType field of the USB
///< descriptor, and is converted from Unicode to ASCII ///< descriptor, and is converted from Unicode to ASCII
///< and is NULL terminated. ///< and is NULL terminated.
UINT8 MacAddress [6]; ///< The MAC address of the PCI/PCIe network device. UINT8 MacAddress[6]; ///< The MAC address of the PCI/PCIe network device.
} USB_INTERFACE_DEVICE_DESCRIPTOR_V2; } USB_INTERFACE_DEVICE_DESCRIPTOR_V2;
// //
@ -57,7 +57,7 @@ typedef struct {
UINT16 DeviceId; ///< The Device ID of the PCI/PCIe device. UINT16 DeviceId; ///< The Device ID of the PCI/PCIe device.
UINT16 SubsystemVendorId; ///< The Subsystem Vendor ID of the PCI/PCIe device. UINT16 SubsystemVendorId; ///< The Subsystem Vendor ID of the PCI/PCIe device.
UINT16 SubsystemId; ///< The Subsystem ID of the PCI/PCIe device. UINT16 SubsystemId; ///< The Subsystem ID of the PCI/PCIe device.
UINT8 MacAddress [6]; ///< The MAC address of the PCI/PCIe network device. UINT8 MacAddress[6]; ///< The MAC address of the PCI/PCIe network device.
UINT16 SegmemtGroupNumber; ///< The Segment Group Number of the PCI/PCIe. UINT16 SegmemtGroupNumber; ///< The Segment Group Number of the PCI/PCIe.
UINT8 BusNumber; ///< The Bus Number of the PCI/PCIe device. UINT8 BusNumber; ///< The Bus Number of the PCI/PCIe device.
UINT8 DeviceFunctionNumber; ///< The Device/Function Number of the PCI/PCIe. UINT8 DeviceFunctionNumber; ///< The Device/Function Number of the PCI/PCIe.
@ -95,7 +95,7 @@ typedef struct {
// the protocol-specific data for the "Redfish Over IP" protocol // the protocol-specific data for the "Redfish Over IP" protocol
// //
typedef struct { typedef struct {
EFI_GUID ServiceUuid; //same as Redfish Service UUID in Redfish Service Root resource EFI_GUID ServiceUuid; // same as Redfish Service UUID in Redfish Service Root resource
// //
// Unknown=00h, // Unknown=00h,
@ -166,4 +166,3 @@ typedef struct {
#pragma pack() #pragma pack()
#endif #endif

View File

@ -7,12 +7,13 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef JSON_LIB_H_ #ifndef JSON_LIB_H_
#define JSON_LIB_H_ #define JSON_LIB_H_
typedef VOID* EDKII_JSON_VALUE; typedef VOID *EDKII_JSON_VALUE;
typedef VOID* EDKII_JSON_ARRAY; typedef VOID *EDKII_JSON_ARRAY;
typedef VOID* EDKII_JSON_OBJECT; typedef VOID *EDKII_JSON_OBJECT;
/// ///
/// Map to json_int_t in jansson.h /// Map to json_int_t in jansson.h
@ -69,8 +70,8 @@ typedef struct {
INTN Line; INTN Line;
INTN Column; INTN Column;
INTN Position; INTN Position;
CHAR8 Source [EDKII_JSON_ERROR_SOURCE_LENGTH]; CHAR8 Source[EDKII_JSON_ERROR_SOURCE_LENGTH];
CHAR8 Text [EDKII_JSON_ERROR_TEXT_LENGTH]; CHAR8 Text[EDKII_JSON_ERROR_TEXT_LENGTH];
} EDKII_JSON_ERROR; } EDKII_JSON_ERROR;
/// ///
@ -499,7 +500,7 @@ JsonValueGetAsciiString (
@retval Return the associated Unicode string in JSON value or NULL. @retval Return the associated Unicode string in JSON value or NULL.
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
JsonValueGetUnicodeString ( JsonValueGetUnicodeString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
@ -549,7 +550,7 @@ JsonValueGetBoolean (
@retval Return the associated Ascii string in JSON value or NULL on errors. @retval Return the associated Ascii string in JSON value or NULL on errors.
**/ **/
CONST CHAR8* CONST CHAR8 *
EFIAPI EFIAPI
JsonValueGetString ( JsonValueGetString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
@ -583,7 +584,7 @@ JsonObjectSize (
JsonObj is not an JSON object, key count is zero or on other errors. JsonObj is not an JSON object, key count is zero or on other errors.
**/ **/
CHAR8** CHAR8 **
JsonObjectGetKeys ( JsonObjectGetKeys (
IN EDKII_JSON_OBJECT JsonObj, IN EDKII_JSON_OBJECT JsonObj,
OUT UINTN *KeyCount OUT UINTN *KeyCount
@ -766,7 +767,7 @@ JsonDumpString (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonLoadString ( JsonLoadString (
IN CONST CHAR8* String, IN CONST CHAR8 *String,
IN UINT64 Flags, IN UINT64 Flags,
IN EDKII_JSON_ERROR *Error IN EDKII_JSON_ERROR *Error
); );
@ -835,6 +836,7 @@ EFIAPI
JsonIncreaseReference ( JsonIncreaseReference (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
); );
/** /**
Returns an opaque iterator which can be used to iterate over all key-value pairs Returns an opaque iterator which can be used to iterate over all key-value pairs
in object, or NULL if object is empty in object, or NULL if object is empty
@ -883,7 +885,7 @@ CHAR8 *
EFIAPI EFIAPI
JsonObjectIteratorKey ( JsonObjectIteratorKey (
IN VOID *Iterator IN VOID *Iterator
); );
/** /**
Returns the pointer of iterator by key. Returns the pointer of iterator by key.
@ -895,7 +897,7 @@ VOID *
EFIAPI EFIAPI
JsonObjectKeyToIterator ( JsonObjectKeyToIterator (
IN CHAR8 *Key IN CHAR8 *Key
); );
/** /**
Returns the json type of this json value Returns the json type of this json value
@ -905,7 +907,8 @@ JsonObjectKeyToIterator (
**/ **/
EDKII_JSON_TYPE EDKII_JSON_TYPE
EFIAPI EFIAPI
JsonGetType( JsonGetType (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
); );
#endif #endif

View File

@ -6,6 +6,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CONTENT_CODING_LIB_H_ #ifndef REDFISH_CONTENT_CODING_LIB_H_
#define REDFISH_CONTENT_CODING_LIB_H_ #define REDFISH_CONTENT_CODING_LIB_H_
@ -75,4 +76,5 @@ RedfishContentDecode (
OUT VOID **DecodedContentPointer, OUT VOID **DecodedContentPointer,
OUT UINTN *DecodedLength OUT UINTN *DecodedLength
); );
#endif #endif

View File

@ -6,6 +6,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CREDENTIAL_LIB_H_ #ifndef REDFISH_CREDENTIAL_LIB_H_
#define REDFISH_CREDENTIAL_LIB_H_ #define REDFISH_CREDENTIAL_LIB_H_
@ -20,7 +21,7 @@ VOID
EFIAPI EFIAPI
LibCredentialExitBootServicesNotify ( LibCredentialExitBootServicesNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
); );
/** /**
Notification of End of DXe. Notification of End of DXe.
@ -31,7 +32,7 @@ VOID
EFIAPI EFIAPI
LibCredentialEndOfDxeNotify ( LibCredentialEndOfDxeNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
); );
/** /**
Retrieve platform's Redfish authentication information. Retrieve platform's Redfish authentication information.
@ -64,7 +65,7 @@ LibCredentialGetAuthInfo (
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
OUT CHAR8 **Password OUT CHAR8 **Password
); );
/** /**
Notify the Redfish service provide to stop provide configuration service to this platform. Notify the Redfish service provide to stop provide configuration service to this platform.
@ -87,5 +88,6 @@ EFIAPI
LibStopRedfishService ( LibStopRedfishService (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
); );
#endif #endif

View File

@ -27,21 +27,21 @@
// We dont support double on edk2 // We dont support double on edk2
#define HUGE_VAL 0 #define HUGE_VAL 0
#if defined(MDE_CPU_X64) || defined(MDE_CPU_AARCH64) || defined(MDE_CPU_RISCV64) #if defined (MDE_CPU_X64) || defined (MDE_CPU_AARCH64) || defined (MDE_CPU_RISCV64)
// //
// With GCC we would normally use SIXTY_FOUR_BIT_LONG, but MSVC needs // With GCC we would normally use SIXTY_FOUR_BIT_LONG, but MSVC needs
// SIXTY_FOUR_BIT, because 'long' is 32-bit and only 'long long' is // SIXTY_FOUR_BIT, because 'long' is 32-bit and only 'long long' is
// 64-bit. Since using 'long long' works fine on GCC too, just do that. // 64-bit. Since using 'long long' works fine on GCC too, just do that.
// //
#define SIXTY_FOUR_BIT #define SIXTY_FOUR_BIT
#elif defined(MDE_CPU_IA32) || defined(MDE_CPU_ARM) || defined(MDE_CPU_EBC) #elif defined (MDE_CPU_IA32) || defined (MDE_CPU_ARM) || defined (MDE_CPU_EBC)
#define THIRTY_TWO_BIT #define THIRTY_TWO_BIT
#endif #endif
// //
// Map all va_xxxx elements to VA_xxx defined in MdePkg/Include/Base.h // Map all va_xxxx elements to VA_xxx defined in MdePkg/Include/Base.h
// //
#if !defined(__CC_ARM) // if va_list is not already defined #if !defined (__CC_ARM) // if va_list is not already defined
#define va_list VA_LIST #define va_list VA_LIST
#define va_arg VA_ARG #define va_arg VA_ARG
#define va_start VA_START #define va_start VA_START
@ -80,7 +80,9 @@ typedef INT32 int32_t;
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
typedef UINT16 uint16_t; typedef UINT16 uint16_t;
typedef UINT8 uint8_t; typedef UINT8 uint8_t;
typedef enum {false, true} bool; typedef enum {
false, true
} bool;
// //
// File operations are not required for EFI building, // File operations are not required for EFI building,
@ -148,90 +150,386 @@ extern FILE *stderr;
// //
// Function prototypes of CRT Library routines // Function prototypes of CRT Library routines
// //
void *malloc (size_t); void *
void *realloc (void *, size_t); malloc (
void *calloc (size_t Num, size_t Size); size_t
void free (void *); );
void *memset (void *, int, size_t);
int memcmp (const void *, const void *, size_t); void *
int isdigit (int); realloc (
int isspace (int); void *,
int tolower (int); size_t
int isupper (int); );
int isxdigit (int);
int isalnum (int); void *
void *memcpy (void *, const void *, size_t); calloc (
void *memset (void *, int, size_t); size_t Num,
void *memchr (const void *, int, size_t); size_t Size
int memcmp (const void *, const void *, size_t); );
void *memmove (void *, const void *, size_t);
int strcmp (const char *, const char *); void
int strncmp (const char *, const char *, size_t); free (
char *strcpy (char *, const char *); void *
size_t strlen (const char *); );
char *strcat (char *, const char *);
char *strchr (const char *, int); void *
int strcasecmp (const char *, const char *); memset (
int strncasecmp (const char *, const char *, size_t); void *,
char *strncpy (char *, size_t, const char *, size_t); int,
int strncmp (const char *, const char *, size_t); size_t
char *strrchr (const char *, int); );
unsigned long strtoul (const char *, char **, int);
char * strstr (const char *s1 , const char *s2); int
long strtol (const char *, char **, int); memcmp (
char *strerror (int); const void *,
size_t strspn (const char *, const char *); const void *,
char * strdup (const char *str); size_t
char * strpbrk (const char *s1, const char *s2); );
unsigned long long strtoull(const char * nptr, char ** endptr, int base);
long long strtoll (const char * nptr, char ** endptr, int base); int
long strtol (const char * nptr, char ** endptr, int base); isdigit (
double strtod (const char * __restrict nptr, char ** __restrict endptr); int
size_t strcspn (const char *, const char *); );
int printf (const char *, ...);
int sscanf (const char *, const char *, ...); int
FILE *fopen (const char *, const char *); isspace (
size_t fread (void *, size_t, size_t, FILE *); int
size_t fwrite (const void *, size_t, size_t, FILE *); );
int fclose (FILE *);
int fprintf (FILE *, const char *, ...); int
int fgetc (FILE * _File); tolower (
uid_t getuid (void); int
uid_t geteuid (void); );
gid_t getgid (void);
gid_t getegid (void); int
void qsort (void *, size_t, size_t, int (*)(const void *, const void *)); isupper (
char *getenv (const char *); int
#if defined(__GNUC__) && (__GNUC__ >= 2) );
void abort (void) __attribute__((__noreturn__));
int
isxdigit (
int
);
int
isalnum (
int
);
void *
memcpy (
void *,
const void *,
size_t
);
void *
memset (
void *,
int,
size_t
);
void *
memchr (
const void *,
int,
size_t
);
int
memcmp (
const void *,
const void *,
size_t
);
void *
memmove (
void *,
const void *,
size_t
);
int
strcmp (
const char *,
const char *
);
int
strncmp (
const char *,
const char *,
size_t
);
char *
strcpy (
char *,
const char *
);
size_t
strlen (
const char *
);
char *
strcat (
char *,
const char *
);
char *
strchr (
const char *,
int
);
int
strcasecmp (
const char *,
const char *
);
int
strncasecmp (
const char *,
const char *,
size_t
);
char *
strncpy (
char *,
size_t,
const char *,
size_t
);
int
strncmp (
const char *,
const char *,
size_t
);
char *
strrchr (
const char *,
int
);
unsigned long
strtoul (
const char *,
char **,
int
);
char *
strstr (
const char *s1,
const char *s2
);
long
strtol (
const char *,
char **,
int
);
char *
strerror (
int
);
size_t
strspn (
const char *,
const char *
);
char *
strdup (
const char *str
);
char *
strpbrk (
const char *s1,
const char *s2
);
unsigned long long
strtoull (
const char *nptr,
char **endptr,
int base
);
long long
strtoll (
const char *nptr,
char **endptr,
int base
);
long
strtol (
const char *nptr,
char **endptr,
int base
);
double
strtod (
const char *__restrict nptr,
char **__restrict endptr
);
size_t
strcspn (
const char *,
const char *
);
int
printf (
const char *,
...
);
int
sscanf (
const char *,
const char *,
...
);
FILE *
fopen (
const char *,
const char *
);
size_t
fread (
void *,
size_t,
size_t,
FILE *
);
size_t
fwrite (
const void *,
size_t,
size_t,
FILE *
);
int
fclose (
FILE *
);
int
fprintf (
FILE *,
const char *,
...
);
int
fgetc (
FILE *_File
);
uid_t
getuid (
void
);
uid_t
geteuid (
void
);
gid_t
getgid (
void
);
gid_t
getegid (
void
);
void
qsort (
void *,
size_t,
size_t,
int (*)(const void *, const void *)
);
char *
getenv (
const char *
);
#if defined (__GNUC__) && (__GNUC__ >= 2)
void
abort (
void
) __attribute__ ((__noreturn__));
#else #else
void abort (void); void
abort (
void
);
#endif #endif
int toupper (int); int
int Digit2Val (int); toupper (
time_t time (time_t *); int
);
int
Digit2Val (
int
);
time_t
time (
time_t *
);
// //
// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions // Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
// //
#define strcmp AsciiStrCmp #define strcmp AsciiStrCmp
#define memcpy(dest,source,count) CopyMem(dest,source,(UINTN)(count)) #define memcpy(dest, source, count) CopyMem(dest,source,(UINTN)(count))
#define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch)) #define memset(dest, ch, count) SetMem(dest,(UINTN)(count),(UINT8)(ch))
#define memchr(buf,ch,count) ScanMem8(buf,(UINTN)(count),(UINT8)ch) #define memchr(buf, ch, count) ScanMem8(buf,(UINTN)(count),(UINT8)ch)
#define memcmp(buf1,buf2,count) (int)(CompareMem(buf1,buf2,(UINTN)(count))) #define memcmp(buf1, buf2, count) (int)(CompareMem(buf1,buf2,(UINTN)(count)))
#define memmove(dest,source,count) CopyMem(dest,source,(UINTN)(count)) #define memmove(dest, source, count) CopyMem(dest,source,(UINTN)(count))
#define strlen(str) (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE)) #define strlen(str) (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE))
#define strcpy(strDest,strSource) AsciiStrCpyS(strDest,(strlen(strSource)+1),strSource) #define strcpy(strDest, strSource) AsciiStrCpyS(strDest,(strlen(strSource)+1),strSource)
#define strncpy(strDest,strSource,count) AsciiStrnCpyS(strDest,(UINTN)count,strSource,(UINTN)count) #define strncpy(strDest, strSource, count) AsciiStrnCpyS(strDest,(UINTN)count,strSource,(UINTN)count)
#define strncpys(strDest, DestLen, strSource,count) AsciiStrnCpyS(strDest,DestLen,strSource,(UINTN)count) #define strncpys(strDest, DestLen, strSource, count) AsciiStrnCpyS(strDest,DestLen,strSource,(UINTN)count)
#define strcat(strDest,strSource) AsciiStrCatS(strDest,(strlen(strSource)+strlen(strDest)+1),strSource) #define strcat(strDest, strSource) AsciiStrCatS(strDest,(strlen(strSource)+strlen(strDest)+1),strSource)
#define strchr(str,ch) ScanMem8((VOID *)(str),AsciiStrSize(str),(UINT8)ch) #define strchr(str, ch) ScanMem8((VOID *)(str),AsciiStrSize(str),(UINT8)ch)
#define strcasecmp(str1,str2) (int)AsciiStriCmp(str1,str2) #define strcasecmp(str1, str2) (int)AsciiStriCmp(str1,str2)
#define strstr(s1,s2) AsciiStrStr(s1,s2) #define strstr(s1, s2) AsciiStrStr(s1,s2)
#define snprintf(buf,len,...) RedfishAsciiSPrint(buf,len,__VA_ARGS__) #define snprintf(buf, len, ...) RedfishAsciiSPrint(buf,len,__VA_ARGS__)
#define vsnprintf(buf,len,format,marker) RedfishAsciiVSPrint((buf),(len),(format),(marker)) #define vsnprintf(buf, len, format, marker) RedfishAsciiVSPrint((buf),(len),(format),(marker))
#define assert(expression) ASSERT(expression) #define assert(expression) ASSERT(expression)
#define offsetof(type,member) OFFSET_OF(type,member) #define offsetof(type, member) OFFSET_OF(type,member)
#define EOF (-1) #define EOF (-1)

View File

@ -6,6 +6,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_HOST_INTERFACE_LIB_H_ #ifndef REDFISH_HOST_INTERFACE_LIB_H_
#define REDFISH_HOST_INTERFACE_LIB_H_ #define REDFISH_HOST_INTERFACE_LIB_H_
@ -29,7 +30,8 @@ EFI_STATUS
RedfishPlatformHostInterfaceDeviceDescriptor ( RedfishPlatformHostInterfaceDeviceDescriptor (
IN UINT8 *DeviceType, IN UINT8 *DeviceType,
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor OUT REDFISH_INTERFACE_DATA **DeviceDescriptor
); );
/** /**
Get platform Redfish host interface protocol data. Get platform Redfish host interface protocol data.
Caller should pass NULL in ProtocolRecord to retrive the first protocol record. Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
@ -48,5 +50,6 @@ EFI_STATUS
RedfishPlatformHostInterfaceProtocolData ( RedfishPlatformHostInterfaceProtocolData (
IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord, IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
IN UINT8 IndexOfProtocolData IN UINT8 IndexOfProtocolData
); );
#endif #endif

View File

@ -37,6 +37,6 @@ RestExLibCreateChild (
IN EFI_REST_EX_CONFIG_TYPE ConfigType, IN EFI_REST_EX_CONFIG_TYPE ConfigType,
IN EFI_REST_EX_SERVICE_TYPE ServiceType, IN EFI_REST_EX_SERVICE_TYPE ServiceType,
OUT EFI_HANDLE *ChildInstanceHandle OUT EFI_HANDLE *ChildInstanceHandle
); );
#endif #endif

View File

@ -47,7 +47,7 @@ typedef struct {
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_INIT) ( (EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_INIT)(
IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This, IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This,
IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishServiceinfo IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishServiceinfo
); );
@ -63,7 +63,7 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP) ( (EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP)(
IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This
); );
@ -72,7 +72,6 @@ struct _EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL {
EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP Stop; EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP Stop;
}; };
extern EFI_GUID gdkIIRedfishConfigHandlerProtocolGuid; extern EFI_GUID gdkIIRedfishConfigHandlerProtocolGuid;
#endif #endif

View File

@ -34,7 +34,6 @@ typedef enum {
ServiceStopTypeMax ServiceStopTypeMax
} EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE; } EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE;
/** /**
Retrieve platform's Redfish authentication information. Retrieve platform's Redfish authentication information.
@ -61,7 +60,7 @@ typedef enum {
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_GET_AUTH_INFO) ( (EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_GET_AUTH_INFO)(
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
@ -86,7 +85,7 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_STOP_SERVICE) ( (EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_STOP_SERVICE)(
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
); );

View File

@ -36,7 +36,6 @@ GetUTF8SizeForUCS2 (
TempChar = *Utf8Buffer; TempChar = *Utf8Buffer;
if ((TempChar & 0xF0) == 0xF0) { if ((TempChar & 0xF0) == 0xF0) {
// //
// This format is not for UCS2. // This format is not for UCS2.
// //
@ -46,11 +45,9 @@ GetUTF8SizeForUCS2 (
Utf8Size = 1; Utf8Size = 1;
if ((TempChar & 0x80) == 0x80) { if ((TempChar & 0x80) == 0x80) {
if ((TempChar & 0xC0) == 0xC0) { if ((TempChar & 0xC0) == 0xC0) {
Utf8Size++;
Utf8Size ++;
if ((TempChar & 0xE0) == 0xE0) { if ((TempChar & 0xE0) == 0xE0) {
Utf8Size++;
Utf8Size ++;
} }
} }
} }
@ -83,7 +80,7 @@ GetUCS2CharByFormat (
UINT8 Index; UINT8 Index;
CHAR8 Ucs2CharFormat[UNICODE_FORMAT_CHAR_SIZE]; /// two Hexadecimal digits Ascii string, like "3F" CHAR8 Ucs2CharFormat[UNICODE_FORMAT_CHAR_SIZE]; /// two Hexadecimal digits Ascii string, like "3F"
for (Index = 0; Index < 4; Index ++) { for (Index = 0; Index < 4; Index++) {
if ((*(Utf8Buffer + 2 + Index) & 0x80) != 0x00) { if ((*(Utf8Buffer + 2 + Index) & 0x80) != 0x00) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -95,19 +92,19 @@ GetUCS2CharByFormat (
// Get the First Number, Offset is 2 // Get the First Number, Offset is 2
// //
CopyMem (Ucs2CharFormat, Utf8Buffer + 2, UNICODE_FORMAT_CHAR_LEN); CopyMem (Ucs2CharFormat, Utf8Buffer + 2, UNICODE_FORMAT_CHAR_LEN);
Num1 = (UINT8) AsciiStrHexToUintn (Ucs2CharFormat); Num1 = (UINT8)AsciiStrHexToUintn (Ucs2CharFormat);
// //
// Get the Second Number, Offset is 4 // Get the Second Number, Offset is 4
// //
CopyMem (Ucs2CharFormat, Utf8Buffer + 4, UNICODE_FORMAT_CHAR_LEN); CopyMem (Ucs2CharFormat, Utf8Buffer + 4, UNICODE_FORMAT_CHAR_LEN);
Num2 = (UINT8) AsciiStrHexToUintn (Ucs2CharFormat); Num2 = (UINT8)AsciiStrHexToUintn (Ucs2CharFormat);
// //
// Ucs2Char is Little-Endian // Ucs2Char is Little-Endian
// //
*((CHAR8 *) Ucs2Char) = Num2; *((CHAR8 *)Ucs2Char) = Num2;
*(((CHAR8 *) Ucs2Char) + 1) = Num1; *(((CHAR8 *)Ucs2Char) + 1) = Num1;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -131,25 +128,22 @@ UCS2CharToUTF8 (
ASSERT (Utf8Buffer != NULL); ASSERT (Utf8Buffer != NULL);
Ucs2Number = (UINT16) Ucs2Char; Ucs2Number = (UINT16)Ucs2Char;
if (Ucs2Number <= 0x007F) { if (Ucs2Number <= 0x007F) {
// //
// UTF8 format: 0xxxxxxx // UTF8 format: 0xxxxxxx
// //
*Utf8Buffer = Ucs2Char & 0x7F; *Utf8Buffer = Ucs2Char & 0x7F;
return 1; return 1;
} else if ((Ucs2Number >= 0x0080) && (Ucs2Number <= 0x07FF)) {
} else if (Ucs2Number >= 0x0080 && Ucs2Number <= 0x07FF) {
// //
// UTF8 format: 110xxxxx 10xxxxxx // UTF8 format: 110xxxxx 10xxxxxx
// //
*(Utf8Buffer + 1) = (Ucs2Char & 0x3F) | 0x80; *(Utf8Buffer + 1) = (Ucs2Char & 0x3F) | 0x80;
*Utf8Buffer = ((Ucs2Char >> 6) & 0x1F) | 0xC0; *Utf8Buffer = ((Ucs2Char >> 6) & 0x1F) | 0xC0;
return 2; return 2;
} else {
} else { /// Ucs2Number >= 0x0800 && Ucs2Number <= 0xFFFF /// Ucs2Number >= 0x0800 && Ucs2Number <= 0xFFFF
// //
// UTF8 format: 1110xxxx 10xxxxxx 10xxxxxx // UTF8 format: 1110xxxx 10xxxxxx 10xxxxxx
@ -186,11 +180,10 @@ UTF8ToUCS2Char (
ASSERT (Utf8Buffer != NULL && Ucs2Char != NULL); ASSERT (Utf8Buffer != NULL && Ucs2Char != NULL);
ZeroMem (Ucs2Char, sizeof (CHAR16)); ZeroMem (Ucs2Char, sizeof (CHAR16));
Ucs2Buffer = (CHAR8 *) Ucs2Char; Ucs2Buffer = (CHAR8 *)Ucs2Char;
Utf8Size = GetUTF8SizeForUCS2 (Utf8Buffer); Utf8Size = GetUTF8SizeForUCS2 (Utf8Buffer);
switch (Utf8Size) { switch (Utf8Size) {
case 1: case 1:
// //
@ -283,15 +276,14 @@ UCS2StrToUTF8 (
CHAR8 Utf8Buffer[UTF8_BUFFER_FOR_UCS2_MAX_SIZE]; CHAR8 Utf8Buffer[UTF8_BUFFER_FOR_UCS2_MAX_SIZE];
UINT8 Utf8BufferSize; UINT8 Utf8BufferSize;
if (Ucs2Str == NULL || Utf8StrAddr == NULL) { if ((Ucs2Str == NULL) || (Utf8StrAddr == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Ucs2StrLength = StrLen (Ucs2Str); Ucs2StrLength = StrLen (Ucs2Str);
Utf8StrLength = 0; Utf8StrLength = 0;
for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex ++) { for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex++) {
ZeroMem (Utf8Buffer, sizeof (Utf8Buffer)); ZeroMem (Utf8Buffer, sizeof (Utf8Buffer));
Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer); Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer);
Utf8StrLength += Utf8BufferSize; Utf8StrLength += Utf8BufferSize;
@ -303,8 +295,7 @@ UCS2StrToUTF8 (
} }
Utf8StrIndex = 0; Utf8StrIndex = 0;
for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex ++) { for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex++) {
ZeroMem (Utf8Buffer, sizeof (Utf8Buffer)); ZeroMem (Utf8Buffer, sizeof (Utf8Buffer));
Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer); Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer);
@ -345,7 +336,7 @@ UTF8StrToUCS2 (
UINT8 Utf8BufferSize; UINT8 Utf8BufferSize;
CHAR16 *Ucs2StrTemp; CHAR16 *Ucs2StrTemp;
if (Utf8Str == NULL || Ucs2StrAddr == NULL) { if ((Utf8Str == NULL) || (Ucs2StrAddr == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -354,7 +345,7 @@ UTF8StrToUCS2 (
// //
Utf8StrLength = 0; Utf8StrLength = 0;
while (*(Utf8Str + Utf8StrLength) != '\0') { while (*(Utf8Str + Utf8StrLength) != '\0') {
Utf8StrLength ++; Utf8StrLength++;
} }
// //
@ -368,46 +359,39 @@ UTF8StrToUCS2 (
Utf8StrIndex = 0; Utf8StrIndex = 0;
Ucs2StrIndex = 0; Ucs2StrIndex = 0;
while (Utf8Str[Utf8StrIndex] != '\0') { while (Utf8Str[Utf8StrIndex] != '\0') {
if ((CompareMem (Utf8Str + Utf8StrIndex, "\\u", 2) == 0) &&
if (CompareMem (Utf8Str + Utf8StrIndex, "\\u", 2) == 0 && (Utf8StrLength - Utf8StrIndex >= UNICODE_FORMAT_LEN))
Utf8StrLength - Utf8StrIndex >= UNICODE_FORMAT_LEN) { {
Status = GetUCS2CharByFormat (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex); Status = GetUCS2CharByFormat (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Utf8StrIndex += UNICODE_FORMAT_LEN; Utf8StrIndex += UNICODE_FORMAT_LEN;
Ucs2StrIndex ++; Ucs2StrIndex++;
} else { } else {
StrCpyS (Ucs2StrTemp + Ucs2StrIndex, 3, L"\\u"); StrCpyS (Ucs2StrTemp + Ucs2StrIndex, 3, L"\\u");
Ucs2StrIndex += 2; Ucs2StrIndex += 2;
Utf8StrIndex += 2; Utf8StrIndex += 2;
} }
} else { } else {
Utf8BufferSize = GetUTF8SizeForUCS2 (Utf8Str + Utf8StrIndex); Utf8BufferSize = GetUTF8SizeForUCS2 (Utf8Str + Utf8StrIndex);
if (Utf8BufferSize == 0 || Utf8StrLength - Utf8StrIndex < Utf8BufferSize) { if ((Utf8BufferSize == 0) || (Utf8StrLength - Utf8StrIndex < Utf8BufferSize)) {
FreePool (Ucs2StrTemp); FreePool (Ucs2StrTemp);
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Status = UTF8ToUCS2Char (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex); Status = UTF8ToUCS2Char (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePool (Ucs2StrTemp); FreePool (Ucs2StrTemp);
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Ucs2StrIndex ++; Ucs2StrIndex++;
Utf8StrIndex += Utf8BufferSize; Utf8StrIndex += Utf8BufferSize;
} }
} }
*Ucs2StrAddr = AllocateZeroPool ((Ucs2StrIndex + 1) * sizeof (CHAR16)); *Ucs2StrAddr = AllocateZeroPool ((Ucs2StrIndex + 1) * sizeof (CHAR16));
if (*Ucs2StrAddr == NULL) { if (*Ucs2StrAddr == NULL) {
FreePool (Ucs2StrTemp); FreePool (Ucs2StrTemp);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -418,4 +402,3 @@ UTF8StrToUCS2 (
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -38,7 +38,7 @@ RestExLibCreateChild (
IN EFI_REST_EX_CONFIG_TYPE ConfigType, IN EFI_REST_EX_CONFIG_TYPE ConfigType,
IN EFI_REST_EX_SERVICE_TYPE ServiceType, IN EFI_REST_EX_SERVICE_TYPE ServiceType,
OUT EFI_HANDLE *ChildInstanceHandle OUT EFI_HANDLE *ChildInstanceHandle
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN NoBuffer; UINTN NoBuffer;
@ -48,12 +48,13 @@ RestExLibCreateChild (
EFI_REST_EX_SERVICE_INFO *RestExServiceInfo; EFI_REST_EX_SERVICE_INFO *RestExServiceInfo;
UINT8 LenOfConfig; UINT8 LenOfConfig;
if (Image == NULL || if ((Image == NULL) ||
AccessMode >= EfiRestExServiceModeMax || (AccessMode >= EfiRestExServiceModeMax) ||
ConfigType >= EfiRestExConfigTypeMax || (ConfigType >= EfiRestExConfigTypeMax) ||
ServiceType >= EfiRestExServiceTypeMax || (ServiceType >= EfiRestExServiceTypeMax) ||
ChildInstanceHandle == NULL (ChildInstanceHandle == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -70,13 +71,15 @@ RestExLibCreateChild (
&NoBuffer, &NoBuffer,
&Handle &Handle
); );
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) { if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
return Status; return Status;
} }
Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof(EFI_HANDLE) * NoBuffer);
Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof (EFI_HANDLE) * NoBuffer);
if (Handle == NULL) { if (Handle == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Status = gBS->LocateHandleBuffer ( Status = gBS->LocateHandleBuffer (
ByProtocol, ByProtocol,
&gEfiRestExServiceBindingProtocolGuid, &gEfiRestExServiceBindingProtocolGuid,
@ -123,6 +126,7 @@ RestExLibCreateChild (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
// //
// Check REST EX property. // Check REST EX property.
// //
@ -138,13 +142,16 @@ RestExLibCreateChild (
default: default:
goto ON_ERROR; goto ON_ERROR;
} }
if (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode ||
RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType || if ((RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode) ||
RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType || (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType) ||
((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig))) { (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType) ||
((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig)))
{
goto ON_ERROR; goto ON_ERROR;
} }
} }
// //
// This is proper REST EX instance. // This is proper REST EX instance.
// //
@ -159,8 +166,9 @@ ON_ERROR:;
&gEfiRestExServiceBindingProtocolGuid, &gEfiRestExServiceBindingProtocolGuid,
ChildHandle ChildHandle
); );
NoBuffer --; NoBuffer--;
}; }
FreePool (Handle); FreePool (Handle);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }

View File

@ -36,7 +36,7 @@ JsonValueInitArray (
VOID VOID
) )
{ {
return (EDKII_JSON_VALUE)json_array(); return (EDKII_JSON_VALUE)json_array ();
} }
/** /**
@ -58,7 +58,7 @@ JsonValueInitObject (
VOID VOID
) )
{ {
return (EDKII_JSON_VALUE)json_object(); return (EDKII_JSON_VALUE)json_object ();
} }
/** /**
@ -201,7 +201,7 @@ JsonValueInitTrue (
VOID VOID
) )
{ {
return (EDKII_JSON_VALUE)json_true(); return (EDKII_JSON_VALUE)json_true ();
} }
/** /**
@ -219,7 +219,7 @@ JsonValueInitFalse (
VOID VOID
) )
{ {
return (EDKII_JSON_VALUE)json_false(); return (EDKII_JSON_VALUE)json_false ();
} }
/** /**
@ -237,7 +237,7 @@ JsonValueInitNull (
VOID VOID
) )
{ {
return (EDKII_JSON_VALUE)json_null(); return (EDKII_JSON_VALUE)json_null ();
} }
/** /**
@ -266,7 +266,7 @@ JsonValueFree (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
json_decref((json_t *)Json); json_decref ((json_t *)Json);
} }
/** /**
@ -292,7 +292,7 @@ JsonValueClone (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return (EDKII_JSON_VALUE)json_deep_copy ((json_t *) Json); return (EDKII_JSON_VALUE)json_deep_copy ((json_t *)Json);
} }
/** /**
@ -310,7 +310,7 @@ JsonValueIsArray (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_array ((json_t *) Json); return json_is_array ((json_t *)Json);
} }
/** /**
@ -328,7 +328,7 @@ JsonValueIsObject (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_object ((json_t *) Json); return json_is_object ((json_t *)Json);
} }
/** /**
@ -347,7 +347,7 @@ JsonValueIsString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_string ((json_t *) Json); return json_is_string ((json_t *)Json);
} }
/** /**
@ -365,7 +365,7 @@ JsonValueIsInteger (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_integer ((json_t *) Json); return json_is_integer ((json_t *)Json);
} }
/** /**
@ -383,7 +383,7 @@ JsonValueIsNumber (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_number ((json_t *) Json); return json_is_number ((json_t *)Json);
} }
/** /**
@ -401,7 +401,7 @@ JsonValueIsBoolean (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_boolean ((json_t *) Json); return json_is_boolean ((json_t *)Json);
} }
/** /**
@ -422,6 +422,7 @@ JsonValueIsTrue (
if (json_is_true ((json_t *)Json)) { if (json_is_true ((json_t *)Json)) {
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
@ -443,8 +444,10 @@ JsonValueIsFalse (
if (json_is_false ((json_t *)Json)) { if (json_is_false ((json_t *)Json)) {
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
/** /**
The function is used to return if the provided JSON value contains a JSON NULL. The function is used to return if the provided JSON value contains a JSON NULL.
@ -460,7 +463,7 @@ JsonValueIsNull (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_null ((json_t *) Json); return json_is_null ((json_t *)Json);
} }
/** /**
@ -479,7 +482,7 @@ JsonValueGetArray (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
if (Json == NULL || !JsonValueIsArray (Json)) { if ((Json == NULL) || !JsonValueIsArray (Json)) {
return NULL; return NULL;
} }
@ -502,7 +505,7 @@ JsonValueGetObject (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
if (Json == NULL || !JsonValueIsObject (Json)) { if ((Json == NULL) || !JsonValueIsObject (Json)) {
return NULL; return NULL;
} }
@ -528,7 +531,7 @@ JsonValueGetAsciiString (
CONST CHAR8 *AsciiStr; CONST CHAR8 *AsciiStr;
UINTN Index; UINTN Index;
AsciiStr = json_string_value ((json_t *) Json); AsciiStr = json_string_value ((json_t *)Json);
if (AsciiStr == NULL) { if (AsciiStr == NULL) {
return NULL; return NULL;
} }
@ -556,7 +559,7 @@ JsonValueGetAsciiString (
@retval Return the associated Unicode string in JSON value or NULL. @retval Return the associated Unicode string in JSON value or NULL.
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
JsonValueGetUnicodeString ( JsonValueGetUnicodeString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
@ -566,12 +569,12 @@ JsonValueGetUnicodeString (
CONST CHAR8 *Utf8Str; CONST CHAR8 *Utf8Str;
CHAR16 *Ucs2Str; CHAR16 *Ucs2Str;
Utf8Str = json_string_value ((json_t *) Json); Utf8Str = json_string_value ((json_t *)Json);
if (Utf8Str == NULL) { if (Utf8Str == NULL) {
return NULL; return NULL;
} }
Status = UTF8StrToUCS2 ((CHAR8*)Utf8Str, &Ucs2Str); Status = UTF8StrToUCS2 ((CHAR8 *)Utf8Str, &Ucs2Str);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return NULL; return NULL;
} }
@ -597,11 +600,11 @@ JsonValueGetInteger (
) )
{ {
ASSERT (Json != NULL && JsonValueIsInteger (Json)); ASSERT (Json != NULL && JsonValueIsInteger (Json));
if (Json == NULL || !JsonValueIsInteger (Json)) { if ((Json == NULL) || !JsonValueIsInteger (Json)) {
return 0; return 0;
} }
return json_integer_value ((json_t *) Json); return json_integer_value ((json_t *)Json);
} }
/** /**
@ -622,11 +625,11 @@ JsonValueGetBoolean (
) )
{ {
ASSERT (Json != NULL && JsonValueIsBoolean (Json)); ASSERT (Json != NULL && JsonValueIsBoolean (Json));
if (Json == NULL || !JsonValueIsBoolean (Json)) { if ((Json == NULL) || !JsonValueIsBoolean (Json)) {
return FALSE; return FALSE;
} }
return json_is_true ((json_t *) Json); return json_is_true ((json_t *)Json);
} }
/** /**
@ -639,7 +642,7 @@ JsonValueGetBoolean (
@retval Return the associated Ascii string in JSON value or NULL on errors. @retval Return the associated Ascii string in JSON value or NULL on errors.
**/ **/
CONST CHAR8* CONST CHAR8 *
EFIAPI EFIAPI
JsonValueGetString ( JsonValueGetString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
@ -663,7 +666,7 @@ JsonObjectSize (
IN EDKII_JSON_OBJECT JsonObject IN EDKII_JSON_OBJECT JsonObject
) )
{ {
return json_object_size ((json_t *) JsonObject); return json_object_size ((json_t *)JsonObject);
} }
/** /**
@ -679,24 +682,23 @@ JsonObjectSize (
JsonObj is not an JSON object, key count is zero or on other errors. JsonObj is not an JSON object, key count is zero or on other errors.
**/ **/
CHAR8** CHAR8 **
JsonObjectGetKeys ( JsonObjectGetKeys (
IN EDKII_JSON_OBJECT JsonObj, IN EDKII_JSON_OBJECT JsonObj,
OUT UINTN *KeyCount OUT UINTN *KeyCount
) )
{ {
UINTN Index; UINTN Index;
CONST CHAR8 **KeyArray; CONST CHAR8 **KeyArray;
CONST CHAR8 *Key; CONST CHAR8 *Key;
EDKII_JSON_VALUE Value; EDKII_JSON_VALUE Value;
if (JsonObj == NULL || KeyCount == NULL) { if ((JsonObj == NULL) || (KeyCount == NULL)) {
return NULL; return NULL;
} }
Index = 0; Index = 0;
json_object_foreach(JsonObj, Key, Value) { json_object_foreach (JsonObj, Key, Value) {
Index++; Index++;
} }
if (Index == 0) { if (Index == 0) {
@ -705,7 +707,7 @@ JsonObjectGetKeys (
} }
*KeyCount = Index; *KeyCount = Index;
KeyArray = (CONST CHAR8 **) AllocateZeroPool (*KeyCount * sizeof (CHAR8 *)); KeyArray = (CONST CHAR8 **)AllocateZeroPool (*KeyCount * sizeof (CHAR8 *));
if (KeyArray == NULL) { if (KeyArray == NULL) {
return NULL; return NULL;
} }
@ -713,7 +715,7 @@ JsonObjectGetKeys (
Key = NULL; Key = NULL;
Value = NULL; Value = NULL;
Index = 0; Index = 0;
json_object_foreach((json_t *) JsonObj, Key, Value) { json_object_foreach ((json_t *)JsonObj, Key, Value) {
KeyArray[Index] = Key; KeyArray[Index] = Key;
Index++; Index++;
} }
@ -773,7 +775,7 @@ JsonObjectSetValue (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
if (json_object_set ((json_t *) JsonObj, Key, (json_t *) Json) != 0) { if (json_object_set ((json_t *)JsonObj, Key, (json_t *)Json) != 0) {
return EFI_ABORTED; return EFI_ABORTED;
} else { } else {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -795,7 +797,7 @@ JsonArrayCount (
IN EDKII_JSON_ARRAY JsonArray IN EDKII_JSON_ARRAY JsonArray
) )
{ {
return json_array_size ((json_t *) JsonArray); return json_array_size ((json_t *)JsonArray);
} }
/** /**
@ -821,7 +823,7 @@ JsonArrayGetValue (
IN UINTN Index IN UINTN Index
) )
{ {
return (EDKII_JSON_VALUE)json_array_get ((json_t *) JsonArray, Index); return (EDKII_JSON_VALUE)json_array_get ((json_t *)JsonArray, Index);
} }
/** /**
@ -844,7 +846,7 @@ JsonArrayAppendValue (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
if (json_array_append ((json_t *) JsonArray, (json_t *) Json) != 0) { if (json_array_append ((json_t *)JsonArray, (json_t *)Json) != 0) {
return EFI_ABORTED; return EFI_ABORTED;
} else { } else {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -872,7 +874,7 @@ JsonArrayRemoveValue (
IN UINTN Index IN UINTN Index
) )
{ {
if (json_array_remove ((json_t *) JsonArray, Index) != 0) { if (json_array_remove ((json_t *)JsonArray, Index) != 0) {
return EFI_ABORTED; return EFI_ABORTED;
} else { } else {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -911,7 +913,8 @@ JsonDumpString (
if (JsonValue == NULL) { if (JsonValue == NULL) {
return NULL; return NULL;
} }
return json_dumps((json_t *)JsonValue, Flags);
return json_dumps ((json_t *)JsonValue, Flags);
} }
/** /**
@ -934,12 +937,12 @@ JsonDumpString (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonLoadString ( JsonLoadString (
IN CONST CHAR8* String, IN CONST CHAR8 *String,
IN UINT64 Flags, IN UINT64 Flags,
IN EDKII_JSON_ERROR *Error IN EDKII_JSON_ERROR *Error
) )
{ {
return (EDKII_JSON_VALUE) json_loads ((const char *)String, Flags, (json_error_t *)Error); return (EDKII_JSON_VALUE)json_loads ((const char *)String, Flags, (json_error_t *)Error);
} }
/** /**
@ -970,7 +973,7 @@ JsonLoadBuffer (
IN OUT EDKII_JSON_ERROR *Error IN OUT EDKII_JSON_ERROR *Error
) )
{ {
return json_loadb(Buffer, BufferLen, Flags, (json_error_t *)Error); return json_loadb (Buffer, BufferLen, Flags, (json_error_t *)Error);
} }
/** /**
@ -1044,7 +1047,7 @@ JsonObjectIteratorValue (
IN VOID *Iterator IN VOID *Iterator
) )
{ {
return json_object_iter_value(Iterator); return json_object_iter_value (Iterator);
} }
/** /**
@ -1062,7 +1065,7 @@ JsonObjectIteratorNext (
IN VOID *Iterator IN VOID *Iterator
) )
{ {
return json_object_iter_next(JsonValue, Iterator); return json_object_iter_next (JsonValue, Iterator);
} }
/** /**
@ -1075,9 +1078,9 @@ CHAR8 *
EFIAPI EFIAPI
JsonObjectIteratorKey ( JsonObjectIteratorKey (
IN VOID *Iterator IN VOID *Iterator
) )
{ {
return (CHAR8 *)json_object_iter_key(Iterator); return (CHAR8 *)json_object_iter_key (Iterator);
} }
/** /**
@ -1090,9 +1093,9 @@ VOID *
EFIAPI EFIAPI
JsonObjectKeyToIterator ( JsonObjectKeyToIterator (
IN CHAR8 *Key IN CHAR8 *Key
) )
{ {
return json_object_key_to_iter(Key); return json_object_key_to_iter (Key);
} }
/** /**

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
**/ **/
#include <Uefi.h> #include <Uefi.h>
#include <Protocol/EdkIIRedfishCredential.h> #include <Protocol/EdkIIRedfishCredential.h>
/** /**
Notification of Exit Boot Service. Notification of Exit Boot Service.
@ -17,7 +18,7 @@ VOID
EFIAPI EFIAPI
LibCredentialExitBootServicesNotify ( LibCredentialExitBootServicesNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
) )
{ {
return; return;
} }
@ -31,7 +32,7 @@ VOID
EFIAPI EFIAPI
LibCredentialEndOfDxeNotify ( LibCredentialEndOfDxeNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
) )
{ {
return; return;
} }
@ -67,7 +68,7 @@ LibCredentialGetAuthInfo (
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
OUT CHAR8 **Password OUT CHAR8 **Password
) )
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -98,4 +99,3 @@ LibStopRedfishService (
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }

View File

@ -25,10 +25,11 @@ EFI_STATUS
RedfishPlatformHostInterfaceDeviceDescriptor ( RedfishPlatformHostInterfaceDeviceDescriptor (
IN UINT8 *DeviceType, IN UINT8 *DeviceType,
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor OUT REDFISH_INTERFACE_DATA **DeviceDescriptor
) )
{ {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
/** /**
Get platform Redfish host interface protocol data. Get platform Redfish host interface protocol data.
Caller should pass NULL in ProtocolRecord to retrive the first protocol record. Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
@ -46,7 +47,7 @@ EFI_STATUS
RedfishPlatformHostInterfaceProtocolData ( RedfishPlatformHostInterfaceProtocolData (
IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord, IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
IN UINT8 IndexOfProtocolData IN UINT8 IndexOfProtocolData
) )
{ {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }

View File

@ -7,6 +7,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CRT_STDARG_H_ #ifndef REDFISH_CRT_STDARG_H_
#define REDFISH_CRT_STDARG_H_ #define REDFISH_CRT_STDARG_H_

View File

@ -7,6 +7,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CRT_STDIO_H_ #ifndef REDFISH_CRT_STDIO_H_
#define REDFISH_CRT_STDIO_H_ #define REDFISH_CRT_STDIO_H_

View File

@ -7,6 +7,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CRT_SYS_TIME_H_ #ifndef REDFISH_CRT_SYS_TIME_H_
#define REDFISH_CRT_SYS_TIME_H_ #define REDFISH_CRT_SYS_TIME_H_

View File

@ -7,6 +7,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CRT_SYS_TYPES_H_ #ifndef REDFISH_CRT_SYS_TYPES_H_
#define REDFISH_CRT_SYS_TYPES_H_ #define REDFISH_CRT_SYS_TYPES_H_

View File

@ -7,6 +7,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CRT_TIME_H_ #ifndef REDFISH_CRT_TIME_H_
#define REDFISH_CRT_TIME_H_ #define REDFISH_CRT_TIME_H_

View File

@ -80,8 +80,8 @@
/// ///
/// Library class public defines /// Library class public defines
/// ///
typedef VOID* REDFISH_SERVICE; typedef VOID *REDFISH_SERVICE;
typedef VOID* REDFISH_PAYLOAD; typedef VOID *REDFISH_PAYLOAD;
/// ///
/// Library class public structures/unions /// Library class public structures/unions
@ -97,8 +97,8 @@ typedef struct {
/// Odata type-name mapping structure. /// Odata type-name mapping structure.
/// ///
typedef struct { typedef struct {
CONST CHAR8 OdataTypeName [ODATA_TYPE_NAME_MAX_SIZE]; CONST CHAR8 OdataTypeName[ODATA_TYPE_NAME_MAX_SIZE];
CONST CHAR8 OdataType [ODATA_TYPE_MAX_SIZE]; CONST CHAR8 OdataType[ODATA_TYPE_MAX_SIZE];
} REDFISH_ODATA_TYPE_MAPPING; } REDFISH_ODATA_TYPE_MAPPING;
/** /**
@ -471,6 +471,7 @@ VOID
RedfishDumpPayload ( RedfishDumpPayload (
IN REDFISH_PAYLOAD Payload IN REDFISH_PAYLOAD Payload
); );
/** /**
Dump text in JSON value. Dump text in JSON value.
@ -481,6 +482,7 @@ VOID
RedfishDumpJson ( RedfishDumpJson (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
); );
/** /**
This function will cleanup the HTTP header and Redfish payload resources. This function will cleanup the HTTP header and Redfish payload resources.
@ -528,7 +530,8 @@ RedfishIsValidOdataType (
BOOLEAN BOOLEAN
RedfishIsPayloadCollection ( RedfishIsPayloadCollection (
IN REDFISH_PAYLOAD Payload IN REDFISH_PAYLOAD Payload
); );
/** /**
Get collection size. Get collection size.
@ -539,10 +542,11 @@ RedfishIsPayloadCollection (
@return EFI_INVALID_PARAMETER The payload is not a collection. @return EFI_INVALID_PARAMETER The payload is not a collection.
**/ **/
EFI_STATUS EFI_STATUS
RedfishGetCollectionSize( RedfishGetCollectionSize (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN UINTN *CollectionSize IN UINTN *CollectionSize
); );
/** /**
Get Redfish payload of collection member Get Redfish payload of collection member
@ -556,7 +560,7 @@ REDFISH_PAYLOAD
RedfishGetPayloadByIndex ( RedfishGetPayloadByIndex (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN UINTN Index IN UINTN Index
); );
/** /**
Check and return Redfish resource of the given Redpath. Check and return Redfish resource of the given Redpath.
@ -572,7 +576,7 @@ RedfishCheckIfRedpathExist (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
IN CHAR8 *Redpath, IN CHAR8 *Redpath,
IN REDFISH_RESPONSE *Response OPTIONAL IN REDFISH_RESPONSE *Response OPTIONAL
); );
/** /**
This function returns the string of Redfish service version. This function returns the string of Redfish service version.
@ -584,7 +588,7 @@ RedfishCheckIfRedpathExist (
**/ **/
EFI_STATUS EFI_STATUS
RedfishGetServiceVersion( RedfishGetServiceVersion (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
OUT CHAR8 **ServiceVersionStr OUT CHAR8 **ServiceVersionStr
); );
@ -608,4 +612,5 @@ RedfishBuildRedpathUseId (
IN CHAR8 *Id, IN CHAR8 *Id,
OUT CHAR8 **Redpath OUT CHAR8 **Redpath
); );
#endif #endif

View File

@ -15,7 +15,7 @@
#include <Library/UefiRuntimeServicesTableLib.h> #include <Library/UefiRuntimeServicesTableLib.h>
int errno = 0; int errno = 0;
char errnum_message [] = "We don't support to map errnum to the error message on edk2 Redfish\n"; char errnum_message[] = "We don't support to map errnum to the error message on edk2 Redfish\n";
// This is required to keep VC++ happy if you use floating-point // This is required to keep VC++ happy if you use floating-point
int _fltused = 1; int _fltused = 1;
@ -24,7 +24,10 @@ int _fltused = 1;
Determine if a particular character is an alphanumeric character Determine if a particular character is an alphanumeric character
@return Returns 1 if c is an alphanumeric character, otherwise returns 0. @return Returns 1 if c is an alphanumeric character, otherwise returns 0.
**/ **/
int isalnum (int c) int
isalnum (
int c
)
{ {
// //
// <alnum> ::= [0-9] | [a-z] | [A-Z] // <alnum> ::= [0-9] | [a-z] | [A-Z]
@ -39,7 +42,10 @@ int isalnum (int c)
@return Returns 1 if c is an digital character, otherwise returns 0. @return Returns 1 if c is an digital character, otherwise returns 0.
**/ **/
int isdchar (int c) int
isdchar (
int c
)
{ {
// //
// [0-9] | [e +-.] // [0-9] | [e +-.]
@ -55,7 +61,10 @@ int isdchar (int c)
@return Returns 1 if c is a space character @return Returns 1 if c is a space character
**/ **/
int isspace (int c) int
isspace (
int c
)
{ {
// //
// <space> ::= [ ] // <space> ::= [ ]
@ -66,15 +75,21 @@ int isspace (int c)
/** /**
Allocates memory blocks Allocates memory blocks
*/ */
void *malloc (size_t size) void *
malloc (
size_t size
)
{ {
return AllocatePool ((UINTN) size); return AllocatePool ((UINTN)size);
} }
/** /**
De-allocates or frees a memory block De-allocates or frees a memory block
*/ */
void free (void *ptr) void
free (
void *ptr
)
{ {
// //
// In Standard C, free() handles a null pointer argument transparently. This // In Standard C, free() handles a null pointer argument transparently. This
@ -90,15 +105,20 @@ void free (void *ptr)
@return Returns the pointer to duplicated string. @return Returns the pointer to duplicated string.
**/ **/
char * strdup(const char *str) char *
strdup (
const char *str
)
{ {
size_t len; size_t len;
char *copy; char *copy;
len = strlen(str) + 1; len = strlen (str) + 1;
if ((copy = malloc(len)) == NULL) if ((copy = malloc (len)) == NULL) {
return (NULL); return (NULL);
memcpy(copy, str, len); }
memcpy (copy, str, len);
return (copy); return (copy);
} }
@ -115,13 +135,14 @@ char * strdup(const char *str)
returned unchanged. returned unchanged.
**/ **/
int int
toupper( toupper (
IN int c IN int c
) )
{ {
if ( (c >= 'a') && (c <= 'z') ) { if ((c >= 'a') && (c <= 'z')) {
c = c - ('a' - 'A'); c = c - ('a' - 'A');
} }
return c; return c;
} }
@ -131,15 +152,18 @@ toupper(
@return Returns the value of digit. @return Returns the value of digit.
**/ **/
int int
Digit2Val( int c) Digit2Val (
int c
)
{ {
if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) { /* If c is one of [A-Za-z]... */ if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) {
c = toupper(c) - 7; // Adjust so 'A' is ('9' + 1) /* If c is one of [A-Za-z]... */
c = toupper (c) - 7; // Adjust so 'A' is ('9' + 1)
} }
return c - '0'; // Value returned is between 0 and 35, inclusive. return c - '0'; // Value returned is between 0 and 35, inclusive.
} }
/** The strtoll function converts the initial portion of the string pointed to /** The strtoll function converts the initial portion of the string pointed to
by nptr to long long int representation. by nptr to long long int representation.
@ -152,7 +176,11 @@ Digit2Val( int c)
and the value of the macro ERANGE is stored in errno. and the value of the macro ERANGE is stored in errno.
**/ **/
long long long long
strtoll(const char * nptr, char ** endptr, int base) strtoll (
const char *nptr,
char **endptr,
int base
)
{ {
const char *pEnd; const char *pEnd;
long long Result = 0; long long Result = 0;
@ -162,71 +190,86 @@ strtoll(const char * nptr, char ** endptr, int base)
pEnd = nptr; pEnd = nptr;
if((base < 0) || (base == 1) || (base > 36)) { if ((base < 0) || (base == 1) || (base > 36)) {
if(endptr != NULL) { if (endptr != NULL) {
*endptr = NULL; *endptr = NULL;
} }
return 0; return 0;
} }
// Skip leading spaces.
while(isspace(*nptr)) ++nptr;
// Process Subject sequence: optional sign followed by digits. // Skip leading spaces.
if(*nptr == '+') { while (isspace (*nptr)) {
Negative = FALSE;
++nptr; ++nptr;
} }
else if(*nptr == '-') {
// Process Subject sequence: optional sign followed by digits.
if (*nptr == '+') {
Negative = FALSE;
++nptr;
} else if (*nptr == '-') {
Negative = TRUE; Negative = TRUE;
++nptr; ++nptr;
} }
if(*nptr == '0') { /* Might be Octal or Hex */ if (*nptr == '0') {
if(toupper(nptr[1]) == 'X') { /* Looks like Hex */ /* Might be Octal or Hex */
if((base == 0) || (base == 16)) { if (toupper (nptr[1]) == 'X') {
/* Looks like Hex */
if ((base == 0) || (base == 16)) {
nptr += 2; /* Skip the "0X" */ nptr += 2; /* Skip the "0X" */
base = 16; /* In case base was 0 */ base = 16; /* In case base was 0 */
} }
} } else {
else { /* Looks like Octal */ /* Looks like Octal */
if((base == 0) || (base == 8)) { if ((base == 0) || (base == 8)) {
++nptr; /* Skip the leading "0" */ ++nptr; /* Skip the leading "0" */
base = 8; /* In case base was 0 */ base = 8; /* In case base was 0 */
} }
} }
} }
if(base == 0) { /* If still zero then must be decimal */
if (base == 0) {
/* If still zero then must be decimal */
base = 10; base = 10;
} }
if(*nptr == '0') {
for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */ if (*nptr == '0') {
for ( ; *nptr == '0'; ++nptr) {
/* Skip any remaining leading zeros */
}
pEnd = nptr; pEnd = nptr;
} }
while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) { while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
Previous = Result; Previous = Result;
Result = MultS64x64 (Result, base) + (long long int)temp; Result = MultS64x64 (Result, base) + (long long int)temp;
if( Result <= Previous) { // Detect Overflow if ( Result <= Previous) {
if(Negative) { // Detect Overflow
if (Negative) {
Result = LLONG_MIN; Result = LLONG_MIN;
} } else {
else {
Result = LLONG_MAX; Result = LLONG_MAX;
} }
Negative = FALSE; Negative = FALSE;
errno = ERANGE; errno = ERANGE;
break; break;
} }
pEnd = ++nptr; pEnd = ++nptr;
} }
if(Negative) {
if (Negative) {
Result = -Result; Result = -Result;
} }
// Save pointer to final sequence // Save pointer to final sequence
if(endptr != NULL) { if (endptr != NULL) {
*endptr = (char *)pEnd; *endptr = (char *)pEnd;
} }
return Result; return Result;
} }
@ -285,7 +328,11 @@ strtoll(const char * nptr, char ** endptr, int base)
is stored in errno. is stored in errno.
**/ **/
long long
strtol(const char * nptr, char ** endptr, int base) strtol (
const char *nptr,
char **endptr,
int base
)
{ {
const char *pEnd; const char *pEnd;
long Result = 0; long Result = 0;
@ -295,71 +342,86 @@ strtol(const char * nptr, char ** endptr, int base)
pEnd = nptr; pEnd = nptr;
if((base < 0) || (base == 1) || (base > 36)) { if ((base < 0) || (base == 1) || (base > 36)) {
if(endptr != NULL) { if (endptr != NULL) {
*endptr = NULL; *endptr = NULL;
} }
return 0; return 0;
} }
// Skip leading spaces.
while(isspace(*nptr)) ++nptr;
// Process Subject sequence: optional sign followed by digits. // Skip leading spaces.
if(*nptr == '+') { while (isspace (*nptr)) {
Negative = FALSE;
++nptr; ++nptr;
} }
else if(*nptr == '-') {
// Process Subject sequence: optional sign followed by digits.
if (*nptr == '+') {
Negative = FALSE;
++nptr;
} else if (*nptr == '-') {
Negative = TRUE; Negative = TRUE;
++nptr; ++nptr;
} }
if(*nptr == '0') { /* Might be Octal or Hex */ if (*nptr == '0') {
if(toupper(nptr[1]) == 'X') { /* Looks like Hex */ /* Might be Octal or Hex */
if((base == 0) || (base == 16)) { if (toupper (nptr[1]) == 'X') {
/* Looks like Hex */
if ((base == 0) || (base == 16)) {
nptr += 2; /* Skip the "0X" */ nptr += 2; /* Skip the "0X" */
base = 16; /* In case base was 0 */ base = 16; /* In case base was 0 */
} }
} } else {
else { /* Looks like Octal */ /* Looks like Octal */
if((base == 0) || (base == 8)) { if ((base == 0) || (base == 8)) {
++nptr; /* Skip the leading "0" */ ++nptr; /* Skip the leading "0" */
base = 8; /* In case base was 0 */ base = 8; /* In case base was 0 */
} }
} }
} }
if(base == 0) { /* If still zero then must be decimal */
if (base == 0) {
/* If still zero then must be decimal */
base = 10; base = 10;
} }
if(*nptr == '0') {
for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */ if (*nptr == '0') {
for ( ; *nptr == '0'; ++nptr) {
/* Skip any remaining leading zeros */
}
pEnd = nptr; pEnd = nptr;
} }
while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) { while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
Previous = Result; Previous = Result;
Result = (Result * base) + (long int)temp; Result = (Result * base) + (long int)temp;
if( Result <= Previous) { // Detect Overflow if ( Result <= Previous) {
if(Negative) { // Detect Overflow
if (Negative) {
Result = LONG_MIN; Result = LONG_MIN;
} } else {
else {
Result = LONG_MAX; Result = LONG_MAX;
} }
Negative = FALSE; Negative = FALSE;
errno = ERANGE; errno = ERANGE;
break; break;
} }
pEnd = ++nptr; pEnd = ++nptr;
} }
if(Negative) {
if (Negative) {
Result = -Result; Result = -Result;
} }
// Save pointer to final sequence // Save pointer to final sequence
if(endptr != NULL) { if (endptr != NULL) {
*endptr = (char *)pEnd; *endptr = (char *)pEnd;
} }
return Result; return Result;
} }
@ -374,7 +436,11 @@ strtol(const char * nptr, char ** endptr, int base)
returned and the value of the macro ERANGE is stored in errno. returned and the value of the macro ERANGE is stored in errno.
**/ **/
unsigned long long unsigned long long
strtoull(const char * nptr, char ** endptr, int base) strtoull (
const char *nptr,
char **endptr,
int base
)
{ {
const char *pEnd; const char *pEnd;
unsigned long long Result = 0; unsigned long long Result = 0;
@ -383,57 +449,72 @@ strtoull(const char * nptr, char ** endptr, int base)
pEnd = nptr; pEnd = nptr;
if((base < 0) || (base == 1) || (base > 36)) { if ((base < 0) || (base == 1) || (base > 36)) {
if(endptr != NULL) { if (endptr != NULL) {
*endptr = NULL; *endptr = NULL;
} }
return 0; return 0;
} }
// Skip leading spaces.
while(isspace(*nptr)) ++nptr;
// Process Subject sequence: optional + sign followed by digits. // Skip leading spaces.
if(*nptr == '+') { while (isspace (*nptr)) {
++nptr; ++nptr;
} }
if(*nptr == '0') { /* Might be Octal or Hex */ // Process Subject sequence: optional + sign followed by digits.
if(toupper(nptr[1]) == 'X') { /* Looks like Hex */ if (*nptr == '+') {
if((base == 0) || (base == 16)) { ++nptr;
}
if (*nptr == '0') {
/* Might be Octal or Hex */
if (toupper (nptr[1]) == 'X') {
/* Looks like Hex */
if ((base == 0) || (base == 16)) {
nptr += 2; /* Skip the "0X" */ nptr += 2; /* Skip the "0X" */
base = 16; /* In case base was 0 */ base = 16; /* In case base was 0 */
} }
} } else {
else { /* Looks like Octal */ /* Looks like Octal */
if((base == 0) || (base == 8)) { if ((base == 0) || (base == 8)) {
++nptr; /* Skip the leading "0" */ ++nptr; /* Skip the leading "0" */
base = 8; /* In case base was 0 */ base = 8; /* In case base was 0 */
} }
} }
} }
if(base == 0) { /* If still zero then must be decimal */
if (base == 0) {
/* If still zero then must be decimal */
base = 10; base = 10;
} }
if(*nptr == '0') {
for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */ if (*nptr == '0') {
for ( ; *nptr == '0'; ++nptr) {
/* Skip any remaining leading zeros */
}
pEnd = nptr; pEnd = nptr;
} }
while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) { while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
Previous = Result; Previous = Result;
Result = DivU64x32 (Result, base) + (unsigned long long)temp; Result = DivU64x32 (Result, base) + (unsigned long long)temp;
if( Result < Previous) { // If we overflowed if ( Result < Previous) {
// If we overflowed
Result = ULLONG_MAX; Result = ULLONG_MAX;
errno = ERANGE; errno = ERANGE;
break; break;
} }
pEnd = ++nptr; pEnd = ++nptr;
} }
// Save pointer to final sequence // Save pointer to final sequence
if(endptr != NULL) { if (endptr != NULL) {
*endptr = (char *)pEnd; *endptr = (char *)pEnd;
} }
return Result; return Result;
} }
@ -462,16 +543,19 @@ strtoull(const char * nptr, char ** endptr, int base)
@return Return 0. @return Return 0.
**/ **/
double double
strtod (const char * __restrict nptr, char ** __restrict endptr) { strtod (
const char *__restrict nptr,
DEBUG((DEBUG_INFO, "We don't supprot double type on edk2 yet!")); char **__restrict endptr
ASSERT(FALSE); )
{
DEBUG ((DEBUG_INFO, "We don't supprot double type on edk2 yet!"));
ASSERT (FALSE);
return (double)0; return (double)0;
} }
static UINT8 BitMask[] = { static UINT8 BitMask[] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
}; };
#define WHICH8(c) ((unsigned char)(c) >> 3) #define WHICH8(c) ((unsigned char)(c) >> 3)
#define WHICH_BIT(c) (BitMask[((c) & 0x7)]) #define WHICH_BIT(c) (BitMask[((c) & 0x7)])
@ -479,7 +563,11 @@ static UINT8 BitMask[] = {
static static
void void
BuildBitmap(unsigned char * bitmap, const char *s2, int n) BuildBitmap (
unsigned char *bitmap,
const char *s2,
int n
)
{ {
unsigned char bit; unsigned char bit;
int index; int index;
@ -490,9 +578,9 @@ BuildBitmap(unsigned char * bitmap, const char *s2, int n)
} }
// Set bits in bitmap corresponding to the characters in s2 // Set bits in bitmap corresponding to the characters in s2
for (; *s2 != '\0'; s2++) { for ( ; *s2 != '\0'; s2++) {
index = WHICH8(*s2); index = WHICH8 (*s2);
bit = WHICH_BIT(*s2); bit = WHICH_BIT (*s2);
bitmap[index] = bitmap[index] | bit; bitmap[index] = bitmap[index] | bit;
} }
} }
@ -504,21 +592,25 @@ BuildBitmap(unsigned char * bitmap, const char *s2, int n)
null pointer if no character from s2 occurs in s1. null pointer if no character from s2 occurs in s1.
**/ **/
char * char *
strpbrk(const char *s1, const char *s2) strpbrk (
const char *s1,
const char *s2
)
{ {
UINT8 bitmap[ (((UCHAR_MAX + 1) / CHAR_BIT) + (CHAR_BIT - 1)) & ~7U]; UINT8 bitmap[(((UCHAR_MAX + 1) / CHAR_BIT) + (CHAR_BIT - 1)) & ~7U];
UINT8 bit; UINT8 bit;
int index; int index;
BuildBitmap( bitmap, s2, sizeof(bitmap) / sizeof(UINT64)); BuildBitmap (bitmap, s2, sizeof (bitmap) / sizeof (UINT64));
for( ; *s1 != '\0'; ++s1) { for ( ; *s1 != '\0'; ++s1) {
index = WHICH8(*s1); index = WHICH8 (*s1);
bit = WHICH_BIT(*s1); bit = WHICH_BIT (*s1);
if( (bitmap[index] & bit) != 0) { if ((bitmap[index] & bit) != 0) {
return (char *)s1; return (char *)s1;
} }
} }
return NULL; return NULL;
} }
@ -535,7 +627,9 @@ strpbrk(const char *s1, const char *s2)
a subsequent call to the strerror function. a subsequent call to the strerror function.
**/ **/
char * char *
strerror(int errnum) strerror (
int errnum
)
{ {
return errnum_message; return errnum_message;
} }
@ -544,7 +638,10 @@ strerror(int errnum)
Allocate and zero-initialize array. Allocate and zero-initialize array.
**/ **/
void * void *
calloc(size_t Num, size_t Size) calloc (
size_t Num,
size_t Size
)
{ {
void *RetVal; void *RetVal;
size_t NumSize; size_t NumSize;
@ -552,12 +649,13 @@ calloc(size_t Num, size_t Size)
NumSize = Num * Size; NumSize = Num * Size;
RetVal = NULL; RetVal = NULL;
if (NumSize != 0) { if (NumSize != 0) {
RetVal = malloc(NumSize); RetVal = malloc (NumSize);
if( RetVal != NULL) { if ( RetVal != NULL) {
(VOID)ZeroMem( RetVal, NumSize); (VOID)ZeroMem (RetVal, NumSize);
} }
} }
DEBUG((DEBUG_POOL, "0x%p = calloc(%d, %d)\n", RetVal, Num, Size));
DEBUG ((DEBUG_POOL, "0x%p = calloc(%d, %d)\n", RetVal, Num, Size));
return RetVal; return RetVal;
} }
@ -610,7 +708,10 @@ UINTN CumulativeDays[2][14] = {
/** /**
Get the system time as seconds elapsed since midnight, January 1, 1970. Get the system time as seconds elapsed since midnight, January 1, 1970.
**/ **/
time_t time (time_t *timer) time_t
time (
time_t *timer
)
{ {
EFI_TIME Time; EFI_TIME Time;
time_t CalTime; time_t CalTime;
@ -626,7 +727,7 @@ time_t time (time_t *timer)
// UTime should now be set to 00:00:00 on Jan 1 of the current year. // UTime should now be set to 00:00:00 on Jan 1 of the current year.
// //
for (Year = 1970, CalTime = 0; Year != Time.Year; Year++) { for (Year = 1970, CalTime = 0; Year != Time.Year; Year++) {
CalTime = CalTime + (time_t)(CumulativeDays[IsLeap(Year)][13] * SECSPERDAY); CalTime = CalTime + (time_t)(CumulativeDays[IsLeap (Year)][13] * SECSPERDAY);
} }
// //
@ -634,7 +735,7 @@ time_t time (time_t *timer)
// //
CalTime = CalTime + CalTime = CalTime +
(time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) + (time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) +
(time_t)(CumulativeDays[IsLeap(Time.Year)][Time.Month] * SECSPERDAY) + (time_t)(CumulativeDays[IsLeap (Time.Year)][Time.Month] * SECSPERDAY) +
(time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) + (time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) +
(time_t)(Time.Hour * SECSPERHOUR) + (time_t)(Time.Hour * SECSPERHOUR) +
(time_t)(Time.Minute * 60) + (time_t)(Time.Minute * 60) +
@ -650,9 +751,14 @@ time_t time (time_t *timer)
/** /**
Performs a quick sort Performs a quick sort
**/ **/
void qsort (void *base, size_t num, size_t width, int (*compare)(const void *, const void *)) void
qsort (
void *base,
size_t num,
size_t width,
int ( *compare )(const void *, const void *)
)
{ {
ASSERT (base != NULL); ASSERT (base != NULL);
ASSERT (compare != NULL); ASSERT (compare != NULL);
@ -666,54 +772,93 @@ void qsort (void *base, size_t num, size_t width, int (*compare)(const void *, c
@return Returns the character currently pointed by the internal file position indicator of the specified stream @return Returns the character currently pointed by the internal file position indicator of the specified stream
**/ **/
int fgetc(FILE * _File){ int
fgetc (
FILE *_File
)
{
return EOF; return EOF;
} }
/** /**
Open stream file, we don't support file operastion on edk2 JSON library. Open stream file, we don't support file operastion on edk2 JSON library.
@return 0 Unsupported @return 0 Unsupported
**/ **/
FILE *fopen (const char *filename, const char *mode) { FILE *
fopen (
const char *filename,
const char *mode
)
{
return NULL; return NULL;
} }
/** /**
Read stream from file, we don't support file operastion on edk2 JSON library. Read stream from file, we don't support file operastion on edk2 JSON library.
@return 0 Unsupported @return 0 Unsupported
**/ **/
size_t fread (void * ptr, size_t size, size_t count, FILE * stream) { size_t
fread (
void *ptr,
size_t size,
size_t count,
FILE *stream
)
{
return 0; return 0;
} }
/** /**
Write stream from file, we don't support file operastion on edk2 JSON library. Write stream from file, we don't support file operastion on edk2 JSON library.
@return 0 Unsupported @return 0 Unsupported
**/ **/
size_t fwrite (const void * ptr, size_t size, size_t count, FILE * stream) { size_t
fwrite (
const void *ptr,
size_t size,
size_t count,
FILE *stream
)
{
return 0; return 0;
} }
/** /**
Close file, we don't support file operastion on edk2 JSON library. Close file, we don't support file operastion on edk2 JSON library.
@return 0 Unsupported @return 0 Unsupported
**/ **/
int fclose (FILE * stream) { int
fclose (
FILE *stream
)
{
return EOF; return EOF;
} }
/** /**
Write the formatted string to file, we don't support file operastion on edk2 JSON library. Write the formatted string to file, we don't support file operastion on edk2 JSON library.
@return 0 Unsupported @return 0 Unsupported
**/ **/
int fprintf (FILE * stream, const char * format, ...) { int
fprintf (
FILE *stream,
const char *format,
...
)
{
return -1; return -1;
} }
/** /**
This function check if this is the formating string specifier. This function check if this is the formating string specifier.
@ -749,14 +894,17 @@ CheckFormatingString (
(FormatStringParamater != '*') && (FormatStringParamater != '*') &&
(FormatStringParamater != '.') && (FormatStringParamater != '.') &&
!(((UINTN)FormatStringParamater >= (UINTN)'0') && ((UINTN)FormatStringParamater <= (UINTN)'9')) !(((UINTN)FormatStringParamater >= (UINTN)'0') && ((UINTN)FormatStringParamater <= (UINTN)'9'))
) { )
{
return FALSE; return FALSE;
} }
(*CurrentPosition)++; (*CurrentPosition)++;
if (*CurrentPosition >= StrLength) { if (*CurrentPosition >= StrLength) {
return FALSE; return FALSE;
} }
}; }
return TRUE; return TRUE;
} }
@ -773,7 +921,7 @@ CheckFormatingString (
CHAR8 * CHAR8 *
ReplaceUnicodeToAsciiStrFormat ( ReplaceUnicodeToAsciiStrFormat (
IN CONST CHAR8 *FormatString IN CONST CHAR8 *FormatString
) )
{ {
UINTN FormatStrSize; UINTN FormatStrSize;
UINTN FormatStrIndex; UINTN FormatStrIndex;
@ -788,15 +936,18 @@ ReplaceUnicodeToAsciiStrFormat (
if (FormatString == NULL) { if (FormatString == NULL) {
return NULL; return NULL;
} }
FormatStrSize = AsciiStrSize(FormatString);
FormatStrSize = AsciiStrSize (FormatString);
if (FormatStrSize == 0) { if (FormatStrSize == 0) {
return NULL; return NULL;
} }
TempFormatBuffer = AllocatePool(FormatStrSize); // Allocate memory for the
TempFormatBuffer = AllocatePool (FormatStrSize); // Allocate memory for the
// new string. // new string.
if (TempFormatBuffer== NULL) { if (TempFormatBuffer == NULL) {
return NULL; return NULL;
} }
// //
// Clone *FormatString but replace "%s" wih "%a". // Clone *FormatString but replace "%s" wih "%a".
// "%%" is not considered as the format tag. // "%%" is not considered as the format tag.
@ -809,18 +960,21 @@ ReplaceUnicodeToAsciiStrFormat (
// Previous character is "%". // Previous character is "%".
// //
PercentageMark = FALSE; PercentageMark = FALSE;
if (*(FormatString + FormatStrIndex) != '%') { // Check if this is double "%". if (*(FormatString + FormatStrIndex) != '%') {
// Check if this is double "%".
FormatStrSpecifier = FormatStrIndex; FormatStrSpecifier = FormatStrIndex;
// //
// Check if this is the formating string specifier. // Check if this is the formating string specifier.
// //
IsFormatString = CheckFormatingString (FormatString, &FormatStrSpecifier, FormatStrSize); IsFormatString = CheckFormatingString (FormatString, &FormatStrSpecifier, FormatStrSize);
if ((FormatStrSpecifier - FormatStrIndex) != 0) { if ((FormatStrSpecifier - FormatStrIndex) != 0) {
CopyMem((VOID *)(TempFormatBuffer + FormatStrIndex), CopyMem (
(VOID *)(TempFormatBuffer + FormatStrIndex),
(VOID *)(FormatString + FormatStrIndex), (VOID *)(FormatString + FormatStrIndex),
FormatStrSpecifier - FormatStrIndex FormatStrSpecifier - FormatStrIndex
); );
} }
FormatStrIndex = FormatStrSpecifier; FormatStrIndex = FormatStrSpecifier;
if (IsFormatString == TRUE) { if (IsFormatString == TRUE) {
// //
@ -828,18 +982,22 @@ ReplaceUnicodeToAsciiStrFormat (
// format on edk2 environment. // format on edk2 environment.
// //
*(TempFormatBuffer + FormatStrSpecifier) = 'a'; *(TempFormatBuffer + FormatStrSpecifier) = 'a';
FormatStrIndex ++; FormatStrIndex++;
} }
continue; continue;
} }
goto ContinueCheck; goto ContinueCheck;
} }
if (*(FormatString + FormatStrIndex) == '%') { if (*(FormatString + FormatStrIndex) == '%') {
// //
// This character is "%", set the flag. // This character is "%", set the flag.
// //
PercentageMark = TRUE; PercentageMark = TRUE;
} }
ContinueCheck: ContinueCheck:
// //
// Clone character to the new string and advance FormatStrIndex // Clone character to the new string and advance FormatStrIndex
@ -847,7 +1005,8 @@ ContinueCheck:
// //
*(TempFormatBuffer + FormatStrIndex) = *(FormatString + FormatStrIndex); *(TempFormatBuffer + FormatStrIndex) = *(FormatString + FormatStrIndex);
FormatStrIndex++; FormatStrIndex++;
}; }
return TempFormatBuffer; return TempFormatBuffer;
} }
@ -888,6 +1047,7 @@ RedfishAsciiVSPrint (
if (TempFormatBuffer == NULL) { if (TempFormatBuffer == NULL) {
return 0; return 0;
} }
LenStrProduced = AsciiVSPrint (StartOfBuffer, BufferSize, (CONST CHAR8 *)TempFormatBuffer, Marker); LenStrProduced = AsciiVSPrint (StartOfBuffer, BufferSize, (CONST CHAR8 *)TempFormatBuffer, Marker);
FreePool (TempFormatBuffer); FreePool (TempFormatBuffer);
return LenStrProduced; return LenStrProduced;
@ -922,8 +1082,7 @@ RedfishAsciiSPrint (
VA_LIST Marker; VA_LIST Marker;
UINTN LenStrProduced; UINTN LenStrProduced;
VA_START(Marker, FormatString); VA_START (Marker, FormatString);
LenStrProduced = RedfishAsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker); LenStrProduced = RedfishAsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
return LenStrProduced; return LenStrProduced;
} }

View File

@ -69,7 +69,8 @@ ON_EXIT:
if (UserId != NULL) { if (UserId != NULL) {
FreePool (UserId); FreePool (UserId);
} }
if (Password!= NULL) {
if (Password != NULL) {
FreePool (Password); FreePool (Password);
} }
@ -94,6 +95,7 @@ RedfishCleanupService (
cleanupServiceEnumerator (RedfishService); cleanupServiceEnumerator (RedfishService);
} }
/** /**
Create REDFISH_PAYLOAD instance in local with JSON represented resource value and Create REDFISH_PAYLOAD instance in local with JSON represented resource value and
the Redfish Service. the Redfish Service.
@ -138,7 +140,7 @@ RedfishCleanupPayload (
return; return;
} }
cleanupPayload ((redfishPayload *) Payload); cleanupPayload ((redfishPayload *)Payload);
} }
/** /**
@ -162,7 +164,7 @@ RedfishJsonInPayload (
return NULL; return NULL;
} }
return ((redfishPayload*)Payload)->json; return ((redfishPayload *)Payload)->json;
} }
/** /**
@ -193,7 +195,7 @@ RedfishBuildPathWithSystemUuid (
) )
{ {
UINTN BufSize; UINTN BufSize;
CHAR8* RetRedPath; CHAR8 *RetRedPath;
EFI_GUID SystemUuid; EFI_GUID SystemUuid;
EFI_STATUS Status; EFI_STATUS Status;
@ -205,10 +207,11 @@ RedfishBuildPathWithSystemUuid (
// Find system UUID from SMBIOS table. // Find system UUID from SMBIOS table.
// //
if (FromSmbios) { if (FromSmbios) {
Status = NetLibGetSystemGuid(&SystemUuid); Status = NetLibGetSystemGuid (&SystemUuid);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return NULL; return NULL;
} }
// AsciiStrLen ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") = 36 // AsciiStrLen ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") = 36
BufSize = AsciiStrSize (RedPath) + AsciiStrLen ("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); BufSize = AsciiStrSize (RedPath) + AsciiStrLen ("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
} else { } else {
@ -219,13 +222,16 @@ RedfishBuildPathWithSystemUuid (
if (RetRedPath == NULL) { if (RetRedPath == NULL) {
return NULL; return NULL;
} }
if (FromSmbios) { if (FromSmbios) {
AsciiSPrint (RetRedPath, BufSize, RedPath, &SystemUuid); AsciiSPrint (RetRedPath, BufSize, RedPath, &SystemUuid);
} else { } else {
AsciiSPrint (RetRedPath, BufSize, RedPath, IdString); AsciiSPrint (RetRedPath, BufSize, RedPath, IdString);
} }
return RetRedPath; return RetRedPath;
} }
/** /**
Get a redfish response addressed by a RedPath string, including HTTP StatusCode, Headers Get a redfish response addressed by a RedPath string, including HTTP StatusCode, Headers
and Payload which record any HTTP response messages. and Payload which record any HTTP response messages.
@ -257,19 +263,19 @@ RedfishGetByService (
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
) )
{ {
if (RedfishService == NULL || RedPath == NULL || RedResponse == NULL) { if ((RedfishService == NULL) || (RedPath == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
RedResponse->Payload = (REDFISH_PAYLOAD) getPayloadByPath (RedfishService, RedPath, &(RedResponse->StatusCode)); RedResponse->Payload = (REDFISH_PAYLOAD)getPayloadByPath (RedfishService, RedPath, &(RedResponse->StatusCode));
// //
// 1. If the returned Payload is NULL, indicates any error happen. // 1. If the returned Payload is NULL, indicates any error happen.
// 2. If the returned StatusCode is NULL, indicates any error happen. // 2. If the returned StatusCode is NULL, indicates any error happen.
// //
if (RedResponse->Payload == NULL || RedResponse->StatusCode == NULL) { if ((RedResponse->Payload == NULL) || (RedResponse->StatusCode == NULL)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -278,13 +284,15 @@ RedfishGetByService (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Get a redfish response addressed by URI, including HTTP StatusCode, Headers Get a redfish response addressed by URI, including HTTP StatusCode, Headers
and Payload which record any HTTP response messages. and Payload which record any HTTP response messages.
@ -317,20 +325,20 @@ RedfishGetByUri (
{ {
EDKII_JSON_VALUE JsonValue; EDKII_JSON_VALUE JsonValue;
if (RedfishService == NULL || Uri == NULL || RedResponse == NULL) { if ((RedfishService == NULL) || (Uri == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
JsonValue = getUriFromService (RedfishService, Uri, &RedResponse->StatusCode); JsonValue = getUriFromService (RedfishService, Uri, &RedResponse->StatusCode);
RedResponse->Payload = createRedfishPayload(JsonValue, RedfishService); RedResponse->Payload = createRedfishPayload (JsonValue, RedfishService);
// //
// 1. If the returned Payload is NULL, indicates any error happen. // 1. If the returned Payload is NULL, indicates any error happen.
// 2. If the returned StatusCode is NULL, indicates any error happen. // 2. If the returned StatusCode is NULL, indicates any error happen.
// //
if (RedResponse->Payload == NULL || RedResponse->StatusCode == NULL) { if ((RedResponse->Payload == NULL) || (RedResponse->StatusCode == NULL)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -339,12 +347,15 @@ RedfishGetByUri (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Get a redfish response addressed by the input Payload and relative RedPath string, Get a redfish response addressed by the input Payload and relative RedPath string,
including HTTP StatusCode, Headers and Payload which record any HTTP response messages. including HTTP StatusCode, Headers and Payload which record any HTTP response messages.
@ -379,13 +390,13 @@ RedfishGetByPayload (
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
) )
{ {
if (Payload == NULL || RedPath == NULL || RedResponse == NULL) { if ((Payload == NULL) || (RedPath == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
RedResponse->Payload = (REDFISH_PAYLOAD) getPayloadForPathString (Payload, RedPath, &(RedResponse->StatusCode)); RedResponse->Payload = (REDFISH_PAYLOAD)getPayloadForPathString (Payload, RedPath, &(RedResponse->StatusCode));
// //
// 1. If the returned Payload is NULL, indicates any error happen. // 1. If the returned Payload is NULL, indicates any error happen.
@ -400,15 +411,17 @@ RedfishGetByPayload (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (RedResponse->StatusCode != NULL && \ if ((RedResponse->StatusCode != NULL) && \
(*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)
)) { ))
{
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Use HTTP PATCH to perform updates on pre-existing Redfish resource. Use HTTP PATCH to perform updates on pre-existing Redfish resource.
@ -454,13 +467,13 @@ RedfishPatchToUri (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
JsonValue = NULL; JsonValue = NULL;
if (RedfishService == NULL || Uri == NULL || Content == NULL || RedResponse == NULL) { if ((RedfishService == NULL) || (Uri == NULL) || (Content == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
JsonValue = (EDKII_JSON_VALUE) patchUriFromService ( JsonValue = (EDKII_JSON_VALUE)patchUriFromService (
RedfishService, RedfishService,
Uri, Uri,
Content, Content,
@ -480,8 +493,9 @@ RedfishPatchToUri (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
@ -499,6 +513,7 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Use HTTP PATCH to perform updates on target payload. Patch to odata.id in Payload directly. Use HTTP PATCH to perform updates on target payload. Patch to odata.id in Payload directly.
@ -535,13 +550,13 @@ RedfishPatchToPayload (
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
) )
{ {
if (Target == NULL || Payload == NULL || RedResponse == NULL) { if ((Target == NULL) || (Payload == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
RedResponse->Payload = (REDFISH_PAYLOAD) patchPayload ( RedResponse->Payload = (REDFISH_PAYLOAD)patchPayload (
Target, Target,
Payload, Payload,
&(RedResponse->StatusCode) &(RedResponse->StatusCode)
@ -559,13 +574,15 @@ RedfishPatchToPayload (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Use HTTP POST to create a new resource in target payload. Use HTTP POST to create a new resource in target payload.
@ -601,13 +618,13 @@ RedfishPostToPayload (
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
) )
{ {
if (Target == NULL || Payload == NULL || RedResponse == NULL) { if ((Target == NULL) || (Payload == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
RedResponse->Payload = (REDFISH_PAYLOAD) postPayload ( RedResponse->Payload = (REDFISH_PAYLOAD)postPayload (
Target, Target,
Payload, Payload,
&(RedResponse->StatusCode) &(RedResponse->StatusCode)
@ -625,13 +642,15 @@ RedfishPostToPayload (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Use HTTP DELETE to remove a resource. Use HTTP DELETE to remove a resource.
@ -673,13 +692,13 @@ RedfishDeleteByUri (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
JsonValue = NULL; JsonValue = NULL;
if (RedfishService == NULL || Uri == NULL || RedResponse == NULL) { if ((RedfishService == NULL) || (Uri == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
JsonValue = (EDKII_JSON_VALUE) deleteUriFromService ( JsonValue = (EDKII_JSON_VALUE)deleteUriFromService (
RedfishService, RedfishService,
Uri, Uri,
&(RedResponse->StatusCode) &(RedResponse->StatusCode)
@ -698,8 +717,9 @@ RedfishDeleteByUri (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
@ -717,6 +737,7 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Dump text in fractions. Dump text in fractions.
@ -736,26 +757,29 @@ RedfishDumpJsonStringFractions (
StringFractionSize = 200; StringFractionSize = 200;
if (String == NULL) { if (String == NULL) {
return ; return;
} }
DEBUG((DEBUG_INFO, "JSON text:\n")); DEBUG ((DEBUG_INFO, "JSON text:\n"));
NextFraction = String; NextFraction = String;
StrLen = AsciiStrLen (String); StrLen = AsciiStrLen (String);
if (StrLen == 0) { if (StrLen == 0) {
return; return;
} }
for (Count = 0; Count < (StrLen / StringFractionSize); Count++) { for (Count = 0; Count < (StrLen / StringFractionSize); Count++) {
BackupChar = *(NextFraction + StringFractionSize); BackupChar = *(NextFraction + StringFractionSize);
*(NextFraction + StringFractionSize) = 0; *(NextFraction + StringFractionSize) = 0;
DEBUG((DEBUG_INFO, "%a", NextFraction)); DEBUG ((DEBUG_INFO, "%a", NextFraction));
*(NextFraction + StringFractionSize) = BackupChar; *(NextFraction + StringFractionSize) = BackupChar;
NextFraction += StringFractionSize; NextFraction += StringFractionSize;
} }
if ((StrLen % StringFractionSize) != 0) { if ((StrLen % StringFractionSize) != 0) {
DEBUG((DEBUG_INFO, "%a\n\n", NextFraction)); DEBUG ((DEBUG_INFO, "%a\n\n", NextFraction));
} }
} }
/** /**
Dump text in JSON value. Dump text in JSON value.
@ -773,9 +797,11 @@ RedfishDumpJson (
if (String == NULL) { if (String == NULL) {
return; return;
} }
RedfishDumpJsonStringFractions (String); RedfishDumpJsonStringFractions (String);
FreePool(String); FreePool (String);
} }
/** /**
Extract the JSON text content from REDFISH_PAYLOAD and dump to debug console. Extract the JSON text content from REDFISH_PAYLOAD and dump to debug console.
@ -808,8 +834,9 @@ RedfishDumpPayload (
} }
RedfishDumpJsonStringFractions (String); RedfishDumpJsonStringFractions (String);
FreePool(String); FreePool (String);
} }
/** /**
This function will cleanup the HTTP header and Redfish payload resources. This function will cleanup the HTTP header and Redfish payload resources.
@ -832,8 +859,8 @@ RedfishFreeResponse (
StatusCode = NULL; StatusCode = NULL;
} }
if (HeaderCount != 0 && Headers != NULL) { if ((HeaderCount != 0) && (Headers != NULL)) {
HttpFreeHeaderFields(Headers, HeaderCount); HttpFreeHeaderFields (Headers, HeaderCount);
Headers = NULL; Headers = NULL;
} }
@ -842,6 +869,7 @@ RedfishFreeResponse (
Payload = NULL; Payload = NULL;
} }
} }
/** /**
Check if the "@odata.type" in Payload is valid or not. Check if the "@odata.type" in Payload is valid or not.
@ -865,7 +893,7 @@ RedfishIsValidOdataType (
EDKII_JSON_VALUE OdataType; EDKII_JSON_VALUE OdataType;
EDKII_JSON_VALUE JsonValue; EDKII_JSON_VALUE JsonValue;
if (Payload == NULL || OdataTypeName == NULL) { if ((Payload == NULL) || (OdataTypeName == NULL)) {
return FALSE; return FALSE;
} }
@ -875,19 +903,22 @@ RedfishIsValidOdataType (
} }
OdataType = JsonObjectGetValue (JsonValueGetObject (JsonValue), "@odata.type"); OdataType = JsonObjectGetValue (JsonValueGetObject (JsonValue), "@odata.type");
if (!JsonValueIsString (OdataType) || JsonValueGetAsciiString (OdataType) == NULL) { if (!JsonValueIsString (OdataType) || (JsonValueGetAsciiString (OdataType) == NULL)) {
return FALSE; return FALSE;
} }
for (Index = 0; Index < OdataTypeMappingListSize; Index ++) { for (Index = 0; Index < OdataTypeMappingListSize; Index++) {
if (AsciiStrCmp (OdataTypeMappingList[Index].OdataTypeName, OdataTypeName) == 0 && if ((AsciiStrCmp (OdataTypeMappingList[Index].OdataTypeName, OdataTypeName) == 0) &&
AsciiStrCmp (OdataTypeMappingList[Index].OdataType, JsonValueGetAsciiString (OdataType)) == 0) { (AsciiStrCmp (OdataTypeMappingList[Index].OdataType, JsonValueGetAsciiString (OdataType)) == 0))
{
return TRUE; return TRUE;
} }
} }
DEBUG ((DEBUG_INFO, "%a: This Odata type is not in the list.\n", __FUNCTION__)); DEBUG ((DEBUG_INFO, "%a: This Odata type is not in the list.\n", __FUNCTION__));
return FALSE; return FALSE;
} }
/** /**
Check if the payload is collection Check if the payload is collection
@ -899,10 +930,11 @@ RedfishIsValidOdataType (
BOOLEAN BOOLEAN
RedfishIsPayloadCollection ( RedfishIsPayloadCollection (
IN REDFISH_PAYLOAD Payload IN REDFISH_PAYLOAD Payload
) )
{ {
return isPayloadCollection (Payload); return isPayloadCollection (Payload);
} }
/** /**
Get collection size. Get collection size.
@ -913,21 +945,23 @@ RedfishIsPayloadCollection (
@return EFI_INVALID_PARAMETER The payload is not a collection. @return EFI_INVALID_PARAMETER The payload is not a collection.
**/ **/
EFI_STATUS EFI_STATUS
RedfishGetCollectionSize( RedfishGetCollectionSize (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN UINTN *CollectionSize IN UINTN *CollectionSize
) )
{ {
if (Payload == NULL || CollectionSize == NULL) { if ((Payload == NULL) || (CollectionSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (!RedfishIsPayloadCollection(Payload)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
*CollectionSize = (UINTN)getCollectionSize(Payload); if (!RedfishIsPayloadCollection (Payload)) {
return EFI_INVALID_PARAMETER;
}
*CollectionSize = (UINTN)getCollectionSize (Payload);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Get Redfish payload of collection member Get Redfish payload of collection member
@ -941,18 +975,21 @@ REDFISH_PAYLOAD
RedfishGetPayloadByIndex ( RedfishGetPayloadByIndex (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN UINTN Index IN UINTN Index
) )
{ {
REDFISH_RESPONSE RedfishResponse; REDFISH_RESPONSE RedfishResponse;
REDFISH_PAYLOAD PayloadReturn; REDFISH_PAYLOAD PayloadReturn;
PayloadReturn = (VOID *)getPayloadByIndex (Payload, Index, &RedfishResponse.StatusCode); PayloadReturn = (VOID *)getPayloadByIndex (Payload, Index, &RedfishResponse.StatusCode);
if(PayloadReturn == NULL || if ((PayloadReturn == NULL) ||
(*(RedfishResponse.StatusCode) < HTTP_STATUS_200_OK && *(RedfishResponse.StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)){ ((*(RedfishResponse.StatusCode) < HTTP_STATUS_200_OK) && (*(RedfishResponse.StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)))
{
return NULL; return NULL;
} }
return PayloadReturn; return PayloadReturn;
} }
/** /**
Check and return Redfish resource of the given Redpath. Check and return Redfish resource of the given Redpath.
@ -975,12 +1012,14 @@ RedfishCheckIfRedpathExist (
if (Redpath == NULL) { if (Redpath == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Status = RedfishGetByService (RedfishService, Redpath, &TempResponse); Status = RedfishGetByService (RedfishService, Redpath, &TempResponse);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
if (Response == NULL) { if (Response == NULL) {
RedfishFreeResponse( RedfishFreeResponse (
TempResponse.StatusCode, TempResponse.StatusCode,
TempResponse.HeaderCount, TempResponse.HeaderCount,
TempResponse.Headers, TempResponse.Headers,
@ -989,5 +1028,6 @@ RedfishCheckIfRedpathExist (
} else { } else {
CopyMem ((VOID *)Response, (VOID *)&TempResponse, sizeof (REDFISH_RESPONSE)); CopyMem ((VOID *)Response, (VOID *)&TempResponse, sizeof (REDFISH_RESPONSE));
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -31,17 +31,20 @@ RedfishGetServiceVersion (
CHAR8 **KeysArray; CHAR8 **KeysArray;
UINTN KeysNum; UINTN KeysNum;
if (RedfishService == NULL || ServiceVersionStr == NULL) { if ((RedfishService == NULL) || (ServiceVersionStr == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Redfish = (redfishService *)RedfishService; Redfish = (redfishService *)RedfishService;
if (Redfish->versions == NULL) { if (Redfish->versions == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
KeysArray = JsonObjectGetKeys (Redfish->versions, &KeysNum); KeysArray = JsonObjectGetKeys (Redfish->versions, &KeysNum);
if (KeysNum == 0 || KeysArray == NULL) { if ((KeysNum == 0) || (KeysArray == NULL)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
*ServiceVersionStr = *KeysArray; *ServiceVersionStr = *KeysArray;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -71,10 +74,9 @@ RedfishCreateLibredfishService (
IN CHAR8 *Password IN CHAR8 *Password
) )
{ {
UINTN Flags; UINTN Flags;
enumeratorAuthentication Auth; enumeratorAuthentication Auth;
redfishService* Redfish; redfishService *Redfish;
Redfish = NULL; Redfish = NULL;
@ -84,25 +86,26 @@ RedfishCreateLibredfishService (
} else if (AuthMethod == AuthMethodRedfishSession) { } else if (AuthMethod == AuthMethodRedfishSession) {
Auth.authType = REDFISH_AUTH_SESSION; Auth.authType = REDFISH_AUTH_SESSION;
} }
Auth.authCodes.userPass.username = UserId; Auth.authCodes.userPass.username = UserId;
Auth.authCodes.userPass.password = Password; Auth.authCodes.userPass.password = Password;
Flags = REDFISH_FLAG_SERVICE_NO_VERSION_DOC; Flags = REDFISH_FLAG_SERVICE_NO_VERSION_DOC;
if (AuthMethod != AuthMethodNone) { if (AuthMethod != AuthMethodNone) {
Redfish = createServiceEnumerator(RedfishConfigServiceInfo, NULL, &Auth, (unsigned int ) Flags); Redfish = createServiceEnumerator (RedfishConfigServiceInfo, NULL, &Auth, (unsigned int)Flags);
} else { } else {
Redfish = createServiceEnumerator(RedfishConfigServiceInfo, NULL, NULL, (unsigned int) Flags); Redfish = createServiceEnumerator (RedfishConfigServiceInfo, NULL, NULL, (unsigned int)Flags);
} }
// //
// Zero the Password after use. // Zero the Password after use.
// //
if (Password != NULL) { if (Password != NULL) {
ZeroMem (Password, AsciiStrLen(Password)); ZeroMem (Password, AsciiStrLen (Password));
} }
return (REDFISH_SERVICE) Redfish; return (REDFISH_SERVICE)Redfish;
} }
/** /**
@ -137,7 +140,7 @@ RedfishGetAuthInfo (
{ {
EFI_STATUS Status; EFI_STATUS Status;
if (AuthMethod == NULL || UserId == NULL || Password == NULL) { if ((AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -161,6 +164,7 @@ RedfishGetAuthInfo (
return Status; return Status;
} }
/** /**
This function returns the string of Redfish service version. This function returns the string of Redfish service version.
@ -183,7 +187,7 @@ RedfishBuildRedpathUseId (
{ {
UINTN RedpathSize; UINTN RedpathSize;
if (Redpath == NULL || ServiceVerisonStr == NULL || Url == NULL || Id == NULL) { if ((Redpath == NULL) || (ServiceVerisonStr == NULL) || (Url == NULL) || (Id == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -192,10 +196,11 @@ RedfishBuildRedpathUseId (
AsciiStrLen (Url) + AsciiStrLen (Url) +
AsciiStrLen ("[Id=]") + AsciiStrLen ("[Id=]") +
AsciiStrLen (Id) + 1; AsciiStrLen (Id) + 1;
*Redpath = AllocatePool(RedpathSize); *Redpath = AllocatePool (RedpathSize);
if (*Redpath == NULL) { if (*Redpath == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=%a]", ServiceVerisonStr, Url, Id); AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=%a]", ServiceVerisonStr, Url, Id);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -14,6 +14,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef LIBREDFISH_REDFISH_H_ #ifndef LIBREDFISH_REDFISH_H_
#define LIBREDFISH_REDFISH_H_ #define LIBREDFISH_REDFISH_H_

View File

@ -14,6 +14,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef LIBREDFISH_REDFISH_PAYLOAD_H_ #ifndef LIBREDFISH_REDFISH_PAYLOAD_H_
#define LIBREDFISH_REDFISH_PAYLOAD_H_ #define LIBREDFISH_REDFISH_PAYLOAD_H_
@ -23,17 +24,83 @@
#include <redfishService.h> #include <redfishService.h>
#include <redpath.h> #include <redpath.h>
redfishPayload* createRedfishPayload(json_t* value, redfishService* service); redfishPayload *
redfishPayload* getPayloadByNodeName(redfishPayload* payload, const char* nodeName, EFI_HTTP_STATUS_CODE** StatusCode); createRedfishPayload (
redfishPayload* getPayloadByIndex(redfishPayload* payload, size_t index, EFI_HTTP_STATUS_CODE** StatusCode); json_t *value,
redfishPayload* getPayloadForPath(redfishPayload* payload, redPathNode* redpath, EFI_HTTP_STATUS_CODE** StatusCode); redfishService *service
redfishPayload* getPayloadForPathString(redfishPayload* payload, const char* string, EFI_HTTP_STATUS_CODE** StatusCode); );
redfishPayload* patchPayload(redfishPayload* target, redfishPayload* payload, EFI_HTTP_STATUS_CODE** StatusCode);
redfishPayload* postContentToPayload(redfishPayload* target, const char* data, size_t dataSize, const char* contentType, EFI_HTTP_STATUS_CODE** StatusCode); redfishPayload *
redfishPayload* postPayload(redfishPayload* target, redfishPayload* payload, EFI_HTTP_STATUS_CODE** StatusCode); getPayloadByNodeName (
void cleanupPayload(redfishPayload* payload); redfishPayload *payload,
bool isPayloadCollection (redfishPayload *Payload); const char *nodeName,
size_t getCollectionSize(redfishPayload* payload); EFI_HTTP_STATUS_CODE **StatusCode
redfishPayload* getPayloadByIndex (redfishPayload* payload, size_t index, EFI_HTTP_STATUS_CODE** StatusCode); );
redfishPayload *
getPayloadByIndex (
redfishPayload *payload,
size_t index,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
getPayloadForPath (
redfishPayload *payload,
redPathNode *redpath,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
getPayloadForPathString (
redfishPayload *payload,
const char *string,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
patchPayload (
redfishPayload *target,
redfishPayload *payload,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
postContentToPayload (
redfishPayload *target,
const char *data,
size_t dataSize,
const char *contentType,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
postPayload (
redfishPayload *target,
redfishPayload *payload,
EFI_HTTP_STATUS_CODE **StatusCode
);
void
cleanupPayload (
redfishPayload *payload
);
bool
isPayloadCollection (
redfishPayload *Payload
);
size_t
getCollectionSize (
redfishPayload *payload
);
redfishPayload *
getPayloadByIndex (
redfishPayload *payload,
size_t index,
EFI_HTTP_STATUS_CODE **StatusCode
);
#endif #endif

View File

@ -38,22 +38,22 @@
#include <jansson.h> #include <jansson.h>
typedef struct { typedef struct {
char* host; char *host;
json_t* versions; json_t *versions;
unsigned int flags; unsigned int flags;
char* sessionToken; char *sessionToken;
char* basicAuthStr; char *basicAuthStr;
// //
// point to the <HOST> part in above "host" field, which will be put into // point to the <HOST> part in above "host" field, which will be put into
// the "Host" header of HTTP request message. // the "Host" header of HTTP request message.
// //
char* HostHeaderValue; char *HostHeaderValue;
EFI_REST_EX_PROTOCOL *RestEx; EFI_REST_EX_PROTOCOL *RestEx;
} redfishService; } redfishService;
typedef struct { typedef struct {
json_t* json; json_t *json;
redfishService* service; redfishService *service;
} redfishPayload; } redfishPayload;
#define REDFISH_AUTH_BASIC 0 #define REDFISH_AUTH_BASIC 0
@ -78,24 +78,74 @@ typedef struct {
unsigned int authType; unsigned int authType;
union { union {
struct { struct {
char* username; char *username;
char* password; char *password;
} userPass; } userPass;
struct { struct {
char* token; char *token;
} authToken; } authToken;
} authCodes; } authCodes;
} enumeratorAuthentication; } enumeratorAuthentication;
//Values for flags // Values for flags
#define REDFISH_FLAG_SERVICE_NO_VERSION_DOC 0x00000001 //The Redfish Service lacks the version document (in violation of the Redfish spec) #define REDFISH_FLAG_SERVICE_NO_VERSION_DOC 0x00000001// The Redfish Service lacks the version document (in violation of the Redfish spec)
redfishService* createServiceEnumerator(REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo, const char* rootUri, enumeratorAuthentication* auth, unsigned int flags); redfishService *
json_t* getUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode); createServiceEnumerator (
json_t* patchUriFromService(redfishService* service, const char* uri, const char* content, EFI_HTTP_STATUS_CODE** StatusCode); REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo,
json_t* postUriFromService(redfishService* service, const char* uri, const char* content, size_t contentLength, const char* contentType, EFI_HTTP_STATUS_CODE** StatusCode); const char *rootUri,
json_t* deleteUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode); enumeratorAuthentication *auth,
redfishPayload* getRedfishServiceRoot(redfishService* service, const char* version, EFI_HTTP_STATUS_CODE** StatusCode); unsigned int flags
redfishPayload* getPayloadByPath(redfishService* service, const char* path, EFI_HTTP_STATUS_CODE** StatusCode); );
void cleanupServiceEnumerator(redfishService* service);
json_t *
getUriFromService (
redfishService *service,
const char *uri,
EFI_HTTP_STATUS_CODE **StatusCode
);
json_t *
patchUriFromService (
redfishService *service,
const char *uri,
const char *content,
EFI_HTTP_STATUS_CODE **StatusCode
);
json_t *
postUriFromService (
redfishService *service,
const char *uri,
const char *content,
size_t contentLength,
const char *contentType,
EFI_HTTP_STATUS_CODE **StatusCode
);
json_t *
deleteUriFromService (
redfishService *service,
const char *uri,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
getRedfishServiceRoot (
redfishService *service,
const char *version,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
getPayloadByPath (
redfishService *service,
const char *path,
EFI_HTTP_STATUS_CODE **StatusCode
);
void
cleanupServiceEnumerator (
redfishService *service
);
#endif #endif

View File

@ -14,6 +14,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef LIBREDFISH_REDPATH_H_ #ifndef LIBREDFISH_REDPATH_H_
#define LIBREDFISH_REDPATH_H_ #define LIBREDFISH_REDPATH_H_
@ -21,22 +22,28 @@
#include <jansson.h> #include <jansson.h>
typedef struct _redPathNode typedef struct _redPathNode {
{
bool isRoot; bool isRoot;
bool isIndex; bool isIndex;
char* version; char *version;
char* nodeName; char *nodeName;
size_t index; size_t index;
char* op; char *op;
char* propName; char *propName;
char* value; char *value;
struct _redPathNode* next; struct _redPathNode *next;
} redPathNode; } redPathNode;
redPathNode* parseRedPath(const char* path); redPathNode *
void cleanupRedPath(redPathNode* node); parseRedPath (
const char *path
);
void
cleanupRedPath (
redPathNode *node
);
#endif #endif

View File

@ -16,177 +16,209 @@
**/ **/
#include <redpath.h> #include <redpath.h>
static char* getVersion(const char* path, char** end); static char *
static void parseNode(const char* path, redPathNode* node, redPathNode** end); getVersion (
const char *path,
char **end
);
static char* getStringTill(const char* string, const char* terminator, char** retEnd); static void
parseNode (
const char *path,
redPathNode *node,
redPathNode **end
);
redPathNode* parseRedPath(const char* path) static char *
getStringTill (
const char *string,
const char *terminator,
char **retEnd
);
redPathNode *
parseRedPath (
const char *path
)
{ {
redPathNode* node; redPathNode *node;
redPathNode* endNode; redPathNode *endNode;
char* curPath; char *curPath;
char* end; char *end;
if(!path || strlen(path) == 0) if (!path || (strlen (path) == 0)) {
{
return NULL; return NULL;
} }
node = (redPathNode*)calloc(1, sizeof(redPathNode)); node = (redPathNode *)calloc (1, sizeof (redPathNode));
if(!node) if (!node) {
{
return NULL; return NULL;
} }
if(path[0] == '/')
{ if (path[0] == '/') {
node->isRoot = true; node->isRoot = true;
if(path[1] == 'v') if (path[1] == 'v') {
{ node->version = getVersion (path+1, &curPath);
node->version = getVersion(path+1, &curPath); if (curPath == NULL) {
if(curPath == NULL)
{
return node; return node;
} }
if(curPath[0] == '/')
{ if (curPath[0] == '/') {
curPath++; curPath++;
} }
node->next = parseRedPath(curPath);
} node->next = parseRedPath (curPath);
else } else {
{ node->next = parseRedPath (path+1);
node->next = parseRedPath(path+1);
} }
return node; return node;
} }
node->isRoot = false; node->isRoot = false;
curPath = getStringTill(path, "/", &end); curPath = getStringTill (path, "/", &end);
endNode = node; endNode = node;
parseNode(curPath, node, &endNode); parseNode (curPath, node, &endNode);
free(curPath); free (curPath);
if(end != NULL) if (end != NULL) {
{ endNode->next = parseRedPath (end+1);
endNode->next = parseRedPath(end+1);
} }
return node; return node;
} }
void cleanupRedPath(redPathNode* node) void
cleanupRedPath (
redPathNode *node
)
{ {
if(!node) if (!node) {
{
return; return;
} }
cleanupRedPath(node->next);
cleanupRedPath (node->next);
node->next = NULL; node->next = NULL;
if(node->version) if (node->version) {
{ free (node->version);
free(node->version);
} }
if(node->nodeName)
{ if (node->nodeName) {
free(node->nodeName); free (node->nodeName);
} }
if(node->op)
{ if (node->op) {
free(node->op); free (node->op);
} }
if(node->propName)
{ if (node->propName) {
free(node->propName); free (node->propName);
} }
if(node->value)
{ if (node->value) {
free(node->value); free (node->value);
} }
free(node);
free (node);
} }
static char* getVersion(const char* path, char** end) static char *
getVersion (
const char *path,
char **end
)
{ {
return getStringTill(path, "/", end); return getStringTill (path, "/", end);
} }
static void parseNode(const char* path, redPathNode* node, redPathNode** end) static void
parseNode (
const char *path,
redPathNode *node,
redPathNode **end
)
{ {
char* indexStart; char *indexStart;
char* index; char *index;
char* indexEnd; char *indexEnd;
char* nodeName = getStringTill(path, "[", &indexStart); char *nodeName = getStringTill (path, "[", &indexStart);
size_t tmpIndex; size_t tmpIndex;
char* opChars; char *opChars;
node->nodeName = nodeName; node->nodeName = nodeName;
if(indexStart == NULL) if (indexStart == NULL) {
{
*end = node; *end = node;
return; return;
} }
node->next = (redPathNode*)calloc(1, sizeof(redPathNode));
if(!node->next) node->next = (redPathNode *)calloc (1, sizeof (redPathNode));
{ if (!node->next) {
return; return;
} }
//Skip past [
// Skip past [
indexStart++; indexStart++;
*end = node->next; *end = node->next;
index = getStringTill(indexStart, "]", NULL); index = getStringTill (indexStart, "]", NULL);
tmpIndex = (size_t)strtoull(index, &indexEnd, 0); tmpIndex = (size_t)strtoull (index, &indexEnd, 0);
if(indexEnd != index) if (indexEnd != index) {
{ free (index);
free(index);
node->next->index = tmpIndex; node->next->index = tmpIndex;
node->next->isIndex = true; node->next->isIndex = true;
return; return;
} }
opChars = strpbrk(index, "<>=~");
if(opChars == NULL) opChars = strpbrk (index, "<>=~");
{ if (opChars == NULL) {
//TODO handle last() and position() // TODO handle last() and position()
node->next->op = strdup("exists"); node->next->op = strdup ("exists");
node->next->propName = index; node->next->propName = index;
return; return;
} }
node->next->propName = (char*)malloc((opChars - index)+1);
memcpy(node->next->propName, index, (opChars - index)); node->next->propName = (char *)malloc ((opChars - index)+1);
memcpy (node->next->propName, index, (opChars - index));
node->next->propName[(opChars - index)] = 0; node->next->propName[(opChars - index)] = 0;
tmpIndex = 1; tmpIndex = 1;
while(1) while (1) {
{ if ((opChars[tmpIndex] == '=') || (opChars[tmpIndex] == '<') || (opChars[tmpIndex] == '>') || (opChars[tmpIndex] == '~')) {
if(opChars[tmpIndex] == '=' || opChars[tmpIndex] == '<' || opChars[tmpIndex] == '>' || opChars[tmpIndex] == '~')
{
tmpIndex++; tmpIndex++;
continue; continue;
} }
break; break;
} }
node->next->op = (char*)malloc(tmpIndex+1); node->next->op = (char *)malloc (tmpIndex+1);
memcpy(node->next->op, opChars, tmpIndex); memcpy (node->next->op, opChars, tmpIndex);
node->next->op[tmpIndex] = 0; node->next->op[tmpIndex] = 0;
node->next->value = strdup(opChars+tmpIndex); node->next->value = strdup (opChars+tmpIndex);
free(index); free (index);
} }
static char* getStringTill(const char* string, const char* terminator, char** retEnd) static char *
getStringTill (
const char *string,
const char *terminator,
char **retEnd
)
{ {
char* ret; char *ret;
char* end; char *end;
end = strstr((char*)string, terminator);
if(retEnd) end = strstr ((char *)string, terminator);
{ if (retEnd) {
*retEnd = end; *retEnd = end;
} }
if(end == NULL)
{ if (end == NULL) {
//No terminator // No terminator
return strdup(string); return strdup (string);
} }
ret = (char*)malloc((end-string)+1);
memcpy(ret, string, (end-string)); ret = (char *)malloc ((end-string)+1);
memcpy (ret, string, (end-string));
ret[(end-string)] = 0; ret[(end-string)] = 0;
return ret; return ret;
} }

View File

@ -33,7 +33,7 @@ RedfishConfigOnEndOfDxe (
EFI_STATUS Status; EFI_STATUS Status;
Status = gCredential->StopService (gCredential, ServiceStopTypeSecureBootDisabled); Status = gCredential->StopService (gCredential, ServiceStopTypeSecureBootDisabled);
if (EFI_ERROR(Status) && Status != EFI_UNSUPPORTED) { if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on EndOfDxe: %r", Status)); DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on EndOfDxe: %r", Status));
} }
@ -61,7 +61,7 @@ RedfishConfigOnExitBootService (
EFI_STATUS Status; EFI_STATUS Status;
Status = gCredential->StopService (gCredential, ServiceStopTypeExitBootService); Status = gCredential->StopService (gCredential, ServiceStopTypeExitBootService);
if (EFI_ERROR(Status) && Status != EFI_UNSUPPORTED) { if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on ExitBootService: %r", Status)); DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on ExitBootService: %r", Status));
} }
} }
@ -114,15 +114,17 @@ RedfishConfigCommonInit (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
// //
// Locate Redfish Credential Protocol to get credential for // Locate Redfish Credential Protocol to get credential for
// accessing to Redfish service. // accessing to Redfish service.
// //
Status = gBS->LocateProtocol (&gEdkIIRedfishCredentialProtocolGuid, NULL, (VOID **) &gCredential); Status = gBS->LocateProtocol (&gEdkIIRedfishCredentialProtocolGuid, NULL, (VOID **)&gCredential);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "%a: No Redfish Credential Protocol is installed on system.", __FUNCTION__)); DEBUG ((DEBUG_INFO, "%a: No Redfish Credential Protocol is installed on system.", __FUNCTION__));
return Status; return Status;
} }
// //
// Create EndOfDxe Event. // Create EndOfDxe Event.
// //
@ -138,6 +140,7 @@ RedfishConfigCommonInit (
DEBUG ((DEBUG_ERROR, "%a: Fail to register End Of DXE event.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to register End Of DXE event.", __FUNCTION__));
return Status; return Status;
} }
// //
// Create Exit Boot Service event. // Create Exit Boot Service event.
// //
@ -155,8 +158,10 @@ RedfishConfigCommonInit (
DEBUG ((DEBUG_ERROR, "%a: Fail to register Exit Boot Service event.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to register Exit Boot Service event.", __FUNCTION__));
return Status; return Status;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
This is the common code to stop EDK2 Redfish feature driver. This is the common code to stop EDK2 Redfish feature driver.
@ -167,7 +172,7 @@ RedfishConfigCommonInit (
EFI_STATUS EFI_STATUS
RedfishConfigCommonStop ( RedfishConfigCommonStop (
VOID VOID
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_HANDLE *HandleBuffer; EFI_HANDLE *HandleBuffer;
@ -182,7 +187,7 @@ RedfishConfigCommonStop (
&NumberOfHandles, &NumberOfHandles,
&HandleBuffer &HandleBuffer
); );
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) { if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
return Status; return Status;
} }
@ -191,18 +196,20 @@ RedfishConfigCommonStop (
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer[Index], HandleBuffer[Index],
&gEdkIIRedfishConfigHandlerProtocolGuid, &gEdkIIRedfishConfigHandlerProtocolGuid,
(VOID**) &ConfigHandler (VOID **)&ConfigHandler
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = ConfigHandler->Stop (ConfigHandler); Status = ConfigHandler->Stop (ConfigHandler);
if (EFI_ERROR (Status) && Status != EFI_UNSUPPORTED) { if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
DEBUG ((DEBUG_ERROR, "ERROR: Failed to stop Redfish config handler %p.\n", ConfigHandler)); DEBUG ((DEBUG_ERROR, "ERROR: Failed to stop Redfish config handler %p.\n", ConfigHandler));
break; break;
} }
} }
return Status; return Status;
} }
/** /**
Callback function executed when a Redfish Config Handler Protocol is installed Callback function executed when a Redfish Config Handler Protocol is installed
by EDK2 Redfish Feature Drivers. by EDK2 Redfish Feature Drivers.
@ -233,29 +240,30 @@ RedfishConfigHandlerInitialization (
for (Index = 0; Index < NumberOfHandles; Index++) { for (Index = 0; Index < NumberOfHandles; Index++) {
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer [Index], HandleBuffer[Index],
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
(VOID **) &Id (VOID **)&Id
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
continue; continue;
} }
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer [Index], HandleBuffer[Index],
&gEdkIIRedfishConfigHandlerProtocolGuid, &gEdkIIRedfishConfigHandlerProtocolGuid,
(VOID**) &ConfigHandler (VOID **)&ConfigHandler
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = ConfigHandler->Init (ConfigHandler, &gRedfishConfigData.RedfishServiceInfo); Status = ConfigHandler->Init (ConfigHandler, &gRedfishConfigData.RedfishServiceInfo);
if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
DEBUG ((DEBUG_ERROR, "ERROR: Failed to init Redfish config handler %p.\n", ConfigHandler)); DEBUG ((DEBUG_ERROR, "ERROR: Failed to init Redfish config handler %p.\n", ConfigHandler));
} }
// //
// Install caller ID to indicate Redfish Configure Handler is initialized. // Install caller ID to indicate Redfish Configure Handler is initialized.
// //
Status = gBS->InstallProtocolInterface ( Status = gBS->InstallProtocolInterface (
&HandleBuffer [Index], &HandleBuffer[Index],
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
EFI_NATIVE_INTERFACE, EFI_NATIVE_INTERFACE,
(VOID *)&gRedfishConfigData.CallerId (VOID *)&gRedfishConfigData.CallerId

View File

@ -86,7 +86,7 @@ RedfishConfigCommonInit (
EFI_STATUS EFI_STATUS
RedfishConfigCommonStop ( RedfishConfigCommonStop (
VOID VOID
); );
/** /**
Callback function executed when a Redfish Config Handler Protocol is installed Callback function executed when a Redfish Config Handler Protocol is installed

View File

@ -48,7 +48,7 @@ EFI_DRIVER_BINDING_PROTOCOL gRedfishConfigDriverBinding = {
VOID VOID
RedfishConfigStopRedfishDiscovery ( RedfishConfigStopRedfishDiscovery (
VOID VOID
) )
{ {
if (gRedfishDiscoverActivated) { if (gRedfishDiscoverActivated) {
// //
@ -57,6 +57,7 @@ RedfishConfigStopRedfishDiscovery (
if (gEfiRedfishDiscoverProtocolEvent != NULL) { if (gEfiRedfishDiscoverProtocolEvent != NULL) {
gBS->CloseEvent (gEfiRedfishDiscoverProtocolEvent); gBS->CloseEvent (gEfiRedfishDiscoverProtocolEvent);
} }
// //
// Stop Redfish service discovery. // Stop Redfish service discovery.
// //
@ -161,10 +162,10 @@ RedfishConfigDriverBindingSupported (
// //
// Test if REST EX protocol is ready. // Test if REST EX protocol is ready.
// //
Status = gBS->OpenProtocol( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEfiRestExProtocolGuid, &gEfiRestExProtocolGuid,
(VOID**) &RestEx, (VOID **)&RestEx,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -172,6 +173,7 @@ RedfishConfigDriverBindingSupported (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
} }
NetLibDestroyServiceChild ( NetLibDestroyServiceChild (
ControllerHandle, ControllerHandle,
This->ImageHandle, This->ImageHandle,
@ -278,6 +280,7 @@ RedfishConfigDriverBindingStop (
if (ControllerHandle == gEfiRedfishDiscoverControllerHandle) { if (ControllerHandle == gEfiRedfishDiscoverControllerHandle) {
RedfishConfigStopRedfishDiscovery (); RedfishConfigStopRedfishDiscovery ();
} }
gBS->CloseProtocol ( gBS->CloseProtocol (
ControllerHandle, ControllerHandle,
&gEfiRedfishDiscoverProtocolGuid, &gEfiRedfishDiscoverProtocolGuid,
@ -294,6 +297,7 @@ RedfishConfigDriverBindingStop (
gBS->CloseEvent (gRedfishConfigData.Event); gBS->CloseEvent (gRedfishConfigData.Event);
gRedfishConfigData.Event = NULL; gRedfishConfigData.Event = NULL;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -368,7 +372,7 @@ RedfishDiscoverProtocolInstalled (
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface;
EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken; EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken;
DEBUG((DEBUG_INFO, "%a: New network interface is installed on system by EFI Redfish discover driver.\n", __FUNCTION__)); DEBUG ((DEBUG_INFO, "%a: New network interface is installed on system by EFI Redfish discover driver.\n", __FUNCTION__));
BufferSize = sizeof (EFI_HANDLE); BufferSize = sizeof (EFI_HANDLE);
Status = gBS->LocateHandle ( Status = gBS->LocateHandle (
@ -379,15 +383,16 @@ RedfishDiscoverProtocolInstalled (
&HandleBuffer &HandleBuffer
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "%a: Can't locate handle with EFI_REDFISH_DISCOVER_PROTOCOL installed.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Can't locate handle with EFI_REDFISH_DISCOVER_PROTOCOL installed.\n", __FUNCTION__));
} }
gRedfishDiscoverActivated = TRUE; gRedfishDiscoverActivated = TRUE;
if (gEfiRedfishDiscoverProtocol == NULL) { if (gEfiRedfishDiscoverProtocol == NULL) {
gEfiRedfishDiscoverControllerHandle = HandleBuffer; gEfiRedfishDiscoverControllerHandle = HandleBuffer;
// //
// First time to open EFI_REDFISH_DISCOVER_PROTOCOL. // First time to open EFI_REDFISH_DISCOVER_PROTOCOL.
// //
Status = gBS->OpenProtocol( Status = gBS->OpenProtocol (
gEfiRedfishDiscoverControllerHandle, gEfiRedfishDiscoverControllerHandle,
&gEfiRedfishDiscoverProtocolGuid, &gEfiRedfishDiscoverProtocolGuid,
(VOID **)&gEfiRedfishDiscoverProtocol, (VOID **)&gEfiRedfishDiscoverProtocol,
@ -398,30 +403,32 @@ RedfishDiscoverProtocolInstalled (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gEfiRedfishDiscoverProtocol = NULL; gEfiRedfishDiscoverProtocol = NULL;
gRedfishDiscoverActivated = FALSE; gRedfishDiscoverActivated = FALSE;
DEBUG((DEBUG_ERROR, "%a: Can't locate EFI_REDFISH_DISCOVER_PROTOCOL.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Can't locate EFI_REDFISH_DISCOVER_PROTOCOL.\n", __FUNCTION__));
return; return;
} }
} }
// //
// Check the new found network interface. // Check the new found network interface.
// //
if (gNetworkInterfaceInstances != NULL) { if (gNetworkInterfaceInstances != NULL) {
FreePool (gNetworkInterfaceInstances); FreePool (gNetworkInterfaceInstances);
} }
Status = gEfiRedfishDiscoverProtocol->GetNetworkInterfaceList(
Status = gEfiRedfishDiscoverProtocol->GetNetworkInterfaceList (
gEfiRedfishDiscoverProtocol, gEfiRedfishDiscoverProtocol,
gRedfishConfigData.Image, gRedfishConfigData.Image,
&gNumberOfNetworkInterfaces, &gNumberOfNetworkInterfaces,
&gNetworkInterfaceInstances &gNetworkInterfaceInstances
); );
if (EFI_ERROR (Status) || gNumberOfNetworkInterfaces == 0) { if (EFI_ERROR (Status) || (gNumberOfNetworkInterfaces == 0)) {
DEBUG((DEBUG_ERROR, "%a: No network interfaces found on the handle.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: No network interfaces found on the handle.\n", __FUNCTION__));
return; return;
} }
gRedfishDiscoveredToken = AllocateZeroPool (gNumberOfNetworkInterfaces * sizeof (EFI_REDFISH_DISCOVERED_TOKEN)); gRedfishDiscoveredToken = AllocateZeroPool (gNumberOfNetworkInterfaces * sizeof (EFI_REDFISH_DISCOVERED_TOKEN));
if (gRedfishDiscoveredToken == NULL) { if (gRedfishDiscoveredToken == NULL) {
DEBUG((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVERED_TOKEN.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVERED_TOKEN.\n", __FUNCTION__));
return; return;
} }
@ -430,7 +437,7 @@ RedfishDiscoverProtocolInstalled (
// //
// Loop to discover Redfish service on each network interface. // Loop to discover Redfish service on each network interface.
// //
for (NetworkInterfaceIndex = 0; NetworkInterfaceIndex < gNumberOfNetworkInterfaces; NetworkInterfaceIndex ++) { for (NetworkInterfaceIndex = 0; NetworkInterfaceIndex < gNumberOfNetworkInterfaces; NetworkInterfaceIndex++) {
// //
// Initial this Redfish Discovered Token // Initial this Redfish Discovered Token
// //
@ -442,9 +449,10 @@ RedfishDiscoverProtocolInstalled (
&ThisRedfishDiscoveredToken->Event &ThisRedfishDiscoveredToken->Event
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered token.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered token.\n", __FUNCTION__));
goto ErrorReturn; goto ErrorReturn;
} }
ThisRedfishDiscoveredToken->Signature = REDFISH_DISCOVER_TOKEN_SIGNATURE; ThisRedfishDiscoveredToken->Signature = REDFISH_DISCOVER_TOKEN_SIGNATURE;
ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound = 0; ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound = 0;
ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances = NULL; ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances = NULL;
@ -452,25 +460,27 @@ RedfishDiscoverProtocolInstalled (
// Acquire for Redfish service which is reported by // Acquire for Redfish service which is reported by
// Redfish Host Interface. // Redfish Host Interface.
// //
Status = gEfiRedfishDiscoverProtocol->AcquireRedfishService( Status = gEfiRedfishDiscoverProtocol->AcquireRedfishService (
gEfiRedfishDiscoverProtocol, gEfiRedfishDiscoverProtocol,
gRedfishConfigData.Image, gRedfishConfigData.Image,
ThisNetworkInterface, ThisNetworkInterface,
EFI_REDFISH_DISCOVER_HOST_INTERFACE, EFI_REDFISH_DISCOVER_HOST_INTERFACE,
ThisRedfishDiscoveredToken ThisRedfishDiscoveredToken
); );
ThisNetworkInterface ++; ThisNetworkInterface++;
ThisRedfishDiscoveredToken ++; ThisRedfishDiscoveredToken++;
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "%a: Acquire Redfish service fail.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Acquire Redfish service fail.\n", __FUNCTION__));
goto ErrorReturn; goto ErrorReturn;
} }
return; return;
ErrorReturn: ErrorReturn:
if (gRedfishDiscoveredToken != NULL) { if (gRedfishDiscoveredToken != NULL) {
FreePool(gRedfishDiscoveredToken); FreePool (gRedfishDiscoveredToken);
} }
} }
@ -496,15 +506,18 @@ RedfishConfigHandlerDriverUnload (
RedfishConfigStopRedfishDiscovery (); RedfishConfigStopRedfishDiscovery ();
if (gRedfishDiscoveredToken != NULL) { if (gRedfishDiscoveredToken != NULL) {
ThisRedfishDiscoveredToken = gRedfishDiscoveredToken; ThisRedfishDiscoveredToken = gRedfishDiscoveredToken;
for (NumberOfNetworkInterfacesIndex = 0; NumberOfNetworkInterfacesIndex < gNumberOfNetworkInterfaces; NumberOfNetworkInterfacesIndex ++) { for (NumberOfNetworkInterfacesIndex = 0; NumberOfNetworkInterfacesIndex < gNumberOfNetworkInterfaces; NumberOfNetworkInterfacesIndex++) {
if (ThisRedfishDiscoveredToken->Event != NULL) { if (ThisRedfishDiscoveredToken->Event != NULL) {
gBS->CloseEvent (ThisRedfishDiscoveredToken->Event); gBS->CloseEvent (ThisRedfishDiscoveredToken->Event);
} }
FreePool (ThisRedfishDiscoveredToken); FreePool (ThisRedfishDiscoveredToken);
ThisRedfishDiscoveredToken ++; ThisRedfishDiscoveredToken++;
} }
gRedfishDiscoveredToken = NULL; gRedfishDiscoveredToken = NULL;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -546,6 +559,7 @@ RedfishConfigHandlerDriverEntryPoint (
DEBUG ((DEBUG_ERROR, "%a: Fail to create event for the installation of EFI_REDFISH_DISCOVER_PROTOCOL.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to create event for the installation of EFI_REDFISH_DISCOVER_PROTOCOL.", __FUNCTION__));
return Status; return Status;
} }
Status = gBS->RegisterProtocolNotify ( Status = gBS->RegisterProtocolNotify (
&gEfiRedfishDiscoverProtocolGuid, &gEfiRedfishDiscoverProtocolGuid,
gEfiRedfishDiscoverProtocolEvent, gEfiRedfishDiscoverProtocolEvent,
@ -582,6 +596,6 @@ RedfishConfigHandlerDriverEntryPoint (
DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI Binding Protocol of EFI Redfish Config driver.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI Binding Protocol of EFI Redfish Config driver.", __FUNCTION__));
return Status; return Status;
} }
return Status; return Status;
} }

View File

@ -156,4 +156,5 @@ RedfishConfigDriverBindingStop (
IN UINTN NumberOfChildren, IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
); );
#endif #endif

View File

@ -85,11 +85,11 @@ RedfishCredentialGetAuthInfo (
OUT CHAR8 **Password OUT CHAR8 **Password
) )
{ {
if (This == NULL || AuthMethod == NULL || UserId == NULL || Password == NULL) { if ((This == NULL) || (AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
return LibCredentialGetAuthInfo (This, AuthMethod, UserId,Password); return LibCredentialGetAuthInfo (This, AuthMethod, UserId, Password);
} }
/** /**

View File

@ -6,6 +6,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef EDKII_REDFISH_CREDENTIAL_DXE_H_ #ifndef EDKII_REDFISH_CREDENTIAL_DXE_H_
#define EDKII_REDFISH_CREDENTIAL_DXE_H_ #define EDKII_REDFISH_CREDENTIAL_DXE_H_
@ -72,4 +73,5 @@ RedfishCredentialStopService (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
); );
#endif #endif

View File

@ -13,6 +13,7 @@
// //
// EFI Component Name Functions // EFI Component Name Functions
// //
/** /**
Retrieves a Unicode string that is the user-readable name of the EFI Driver. Retrieves a Unicode string that is the user-readable name of the EFI Driver.
@ -93,7 +94,6 @@ RedfishDiscoverComponentNameGetControllerName (
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
); );
/// ///
/// Component Name Protocol instance /// Component Name Protocol instance
/// ///
@ -109,8 +109,8 @@ EFI_COMPONENT_NAME_PROTOCOL gRedfishDiscoverComponentName = {
/// ///
GLOBAL_REMOVE_IF_UNREFERENCED GLOBAL_REMOVE_IF_UNREFERENCED
EFI_COMPONENT_NAME2_PROTOCOL gRedfishDiscoverComponentName2 = { EFI_COMPONENT_NAME2_PROTOCOL gRedfishDiscoverComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) RedfishDiscoverComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)RedfishDiscoverComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) RedfishDiscoverComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)RedfishDiscoverComponentNameGetControllerName,
"en" "en"
}; };

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,7 @@
#define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL TPL_NOTIFY #define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL TPL_NOTIFY
// //
//GUID definitions // GUID definitions
// //
#define EFI_REDFISH_DISCOVER_TCP4_INSTANCE_GUID \ #define EFI_REDFISH_DISCOVER_TCP4_INSTANCE_GUID \
@ -135,7 +135,7 @@ EFI_STATUS
(EFIAPI *EFI_REDFISH_DISCOVER_GET_SUBNET_INFO)( (EFIAPI *EFI_REDFISH_DISCOVER_GET_SUBNET_INFO)(
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *Instance IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *Instance
); );
// //
// The require network protocol matrix. // The require network protocol matrix.

View File

@ -52,17 +52,17 @@ RedfishGetHostInterfaceProtocolData (
// //
// Check Interface Type, should be Network Host Interface = 40h // Check Interface Type, should be Network Host Interface = 40h
// //
mType42Record = (SMBIOS_TABLE_TYPE42 *) Record; mType42Record = (SMBIOS_TABLE_TYPE42 *)Record;
if (mType42Record->InterfaceType == MCHostInterfaceTypeNetworkHostInterface) { if (mType42Record->InterfaceType == MCHostInterfaceTypeNetworkHostInterface) {
ASSERT (Record->Length >= 9); ASSERT (Record->Length >= 9);
Offset = 5; Offset = 5;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
// //
// Get interface specific data length. // Get interface specific data length.
// //
SpecificDataLen = *RecordTmp; SpecificDataLen = *RecordTmp;
Offset += 1; Offset += 1;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
// //
// Check Device Type, only PCI/PCIe Network Interface v2 is supported now. // Check Device Type, only PCI/PCIe Network Interface v2 is supported now.
@ -71,23 +71,23 @@ RedfishGetHostInterfaceProtocolData (
ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1); ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
*DeviceDescriptor = (REDFISH_INTERFACE_DATA *)RecordTmp; *DeviceDescriptor = (REDFISH_INTERFACE_DATA *)RecordTmp;
Offset = Offset + SpecificDataLen; Offset = Offset + SpecificDataLen;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
// //
// Check Protocol count. if > 1, only use the first protocol. // Check Protocol count. if > 1, only use the first protocol.
// //
ASSERT (*RecordTmp == 1); ASSERT (*RecordTmp == 1);
Offset += 1; Offset += 1;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
// //
// Check protocol identifier. // Check protocol identifier.
// //
if (*RecordTmp == MCHostInterfaceProtocolTypeRedfishOverIP) { if (*RecordTmp == MCHostInterfaceProtocolTypeRedfishOverIP) {
Offset += 1; Offset += 1;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
ProtocolLength = *RecordTmp; ProtocolLength = *RecordTmp;
Offset += 1; Offset += 1;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
// //
// This SMBIOS record is invalid, if the length of protocol specific data for // This SMBIOS record is invalid, if the length of protocol specific data for
@ -104,12 +104,14 @@ RedfishGetHostInterfaceProtocolData (
if (Offset > mType42Record->Hdr.Length) { if (Offset > mType42Record->Hdr.Length) {
return EFI_SECURITY_VIOLATION; return EFI_SECURITY_VIOLATION;
} }
*ProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)RecordTmp; *ProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)RecordTmp;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
} }
} }
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL); Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
} }

View File

@ -57,20 +57,25 @@ RedfishCreateSmbiosTable42 (
DEBUG ((DEBUG_ERROR, "%a: No Redfish host interface descriptor is provided on this platform.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: No Redfish host interface descriptor is provided on this platform.", __FUNCTION__));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
DEBUG((DEBUG_ERROR, "%a: Fail to get device descriptor, %r.", __FUNCTION__, Status));
DEBUG ((DEBUG_ERROR, "%a: Fail to get device descriptor, %r.", __FUNCTION__, Status));
return Status; return Status;
} }
if (DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2 &&
DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2 if ((DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2) &&
) { (DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2)
)
{
DEBUG ((DEBUG_ERROR, "%a: Only support either protocol type 04h or 05h as Redfish host interface.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Only support either protocol type 04h or 05h as Redfish host interface.", __FUNCTION__));
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
if (DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) { if (DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
DeviceDataLength = DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.Length; DeviceDataLength = DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.Length;
} else { } else {
DeviceDataLength = DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.Length; DeviceDataLength = DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.Length;
} }
// //
// Loop to get platform Redfish host interface protocol type data. // Loop to get platform Redfish host interface protocol type data.
// //
@ -86,17 +91,21 @@ RedfishCreateSmbiosTable42 (
if (Status == EFI_NOT_FOUND) { if (Status == EFI_NOT_FOUND) {
break; break;
} }
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Fail to get Redfish host interafce protocol type data.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to get Redfish host interafce protocol type data.", __FUNCTION__));
if (ProtocolRecords != NULL) { if (ProtocolRecords != NULL) {
FreePool (ProtocolRecords); FreePool (ProtocolRecords);
} }
if (ProtocolRecord != NULL) { if (ProtocolRecord != NULL) {
FreePool (ProtocolRecord); FreePool (ProtocolRecord);
} }
return Status; return Status;
} }
ProtocolDataSize = sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - sizeof(ProtocolRecord->ProtocolTypeData) + ProtocolRecord->ProtocolTypeDataLen;
ProtocolDataSize = sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - sizeof (ProtocolRecord->ProtocolTypeData) + ProtocolRecord->ProtocolTypeDataLen;
NewProtocolsDataLength += ProtocolDataSize; NewProtocolsDataLength += ProtocolDataSize;
if (ProtocolRecords == NULL) { if (ProtocolRecords == NULL) {
ProtocolRecords = AllocateZeroPool (NewProtocolsDataLength); ProtocolRecords = AllocateZeroPool (NewProtocolsDataLength);
@ -104,29 +113,34 @@ RedfishCreateSmbiosTable42 (
FreePool (ProtocolRecord); FreePool (ProtocolRecord);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem ((VOID *)ProtocolRecords, (VOID *)ProtocolRecord, ProtocolDataSize); CopyMem ((VOID *)ProtocolRecords, (VOID *)ProtocolRecord, ProtocolDataSize);
NewProtocolRecords = ProtocolRecords; NewProtocolRecords = ProtocolRecords;
} else { } else {
NewProtocolRecords = ReallocatePool(CurrentProtocolsDataLength, NewProtocolsDataLength, (VOID *)ProtocolRecords); NewProtocolRecords = ReallocatePool (CurrentProtocolsDataLength, NewProtocolsDataLength, (VOID *)ProtocolRecords);
if (NewProtocolRecords == NULL) { if (NewProtocolRecords == NULL) {
DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for Redfish host interface protocol data.")); DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for Redfish host interface protocol data."));
FreePool (ProtocolRecords); FreePool (ProtocolRecords);
FreePool (ProtocolRecord); FreePool (ProtocolRecord);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem ( CopyMem (
(VOID *)((UINT8 *)NewProtocolRecords + CurrentProtocolsDataLength), (VOID *)((UINT8 *)NewProtocolRecords + CurrentProtocolsDataLength),
(VOID *)ProtocolRecord, (VOID *)ProtocolRecord,
ProtocolDataSize ProtocolDataSize
); );
} }
FreePool (ProtocolRecord); FreePool (ProtocolRecord);
CurrentProtocolsDataLength = NewProtocolsDataLength; CurrentProtocolsDataLength = NewProtocolsDataLength;
ProtocolCount ++; ProtocolCount++;
}; }
if (ProtocolCount == 0) { if (ProtocolCount == 0) {
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Construct SMBIOS Type 42h for Redfish host inteface. // Construct SMBIOS Type 42h for Redfish host inteface.
// //
@ -140,7 +154,7 @@ RedfishCreateSmbiosTable42 (
// 06h+n number of protocols defined for the host interface (typically 1) // 06h+n number of protocols defined for the host interface (typically 1)
// 07h+n Include a Protocol Record for each protocol supported. // 07h+n Include a Protocol Record for each protocol supported.
// //
Type42Record = (SMBIOS_TABLE_TYPE42 *) AllocateZeroPool ( Type42Record = (SMBIOS_TABLE_TYPE42 *)AllocateZeroPool (
sizeof (SMBIOS_TABLE_TYPE42) - 4 sizeof (SMBIOS_TABLE_TYPE42) - 4
+ DeviceDataLength + DeviceDataLength
+ 1 /// For Protocol Record Count + 1 /// For Protocol Record Count
@ -189,7 +203,7 @@ RedfishCreateSmbiosTable42 (
// //
// 5. Add Redfish interface data record to SMBIOS table 42 // 5. Add Redfish interface data record to SMBIOS table 42
// //
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios); Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
@ -199,24 +213,28 @@ RedfishCreateSmbiosTable42 (
Smbios, Smbios,
NULL, NULL,
&MemArrayMappedAddrSmbiosHandle, &MemArrayMappedAddrSmbiosHandle,
(EFI_SMBIOS_TABLE_HEADER*) Type42Record (EFI_SMBIOS_TABLE_HEADER *)Type42Record
); );
DEBUG ((DEBUG_INFO, "RedfishPlatformDxe: Smbios->Add() - %r\n", Status)); DEBUG ((DEBUG_INFO, "RedfishPlatformDxe: Smbios->Add() - %r\n", Status));
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
ON_EXIT: ON_EXIT:
if (DeviceDescriptor != NULL) { if (DeviceDescriptor != NULL) {
FreePool (DeviceDescriptor); FreePool (DeviceDescriptor);
} }
if (NewProtocolRecords != NULL) { if (NewProtocolRecords != NULL) {
FreePool (NewProtocolRecords); FreePool (NewProtocolRecords);
} }
if (Type42Record != NULL) { if (Type42Record != NULL) {
FreePool (Type42Record); FreePool (Type42Record);
} }
return Status; return Status;
} }

View File

@ -18,6 +18,7 @@
// //
// EFI Component Name Functions // EFI Component Name Functions
// //
/** /**
Retrieves a Unicode string that is the user-readable name of the EFI Driver. Retrieves a Unicode string that is the user-readable name of the EFI Driver.
@ -113,8 +114,8 @@ EFI_COMPONENT_NAME_PROTOCOL gRedfishRestExComponentName = {
/// ///
GLOBAL_REMOVE_IF_UNREFERENCED GLOBAL_REMOVE_IF_UNREFERENCED
EFI_COMPONENT_NAME2_PROTOCOL gRedfishRestExComponentName2 = { EFI_COMPONENT_NAME2_PROTOCOL gRedfishRestExComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) RedfishRestExComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)RedfishRestExComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) RedfishRestExComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)RedfishRestExComponentNameGetControllerName,
"en" "en"
}; };

View File

@ -47,14 +47,14 @@ RestExDestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren; UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer; EFI_HANDLE *ChildHandleBuffer;
if (Entry == NULL || Context == NULL) { if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Instance = NET_LIST_USER_STRUCT_S (Entry, RESTEX_INSTANCE, Link, RESTEX_INSTANCE_SIGNATURE); Instance = NET_LIST_USER_STRUCT_S (Entry, RESTEX_INSTANCE, Link, RESTEX_INSTANCE_SIGNATURE);
ServiceBinding = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; ServiceBinding = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
NumberOfChildren = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; NumberOfChildren = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
ChildHandleBuffer = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; ChildHandleBuffer = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) { if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -354,7 +354,6 @@ RedfishRestExDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
) )
{ {
// //
// Test for the HttpServiceBinding Protocol. // Test for the HttpServiceBinding Protocol.
// //
@ -366,7 +365,6 @@ RedfishRestExDriverBindingSupported (
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL EFI_OPEN_PROTOCOL_TEST_PROTOCOL
); );
} }
/** /**
@ -420,7 +418,7 @@ RedfishRestExDriverBindingStart (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
(VOID **) &Id, (VOID **)&Id,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -538,7 +536,7 @@ RedfishRestExDriverBindingStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
NicHandle, NicHandle,
&gEfiRestExServiceBindingProtocolGuid, &gEfiRestExServiceBindingProtocolGuid,
(VOID **) &ServiceBinding, (VOID **)&ServiceBinding,
This->DriverBindingHandle, This->DriverBindingHandle,
NicHandle, NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -565,7 +563,7 @@ RedfishRestExDriverBindingStop (
); );
} }
if (NumberOfChildren == 0 && IsListEmpty (&RestExSb->RestExChildrenList)) { if ((NumberOfChildren == 0) && IsListEmpty (&RestExSb->RestExChildrenList)) {
gBS->UninstallProtocolInterface ( gBS->UninstallProtocolInterface (
NicHandle, NicHandle,
&gEfiRestExServiceBindingProtocolGuid, &gEfiRestExServiceBindingProtocolGuid,
@ -627,6 +625,7 @@ RedfishRestExServiceBindingCreateChild (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
ASSERT (Instance != NULL); ASSERT (Instance != NULL);
// //
@ -650,7 +649,7 @@ RedfishRestExServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
RestExSb->HttpChildHandle, RestExSb->HttpChildHandle,
&gEfiHttpProtocolGuid, &gEfiHttpProtocolGuid,
(VOID **) &Http, (VOID **)&Http,
gRedfishRestExDriverBinding.DriverBindingHandle, gRedfishRestExDriverBinding.DriverBindingHandle,
Instance->ChildHandle, Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -672,7 +671,7 @@ RedfishRestExServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Instance->HttpIo.Handle, Instance->HttpIo.Handle,
&gEfiHttpProtocolGuid, &gEfiHttpProtocolGuid,
(VOID **) &Http, (VOID **)&Http,
gRedfishRestExDriverBinding.DriverBindingHandle, gRedfishRestExDriverBinding.DriverBindingHandle,
Instance->ChildHandle, Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -758,7 +757,7 @@ RedfishRestExServiceBindingDestroyChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEfiRestExProtocolGuid, &gEfiRestExProtocolGuid,
(VOID **) &RestEx, (VOID **)&RestEx,
NULL, NULL,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -800,7 +799,6 @@ RedfishRestExServiceBindingDestroyChild (
ChildHandle ChildHandle
); );
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
// //
@ -828,4 +826,3 @@ RedfishRestExServiceBindingDestroyChild (
RestExDestroyInstance (Instance); RestExDestroyInstance (Instance);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -66,7 +66,6 @@ typedef struct _RESTEX_INSTANCE RESTEX_INSTANCE;
#define RESTEX_INSTANCE_FROM_THIS(a) \ #define RESTEX_INSTANCE_FROM_THIS(a) \
CR (a, RESTEX_INSTANCE, RestEx, RESTEX_INSTANCE_SIGNATURE) CR (a, RESTEX_INSTANCE, RestEx, RESTEX_INSTANCE_SIGNATURE)
#define RESTEX_STATE_UNCONFIGED 0 #define RESTEX_STATE_UNCONFIGED 0
#define RESTEX_STATE_CONFIGED 1 #define RESTEX_STATE_CONFIGED 1
@ -359,6 +358,7 @@ RedfishRestExEventService (
IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL, IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL,
IN EFI_REST_EX_TOKEN *RestExToken IN EFI_REST_EX_TOKEN *RestExToken
); );
/** /**
Create a new TLS session becuase the previous on is closed. Create a new TLS session becuase the previous on is closed.
status. status.
@ -372,8 +372,7 @@ RedfishRestExEventService (
EFI_STATUS EFI_STATUS
ResetHttpTslSession ( ResetHttpTslSession (
IN RESTEX_INSTANCE *Instance IN RESTEX_INSTANCE *Instance
); );
/** /**
Callback function which provided by user to remove one node in NetDestroyLinkList process. Callback function which provided by user to remove one node in NetDestroyLinkList process.
@ -419,7 +418,6 @@ RestExCreateInstance (
OUT RESTEX_INSTANCE **Instance OUT RESTEX_INSTANCE **Instance
); );
/** /**
Release all the resource used the RestEx service binding instance. Release all the resource used the RestEx service binding instance.
@ -647,4 +645,5 @@ RedfishRestExServiceBindingDestroyChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle IN EFI_HANDLE ChildHandle
); );
#endif #endif

View File

@ -23,7 +23,7 @@
EFI_STATUS EFI_STATUS
ResetHttpTslSession ( ResetHttpTslSession (
IN RESTEX_INSTANCE *Instance IN RESTEX_INSTANCE *Instance
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -34,12 +34,15 @@ ResetHttpTslSession (
DEBUG ((DEBUG_ERROR, "%a: Error to reset HTTP instance.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Error to reset HTTP instance.\n", __FUNCTION__));
return Status; return Status;
} }
Status = Instance->HttpIo.Http->Configure(Instance->HttpIo.Http, &((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData);
Status = Instance->HttpIo.Http->Configure (Instance->HttpIo.Http, &((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Error to re-initiate HTTP instance.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Error to re-initiate HTTP instance.\n", __FUNCTION__));
} }
return Status; return Status;
} }
/** /**
This function check This function check
@ -62,9 +65,9 @@ RedfishCheckHttpReceiveStatus (
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS ReturnStatus; EFI_STATUS ReturnStatus;
if (!EFI_ERROR (HttpIoReceiveStatus)){ if (!EFI_ERROR (HttpIoReceiveStatus)) {
ReturnStatus = EFI_SUCCESS; ReturnStatus = EFI_SUCCESS;
} else if (EFI_ERROR (HttpIoReceiveStatus) && HttpIoReceiveStatus != EFI_CONNECTION_FIN) { } else if (EFI_ERROR (HttpIoReceiveStatus) && (HttpIoReceiveStatus != EFI_CONNECTION_FIN)) {
if ((Instance->Flags & RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY) == 0) { if ((Instance->Flags & RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY) == 0) {
DEBUG ((DEBUG_ERROR, "%a: TCP error, reset HTTP session.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: TCP error, reset HTTP session.\n", __FUNCTION__));
Instance->Flags |= RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY; Instance->Flags |= RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY;
@ -85,19 +88,22 @@ RedfishCheckHttpReceiveStatus (
DEBUG ((DEBUG_ERROR, "%a: REST_EX Send and receive fail even with a new TLS session.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: REST_EX Send and receive fail even with a new TLS session.\n", __FUNCTION__));
ReturnStatus = EFI_DEVICE_ERROR; ReturnStatus = EFI_DEVICE_ERROR;
} }
Instance->Flags |= RESTEX_INSTANCE_FLAGS_TLS_RETRY; Instance->Flags |= RESTEX_INSTANCE_FLAGS_TLS_RETRY;
Status = ResetHttpTslSession (Instance); Status = ResetHttpTslSession (Instance);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Reset HTTP instance fail.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Reset HTTP instance fail.\n", __FUNCTION__));
ReturnStatus = EFI_DEVICE_ERROR; ReturnStatus = EFI_DEVICE_ERROR;
} }
return EFI_NOT_READY; return EFI_NOT_READY;
} }
} }
// //
// Clean TLS new session retry and error try flags. // Clean TLS new session retry and error try flags.
// //
Instance->Flags &= ~ (RESTEX_INSTANCE_FLAGS_TLS_RETRY | RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY); Instance->Flags &= ~(RESTEX_INSTANCE_FLAGS_TLS_RETRY | RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY);
return ReturnStatus; return ReturnStatus;
} }
@ -132,7 +138,7 @@ RedfishHttpAddExpectation (
{ {
EFI_HTTP_HEADER *NewHeaders; EFI_HTTP_HEADER *NewHeaders;
if (This == NULL || RequestMessage == NULL) { if ((This == NULL) || (RequestMessage == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -142,16 +148,17 @@ RedfishHttpAddExpectation (
} }
if ((RequestMessage->Data.Request->Method != HttpMethodPut) && (RequestMessage->Data.Request->Method != HttpMethodPost) && if ((RequestMessage->Data.Request->Method != HttpMethodPut) && (RequestMessage->Data.Request->Method != HttpMethodPost) &&
(RequestMessage->Data.Request->Method != HttpMethodPatch)) { (RequestMessage->Data.Request->Method != HttpMethodPatch))
{
return EFI_SUCCESS; return EFI_SUCCESS;
} }
*ItsWrite = TRUE; *ItsWrite = TRUE;
NewHeaders = AllocateZeroPool((RequestMessage->HeaderCount + 1) * sizeof(EFI_HTTP_HEADER)); NewHeaders = AllocateZeroPool ((RequestMessage->HeaderCount + 1) * sizeof (EFI_HTTP_HEADER));
CopyMem ((VOID*)NewHeaders, (VOID *)RequestMessage->Headers, RequestMessage->HeaderCount * sizeof (EFI_HTTP_HEADER)); CopyMem ((VOID *)NewHeaders, (VOID *)RequestMessage->Headers, RequestMessage->HeaderCount * sizeof (EFI_HTTP_HEADER));
HttpSetFieldNameAndValue (NewHeaders + RequestMessage->HeaderCount, HTTP_HEADER_EXPECT, HTTP_EXPECT_100_CONTINUE); HttpSetFieldNameAndValue (NewHeaders + RequestMessage->HeaderCount, HTTP_HEADER_EXPECT, HTTP_EXPECT_100_CONTINUE);
RequestMessage->HeaderCount ++; RequestMessage->HeaderCount++;
RequestMessage->Headers = NewHeaders; RequestMessage->Headers = NewHeaders;
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -320,6 +320,7 @@ RedfishRestExEventService (
IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL, IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL,
IN EFI_REST_EX_TOKEN *RestExToken IN EFI_REST_EX_TOKEN *RestExToken
); );
/** /**
Create a new TLS session becuase the previous on is closed. Create a new TLS session becuase the previous on is closed.
status. status.
@ -333,8 +334,7 @@ RedfishRestExEventService (
EFI_STATUS EFI_STATUS
ResetHttpTslSession ( ResetHttpTslSession (
IN RESTEX_INSTANCE *Instance IN RESTEX_INSTANCE *Instance
); );
/** /**
Callback function which provided by user to remove one node in NetDestroyLinkList process. Callback function which provided by user to remove one node in NetDestroyLinkList process.
@ -380,7 +380,6 @@ RestExCreateInstance (
OUT RESTEX_INSTANCE **Instance OUT RESTEX_INSTANCE **Instance
); );
/** /**
Release all the resource used the RestEx service binding instance. Release all the resource used the RestEx service binding instance.
@ -608,4 +607,5 @@ RedfishRestExServiceBindingDestroyChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle IN EFI_HANDLE ChildHandle
); );
#endif #endif

View File

@ -75,7 +75,7 @@ RedfishRestExSendReceive (
// //
// Validate the parameters // Validate the parameters
// //
if ((This == NULL) || (RequestMessage == NULL) || ResponseMessage == NULL) { if ((This == NULL) || (RequestMessage == NULL) || (ResponseMessage == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -101,17 +101,19 @@ RedfishRestExSendReceive (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
if (ItsWrite == TRUE) { if (ItsWrite == TRUE) {
if (RequestMessage->BodyLength > HTTP_IO_MAX_SEND_PAYLOAD) { if (RequestMessage->BodyLength > HTTP_IO_MAX_SEND_PAYLOAD) {
// //
// Send chunked transfer. // Send chunked transfer.
// //
SendChunkProcess ++; SendChunkProcess++;
CopyMem ((VOID *)&ChunkTransferRequestMessage, (VOID *)RequestMessage, sizeof (EFI_HTTP_MESSAGE)); CopyMem ((VOID *)&ChunkTransferRequestMessage, (VOID *)RequestMessage, sizeof (EFI_HTTP_MESSAGE));
} else { } else {
SendNonChunkProcess ++; SendNonChunkProcess++;
} }
} }
ReSendRequest:; ReSendRequest:;
// //
// Send out the request to REST service. // Send out the request to REST service.
@ -127,7 +129,7 @@ ReSendRequest:;
// following request message body using chunk transfer. // following request message body using chunk transfer.
// //
do { do {
Status = HttpIoSendChunkedTransfer( Status = HttpIoSendChunkedTransfer (
&(Instance->HttpIo), &(Instance->HttpIo),
&SendChunkProcess, &SendChunkProcess,
&ChunkTransferRequestMessage &ChunkTransferRequestMessage
@ -141,20 +143,20 @@ ReSendRequest:;
// This is the non-chunk transfer, send request header first and then // This is the non-chunk transfer, send request header first and then
// handle the following request message body using chunk transfer. // handle the following request message body using chunk transfer.
// //
Status = HttpIoSendRequest( Status = HttpIoSendRequest (
&(Instance->HttpIo), &(Instance->HttpIo),
(SendNonChunkProcess == HttpIoSendNonChunkContent)? NULL: RequestMessage->Data.Request, (SendNonChunkProcess == HttpIoSendNonChunkContent) ? NULL : RequestMessage->Data.Request,
(SendNonChunkProcess == HttpIoSendNonChunkContent)? 0: RequestMessage->HeaderCount, (SendNonChunkProcess == HttpIoSendNonChunkContent) ? 0 : RequestMessage->HeaderCount,
(SendNonChunkProcess == HttpIoSendNonChunkContent)? NULL: RequestMessage->Headers, (SendNonChunkProcess == HttpIoSendNonChunkContent) ? NULL : RequestMessage->Headers,
(SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent)? 0: RequestMessage->BodyLength, (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) ? 0 : RequestMessage->BodyLength,
(SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent)? NULL: RequestMessage->Body (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) ? NULL : RequestMessage->Body
); );
} }
} else { } else {
// //
// This is read from URI. // This is read from URI.
// //
Status = HttpIoSendRequest( Status = HttpIoSendRequest (
&(Instance->HttpIo), &(Instance->HttpIo),
RequestMessage->Data.Request, RequestMessage->Data.Request,
RequestMessage->HeaderCount, RequestMessage->HeaderCount,
@ -163,6 +165,7 @@ ReSendRequest:;
RequestMessage->Body RequestMessage->Body
); );
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
@ -173,20 +176,20 @@ ReSendRequest:;
// Clean the previous buffers and all of them will be allocated later according to the actual situation. // Clean the previous buffers and all of them will be allocated later according to the actual situation.
// //
if (ResponseMessage->Data.Response != NULL) { if (ResponseMessage->Data.Response != NULL) {
FreePool(ResponseMessage->Data.Response); FreePool (ResponseMessage->Data.Response);
ResponseMessage->Data.Response = NULL; ResponseMessage->Data.Response = NULL;
} }
ResponseMessage->BodyLength = 0; ResponseMessage->BodyLength = 0;
if (ResponseMessage->Body != NULL) { if (ResponseMessage->Body != NULL) {
FreePool(ResponseMessage->Body); FreePool (ResponseMessage->Body);
ResponseMessage->Body = NULL; ResponseMessage->Body = NULL;
} }
// //
// Use zero BodyLength to only receive the response headers. // Use zero BodyLength to only receive the response headers.
// //
ResponseData = AllocateZeroPool (sizeof(HTTP_IO_RESPONSE_DATA)); ResponseData = AllocateZeroPool (sizeof (HTTP_IO_RESPONSE_DATA));
if (ResponseData == NULL) { if (ResponseData == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -206,13 +209,14 @@ ReSendRequest:;
} else if (Status == EFI_DEVICE_ERROR) { } else if (Status == EFI_DEVICE_ERROR) {
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Restore the headers if it ever changed in RedfishHttpAddExpectation(). // Restore the headers if it ever changed in RedfishHttpAddExpectation().
// //
if (RequestMessage->Headers != PreservedRequestHeaders) { if (RequestMessage->Headers != PreservedRequestHeaders) {
FreePool (RequestMessage->Headers); FreePool (RequestMessage->Headers);
RequestMessage->Headers = PreservedRequestHeaders; // Restore headers before we adding "Expect". RequestMessage->Headers = PreservedRequestHeaders; // Restore headers before we adding "Expect".
RequestMessage->HeaderCount --; // Minus one header count for "Expect". RequestMessage->HeaderCount--; // Minus one header count for "Expect".
} }
DEBUG ((DEBUG_INFO, "HTTP Response StatusCode - %d:", ResponseData->Response.StatusCode)); DEBUG ((DEBUG_INFO, "HTTP Response StatusCode - %d:", ResponseData->Response.StatusCode));
@ -221,7 +225,7 @@ ReSendRequest:;
if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) { if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) {
DEBUG ((DEBUG_INFO, "This is chunk transfer, start to send all chunks.", ResponseData->Response.StatusCode)); DEBUG ((DEBUG_INFO, "This is chunk transfer, start to send all chunks.", ResponseData->Response.StatusCode));
SendChunkProcess ++; SendChunkProcess++;
goto ReSendRequest; goto ReSendRequest;
} }
} else if (ResponseData->Response.StatusCode == HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE) { } else if (ResponseData->Response.StatusCode == HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE) {
@ -229,7 +233,7 @@ ReSendRequest:;
Status = EFI_BAD_BUFFER_SIZE; Status = EFI_BAD_BUFFER_SIZE;
goto ON_EXIT; goto ON_EXIT;
} else if (ResponseData->Response.StatusCode == HTTP_STATUS_405_METHOD_NOT_ALLOWED){ } else if (ResponseData->Response.StatusCode == HTTP_STATUS_405_METHOD_NOT_ALLOWED) {
DEBUG ((DEBUG_ERROR, "HTTP_STATUS_405_METHOD_NOT_ALLOWED\n")); DEBUG ((DEBUG_ERROR, "HTTP_STATUS_405_METHOD_NOT_ALLOWED\n"));
Status = EFI_ACCESS_DENIED; Status = EFI_ACCESS_DENIED;
@ -238,7 +242,7 @@ ReSendRequest:;
DEBUG ((DEBUG_INFO, "HTTP_STATUS_400_BAD_REQUEST\n")); DEBUG ((DEBUG_INFO, "HTTP_STATUS_400_BAD_REQUEST\n"));
if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) { if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) {
DEBUG ((DEBUG_INFO, "Bad request may caused by zero length chunk. Try to send all chunks...\n")); DEBUG ((DEBUG_INFO, "Bad request may caused by zero length chunk. Try to send all chunks...\n"));
SendChunkProcess ++; SendChunkProcess++;
goto ReSendRequest; goto ReSendRequest;
} }
} else if (ResponseData->Response.StatusCode == HTTP_STATUS_100_CONTINUE) { } else if (ResponseData->Response.StatusCode == HTTP_STATUS_100_CONTINUE) {
@ -248,22 +252,25 @@ ReSendRequest:;
// We get HTTP_STATUS_100_CONTINUE to send the body using chunk transfer. // We get HTTP_STATUS_100_CONTINUE to send the body using chunk transfer.
// //
DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for chunk transfer...\n")); DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for chunk transfer...\n"));
SendChunkProcess ++; SendChunkProcess++;
goto ReSendRequest; goto ReSendRequest;
} }
if (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) { if (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) {
DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for non chunk transfer...\n")); DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for non chunk transfer...\n"));
SendNonChunkProcess ++; SendNonChunkProcess++;
goto ReSendRequest; goto ReSendRequest;
} }
// //
// It's the REST protocol's responsibility to handle the interim HTTP response (e.g. 100 Continue Informational), // It's the REST protocol's responsibility to handle the interim HTTP response (e.g. 100 Continue Informational),
// and return the final response content to the caller. // and return the final response content to the caller.
// //
if (ResponseData->Headers != NULL && ResponseData->HeaderCount != 0) { if ((ResponseData->Headers != NULL) && (ResponseData->HeaderCount != 0)) {
FreePool (ResponseData->Headers); FreePool (ResponseData->Headers);
} }
ZeroMem (ResponseData, sizeof(HTTP_IO_RESPONSE_DATA));
ZeroMem (ResponseData, sizeof (HTTP_IO_RESPONSE_DATA));
Status = HttpIoRecvResponse ( Status = HttpIoRecvResponse (
&(Instance->HttpIo), &(Instance->HttpIo),
TRUE, TRUE,
@ -296,7 +303,7 @@ ReSendRequest:;
// //
if (ResponseMessage->HeaderCount > 0) { if (ResponseMessage->HeaderCount > 0) {
Status = HttpIoGetContentLength (ResponseMessage->HeaderCount, ResponseMessage->Headers, &ResponseMessage->BodyLength); Status = HttpIoGetContentLength (ResponseMessage->HeaderCount, ResponseMessage->Headers, &ResponseMessage->BodyLength);
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) { if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
goto ON_EXIT; goto ON_EXIT;
} }
@ -315,13 +322,15 @@ ReSendRequest:;
&ChunkListLink, &ChunkListLink,
&ResponseMessage->BodyLength &ResponseMessage->BodyLength
); );
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) { if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
goto ON_EXIT; goto ON_EXIT;
} }
if (Status == EFI_SUCCESS &&
ChunkListLink != NULL && if ((Status == EFI_SUCCESS) &&
!IsListEmpty(ChunkListLink) && (ChunkListLink != NULL) &&
ResponseMessage->BodyLength != 0) { !IsListEmpty (ChunkListLink) &&
(ResponseMessage->BodyLength != 0))
{
IsGetChunkedTransfer = TRUE; IsGetChunkedTransfer = TRUE;
// //
// Copy data to Message body. // Copy data to Message body.
@ -332,27 +341,31 @@ ReSendRequest:;
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
CopyChunkData = FALSE; CopyChunkData = FALSE;
} }
Index = 0; Index = 0;
while (!IsListEmpty(ChunkListLink)) { while (!IsListEmpty (ChunkListLink)) {
ThisChunk = (HTTP_IO_CHUNKS *)GetFirstNode (ChunkListLink); ThisChunk = (HTTP_IO_CHUNKS *)GetFirstNode (ChunkListLink);
if (CopyChunkData) { if (CopyChunkData) {
CopyMem(((UINT8 *)ResponseMessage->Body + Index), (UINT8 *)ThisChunk->Data, ThisChunk->Length); CopyMem (((UINT8 *)ResponseMessage->Body + Index), (UINT8 *)ThisChunk->Data, ThisChunk->Length);
Index += ThisChunk->Length; Index += ThisChunk->Length;
} }
RemoveEntryList (&ThisChunk->NextChunk); RemoveEntryList (&ThisChunk->NextChunk);
FreePool ((VOID *)ThisChunk->Data); FreePool ((VOID *)ThisChunk->Data);
FreePool ((VOID *)ThisChunk); FreePool ((VOID *)ThisChunk);
}; }
FreePool ((VOID *)ChunkListLink); FreePool ((VOID *)ChunkListLink);
} }
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
// //
// Ready to return the Body from REST service if have any. // Ready to return the Body from REST service if have any.
// //
if (ResponseMessage->BodyLength > 0 && !IsGetChunkedTransfer) { if ((ResponseMessage->BodyLength > 0) && !IsGetChunkedTransfer) {
ResponseData->HeaderCount = 0; ResponseData->HeaderCount = 0;
ResponseData->Headers = NULL; ResponseData->Headers = NULL;
@ -368,7 +381,7 @@ ReSendRequest:;
TotalReceivedSize = 0; TotalReceivedSize = 0;
while (TotalReceivedSize < ResponseMessage->BodyLength) { while (TotalReceivedSize < ResponseMessage->BodyLength) {
ResponseData->BodyLength = ResponseMessage->BodyLength - TotalReceivedSize; ResponseData->BodyLength = ResponseMessage->BodyLength - TotalReceivedSize;
ResponseData->Body = (CHAR8 *) ResponseMessage->Body + TotalReceivedSize; ResponseData->Body = (CHAR8 *)ResponseMessage->Body + TotalReceivedSize;
Status = HttpIoRecvResponse ( Status = HttpIoRecvResponse (
&(Instance->HttpIo), &(Instance->HttpIo),
FALSE, FALSE,
@ -380,8 +393,10 @@ ReSendRequest:;
TotalReceivedSize += ResponseData->BodyLength; TotalReceivedSize += ResponseData->BodyLength;
} }
DEBUG ((DEBUG_INFO, "Total of lengh of Response :%d\n", TotalReceivedSize)); DEBUG ((DEBUG_INFO, "Total of lengh of Response :%d\n", TotalReceivedSize));
} }
DEBUG ((DEBUG_INFO, "RedfishRestExSendReceive()- EFI_STATUS: %r\n", Status)); DEBUG ((DEBUG_INFO, "RedfishRestExSendReceive()- EFI_STATUS: %r\n", Status));
ON_EXIT: ON_EXIT:
@ -401,6 +416,7 @@ ON_EXIT:
ResponseMessage->Body = NULL; ResponseMessage->Body = NULL;
} }
} }
return Status; return Status;
} }
@ -480,7 +496,7 @@ RedfishRestExGetService (
ServiceInfo = NULL; ServiceInfo = NULL;
if (This == NULL || RestExServiceInfo == NULL) { if ((This == NULL) || (RestExServiceInfo == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -601,9 +617,10 @@ RedfishRestExConfigure (
if (Instance->ConfigData != NULL) { if (Instance->ConfigData != NULL) {
if (((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node != NULL) { if (((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node != NULL) {
FreePool(((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node); FreePool (((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node);
} }
FreePool(Instance->ConfigData);
FreePool (Instance->ConfigData);
Instance->ConfigData = NULL; Instance->ConfigData = NULL;
} }
@ -614,6 +631,7 @@ RedfishRestExConfigure (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
Instance->HttpIo.Timeout = ((EFI_REST_EX_HTTP_CONFIG_DATA *)RestExConfigData)->SendReceiveTimeout; Instance->HttpIo.Timeout = ((EFI_REST_EX_HTTP_CONFIG_DATA *)RestExConfigData)->SendReceiveTimeout;
Instance->ConfigData = AllocateZeroPool (sizeof (EFI_REST_EX_HTTP_CONFIG_DATA)); Instance->ConfigData = AllocateZeroPool (sizeof (EFI_REST_EX_HTTP_CONFIG_DATA));
@ -621,6 +639,7 @@ RedfishRestExConfigure (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem (Instance->ConfigData, RestExConfigData, sizeof (EFI_REST_EX_HTTP_CONFIG_DATA)); CopyMem (Instance->ConfigData, RestExConfigData, sizeof (EFI_REST_EX_HTTP_CONFIG_DATA));
if (HttpConfigData->LocalAddressIsIPv6 == TRUE) { if (HttpConfigData->LocalAddressIsIPv6 == TRUE) {
((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node = AllocateZeroPool (sizeof (EFI_HTTPv6_ACCESS_POINT)); ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node = AllocateZeroPool (sizeof (EFI_HTTPv6_ACCESS_POINT));
@ -628,6 +647,7 @@ RedfishRestExConfigure (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem ( CopyMem (
((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node, ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node,
HttpConfigData->AccessPoint.IPv6Node, HttpConfigData->AccessPoint.IPv6Node,
@ -639,12 +659,14 @@ RedfishRestExConfigure (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem ( CopyMem (
((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node, ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node,
HttpConfigData->AccessPoint.IPv4Node, HttpConfigData->AccessPoint.IPv4Node,
sizeof (EFI_HTTPv4_ACCESS_POINT) sizeof (EFI_HTTPv4_ACCESS_POINT)
); );
} }
Instance->State = RESTEX_STATE_CONFIGED; Instance->State = RESTEX_STATE_CONFIGED;
} }
@ -732,4 +754,3 @@ RedfishRestExEventService (
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }

View File

@ -39,7 +39,7 @@ RestJsonStructureRegister (
IN EFI_REST_JSON_STRUCTURE_TO_STRUCTURE ToStructure, IN EFI_REST_JSON_STRUCTURE_TO_STRUCTURE ToStructure,
IN EFI_REST_JSON_STRUCTURE_TO_JSON ToJson, IN EFI_REST_JSON_STRUCTURE_TO_JSON ToJson,
IN EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE DestroyStructure IN EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE DestroyStructure
) )
{ {
UINTN NumberOfNS; UINTN NumberOfNS;
UINTN Index; UINTN Index;
@ -48,12 +48,13 @@ RestJsonStructureRegister (
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *CloneSupportedInterpId; EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *CloneSupportedInterpId;
EFI_REST_JSON_STRUCTURE_SUPPORTED *ThisSupportedInterp; EFI_REST_JSON_STRUCTURE_SUPPORTED *ThisSupportedInterp;
if (This == NULL || if ((This == NULL) ||
ToStructure == NULL || (ToStructure == NULL) ||
ToJson == NULL || (ToJson == NULL) ||
DestroyStructure == NULL || (DestroyStructure == NULL) ||
JsonStructureSupported == NULL (JsonStructureSupported == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -67,15 +68,16 @@ RestJsonStructureRegister (
break; break;
} else { } else {
ThisList = ThisList->ForwardLink; ThisList = ThisList->ForwardLink;
NumberOfNS ++; NumberOfNS++;
}
} }
};
Instance = Instance =
(REST_JSON_STRUCTURE_INSTANCE *)AllocateZeroPool (sizeof (REST_JSON_STRUCTURE_INSTANCE) + NumberOfNS * sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER)); (REST_JSON_STRUCTURE_INSTANCE *)AllocateZeroPool (sizeof (REST_JSON_STRUCTURE_INSTANCE) + NumberOfNS * sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER));
if (Instance == NULL) { if (Instance == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
InitializeListHead (&Instance->NextRestJsonStructureInstance); InitializeListHead (&Instance->NextRestJsonStructureInstance);
Instance->NumberOfNameSpaceToConvert = NumberOfNS; Instance->NumberOfNameSpaceToConvert = NumberOfNS;
Instance->SupportedRsrcIndentifier = (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *)((REST_JSON_STRUCTURE_INSTANCE *)Instance + 1); Instance->SupportedRsrcIndentifier = (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *)((REST_JSON_STRUCTURE_INSTANCE *)Instance + 1);
@ -84,11 +86,12 @@ RestJsonStructureRegister (
// //
CloneSupportedInterpId = Instance->SupportedRsrcIndentifier; CloneSupportedInterpId = Instance->SupportedRsrcIndentifier;
ThisSupportedInterp = JsonStructureSupported; ThisSupportedInterp = JsonStructureSupported;
for (Index = 0; Index < NumberOfNS; Index ++) { for (Index = 0; Index < NumberOfNS; Index++) {
CopyMem ((VOID *)CloneSupportedInterpId, (VOID *)&ThisSupportedInterp->RestResourceInterp, sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER)); CopyMem ((VOID *)CloneSupportedInterpId, (VOID *)&ThisSupportedInterp->RestResourceInterp, sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER));
ThisSupportedInterp = (EFI_REST_JSON_STRUCTURE_SUPPORTED *)ThisSupportedInterp->NextSupportedRsrcInterp.ForwardLink; ThisSupportedInterp = (EFI_REST_JSON_STRUCTURE_SUPPORTED *)ThisSupportedInterp->NextSupportedRsrcInterp.ForwardLink;
CloneSupportedInterpId ++; CloneSupportedInterpId++;
} }
Instance->JsonToStructure = ToStructure; Instance->JsonToStructure = ToStructure;
Instance->StructureToJson = ToJson; Instance->StructureToJson = ToJson;
Instance->DestroyStructure = DestroyStructure; Instance->DestroyStructure = DestroyStructure;
@ -122,11 +125,12 @@ InterpreterInstanceToStruct (
EFI_STATUS Status; EFI_STATUS Status;
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId; EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
if (This == NULL || if ((This == NULL) ||
InterpreterInstance == NULL || (InterpreterInstance == NULL) ||
ResourceRaw == NULL || (ResourceRaw == NULL) ||
RestJSonHeader == NULL (RestJSonHeader == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -147,14 +151,17 @@ InterpreterInstanceToStruct (
// Check if the namesapce and version is supported by this interpreter. // Check if the namesapce and version is supported by this interpreter.
// //
ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier; ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index ++){ for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
if (AsciiStrCmp ( if (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.ResourceTypeName, RsrcTypeIdentifier->NameSpace.ResourceTypeName,
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0){ ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
) == 0)
{
if ((RsrcTypeIdentifier->NameSpace.MajorVersion == NULL) && if ((RsrcTypeIdentifier->NameSpace.MajorVersion == NULL) &&
(RsrcTypeIdentifier->NameSpace.MinorVersion == NULL) && (RsrcTypeIdentifier->NameSpace.MinorVersion == NULL) &&
(RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL) (RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL)
) { )
{
// //
// Don't check version of this resource type identifier. // Don't check version of this resource type identifier.
// //
@ -171,13 +178,17 @@ InterpreterInstanceToStruct (
// //
if ((AsciiStrCmp ( if ((AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.MajorVersion, RsrcTypeIdentifier->NameSpace.MajorVersion,
ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MajorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.MinorVersion, RsrcTypeIdentifier->NameSpace.MinorVersion,
ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MinorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.ErrataVersion, RsrcTypeIdentifier->NameSpace.ErrataVersion,
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) { ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
) == 0))
{
Status = InterpreterInstance->JsonToStructure ( Status = InterpreterInstance->JsonToStructure (
This, This,
RsrcTypeIdentifier, RsrcTypeIdentifier,
@ -188,11 +199,14 @@ InterpreterInstanceToStruct (
} }
} }
} }
ThisSupportedRsrcTypeId ++;
ThisSupportedRsrcTypeId++;
} }
} }
return Status; return Status;
} }
/** /**
This function converts JSON C structure to JSON property. This function converts JSON C structure to JSON property.
@ -211,27 +225,30 @@ InterpreterEfiStructToInstance (
IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance, IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance,
IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader, IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader,
OUT CHAR8 **ResourceRaw OUT CHAR8 **ResourceRaw
) )
{ {
UINTN Index; UINTN Index;
EFI_STATUS Status; EFI_STATUS Status;
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId; EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier; EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier;
if (This == NULL || if ((This == NULL) ||
InterpreterInstance == NULL || (InterpreterInstance == NULL) ||
RestJSonHeader == NULL || (RestJSonHeader == NULL) ||
ResourceRaw == NULL (ResourceRaw == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
RsrcTypeIdentifier = &RestJSonHeader->JsonRsrcIdentifier; RsrcTypeIdentifier = &RestJSonHeader->JsonRsrcIdentifier;
if (RsrcTypeIdentifier == NULL || if ((RsrcTypeIdentifier == NULL) ||
RsrcTypeIdentifier->NameSpace.ResourceTypeName == NULL || (RsrcTypeIdentifier->NameSpace.ResourceTypeName == NULL) ||
RsrcTypeIdentifier->NameSpace.MajorVersion == NULL || (RsrcTypeIdentifier->NameSpace.MajorVersion == NULL) ||
RsrcTypeIdentifier->NameSpace.MinorVersion == NULL || (RsrcTypeIdentifier->NameSpace.MinorVersion == NULL) ||
RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL (RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -240,22 +257,28 @@ InterpreterEfiStructToInstance (
// //
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier; ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index ++){ for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
if (AsciiStrCmp ( if (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.ResourceTypeName, RsrcTypeIdentifier->NameSpace.ResourceTypeName,
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0){ ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
) == 0)
{
// //
// Check version. // Check version.
// //
if ((AsciiStrCmp ( if ((AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.MajorVersion, RsrcTypeIdentifier->NameSpace.MajorVersion,
ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MajorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.MinorVersion, RsrcTypeIdentifier->NameSpace.MinorVersion,
ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MinorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.ErrataVersion, RsrcTypeIdentifier->NameSpace.ErrataVersion,
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) { ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
) == 0))
{
Status = InterpreterInstance->StructureToJson ( Status = InterpreterInstance->StructureToJson (
This, This,
RestJSonHeader, RestJSonHeader,
@ -264,8 +287,10 @@ InterpreterEfiStructToInstance (
break; break;
} }
} }
ThisSupportedRsrcTypeId ++;
ThisSupportedRsrcTypeId++;
} }
return Status; return Status;
} }
@ -291,10 +316,11 @@ InterpreterInstanceDestoryJsonStruct (
EFI_STATUS Status; EFI_STATUS Status;
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId; EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
if (This == NULL || if ((This == NULL) ||
InterpreterInstance == NULL || (InterpreterInstance == NULL) ||
RestJSonHeader == NULL (RestJSonHeader == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -303,14 +329,17 @@ InterpreterInstanceDestoryJsonStruct (
// Check if the namesapce and version is supported by this interpreter. // Check if the namesapce and version is supported by this interpreter.
// //
ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier; ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index ++){ for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
if (AsciiStrCmp ( if (AsciiStrCmp (
RestJSonHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, RestJSonHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName,
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0) { ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
) == 0)
{
if ((RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion == NULL) && if ((RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion == NULL) &&
(RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion == NULL) && (RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion == NULL) &&
(RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion == NULL) (RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion == NULL)
) { )
{
// //
// Don't check version of this resource type identifier. // Don't check version of this resource type identifier.
// //
@ -325,13 +354,17 @@ InterpreterInstanceDestoryJsonStruct (
// //
if ((AsciiStrCmp ( if ((AsciiStrCmp (
RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion,
ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MajorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion,
ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MinorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion,
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) { ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
) == 0))
{
Status = InterpreterInstance->DestroyStructure ( Status = InterpreterInstance->DestroyStructure (
This, This,
RestJSonHeader RestJSonHeader
@ -340,8 +373,10 @@ InterpreterInstanceDestoryJsonStruct (
} }
} }
} }
ThisSupportedRsrcTypeId ++;
ThisSupportedRsrcTypeId++;
} }
return Status; return Status;
} }
@ -364,21 +399,23 @@ RestJsonStructureToStruct (
IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier OPTIONAL, IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier OPTIONAL,
IN CHAR8 *ResourceJsonText, IN CHAR8 *ResourceJsonText,
OUT EFI_REST_JSON_STRUCTURE_HEADER **JsonStructure OUT EFI_REST_JSON_STRUCTURE_HEADER **JsonStructure
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
REST_JSON_STRUCTURE_INSTANCE *Instance; REST_JSON_STRUCTURE_INSTANCE *Instance;
if (This == NULL || if ((This == NULL) ||
ResourceJsonText == NULL || (ResourceJsonText == NULL) ||
JsonStructure == NULL (JsonStructure == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (IsListEmpty (&mRestJsonStructureList)) { if (IsListEmpty (&mRestJsonStructureList)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
while (TRUE) { while (TRUE) {
@ -392,12 +429,15 @@ RestJsonStructureToStruct (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
break; break;
} }
if (IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
break; break;
} }
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
}; }
return Status; return Status;
} }
@ -417,18 +457,19 @@ EFIAPI
RestJsonStructureDestroyStruct ( RestJsonStructureDestroyStruct (
IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This,
IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
REST_JSON_STRUCTURE_INSTANCE *Instance; REST_JSON_STRUCTURE_INSTANCE *Instance;
if (This == NULL || RestJSonHeader == NULL) { if ((This == NULL) || (RestJSonHeader == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (IsListEmpty (&mRestJsonStructureList)) { if (IsListEmpty (&mRestJsonStructureList)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
while (TRUE) { while (TRUE) {
@ -440,12 +481,15 @@ RestJsonStructureDestroyStruct (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
break; break;
} }
if (IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
break; break;
} }
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
}; }
return Status; return Status;
} }
@ -466,18 +510,19 @@ RestJsonStructureToJson (
IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This,
IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader, IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader,
OUT CHAR8 **ResourceRaw OUT CHAR8 **ResourceRaw
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
REST_JSON_STRUCTURE_INSTANCE *Instance; REST_JSON_STRUCTURE_INSTANCE *Instance;
if (This == NULL || RestJSonHeader == NULL || ResourceRaw == NULL) { if ((This == NULL) || (RestJSonHeader == NULL) || (ResourceRaw == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (IsListEmpty (&mRestJsonStructureList)) { if (IsListEmpty (&mRestJsonStructureList)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
while (TRUE) { while (TRUE) {
@ -490,12 +535,15 @@ RestJsonStructureToJson (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
break; break;
} }
if (IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
break; break;
} }
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
}; }
return Status; return Status;
} }
@ -569,15 +617,17 @@ RestJsonStructureUnload (
if (IsListEmpty (&mRestJsonStructureList)) { if (IsListEmpty (&mRestJsonStructureList)) {
return Status; return Status;
} }
// //
// Free memory of REST_JSON_STRUCTURE_INSTANCE instance. // Free memory of REST_JSON_STRUCTURE_INSTANCE instance.
// //
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
do { do {
NextInstance = NULL; NextInstance = NULL;
if (!IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) { if (!IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
NextInstance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); NextInstance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
} }
FreePool ((VOID *)Instance); FreePool ((VOID *)Instance);
Instance = NextInstance; Instance = NextInstance;
} while (Instance != NULL); } while (Instance != NULL);