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:
committed by
mergify[bot]
parent
5220bd211d
commit
39de741e2d
@ -166,4 +166,3 @@ typedef struct {
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef JSON_LIB_H_
|
||||
#define JSON_LIB_H_
|
||||
|
||||
@ -835,6 +836,7 @@ EFIAPI
|
||||
JsonIncreaseReference (
|
||||
IN EDKII_JSON_VALUE JsonValue
|
||||
);
|
||||
|
||||
/**
|
||||
Returns an opaque iterator which can be used to iterate over all key-value pairs
|
||||
in object, or NULL if object is empty
|
||||
@ -908,4 +910,5 @@ EFIAPI
|
||||
JsonGetType (
|
||||
IN EDKII_JSON_VALUE JsonValue
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_CONTENT_CODING_LIB_H_
|
||||
#define REDFISH_CONTENT_CODING_LIB_H_
|
||||
|
||||
@ -75,4 +76,5 @@ RedfishContentDecode (
|
||||
OUT VOID **DecodedContentPointer,
|
||||
OUT UINTN *DecodedLength
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_CREDENTIAL_LIB_H_
|
||||
#define REDFISH_CREDENTIAL_LIB_H_
|
||||
|
||||
@ -88,4 +89,5 @@ LibStopRedfishService (
|
||||
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
|
||||
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -80,7 +80,9 @@ typedef INT32 int32_t;
|
||||
typedef UINT32 uint32_t;
|
||||
typedef UINT16 uint16_t;
|
||||
typedef UINT8 uint8_t;
|
||||
typedef enum {false, true} bool;
|
||||
typedef enum {
|
||||
false, true
|
||||
} bool;
|
||||
|
||||
//
|
||||
// File operations are not required for EFI building,
|
||||
@ -148,68 +150,364 @@ extern FILE *stderr;
|
||||
//
|
||||
// Function prototypes of CRT Library routines
|
||||
//
|
||||
void *malloc (size_t);
|
||||
void *realloc (void *, size_t);
|
||||
void *calloc (size_t Num, size_t Size);
|
||||
void free (void *);
|
||||
void *memset (void *, int, size_t);
|
||||
int memcmp (const void *, const void *, size_t);
|
||||
int isdigit (int);
|
||||
int isspace (int);
|
||||
int tolower (int);
|
||||
int isupper (int);
|
||||
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 *);
|
||||
void *
|
||||
malloc (
|
||||
size_t
|
||||
);
|
||||
|
||||
void *
|
||||
realloc (
|
||||
void *,
|
||||
size_t
|
||||
);
|
||||
|
||||
void *
|
||||
calloc (
|
||||
size_t Num,
|
||||
size_t Size
|
||||
);
|
||||
|
||||
void
|
||||
free (
|
||||
void *
|
||||
);
|
||||
|
||||
void *
|
||||
memset (
|
||||
void *,
|
||||
int,
|
||||
size_t
|
||||
);
|
||||
|
||||
int
|
||||
memcmp (
|
||||
const void *,
|
||||
const void *,
|
||||
size_t
|
||||
);
|
||||
|
||||
int
|
||||
isdigit (
|
||||
int
|
||||
);
|
||||
|
||||
int
|
||||
isspace (
|
||||
int
|
||||
);
|
||||
|
||||
int
|
||||
tolower (
|
||||
int
|
||||
);
|
||||
|
||||
int
|
||||
isupper (
|
||||
int
|
||||
);
|
||||
|
||||
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__));
|
||||
void
|
||||
abort (
|
||||
void
|
||||
) __attribute__ ((__noreturn__));
|
||||
|
||||
#else
|
||||
void abort (void);
|
||||
void
|
||||
abort (
|
||||
void
|
||||
);
|
||||
|
||||
#endif
|
||||
int toupper (int);
|
||||
int Digit2Val (int);
|
||||
time_t time (time_t *);
|
||||
int
|
||||
toupper (
|
||||
int
|
||||
);
|
||||
|
||||
int
|
||||
Digit2Val (
|
||||
int
|
||||
);
|
||||
|
||||
time_t
|
||||
time (
|
||||
time_t *
|
||||
);
|
||||
|
||||
//
|
||||
// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
|
||||
|
@ -6,6 +6,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_HOST_INTERFACE_LIB_H_
|
||||
#define REDFISH_HOST_INTERFACE_LIB_H_
|
||||
|
||||
@ -30,6 +31,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
|
||||
IN UINT8 *DeviceType,
|
||||
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor
|
||||
);
|
||||
|
||||
/**
|
||||
Get platform Redfish host interface protocol data.
|
||||
Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
|
||||
@ -49,4 +51,5 @@ RedfishPlatformHostInterfaceProtocolData (
|
||||
IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
|
||||
IN UINT8 IndexOfProtocolData
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -72,7 +72,6 @@ struct _EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL {
|
||||
EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP Stop;
|
||||
};
|
||||
|
||||
|
||||
extern EFI_GUID gdkIIRedfishConfigHandlerProtocolGuid;
|
||||
|
||||
#endif
|
||||
|
@ -34,7 +34,6 @@ typedef enum {
|
||||
ServiceStopTypeMax
|
||||
} EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE;
|
||||
|
||||
|
||||
/**
|
||||
Retrieve platform's Redfish authentication information.
|
||||
|
||||
|
@ -36,7 +36,6 @@ GetUTF8SizeForUCS2 (
|
||||
|
||||
TempChar = *Utf8Buffer;
|
||||
if ((TempChar & 0xF0) == 0xF0) {
|
||||
|
||||
//
|
||||
// This format is not for UCS2.
|
||||
//
|
||||
@ -46,10 +45,8 @@ GetUTF8SizeForUCS2 (
|
||||
Utf8Size = 1;
|
||||
if ((TempChar & 0x80) == 0x80) {
|
||||
if ((TempChar & 0xC0) == 0xC0) {
|
||||
|
||||
Utf8Size++;
|
||||
if ((TempChar & 0xE0) == 0xE0) {
|
||||
|
||||
Utf8Size++;
|
||||
}
|
||||
}
|
||||
@ -133,23 +130,20 @@ UCS2CharToUTF8 (
|
||||
|
||||
Ucs2Number = (UINT16)Ucs2Char;
|
||||
if (Ucs2Number <= 0x007F) {
|
||||
|
||||
//
|
||||
// UTF8 format: 0xxxxxxx
|
||||
//
|
||||
*Utf8Buffer = Ucs2Char & 0x7F;
|
||||
return 1;
|
||||
|
||||
} else if (Ucs2Number >= 0x0080 && Ucs2Number <= 0x07FF) {
|
||||
|
||||
} else if ((Ucs2Number >= 0x0080) && (Ucs2Number <= 0x07FF)) {
|
||||
//
|
||||
// UTF8 format: 110xxxxx 10xxxxxx
|
||||
//
|
||||
*(Utf8Buffer + 1) = (Ucs2Char & 0x3F) | 0x80;
|
||||
*Utf8Buffer = ((Ucs2Char >> 6) & 0x1F) | 0xC0;
|
||||
return 2;
|
||||
|
||||
} else { /// Ucs2Number >= 0x0800 && Ucs2Number <= 0xFFFF
|
||||
} else {
|
||||
/// Ucs2Number >= 0x0800 && Ucs2Number <= 0xFFFF
|
||||
|
||||
//
|
||||
// UTF8 format: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
@ -190,7 +184,6 @@ UTF8ToUCS2Char (
|
||||
|
||||
Utf8Size = GetUTF8SizeForUCS2 (Utf8Buffer);
|
||||
switch (Utf8Size) {
|
||||
|
||||
case 1:
|
||||
|
||||
//
|
||||
@ -283,7 +276,7 @@ UCS2StrToUTF8 (
|
||||
CHAR8 Utf8Buffer[UTF8_BUFFER_FOR_UCS2_MAX_SIZE];
|
||||
UINT8 Utf8BufferSize;
|
||||
|
||||
if (Ucs2Str == NULL || Utf8StrAddr == NULL) {
|
||||
if ((Ucs2Str == NULL) || (Utf8StrAddr == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -291,7 +284,6 @@ UCS2StrToUTF8 (
|
||||
Utf8StrLength = 0;
|
||||
|
||||
for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex++) {
|
||||
|
||||
ZeroMem (Utf8Buffer, sizeof (Utf8Buffer));
|
||||
Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer);
|
||||
Utf8StrLength += Utf8BufferSize;
|
||||
@ -304,7 +296,6 @@ UCS2StrToUTF8 (
|
||||
|
||||
Utf8StrIndex = 0;
|
||||
for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex++) {
|
||||
|
||||
ZeroMem (Utf8Buffer, sizeof (Utf8Buffer));
|
||||
Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer);
|
||||
|
||||
@ -345,7 +336,7 @@ UTF8StrToUCS2 (
|
||||
UINT8 Utf8BufferSize;
|
||||
CHAR16 *Ucs2StrTemp;
|
||||
|
||||
if (Utf8Str == NULL || Ucs2StrAddr == NULL) {
|
||||
if ((Utf8Str == NULL) || (Ucs2StrAddr == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -368,34 +359,28 @@ UTF8StrToUCS2 (
|
||||
Utf8StrIndex = 0;
|
||||
Ucs2StrIndex = 0;
|
||||
while (Utf8Str[Utf8StrIndex] != '\0') {
|
||||
|
||||
if (CompareMem (Utf8Str + Utf8StrIndex, "\\u", 2) == 0 &&
|
||||
Utf8StrLength - Utf8StrIndex >= UNICODE_FORMAT_LEN) {
|
||||
|
||||
if ((CompareMem (Utf8Str + Utf8StrIndex, "\\u", 2) == 0) &&
|
||||
(Utf8StrLength - Utf8StrIndex >= UNICODE_FORMAT_LEN))
|
||||
{
|
||||
Status = GetUCS2CharByFormat (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
||||
Utf8StrIndex += UNICODE_FORMAT_LEN;
|
||||
Ucs2StrIndex++;
|
||||
} else {
|
||||
|
||||
StrCpyS (Ucs2StrTemp + Ucs2StrIndex, 3, L"\\u");
|
||||
|
||||
Ucs2StrIndex += 2;
|
||||
Utf8StrIndex += 2;
|
||||
}
|
||||
} else {
|
||||
|
||||
Utf8BufferSize = GetUTF8SizeForUCS2 (Utf8Str + Utf8StrIndex);
|
||||
if (Utf8BufferSize == 0 || Utf8StrLength - Utf8StrIndex < Utf8BufferSize) {
|
||||
|
||||
if ((Utf8BufferSize == 0) || (Utf8StrLength - Utf8StrIndex < Utf8BufferSize)) {
|
||||
FreePool (Ucs2StrTemp);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = UTF8ToUCS2Char (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
FreePool (Ucs2StrTemp);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -407,7 +392,6 @@ UTF8StrToUCS2 (
|
||||
|
||||
*Ucs2StrAddr = AllocateZeroPool ((Ucs2StrIndex + 1) * sizeof (CHAR16));
|
||||
if (*Ucs2StrAddr == NULL) {
|
||||
|
||||
FreePool (Ucs2StrTemp);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -418,4 +402,3 @@ UTF8StrToUCS2 (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -48,12 +48,13 @@ RestExLibCreateChild (
|
||||
EFI_REST_EX_SERVICE_INFO *RestExServiceInfo;
|
||||
UINT8 LenOfConfig;
|
||||
|
||||
if (Image == NULL ||
|
||||
AccessMode >= EfiRestExServiceModeMax ||
|
||||
ConfigType >= EfiRestExConfigTypeMax ||
|
||||
ServiceType >= EfiRestExServiceTypeMax ||
|
||||
ChildInstanceHandle == NULL
|
||||
) {
|
||||
if ((Image == NULL) ||
|
||||
(AccessMode >= EfiRestExServiceModeMax) ||
|
||||
(ConfigType >= EfiRestExConfigTypeMax) ||
|
||||
(ServiceType >= EfiRestExServiceTypeMax) ||
|
||||
(ChildInstanceHandle == NULL)
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -70,13 +71,15 @@ RestExLibCreateChild (
|
||||
&NoBuffer,
|
||||
&Handle
|
||||
);
|
||||
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof (EFI_HANDLE) * NoBuffer);
|
||||
if (Handle == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiRestExServiceBindingProtocolGuid,
|
||||
@ -123,6 +126,7 @@ RestExLibCreateChild (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Check REST EX property.
|
||||
//
|
||||
@ -138,13 +142,16 @@ RestExLibCreateChild (
|
||||
default:
|
||||
goto ON_ERROR;
|
||||
}
|
||||
if (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode ||
|
||||
RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType ||
|
||||
RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType ||
|
||||
((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig))) {
|
||||
|
||||
if ((RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode) ||
|
||||
(RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType) ||
|
||||
(RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType) ||
|
||||
((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig)))
|
||||
{
|
||||
goto ON_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This is proper REST EX instance.
|
||||
//
|
||||
@ -160,7 +167,8 @@ ON_ERROR:;
|
||||
ChildHandle
|
||||
);
|
||||
NoBuffer--;
|
||||
};
|
||||
}
|
||||
|
||||
FreePool (Handle);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
@ -422,6 +422,7 @@ JsonValueIsTrue (
|
||||
if (json_is_true ((json_t *)Json)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -443,8 +444,10 @@ JsonValueIsFalse (
|
||||
if (json_is_false ((json_t *)Json)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
The function is used to return if the provided JSON value contains a JSON NULL.
|
||||
|
||||
@ -479,7 +482,7 @@ JsonValueGetArray (
|
||||
IN EDKII_JSON_VALUE Json
|
||||
)
|
||||
{
|
||||
if (Json == NULL || !JsonValueIsArray (Json)) {
|
||||
if ((Json == NULL) || !JsonValueIsArray (Json)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -502,7 +505,7 @@ JsonValueGetObject (
|
||||
IN EDKII_JSON_VALUE Json
|
||||
)
|
||||
{
|
||||
if (Json == NULL || !JsonValueIsObject (Json)) {
|
||||
if ((Json == NULL) || !JsonValueIsObject (Json)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -597,7 +600,7 @@ JsonValueGetInteger (
|
||||
)
|
||||
{
|
||||
ASSERT (Json != NULL && JsonValueIsInteger (Json));
|
||||
if (Json == NULL || !JsonValueIsInteger (Json)) {
|
||||
if ((Json == NULL) || !JsonValueIsInteger (Json)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -622,7 +625,7 @@ JsonValueGetBoolean (
|
||||
)
|
||||
{
|
||||
ASSERT (Json != NULL && JsonValueIsBoolean (Json));
|
||||
if (Json == NULL || !JsonValueIsBoolean (Json)) {
|
||||
if ((Json == NULL) || !JsonValueIsBoolean (Json)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -685,13 +688,12 @@ JsonObjectGetKeys (
|
||||
OUT UINTN *KeyCount
|
||||
)
|
||||
{
|
||||
|
||||
UINTN Index;
|
||||
CONST CHAR8 **KeyArray;
|
||||
CONST CHAR8 *Key;
|
||||
EDKII_JSON_VALUE Value;
|
||||
|
||||
if (JsonObj == NULL || KeyCount == NULL) {
|
||||
if ((JsonObj == NULL) || (KeyCount == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -911,6 +913,7 @@ JsonDumpString (
|
||||
if (JsonValue == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return json_dumps ((json_t *)JsonValue, Flags);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@
|
||||
**/
|
||||
#include <Uefi.h>
|
||||
#include <Protocol/EdkIIRedfishCredential.h>
|
||||
|
||||
/**
|
||||
Notification of Exit Boot Service.
|
||||
|
||||
@ -98,4 +99,3 @@ LibStopRedfishService (
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
|
||||
{
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
Get platform Redfish host interface protocol data.
|
||||
Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
|
||||
|
@ -7,6 +7,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_CRT_STDARG_H_
|
||||
#define REDFISH_CRT_STDARG_H_
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_CRT_STDIO_H_
|
||||
#define REDFISH_CRT_STDIO_H_
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_CRT_SYS_TIME_H_
|
||||
#define REDFISH_CRT_SYS_TIME_H_
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_CRT_SYS_TYPES_H_
|
||||
#define REDFISH_CRT_SYS_TYPES_H_
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef REDFISH_CRT_TIME_H_
|
||||
#define REDFISH_CRT_TIME_H_
|
||||
|
||||
|
@ -471,6 +471,7 @@ VOID
|
||||
RedfishDumpPayload (
|
||||
IN REDFISH_PAYLOAD Payload
|
||||
);
|
||||
|
||||
/**
|
||||
Dump text in JSON value.
|
||||
|
||||
@ -481,6 +482,7 @@ VOID
|
||||
RedfishDumpJson (
|
||||
IN EDKII_JSON_VALUE JsonValue
|
||||
);
|
||||
|
||||
/**
|
||||
This function will cleanup the HTTP header and Redfish payload resources.
|
||||
|
||||
@ -529,6 +531,7 @@ BOOLEAN
|
||||
RedfishIsPayloadCollection (
|
||||
IN REDFISH_PAYLOAD Payload
|
||||
);
|
||||
|
||||
/**
|
||||
Get collection size.
|
||||
|
||||
@ -543,6 +546,7 @@ RedfishGetCollectionSize(
|
||||
IN REDFISH_PAYLOAD Payload,
|
||||
IN UINTN *CollectionSize
|
||||
);
|
||||
|
||||
/**
|
||||
Get Redfish payload of collection member
|
||||
|
||||
@ -608,4 +612,5 @@ RedfishBuildRedpathUseId (
|
||||
IN CHAR8 *Id,
|
||||
OUT CHAR8 **Redpath
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -24,7 +24,10 @@ int _fltused = 1;
|
||||
Determine if a particular character is an alphanumeric character
|
||||
@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]
|
||||
@ -39,7 +42,10 @@ int isalnum (int c)
|
||||
|
||||
@return Returns 1 if c is an digital character, otherwise returns 0.
|
||||
**/
|
||||
int isdchar (int c)
|
||||
int
|
||||
isdchar (
|
||||
int c
|
||||
)
|
||||
{
|
||||
//
|
||||
// [0-9] | [e +-.]
|
||||
@ -55,7 +61,10 @@ int isdchar (int c)
|
||||
|
||||
@return Returns 1 if c is a space character
|
||||
**/
|
||||
int isspace (int c)
|
||||
int
|
||||
isspace (
|
||||
int c
|
||||
)
|
||||
{
|
||||
//
|
||||
// <space> ::= [ ]
|
||||
@ -66,7 +75,10 @@ int isspace (int c)
|
||||
/**
|
||||
Allocates memory blocks
|
||||
*/
|
||||
void *malloc (size_t size)
|
||||
void *
|
||||
malloc (
|
||||
size_t size
|
||||
)
|
||||
{
|
||||
return AllocatePool ((UINTN)size);
|
||||
}
|
||||
@ -74,7 +86,10 @@ void *malloc (size_t size)
|
||||
/**
|
||||
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
|
||||
@ -90,14 +105,19 @@ void free (void *ptr)
|
||||
|
||||
@return Returns the pointer to duplicated string.
|
||||
**/
|
||||
char * strdup(const char *str)
|
||||
char *
|
||||
strdup (
|
||||
const char *str
|
||||
)
|
||||
{
|
||||
size_t len;
|
||||
char *copy;
|
||||
|
||||
len = strlen (str) + 1;
|
||||
if ((copy = malloc(len)) == NULL)
|
||||
if ((copy = malloc (len)) == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
memcpy (copy, str, len);
|
||||
return (copy);
|
||||
}
|
||||
@ -122,6 +142,7 @@ toupper(
|
||||
if ((c >= 'a') && (c <= 'z')) {
|
||||
c = c - ('a' - 'A');
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -131,15 +152,18 @@ toupper(
|
||||
@return Returns the value of digit.
|
||||
**/
|
||||
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'))) {
|
||||
/* 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.
|
||||
}
|
||||
|
||||
|
||||
/** The strtoll function converts the initial portion of the string pointed to
|
||||
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.
|
||||
**/
|
||||
long long
|
||||
strtoll(const char * nptr, char ** endptr, int base)
|
||||
strtoll (
|
||||
const char *nptr,
|
||||
char **endptr,
|
||||
int base
|
||||
)
|
||||
{
|
||||
const char *pEnd;
|
||||
long long Result = 0;
|
||||
@ -166,59 +194,73 @@ strtoll(const char * nptr, char ** endptr, int base)
|
||||
if (endptr != NULL) {
|
||||
*endptr = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Skip leading spaces.
|
||||
while(isspace(*nptr)) ++nptr;
|
||||
while (isspace (*nptr)) {
|
||||
++nptr;
|
||||
}
|
||||
|
||||
// Process Subject sequence: optional sign followed by digits.
|
||||
if (*nptr == '+') {
|
||||
Negative = FALSE;
|
||||
++nptr;
|
||||
}
|
||||
else if(*nptr == '-') {
|
||||
} else if (*nptr == '-') {
|
||||
Negative = TRUE;
|
||||
++nptr;
|
||||
}
|
||||
|
||||
if(*nptr == '0') { /* Might be Octal or Hex */
|
||||
if(toupper(nptr[1]) == 'X') { /* Looks like Hex */
|
||||
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" */
|
||||
base = 16; /* In case base was 0 */
|
||||
}
|
||||
}
|
||||
else { /* Looks like Octal */
|
||||
} else {
|
||||
/* Looks like Octal */
|
||||
if ((base == 0) || (base == 8)) {
|
||||
++nptr; /* Skip the leading "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;
|
||||
}
|
||||
|
||||
if (*nptr == '0') {
|
||||
for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */
|
||||
for ( ; *nptr == '0'; ++nptr) {
|
||||
/* Skip any remaining leading zeros */
|
||||
}
|
||||
|
||||
pEnd = nptr;
|
||||
}
|
||||
|
||||
while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
|
||||
Previous = Result;
|
||||
Result = MultS64x64 (Result, base) + (long long int)temp;
|
||||
if( Result <= Previous) { // Detect Overflow
|
||||
if ( Result <= Previous) {
|
||||
// Detect Overflow
|
||||
if (Negative) {
|
||||
Result = LLONG_MIN;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Result = LLONG_MAX;
|
||||
}
|
||||
|
||||
Negative = FALSE;
|
||||
errno = ERANGE;
|
||||
break;
|
||||
}
|
||||
|
||||
pEnd = ++nptr;
|
||||
}
|
||||
|
||||
if (Negative) {
|
||||
Result = -Result;
|
||||
}
|
||||
@ -227,6 +269,7 @@ strtoll(const char * nptr, char ** endptr, int base)
|
||||
if (endptr != NULL) {
|
||||
*endptr = (char *)pEnd;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
@ -285,7 +328,11 @@ strtoll(const char * nptr, char ** endptr, int base)
|
||||
is stored in errno.
|
||||
**/
|
||||
long
|
||||
strtol(const char * nptr, char ** endptr, int base)
|
||||
strtol (
|
||||
const char *nptr,
|
||||
char **endptr,
|
||||
int base
|
||||
)
|
||||
{
|
||||
const char *pEnd;
|
||||
long Result = 0;
|
||||
@ -299,59 +346,73 @@ strtol(const char * nptr, char ** endptr, int base)
|
||||
if (endptr != NULL) {
|
||||
*endptr = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Skip leading spaces.
|
||||
while(isspace(*nptr)) ++nptr;
|
||||
while (isspace (*nptr)) {
|
||||
++nptr;
|
||||
}
|
||||
|
||||
// Process Subject sequence: optional sign followed by digits.
|
||||
if (*nptr == '+') {
|
||||
Negative = FALSE;
|
||||
++nptr;
|
||||
}
|
||||
else if(*nptr == '-') {
|
||||
} else if (*nptr == '-') {
|
||||
Negative = TRUE;
|
||||
++nptr;
|
||||
}
|
||||
|
||||
if(*nptr == '0') { /* Might be Octal or Hex */
|
||||
if(toupper(nptr[1]) == 'X') { /* Looks like Hex */
|
||||
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" */
|
||||
base = 16; /* In case base was 0 */
|
||||
}
|
||||
}
|
||||
else { /* Looks like Octal */
|
||||
} else {
|
||||
/* Looks like Octal */
|
||||
if ((base == 0) || (base == 8)) {
|
||||
++nptr; /* Skip the leading "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;
|
||||
}
|
||||
|
||||
if (*nptr == '0') {
|
||||
for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */
|
||||
for ( ; *nptr == '0'; ++nptr) {
|
||||
/* Skip any remaining leading zeros */
|
||||
}
|
||||
|
||||
pEnd = nptr;
|
||||
}
|
||||
|
||||
while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
|
||||
Previous = Result;
|
||||
Result = (Result * base) + (long int)temp;
|
||||
if( Result <= Previous) { // Detect Overflow
|
||||
if ( Result <= Previous) {
|
||||
// Detect Overflow
|
||||
if (Negative) {
|
||||
Result = LONG_MIN;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Result = LONG_MAX;
|
||||
}
|
||||
|
||||
Negative = FALSE;
|
||||
errno = ERANGE;
|
||||
break;
|
||||
}
|
||||
|
||||
pEnd = ++nptr;
|
||||
}
|
||||
|
||||
if (Negative) {
|
||||
Result = -Result;
|
||||
}
|
||||
@ -360,6 +421,7 @@ strtol(const char * nptr, char ** endptr, int base)
|
||||
if (endptr != NULL) {
|
||||
*endptr = (char *)pEnd;
|
||||
}
|
||||
|
||||
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.
|
||||
**/
|
||||
unsigned long long
|
||||
strtoull(const char * nptr, char ** endptr, int base)
|
||||
strtoull (
|
||||
const char *nptr,
|
||||
char **endptr,
|
||||
int base
|
||||
)
|
||||
{
|
||||
const char *pEnd;
|
||||
unsigned long long Result = 0;
|
||||
@ -387,46 +453,60 @@ strtoull(const char * nptr, char ** endptr, int base)
|
||||
if (endptr != NULL) {
|
||||
*endptr = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Skip leading spaces.
|
||||
while(isspace(*nptr)) ++nptr;
|
||||
while (isspace (*nptr)) {
|
||||
++nptr;
|
||||
}
|
||||
|
||||
// Process Subject sequence: optional + sign followed by digits.
|
||||
if (*nptr == '+') {
|
||||
++nptr;
|
||||
}
|
||||
|
||||
if(*nptr == '0') { /* Might be Octal or Hex */
|
||||
if(toupper(nptr[1]) == 'X') { /* Looks like Hex */
|
||||
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" */
|
||||
base = 16; /* In case base was 0 */
|
||||
}
|
||||
}
|
||||
else { /* Looks like Octal */
|
||||
} else {
|
||||
/* Looks like Octal */
|
||||
if ((base == 0) || (base == 8)) {
|
||||
++nptr; /* Skip the leading "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;
|
||||
}
|
||||
|
||||
if (*nptr == '0') {
|
||||
for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */
|
||||
for ( ; *nptr == '0'; ++nptr) {
|
||||
/* Skip any remaining leading zeros */
|
||||
}
|
||||
|
||||
pEnd = nptr;
|
||||
}
|
||||
|
||||
while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
|
||||
Previous = Result;
|
||||
Result = DivU64x32 (Result, base) + (unsigned long long)temp;
|
||||
if( Result < Previous) { // If we overflowed
|
||||
if ( Result < Previous) {
|
||||
// If we overflowed
|
||||
Result = ULLONG_MAX;
|
||||
errno = ERANGE;
|
||||
break;
|
||||
}
|
||||
|
||||
pEnd = ++nptr;
|
||||
}
|
||||
|
||||
@ -434,6 +514,7 @@ strtoull(const char * nptr, char ** endptr, int base)
|
||||
if (endptr != NULL) {
|
||||
*endptr = (char *)pEnd;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
@ -462,8 +543,11 @@ strtoull(const char * nptr, char ** endptr, int base)
|
||||
@return Return 0.
|
||||
**/
|
||||
double
|
||||
strtod (const char * __restrict nptr, char ** __restrict endptr) {
|
||||
|
||||
strtod (
|
||||
const char *__restrict nptr,
|
||||
char **__restrict endptr
|
||||
)
|
||||
{
|
||||
DEBUG ((DEBUG_INFO, "We don't supprot double type on edk2 yet!"));
|
||||
ASSERT (FALSE);
|
||||
return (double)0;
|
||||
@ -479,7 +563,11 @@ static UINT8 BitMask[] = {
|
||||
|
||||
static
|
||||
void
|
||||
BuildBitmap(unsigned char * bitmap, const char *s2, int n)
|
||||
BuildBitmap (
|
||||
unsigned char *bitmap,
|
||||
const char *s2,
|
||||
int n
|
||||
)
|
||||
{
|
||||
unsigned char bit;
|
||||
int index;
|
||||
@ -504,7 +592,10 @@ BuildBitmap(unsigned char * bitmap, const char *s2, int n)
|
||||
null pointer if no character from s2 occurs in s1.
|
||||
**/
|
||||
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 bit;
|
||||
@ -519,6 +610,7 @@ strpbrk(const char *s1, const char *s2)
|
||||
return (char *)s1;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -535,7 +627,9 @@ strpbrk(const char *s1, const char *s2)
|
||||
a subsequent call to the strerror function.
|
||||
**/
|
||||
char *
|
||||
strerror(int errnum)
|
||||
strerror (
|
||||
int errnum
|
||||
)
|
||||
{
|
||||
return errnum_message;
|
||||
}
|
||||
@ -544,7 +638,10 @@ strerror(int errnum)
|
||||
Allocate and zero-initialize array.
|
||||
**/
|
||||
void *
|
||||
calloc(size_t Num, size_t Size)
|
||||
calloc (
|
||||
size_t Num,
|
||||
size_t Size
|
||||
)
|
||||
{
|
||||
void *RetVal;
|
||||
size_t NumSize;
|
||||
@ -557,6 +654,7 @@ calloc(size_t Num, size_t Size)
|
||||
(VOID)ZeroMem (RetVal, NumSize);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_POOL, "0x%p = calloc(%d, %d)\n", RetVal, Num, Size));
|
||||
|
||||
return RetVal;
|
||||
@ -610,7 +708,10 @@ UINTN CumulativeDays[2][14] = {
|
||||
/**
|
||||
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;
|
||||
time_t CalTime;
|
||||
@ -650,9 +751,14 @@ time_t time (time_t *timer)
|
||||
/**
|
||||
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 (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
|
||||
|
||||
**/
|
||||
int fgetc(FILE * _File){
|
||||
int
|
||||
fgetc (
|
||||
FILE *_File
|
||||
)
|
||||
{
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
Open stream file, we don't support file operastion on edk2 JSON library.
|
||||
|
||||
@return 0 Unsupported
|
||||
|
||||
**/
|
||||
FILE *fopen (const char *filename, const char *mode) {
|
||||
FILE *
|
||||
fopen (
|
||||
const char *filename,
|
||||
const char *mode
|
||||
)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
Read stream from file, we don't support file operastion on edk2 JSON library.
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
/**
|
||||
Write stream from file, we don't support file operastion on edk2 JSON library.
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
/**
|
||||
Close file, we don't support file operastion on edk2 JSON library.
|
||||
|
||||
@return 0 Unsupported
|
||||
|
||||
**/
|
||||
int fclose (FILE * stream) {
|
||||
int
|
||||
fclose (
|
||||
FILE *stream
|
||||
)
|
||||
{
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
Write the formatted string to file, we don't support file operastion on edk2 JSON library.
|
||||
|
||||
@return 0 Unsupported
|
||||
|
||||
**/
|
||||
int fprintf (FILE * stream, const char * format, ...) {
|
||||
int
|
||||
fprintf (
|
||||
FILE *stream,
|
||||
const char *format,
|
||||
...
|
||||
)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
This function check if this is the formating string specifier.
|
||||
|
||||
@ -749,14 +894,17 @@ CheckFormatingString (
|
||||
(FormatStringParamater != '*') &&
|
||||
(FormatStringParamater != '.') &&
|
||||
!(((UINTN)FormatStringParamater >= (UINTN)'0') && ((UINTN)FormatStringParamater <= (UINTN)'9'))
|
||||
) {
|
||||
)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
(*CurrentPosition)++;
|
||||
if (*CurrentPosition >= StrLength) {
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -788,15 +936,18 @@ ReplaceUnicodeToAsciiStrFormat (
|
||||
if (FormatString == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FormatStrSize = AsciiStrSize (FormatString);
|
||||
if (FormatStrSize == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TempFormatBuffer = AllocatePool (FormatStrSize); // Allocate memory for the
|
||||
// new string.
|
||||
if (TempFormatBuffer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Clone *FormatString but replace "%s" wih "%a".
|
||||
// "%%" is not considered as the format tag.
|
||||
@ -809,18 +960,21 @@ ReplaceUnicodeToAsciiStrFormat (
|
||||
// Previous character is "%".
|
||||
//
|
||||
PercentageMark = FALSE;
|
||||
if (*(FormatString + FormatStrIndex) != '%') { // Check if this is double "%".
|
||||
if (*(FormatString + FormatStrIndex) != '%') {
|
||||
// Check if this is double "%".
|
||||
FormatStrSpecifier = FormatStrIndex;
|
||||
//
|
||||
// Check if this is the formating string specifier.
|
||||
//
|
||||
IsFormatString = CheckFormatingString (FormatString, &FormatStrSpecifier, FormatStrSize);
|
||||
if ((FormatStrSpecifier - FormatStrIndex) != 0) {
|
||||
CopyMem((VOID *)(TempFormatBuffer + FormatStrIndex),
|
||||
CopyMem (
|
||||
(VOID *)(TempFormatBuffer + FormatStrIndex),
|
||||
(VOID *)(FormatString + FormatStrIndex),
|
||||
FormatStrSpecifier - FormatStrIndex
|
||||
);
|
||||
}
|
||||
|
||||
FormatStrIndex = FormatStrSpecifier;
|
||||
if (IsFormatString == TRUE) {
|
||||
//
|
||||
@ -830,16 +984,20 @@ ReplaceUnicodeToAsciiStrFormat (
|
||||
*(TempFormatBuffer + FormatStrSpecifier) = 'a';
|
||||
FormatStrIndex++;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
goto ContinueCheck;
|
||||
}
|
||||
|
||||
if (*(FormatString + FormatStrIndex) == '%') {
|
||||
//
|
||||
// This character is "%", set the flag.
|
||||
//
|
||||
PercentageMark = TRUE;
|
||||
}
|
||||
|
||||
ContinueCheck:
|
||||
//
|
||||
// Clone character to the new string and advance FormatStrIndex
|
||||
@ -847,7 +1005,8 @@ ContinueCheck:
|
||||
//
|
||||
*(TempFormatBuffer + FormatStrIndex) = *(FormatString + FormatStrIndex);
|
||||
FormatStrIndex++;
|
||||
};
|
||||
}
|
||||
|
||||
return TempFormatBuffer;
|
||||
}
|
||||
|
||||
@ -888,6 +1047,7 @@ RedfishAsciiVSPrint (
|
||||
if (TempFormatBuffer == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
LenStrProduced = AsciiVSPrint (StartOfBuffer, BufferSize, (CONST CHAR8 *)TempFormatBuffer, Marker);
|
||||
FreePool (TempFormatBuffer);
|
||||
return LenStrProduced;
|
||||
@ -926,4 +1086,3 @@ RedfishAsciiSPrint (
|
||||
LenStrProduced = RedfishAsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
|
||||
return LenStrProduced;
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ ON_EXIT:
|
||||
if (UserId != NULL) {
|
||||
FreePool (UserId);
|
||||
}
|
||||
|
||||
if (Password != NULL) {
|
||||
FreePool (Password);
|
||||
}
|
||||
@ -94,6 +95,7 @@ RedfishCleanupService (
|
||||
|
||||
cleanupServiceEnumerator (RedfishService);
|
||||
}
|
||||
|
||||
/**
|
||||
Create REDFISH_PAYLOAD instance in local with JSON represented resource value and
|
||||
the Redfish Service.
|
||||
@ -209,6 +211,7 @@ RedfishBuildPathWithSystemUuid (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// AsciiStrLen ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") = 36
|
||||
BufSize = AsciiStrSize (RedPath) + AsciiStrLen ("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
|
||||
} else {
|
||||
@ -219,13 +222,16 @@ RedfishBuildPathWithSystemUuid (
|
||||
if (RetRedPath == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (FromSmbios) {
|
||||
AsciiSPrint (RetRedPath, BufSize, RedPath, &SystemUuid);
|
||||
} else {
|
||||
AsciiSPrint (RetRedPath, BufSize, RedPath, IdString);
|
||||
}
|
||||
|
||||
return RetRedPath;
|
||||
}
|
||||
|
||||
/**
|
||||
Get a redfish response addressed by a RedPath string, including HTTP StatusCode, Headers
|
||||
and Payload which record any HTTP response messages.
|
||||
@ -257,7 +263,7 @@ RedfishGetByService (
|
||||
OUT REDFISH_RESPONSE *RedResponse
|
||||
)
|
||||
{
|
||||
if (RedfishService == NULL || RedPath == NULL || RedResponse == NULL) {
|
||||
if ((RedfishService == NULL) || (RedPath == NULL) || (RedResponse == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -269,7 +275,7 @@ RedfishGetByService (
|
||||
// 1. If the returned Payload 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;
|
||||
}
|
||||
|
||||
@ -278,13 +284,15 @@ RedfishGetByService (
|
||||
// NOTE: If there is any error message returned from server, it will be returned in
|
||||
// Payload within RedResponse.
|
||||
//
|
||||
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
|
||||
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
|
||||
if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
|
||||
(*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
|
||||
{
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Get a redfish response addressed by URI, including HTTP StatusCode, Headers
|
||||
and Payload which record any HTTP response messages.
|
||||
@ -317,7 +325,7 @@ RedfishGetByUri (
|
||||
{
|
||||
EDKII_JSON_VALUE JsonValue;
|
||||
|
||||
if (RedfishService == NULL || Uri == NULL || RedResponse == NULL) {
|
||||
if ((RedfishService == NULL) || (Uri == NULL) || (RedResponse == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -330,7 +338,7 @@ RedfishGetByUri (
|
||||
// 1. If the returned Payload 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;
|
||||
}
|
||||
|
||||
@ -339,12 +347,15 @@ RedfishGetByUri (
|
||||
// NOTE: If there is any error message returned from server, it will be returned in
|
||||
// Payload within RedResponse.
|
||||
//
|
||||
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
|
||||
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
|
||||
if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
|
||||
(*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
|
||||
{
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
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.
|
||||
@ -379,7 +390,7 @@ RedfishGetByPayload (
|
||||
OUT REDFISH_RESPONSE *RedResponse
|
||||
)
|
||||
{
|
||||
if (Payload == NULL || RedPath == NULL || RedResponse == NULL) {
|
||||
if ((Payload == NULL) || (RedPath == NULL) || (RedResponse == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -400,15 +411,17 @@ RedfishGetByPayload (
|
||||
// NOTE: If there is any error message returned from server, it will be returned in
|
||||
// Payload within RedResponse.
|
||||
//
|
||||
if (RedResponse->StatusCode != NULL && \
|
||||
(*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
|
||||
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT
|
||||
)) {
|
||||
if ((RedResponse->StatusCode != NULL) && \
|
||||
((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
|
||||
(*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)
|
||||
))
|
||||
{
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Use HTTP PATCH to perform updates on pre-existing Redfish resource.
|
||||
|
||||
@ -454,7 +467,7 @@ RedfishPatchToUri (
|
||||
Status = EFI_SUCCESS;
|
||||
JsonValue = NULL;
|
||||
|
||||
if (RedfishService == NULL || Uri == NULL || Content == NULL || RedResponse == NULL) {
|
||||
if ((RedfishService == NULL) || (Uri == NULL) || (Content == NULL) || (RedResponse == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -480,8 +493,9 @@ RedfishPatchToUri (
|
||||
// NOTE: If there is any error message returned from server, it will be returned in
|
||||
// Payload within RedResponse.
|
||||
//
|
||||
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
|
||||
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
|
||||
if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
|
||||
(*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
|
||||
{
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@ -499,6 +513,7 @@ ON_EXIT:
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Use HTTP PATCH to perform updates on target payload. Patch to odata.id in Payload directly.
|
||||
|
||||
@ -535,7 +550,7 @@ RedfishPatchToPayload (
|
||||
OUT REDFISH_RESPONSE *RedResponse
|
||||
)
|
||||
{
|
||||
if (Target == NULL || Payload == NULL || RedResponse == NULL) {
|
||||
if ((Target == NULL) || (Payload == NULL) || (RedResponse == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -559,13 +574,15 @@ RedfishPatchToPayload (
|
||||
// NOTE: If there is any error message returned from server, it will be returned in
|
||||
// Payload within RedResponse.
|
||||
//
|
||||
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
|
||||
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
|
||||
if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
|
||||
(*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
|
||||
{
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Use HTTP POST to create a new resource in target payload.
|
||||
|
||||
@ -601,7 +618,7 @@ RedfishPostToPayload (
|
||||
OUT REDFISH_RESPONSE *RedResponse
|
||||
)
|
||||
{
|
||||
if (Target == NULL || Payload == NULL || RedResponse == NULL) {
|
||||
if ((Target == NULL) || (Payload == NULL) || (RedResponse == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -625,13 +642,15 @@ RedfishPostToPayload (
|
||||
// NOTE: If there is any error message returned from server, it will be returned in
|
||||
// Payload within RedResponse.
|
||||
//
|
||||
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
|
||||
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
|
||||
if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
|
||||
(*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
|
||||
{
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Use HTTP DELETE to remove a resource.
|
||||
|
||||
@ -673,7 +692,7 @@ RedfishDeleteByUri (
|
||||
Status = EFI_SUCCESS;
|
||||
JsonValue = NULL;
|
||||
|
||||
if (RedfishService == NULL || Uri == NULL || RedResponse == NULL) {
|
||||
if ((RedfishService == NULL) || (Uri == NULL) || (RedResponse == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -698,8 +717,9 @@ RedfishDeleteByUri (
|
||||
// NOTE: If there is any error message returned from server, it will be returned in
|
||||
// Payload within RedResponse.
|
||||
//
|
||||
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
|
||||
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
|
||||
if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
|
||||
(*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
|
||||
{
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@ -717,6 +737,7 @@ ON_EXIT:
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Dump text in fractions.
|
||||
|
||||
@ -745,6 +766,7 @@ RedfishDumpJsonStringFractions (
|
||||
if (StrLen == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Count = 0; Count < (StrLen / StringFractionSize); Count++) {
|
||||
BackupChar = *(NextFraction + StringFractionSize);
|
||||
*(NextFraction + StringFractionSize) = 0;
|
||||
@ -752,10 +774,12 @@ RedfishDumpJsonStringFractions (
|
||||
*(NextFraction + StringFractionSize) = BackupChar;
|
||||
NextFraction += StringFractionSize;
|
||||
}
|
||||
|
||||
if ((StrLen % StringFractionSize) != 0) {
|
||||
DEBUG ((DEBUG_INFO, "%a\n\n", NextFraction));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Dump text in JSON value.
|
||||
|
||||
@ -773,9 +797,11 @@ RedfishDumpJson (
|
||||
if (String == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
RedfishDumpJsonStringFractions (String);
|
||||
FreePool (String);
|
||||
}
|
||||
|
||||
/**
|
||||
Extract the JSON text content from REDFISH_PAYLOAD and dump to debug console.
|
||||
|
||||
@ -810,6 +836,7 @@ RedfishDumpPayload (
|
||||
RedfishDumpJsonStringFractions (String);
|
||||
FreePool (String);
|
||||
}
|
||||
|
||||
/**
|
||||
This function will cleanup the HTTP header and Redfish payload resources.
|
||||
|
||||
@ -832,7 +859,7 @@ RedfishFreeResponse (
|
||||
StatusCode = NULL;
|
||||
}
|
||||
|
||||
if (HeaderCount != 0 && Headers != NULL) {
|
||||
if ((HeaderCount != 0) && (Headers != NULL)) {
|
||||
HttpFreeHeaderFields (Headers, HeaderCount);
|
||||
Headers = NULL;
|
||||
}
|
||||
@ -842,6 +869,7 @@ RedfishFreeResponse (
|
||||
Payload = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Check if the "@odata.type" in Payload is valid or not.
|
||||
|
||||
@ -865,7 +893,7 @@ RedfishIsValidOdataType (
|
||||
EDKII_JSON_VALUE OdataType;
|
||||
EDKII_JSON_VALUE JsonValue;
|
||||
|
||||
if (Payload == NULL || OdataTypeName == NULL) {
|
||||
if ((Payload == NULL) || (OdataTypeName == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -875,19 +903,22 @@ RedfishIsValidOdataType (
|
||||
}
|
||||
|
||||
OdataType = JsonObjectGetValue (JsonValueGetObject (JsonValue), "@odata.type");
|
||||
if (!JsonValueIsString (OdataType) || JsonValueGetAsciiString (OdataType) == NULL) {
|
||||
if (!JsonValueIsString (OdataType) || (JsonValueGetAsciiString (OdataType) == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < OdataTypeMappingListSize; Index++) {
|
||||
if (AsciiStrCmp (OdataTypeMappingList[Index].OdataTypeName, OdataTypeName) == 0 &&
|
||||
AsciiStrCmp (OdataTypeMappingList[Index].OdataType, JsonValueGetAsciiString (OdataType)) == 0) {
|
||||
if ((AsciiStrCmp (OdataTypeMappingList[Index].OdataTypeName, OdataTypeName) == 0) &&
|
||||
(AsciiStrCmp (OdataTypeMappingList[Index].OdataType, JsonValueGetAsciiString (OdataType)) == 0))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a: This Odata type is not in the list.\n", __FUNCTION__));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
Check if the payload is collection
|
||||
|
||||
@ -903,6 +934,7 @@ RedfishIsPayloadCollection (
|
||||
{
|
||||
return isPayloadCollection (Payload);
|
||||
}
|
||||
|
||||
/**
|
||||
Get collection size.
|
||||
|
||||
@ -918,9 +950,10 @@ RedfishGetCollectionSize(
|
||||
IN UINTN *CollectionSize
|
||||
)
|
||||
{
|
||||
if (Payload == NULL || CollectionSize == NULL) {
|
||||
if ((Payload == NULL) || (CollectionSize == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (!RedfishIsPayloadCollection (Payload)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -928,6 +961,7 @@ RedfishGetCollectionSize(
|
||||
*CollectionSize = (UINTN)getCollectionSize (Payload);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Get Redfish payload of collection member
|
||||
|
||||
@ -947,12 +981,15 @@ RedfishGetPayloadByIndex (
|
||||
REDFISH_PAYLOAD PayloadReturn;
|
||||
|
||||
PayloadReturn = (VOID *)getPayloadByIndex (Payload, Index, &RedfishResponse.StatusCode);
|
||||
if(PayloadReturn == NULL ||
|
||||
(*(RedfishResponse.StatusCode) < HTTP_STATUS_200_OK && *(RedfishResponse.StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)){
|
||||
if ((PayloadReturn == NULL) ||
|
||||
((*(RedfishResponse.StatusCode) < HTTP_STATUS_200_OK) && (*(RedfishResponse.StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PayloadReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
Check and return Redfish resource of the given Redpath.
|
||||
|
||||
@ -975,10 +1012,12 @@ RedfishCheckIfRedpathExist (
|
||||
if (Redpath == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = RedfishGetByService (RedfishService, Redpath, &TempResponse);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (Response == NULL) {
|
||||
RedfishFreeResponse (
|
||||
TempResponse.StatusCode,
|
||||
@ -989,5 +1028,6 @@ RedfishCheckIfRedpathExist (
|
||||
} else {
|
||||
CopyMem ((VOID *)Response, (VOID *)&TempResponse, sizeof (REDFISH_RESPONSE));
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -31,17 +31,20 @@ RedfishGetServiceVersion (
|
||||
CHAR8 **KeysArray;
|
||||
UINTN KeysNum;
|
||||
|
||||
if (RedfishService == NULL || ServiceVersionStr == NULL) {
|
||||
if ((RedfishService == NULL) || (ServiceVersionStr == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Redfish = (redfishService *)RedfishService;
|
||||
if (Redfish->versions == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
KeysArray = JsonObjectGetKeys (Redfish->versions, &KeysNum);
|
||||
if (KeysNum == 0 || KeysArray == NULL) {
|
||||
if ((KeysNum == 0) || (KeysArray == NULL)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
*ServiceVersionStr = *KeysArray;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -71,7 +74,6 @@ RedfishCreateLibredfishService (
|
||||
IN CHAR8 *Password
|
||||
)
|
||||
{
|
||||
|
||||
UINTN Flags;
|
||||
enumeratorAuthentication Auth;
|
||||
redfishService *Redfish;
|
||||
@ -84,6 +86,7 @@ RedfishCreateLibredfishService (
|
||||
} else if (AuthMethod == AuthMethodRedfishSession) {
|
||||
Auth.authType = REDFISH_AUTH_SESSION;
|
||||
}
|
||||
|
||||
Auth.authCodes.userPass.username = UserId;
|
||||
Auth.authCodes.userPass.password = Password;
|
||||
|
||||
@ -137,7 +140,7 @@ RedfishGetAuthInfo (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (AuthMethod == NULL || UserId == NULL || Password == NULL) {
|
||||
if ((AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -161,6 +164,7 @@ RedfishGetAuthInfo (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
This function returns the string of Redfish service version.
|
||||
|
||||
@ -183,7 +187,7 @@ RedfishBuildRedpathUseId (
|
||||
{
|
||||
UINTN RedpathSize;
|
||||
|
||||
if (Redpath == NULL || ServiceVerisonStr == NULL || Url == NULL || Id == NULL) {
|
||||
if ((Redpath == NULL) || (ServiceVerisonStr == NULL) || (Url == NULL) || (Id == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -196,6 +200,7 @@ RedfishBuildRedpathUseId (
|
||||
if (*Redpath == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=%a]", ServiceVerisonStr, Url, Id);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef LIBREDFISH_REDFISH_H_
|
||||
#define LIBREDFISH_REDFISH_H_
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef LIBREDFISH_REDFISH_PAYLOAD_H_
|
||||
#define LIBREDFISH_REDFISH_PAYLOAD_H_
|
||||
|
||||
@ -23,17 +24,83 @@
|
||||
#include <redfishService.h>
|
||||
#include <redpath.h>
|
||||
|
||||
redfishPayload* createRedfishPayload(json_t* value, redfishService* service);
|
||||
redfishPayload* getPayloadByNodeName(redfishPayload* payload, const char* nodeName, 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);
|
||||
redfishPayload *
|
||||
createRedfishPayload (
|
||||
json_t *value,
|
||||
redfishService *service
|
||||
);
|
||||
|
||||
redfishPayload *
|
||||
getPayloadByNodeName (
|
||||
redfishPayload *payload,
|
||||
const char *nodeName,
|
||||
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
|
||||
|
@ -89,13 +89,63 @@ typedef struct {
|
||||
|
||||
// Values for flags
|
||||
#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);
|
||||
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);
|
||||
redfishService *
|
||||
createServiceEnumerator (
|
||||
REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo,
|
||||
const char *rootUri,
|
||||
enumeratorAuthentication *auth,
|
||||
unsigned int flags
|
||||
);
|
||||
|
||||
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
|
||||
|
@ -14,6 +14,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef LIBREDFISH_REDPATH_H_
|
||||
#define LIBREDFISH_REDPATH_H_
|
||||
|
||||
@ -21,8 +22,7 @@
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
typedef struct _redPathNode
|
||||
{
|
||||
typedef struct _redPathNode {
|
||||
bool isRoot;
|
||||
bool isIndex;
|
||||
|
||||
@ -36,7 +36,14 @@ typedef struct _redPathNode
|
||||
struct _redPathNode *next;
|
||||
} redPathNode;
|
||||
|
||||
redPathNode* parseRedPath(const char* path);
|
||||
void cleanupRedPath(redPathNode* node);
|
||||
redPathNode *
|
||||
parseRedPath (
|
||||
const char *path
|
||||
);
|
||||
|
||||
void
|
||||
cleanupRedPath (
|
||||
redPathNode *node
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -16,117 +16,171 @@
|
||||
**/
|
||||
#include <redfishPayload.h>
|
||||
|
||||
static redfishPayload* getOpResult(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode);
|
||||
static redfishPayload* collectionEvalOp(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode);
|
||||
static redfishPayload* arrayEvalOp(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode);
|
||||
static redfishPayload* createCollection(redfishService* service, size_t count, redfishPayload** payloads);
|
||||
static json_t* json_object_get_by_index(json_t* json, size_t index);
|
||||
static redfishPayload *
|
||||
getOpResult (
|
||||
redfishPayload *payload,
|
||||
const char *propName,
|
||||
const char *op,
|
||||
const char *value,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
);
|
||||
|
||||
bool isPayloadCollection(redfishPayload* payload)
|
||||
static redfishPayload *
|
||||
collectionEvalOp (
|
||||
redfishPayload *payload,
|
||||
const char *propName,
|
||||
const char *op,
|
||||
const char *value,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
);
|
||||
|
||||
static redfishPayload *
|
||||
arrayEvalOp (
|
||||
redfishPayload *payload,
|
||||
const char *propName,
|
||||
const char *op,
|
||||
const char *value,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
);
|
||||
|
||||
static redfishPayload *
|
||||
createCollection (
|
||||
redfishService *service,
|
||||
size_t count,
|
||||
redfishPayload **payloads
|
||||
);
|
||||
|
||||
static json_t *
|
||||
json_object_get_by_index (
|
||||
json_t *json,
|
||||
size_t index
|
||||
);
|
||||
|
||||
bool
|
||||
isPayloadCollection (
|
||||
redfishPayload *payload
|
||||
)
|
||||
{
|
||||
json_t *members;
|
||||
json_t *count;
|
||||
|
||||
if(!payload || !json_is_object(payload->json))
|
||||
{
|
||||
if (!payload || !json_is_object (payload->json)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
members = json_object_get (payload->json, "Members");
|
||||
count = json_object_get (payload->json, "Members@odata.count");
|
||||
return ((members != NULL) && (count != NULL));
|
||||
}
|
||||
|
||||
size_t getCollectionSize(redfishPayload* payload)
|
||||
size_t
|
||||
getCollectionSize (
|
||||
redfishPayload *payload
|
||||
)
|
||||
{
|
||||
json_t *members;
|
||||
json_t *count;
|
||||
|
||||
if(!payload || !json_is_object(payload->json))
|
||||
{
|
||||
if (!payload || !json_is_object (payload->json)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
members = json_object_get (payload->json, "Members");
|
||||
count = json_object_get (payload->json, "Members@odata.count");
|
||||
if(!members || !count)
|
||||
{
|
||||
if (!members || !count) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (size_t)json_integer_value (count);
|
||||
}
|
||||
|
||||
bool isPayloadArray(redfishPayload* payload)
|
||||
{
|
||||
if(!payload || !json_is_array(payload->json))
|
||||
bool
|
||||
isPayloadArray (
|
||||
redfishPayload *payload
|
||||
)
|
||||
{
|
||||
if (!payload || !json_is_array (payload->json)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
char* payloadToString(redfishPayload* payload, bool prettyPrint)
|
||||
char *
|
||||
payloadToString (
|
||||
redfishPayload *payload,
|
||||
bool prettyPrint
|
||||
)
|
||||
{
|
||||
size_t flags = 0;
|
||||
if(!payload)
|
||||
{
|
||||
|
||||
if (!payload) {
|
||||
return NULL;
|
||||
}
|
||||
if(prettyPrint)
|
||||
{
|
||||
|
||||
if (prettyPrint) {
|
||||
flags = JSON_INDENT (2);
|
||||
}
|
||||
|
||||
return json_dumps (payload->json, flags);
|
||||
}
|
||||
|
||||
redfishPayload* createRedfishPayload(json_t* value, redfishService* service)
|
||||
redfishPayload *
|
||||
createRedfishPayload (
|
||||
json_t *value,
|
||||
redfishService *service
|
||||
)
|
||||
{
|
||||
redfishPayload *payload;
|
||||
|
||||
payload = (redfishPayload *)malloc (sizeof (redfishPayload));
|
||||
if(payload != NULL)
|
||||
{
|
||||
if (payload != NULL) {
|
||||
payload->json = value;
|
||||
payload->service = service;
|
||||
}
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
redfishPayload* getPayloadByNodeName(redfishPayload* payload, const char* nodeName, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
redfishPayload *
|
||||
getPayloadByNodeName (
|
||||
redfishPayload *payload,
|
||||
const char *nodeName,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
json_t *value;
|
||||
json_t *odataId;
|
||||
const char *uri;
|
||||
|
||||
if(!payload || !nodeName || StatusCode == NULL)
|
||||
{
|
||||
if (!payload || !nodeName || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
|
||||
value = json_object_get (payload->json, nodeName);
|
||||
if(value == NULL)
|
||||
{
|
||||
if (value == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
json_incref (value);
|
||||
if(json_object_size(value) == 1)
|
||||
{
|
||||
if (json_object_size (value) == 1) {
|
||||
odataId = json_object_get (value, "@odata.id");
|
||||
if(odataId != NULL)
|
||||
{
|
||||
if (odataId != NULL) {
|
||||
json_incref (odataId);
|
||||
uri = json_string_value (odataId);
|
||||
json_decref (value);
|
||||
value = getUriFromService (payload->service, uri, StatusCode);
|
||||
json_decref (odataId);
|
||||
if(value == NULL || *StatusCode == NULL)
|
||||
{
|
||||
if ((value == NULL) || (*StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (*StatusCode == NULL || (**StatusCode >= HTTP_STATUS_200_OK && **StatusCode <= HTTP_STATUS_206_PARTIAL_CONTENT)) {
|
||||
if(json_is_string(value))
|
||||
{
|
||||
|
||||
if ((*StatusCode == NULL) || ((**StatusCode >= HTTP_STATUS_200_OK) && (**StatusCode <= HTTP_STATUS_206_PARTIAL_CONTENT))) {
|
||||
if (json_is_string (value)) {
|
||||
odataId = json_object ();
|
||||
json_object_set (odataId, nodeName, value);
|
||||
json_decref (value);
|
||||
@ -137,25 +191,29 @@ redfishPayload* getPayloadByNodeName(redfishPayload* payload, const char* nodeNa
|
||||
return createRedfishPayload (value, payload->service);
|
||||
}
|
||||
|
||||
redfishPayload* getPayloadByIndex(redfishPayload* payload, size_t index, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
redfishPayload *
|
||||
getPayloadByIndex (
|
||||
redfishPayload *payload,
|
||||
size_t index,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
json_t *value = NULL;
|
||||
json_t *odataId;
|
||||
const char *uri;
|
||||
BOOLEAN FromServerFlag = FALSE;
|
||||
|
||||
if(!payload || StatusCode == NULL)
|
||||
{
|
||||
if (!payload || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
|
||||
if(isPayloadCollection(payload))
|
||||
{
|
||||
if (isPayloadCollection (payload)) {
|
||||
redfishPayload *members = getPayloadByNodeName (payload, "Members", StatusCode);
|
||||
if ((*StatusCode == NULL && members == NULL) ||
|
||||
(*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
|
||||
if (((*StatusCode == NULL) && (members == NULL)) ||
|
||||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
|
||||
{
|
||||
return members;
|
||||
}
|
||||
|
||||
@ -169,7 +227,7 @@ redfishPayload* getPayloadByIndex(redfishPayload* payload, size_t index, EFI_HTT
|
||||
}
|
||||
|
||||
redfishPayload *ret = getPayloadByIndex (members, index, StatusCode);
|
||||
if (*StatusCode == NULL && ret != NULL && FromServerFlag) {
|
||||
if ((*StatusCode == NULL) && (ret != NULL) && FromServerFlag) {
|
||||
//
|
||||
// In such a case, the Redfish resource is parsed from the input payload (members) directly.
|
||||
// Since the members are retrived from server, we still return HTTP_STATUS_200_OK.
|
||||
@ -186,99 +244,90 @@ redfishPayload* getPayloadByIndex(redfishPayload* payload, size_t index, EFI_HTT
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(json_is_array(payload->json))
|
||||
{
|
||||
if (json_is_array (payload->json)) {
|
||||
//
|
||||
// The valid range for index is from 0 to the return value of json_array_size() minus 1
|
||||
//
|
||||
value = json_array_get (payload->json, index);
|
||||
}
|
||||
else if(json_is_object(payload->json))
|
||||
{
|
||||
} else if (json_is_object (payload->json)) {
|
||||
value = json_object_get_by_index (payload->json, index);
|
||||
}
|
||||
|
||||
if(value == NULL)
|
||||
{
|
||||
if (value == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
json_incref (value);
|
||||
if(json_object_size(value) == 1)
|
||||
{
|
||||
if (json_object_size (value) == 1) {
|
||||
odataId = json_object_get (value, "@odata.id");
|
||||
if(odataId != NULL)
|
||||
{
|
||||
if (odataId != NULL) {
|
||||
uri = json_string_value (odataId);
|
||||
json_decref (value);
|
||||
value = getUriFromService (payload->service, uri, StatusCode);
|
||||
if(value == NULL)
|
||||
{
|
||||
if (value == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return createRedfishPayload (value, payload->service);
|
||||
}
|
||||
|
||||
redfishPayload* getPayloadForPath(redfishPayload* payload, redPathNode* redpath, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
redfishPayload *
|
||||
getPayloadForPath (
|
||||
redfishPayload *payload,
|
||||
redPathNode *redpath,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
redfishPayload *ret = NULL;
|
||||
redfishPayload *tmp;
|
||||
|
||||
if(!payload || !redpath || StatusCode == NULL)
|
||||
{
|
||||
if (!payload || !redpath || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
BOOLEAN FromServerFlag = FALSE;
|
||||
|
||||
if(redpath->nodeName)
|
||||
{
|
||||
if (redpath->nodeName) {
|
||||
ret = getPayloadByNodeName (payload, redpath->nodeName, StatusCode);
|
||||
if ((*StatusCode == NULL && ret == NULL) ||
|
||||
(*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
|
||||
if (((*StatusCode == NULL) && (ret == NULL)) ||
|
||||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
|
||||
{
|
||||
//
|
||||
// Any error happen, return directly.
|
||||
//
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
else if(redpath->isIndex)
|
||||
{
|
||||
} else if (redpath->isIndex) {
|
||||
ASSERT (redpath->index >= 1);
|
||||
ret = getPayloadByIndex (payload, redpath->index - 1, StatusCode);
|
||||
if ((*StatusCode == NULL && ret == NULL) ||
|
||||
(*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
|
||||
if (((*StatusCode == NULL) && (ret == NULL)) ||
|
||||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
|
||||
{
|
||||
//
|
||||
// Any error happen, return directly.
|
||||
//
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
else if(redpath->op)
|
||||
{
|
||||
} else if (redpath->op) {
|
||||
ret = getOpResult (payload, redpath->propName, redpath->op, redpath->value, StatusCode);
|
||||
if ((*StatusCode == NULL && ret == NULL) ||
|
||||
(*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
|
||||
if (((*StatusCode == NULL) && (ret == NULL)) ||
|
||||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
|
||||
{
|
||||
//
|
||||
// Any error happen, return directly.
|
||||
//
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(redpath->next == NULL || ret == NULL)
|
||||
{
|
||||
if ((redpath->next == NULL) || (ret == NULL)) {
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (*StatusCode != NULL) {
|
||||
FreePool (*StatusCode);
|
||||
*StatusCode = NULL;
|
||||
@ -286,7 +335,7 @@ redfishPayload* getPayloadForPath(redfishPayload* payload, redPathNode* redpath,
|
||||
}
|
||||
|
||||
tmp = getPayloadForPath (ret, redpath->next, StatusCode);
|
||||
if (*StatusCode == NULL && tmp != NULL && FromServerFlag) {
|
||||
if ((*StatusCode == NULL) && (tmp != NULL) && FromServerFlag) {
|
||||
//
|
||||
// In such a case, the Redfish resource is parsed from the input payload (ret) directly.
|
||||
// Since the ret are retrived from server, we still return HTTP_STATUS_200_OK.
|
||||
@ -304,46 +353,54 @@ redfishPayload* getPayloadForPath(redfishPayload* payload, redPathNode* redpath,
|
||||
}
|
||||
}
|
||||
|
||||
redfishPayload* getPayloadForPathString(redfishPayload* payload, const char* string, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
redfishPayload *
|
||||
getPayloadForPathString (
|
||||
redfishPayload *payload,
|
||||
const char *string,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
redPathNode *redpath;
|
||||
redfishPayload *ret;
|
||||
|
||||
if(!string || StatusCode == NULL)
|
||||
{
|
||||
if (!string || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
|
||||
redpath = parseRedPath (string);
|
||||
if(redpath == NULL)
|
||||
{
|
||||
if (redpath == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = getPayloadForPath (payload, redpath, StatusCode);
|
||||
cleanupRedPath (redpath);
|
||||
return ret;
|
||||
}
|
||||
|
||||
redfishPayload* patchPayload(redfishPayload* target, redfishPayload* payload, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
redfishPayload *
|
||||
patchPayload (
|
||||
redfishPayload *target,
|
||||
redfishPayload *payload,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
json_t *json;
|
||||
char *content;
|
||||
char *uri;
|
||||
|
||||
if(!target || !payload || StatusCode == NULL)
|
||||
{
|
||||
if (!target || !payload || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
|
||||
json = json_object_get (target->json, "@odata.id");
|
||||
if(json == NULL)
|
||||
{
|
||||
if (json == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uri = strdup (json_string_value (json));
|
||||
|
||||
content = json_dumps (payload->json, 0);
|
||||
@ -352,80 +409,97 @@ redfishPayload* patchPayload(redfishPayload* target, redfishPayload* payload, EF
|
||||
json = patchUriFromService (target->service, uri, content, StatusCode);
|
||||
free (uri);
|
||||
free (content);
|
||||
if(json == NULL)
|
||||
{
|
||||
if (json == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return createRedfishPayload (json, target->service);
|
||||
}
|
||||
|
||||
redfishPayload* postContentToPayload(redfishPayload* target, const char* data, size_t dataSize, const char* contentType, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
redfishPayload *
|
||||
postContentToPayload (
|
||||
redfishPayload *target,
|
||||
const char *data,
|
||||
size_t dataSize,
|
||||
const char *contentType,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
json_t *json;
|
||||
char *uri;
|
||||
|
||||
if(!target || !data || StatusCode == NULL)
|
||||
{
|
||||
if (!target || !data || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
|
||||
json = json_object_get (target->json, "@odata.id");
|
||||
if(json == NULL)
|
||||
{
|
||||
if (json == NULL) {
|
||||
json = json_object_get (target->json, "target");
|
||||
if(json == NULL)
|
||||
{
|
||||
if (json == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
uri = strdup (json_string_value (json));
|
||||
json = postUriFromService (target->service, uri, data, dataSize, contentType, StatusCode);
|
||||
free (uri);
|
||||
if(json == NULL)
|
||||
{
|
||||
if (json == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return createRedfishPayload (json, target->service);
|
||||
}
|
||||
|
||||
redfishPayload* postPayload(redfishPayload* target, redfishPayload* payload, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
redfishPayload *
|
||||
postPayload (
|
||||
redfishPayload *target,
|
||||
redfishPayload *payload,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
char *content;
|
||||
redfishPayload *ret;
|
||||
|
||||
if(!target || !payload || StatusCode == NULL)
|
||||
{
|
||||
if (!target || !payload || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
|
||||
if(!json_is_object(payload->json))
|
||||
{
|
||||
if (!json_is_object (payload->json)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
content = payloadToString (payload, false);
|
||||
ret = postContentToPayload (target, content, strlen (content), NULL, StatusCode);
|
||||
free (content);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void cleanupPayload(redfishPayload* payload)
|
||||
{
|
||||
if(!payload)
|
||||
void
|
||||
cleanupPayload (
|
||||
redfishPayload *payload
|
||||
)
|
||||
{
|
||||
if (!payload) {
|
||||
return;
|
||||
}
|
||||
|
||||
json_decref (payload->json);
|
||||
// Don't free payload->service, let the caller handle cleaning up the service
|
||||
free (payload);
|
||||
}
|
||||
|
||||
static redfishPayload* getOpResult(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
static redfishPayload *
|
||||
getOpResult (
|
||||
redfishPayload *payload,
|
||||
const char *propName,
|
||||
const char *op,
|
||||
const char *value,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
const char *propStr;
|
||||
json_t *stringProp;
|
||||
@ -434,98 +508,94 @@ static redfishPayload* getOpResult(redfishPayload* payload, const char* propName
|
||||
long long intVal, intPropVal;
|
||||
json_type jsonType;
|
||||
|
||||
if(isPayloadCollection(payload))
|
||||
{
|
||||
if (isPayloadCollection (payload)) {
|
||||
return collectionEvalOp (payload, propName, op, value, StatusCode);
|
||||
}
|
||||
if(isPayloadArray(payload))
|
||||
{
|
||||
|
||||
if (isPayloadArray (payload)) {
|
||||
return arrayEvalOp (payload, propName, op, value, StatusCode);
|
||||
}
|
||||
|
||||
prop = getPayloadByNodeName (payload, propName, StatusCode);
|
||||
if ((*StatusCode == NULL && prop == NULL) ||
|
||||
(*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
|
||||
if (((*StatusCode == NULL) && (prop == NULL)) ||
|
||||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
|
||||
{
|
||||
return prop;
|
||||
}
|
||||
|
||||
stringProp = prop->json;
|
||||
jsonType = prop->json->type;
|
||||
switch(jsonType)
|
||||
{
|
||||
switch (jsonType) {
|
||||
case JSON_OBJECT:
|
||||
stringProp = json_object_get (prop->json, propName);
|
||||
case JSON_STRING:
|
||||
if(strcmp(op, "=") == 0)
|
||||
{
|
||||
if (strcmp (op, "=") == 0) {
|
||||
propStr = json_string_value (stringProp);
|
||||
if(propStr == NULL)
|
||||
{
|
||||
if (propStr == NULL) {
|
||||
cleanupPayload (prop);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = (strcmp (propStr, value) == 0);
|
||||
} else if(strcmp(op, "~") == 0)
|
||||
{
|
||||
} else if (strcmp (op, "~") == 0) {
|
||||
propStr = json_string_value (stringProp);
|
||||
if(propStr == NULL)
|
||||
{
|
||||
if (propStr == NULL) {
|
||||
cleanupPayload (prop);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = (strcasecmp (propStr, value) == 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case JSON_TRUE:
|
||||
if(strcmp(op, "=") == 0)
|
||||
{
|
||||
if (strcmp (op, "=") == 0) {
|
||||
ret = (strcmp (value, "true") == 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case JSON_FALSE:
|
||||
if(strcmp(op, "=") == 0)
|
||||
{
|
||||
if (strcmp (op, "=") == 0) {
|
||||
ret = (strcmp (value, "false") == 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case JSON_INTEGER:
|
||||
intPropVal = json_integer_value (prop->json);
|
||||
intVal = strtoll (value, NULL, 0);
|
||||
if(strcmp(op, "=") == 0)
|
||||
{
|
||||
if (strcmp (op, "=") == 0) {
|
||||
ret = (intPropVal == intVal);
|
||||
}
|
||||
else if(strcmp(op, "<") == 0)
|
||||
{
|
||||
} else if (strcmp (op, "<") == 0) {
|
||||
ret = (intPropVal < intVal);
|
||||
}
|
||||
else if(strcmp(op, ">") == 0)
|
||||
{
|
||||
} else if (strcmp (op, ">") == 0) {
|
||||
ret = (intPropVal > intVal);
|
||||
}
|
||||
else if(strcmp(op, "<=") == 0)
|
||||
{
|
||||
} else if (strcmp (op, "<=") == 0) {
|
||||
ret = (intPropVal <= intVal);
|
||||
}
|
||||
else if(strcmp(op, ">=") == 0)
|
||||
{
|
||||
} else if (strcmp (op, ">=") == 0) {
|
||||
ret = (intPropVal >= intVal);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
cleanupPayload (prop);
|
||||
if(ret)
|
||||
{
|
||||
if (ret) {
|
||||
return payload;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static redfishPayload* collectionEvalOp(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
static redfishPayload *
|
||||
collectionEvalOp (
|
||||
redfishPayload *payload,
|
||||
const char *propName,
|
||||
const char *op,
|
||||
const char *value,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
redfishPayload *ret;
|
||||
redfishPayload *tmp;
|
||||
@ -536,33 +606,33 @@ static redfishPayload* collectionEvalOp(redfishPayload* payload, const char* pro
|
||||
size_t i;
|
||||
|
||||
validMax = getCollectionSize (payload);
|
||||
if(validMax == 0)
|
||||
{
|
||||
if (validMax == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
valid = (redfishPayload **)calloc (validMax, sizeof (redfishPayload *));
|
||||
if(valid == NULL)
|
||||
{
|
||||
if (valid == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*Technically getPayloadByIndex would do this, but this optimizes things*/
|
||||
members = getPayloadByNodeName (payload, "Members", StatusCode);
|
||||
if ((*StatusCode == NULL && members == NULL) ||
|
||||
(*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
|
||||
if (((*StatusCode == NULL) && (members == NULL)) ||
|
||||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
|
||||
{
|
||||
return members;
|
||||
}
|
||||
|
||||
for(i = 0; i < validMax; i++)
|
||||
{
|
||||
for (i = 0; i < validMax; i++) {
|
||||
if (*StatusCode != NULL) {
|
||||
FreePool (*StatusCode);
|
||||
*StatusCode = NULL;
|
||||
}
|
||||
|
||||
tmp = getPayloadByIndex (members, i, StatusCode);
|
||||
if ((*StatusCode == NULL && tmp == NULL) ||
|
||||
(*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
|
||||
if (((*StatusCode == NULL) && (tmp == NULL)) ||
|
||||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
|
||||
{
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@ -572,42 +642,45 @@ static redfishPayload* collectionEvalOp(redfishPayload* payload, const char* pro
|
||||
}
|
||||
|
||||
valid[validCount] = getOpResult (tmp, propName, op, value, StatusCode);
|
||||
|
||||
/*
|
||||
if ((*StatusCode == NULL && valid[validCount] == NULL) ||
|
||||
(*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
|
||||
return valid[validCount];
|
||||
}
|
||||
*/
|
||||
if(valid[validCount] != NULL)
|
||||
{
|
||||
if (valid[validCount] != NULL) {
|
||||
validCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cleanupPayload (tmp);
|
||||
}
|
||||
}
|
||||
|
||||
cleanupPayload (members);
|
||||
if(validCount == 0)
|
||||
{
|
||||
if (validCount == 0) {
|
||||
free (valid);
|
||||
return NULL;
|
||||
}
|
||||
if(validCount == 1)
|
||||
{
|
||||
|
||||
if (validCount == 1) {
|
||||
ret = valid[0];
|
||||
free (valid);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ret = createCollection (payload->service, validCount, valid);
|
||||
free (valid);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
static redfishPayload* arrayEvalOp(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
static redfishPayload *
|
||||
arrayEvalOp (
|
||||
redfishPayload *payload,
|
||||
const char *propName,
|
||||
const char *op,
|
||||
const char *value,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
redfishPayload *ret;
|
||||
redfishPayload *tmp;
|
||||
@ -617,26 +690,25 @@ static redfishPayload* arrayEvalOp(redfishPayload* payload, const char* propName
|
||||
size_t i;
|
||||
|
||||
validMax = json_array_size (payload->json);
|
||||
if(validMax == 0)
|
||||
{
|
||||
if (validMax == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
valid = (redfishPayload **)calloc (validMax, sizeof (redfishPayload *));
|
||||
if(valid == NULL)
|
||||
{
|
||||
if (valid == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for(i = 0; i < validMax; i++)
|
||||
{
|
||||
|
||||
for (i = 0; i < validMax; i++) {
|
||||
if (*StatusCode != NULL) {
|
||||
FreePool (*StatusCode);
|
||||
*StatusCode = NULL;
|
||||
}
|
||||
|
||||
tmp = getPayloadByIndex (payload, i, StatusCode);
|
||||
if ((*StatusCode == NULL && tmp == NULL) ||
|
||||
(*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
|
||||
if (((*StatusCode == NULL) && (tmp == NULL)) ||
|
||||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
|
||||
{
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@ -646,6 +718,7 @@ static redfishPayload* arrayEvalOp(redfishPayload* payload, const char* propName
|
||||
}
|
||||
|
||||
valid[validCount] = getOpResult (tmp, propName, op, value, StatusCode);
|
||||
|
||||
/*
|
||||
if ((*StatusCode == NULL && valid[validCount] == NULL) ||
|
||||
(*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
|
||||
@ -653,35 +726,35 @@ static redfishPayload* arrayEvalOp(redfishPayload* payload, const char* propName
|
||||
}
|
||||
*/
|
||||
|
||||
if(valid[validCount] != NULL)
|
||||
{
|
||||
if (valid[validCount] != NULL) {
|
||||
validCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cleanupPayload (tmp);
|
||||
}
|
||||
}
|
||||
if(validCount == 0)
|
||||
{
|
||||
|
||||
if (validCount == 0) {
|
||||
free (valid);
|
||||
return NULL;
|
||||
}
|
||||
if(validCount == 1)
|
||||
{
|
||||
|
||||
if (validCount == 1) {
|
||||
ret = valid[0];
|
||||
free (valid);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ret = createCollection (payload->service, validCount, valid);
|
||||
free (valid);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
static redfishPayload* createCollection(redfishService* service, size_t count, redfishPayload** payloads)
|
||||
static redfishPayload *
|
||||
createCollection (
|
||||
redfishService *service,
|
||||
size_t count,
|
||||
redfishPayload **payloads
|
||||
)
|
||||
{
|
||||
redfishPayload *ret;
|
||||
json_t *collectionJson = json_object ();
|
||||
@ -689,22 +762,22 @@ static redfishPayload* createCollection(redfishService* service, size_t count, r
|
||||
json_t *members = json_array ();
|
||||
size_t i;
|
||||
|
||||
if(!collectionJson)
|
||||
{
|
||||
if (!collectionJson) {
|
||||
return NULL;
|
||||
}
|
||||
if(!members)
|
||||
{
|
||||
|
||||
if (!members) {
|
||||
json_decref (collectionJson);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
json_object_set (collectionJson, "Members@odata.count", jcount);
|
||||
json_decref (jcount);
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
for (i = 0; i < count; i++) {
|
||||
json_array_append (members, payloads[i]->json);
|
||||
cleanupPayload (payloads[i]);
|
||||
}
|
||||
|
||||
json_object_set (collectionJson, "Members", members);
|
||||
json_decref (members);
|
||||
|
||||
@ -712,21 +785,28 @@ static redfishPayload* createCollection(redfishService* service, size_t count, r
|
||||
return ret;
|
||||
}
|
||||
|
||||
static json_t* json_object_get_by_index(json_t* json, size_t index)
|
||||
static json_t *
|
||||
json_object_get_by_index (
|
||||
json_t *json,
|
||||
size_t index
|
||||
)
|
||||
{
|
||||
void *iter;
|
||||
size_t i;
|
||||
|
||||
iter = json_object_iter (json);
|
||||
for(i = 0; i < index; i++)
|
||||
{
|
||||
for (i = 0; i < index; i++) {
|
||||
iter = json_object_iter_next (json, iter);
|
||||
if(iter == NULL) break;
|
||||
if (iter == NULL) {
|
||||
break;
|
||||
}
|
||||
if(iter == NULL)
|
||||
{
|
||||
}
|
||||
|
||||
if (iter == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return json_object_iter_value (iter);
|
||||
}
|
||||
|
||||
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
|
||||
|
@ -16,99 +16,126 @@
|
||||
**/
|
||||
#include <redpath.h>
|
||||
|
||||
static char* getVersion(const char* path, char** end);
|
||||
static void parseNode(const char* path, redPathNode* node, redPathNode** end);
|
||||
static char *
|
||||
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 *endNode;
|
||||
char *curPath;
|
||||
char *end;
|
||||
|
||||
if(!path || strlen(path) == 0)
|
||||
{
|
||||
if (!path || (strlen (path) == 0)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node = (redPathNode *)calloc (1, sizeof (redPathNode));
|
||||
if(!node)
|
||||
{
|
||||
if (!node) {
|
||||
return NULL;
|
||||
}
|
||||
if(path[0] == '/')
|
||||
{
|
||||
|
||||
if (path[0] == '/') {
|
||||
node->isRoot = true;
|
||||
if(path[1] == 'v')
|
||||
{
|
||||
if (path[1] == 'v') {
|
||||
node->version = getVersion (path+1, &curPath);
|
||||
if(curPath == NULL)
|
||||
{
|
||||
if (curPath == NULL) {
|
||||
return node;
|
||||
}
|
||||
if(curPath[0] == '/')
|
||||
{
|
||||
|
||||
if (curPath[0] == '/') {
|
||||
curPath++;
|
||||
}
|
||||
|
||||
node->next = parseRedPath (curPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
node->next = parseRedPath (path+1);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
node->isRoot = false;
|
||||
curPath = getStringTill (path, "/", &end);
|
||||
endNode = node;
|
||||
parseNode (curPath, node, &endNode);
|
||||
free (curPath);
|
||||
if(end != NULL)
|
||||
{
|
||||
if (end != NULL) {
|
||||
endNode->next = parseRedPath (end+1);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
void cleanupRedPath(redPathNode* node)
|
||||
{
|
||||
if(!node)
|
||||
void
|
||||
cleanupRedPath (
|
||||
redPathNode *node
|
||||
)
|
||||
{
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
||||
cleanupRedPath (node->next);
|
||||
node->next = NULL;
|
||||
if(node->version)
|
||||
{
|
||||
if (node->version) {
|
||||
free (node->version);
|
||||
}
|
||||
if(node->nodeName)
|
||||
{
|
||||
|
||||
if (node->nodeName) {
|
||||
free (node->nodeName);
|
||||
}
|
||||
if(node->op)
|
||||
{
|
||||
|
||||
if (node->op) {
|
||||
free (node->op);
|
||||
}
|
||||
if(node->propName)
|
||||
{
|
||||
|
||||
if (node->propName) {
|
||||
free (node->propName);
|
||||
}
|
||||
if(node->value)
|
||||
{
|
||||
|
||||
if (node->value) {
|
||||
free (node->value);
|
||||
}
|
||||
|
||||
free (node);
|
||||
}
|
||||
|
||||
static char* getVersion(const char* path, char** end)
|
||||
static char *
|
||||
getVersion (
|
||||
const char *path,
|
||||
char **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 *index;
|
||||
@ -118,48 +145,47 @@ static void parseNode(const char* path, redPathNode* node, redPathNode** end)
|
||||
char *opChars;
|
||||
|
||||
node->nodeName = nodeName;
|
||||
if(indexStart == NULL)
|
||||
{
|
||||
if (indexStart == NULL) {
|
||||
*end = node;
|
||||
return;
|
||||
}
|
||||
|
||||
node->next = (redPathNode *)calloc (1, sizeof (redPathNode));
|
||||
if(!node->next)
|
||||
{
|
||||
if (!node->next) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip past [
|
||||
indexStart++;
|
||||
*end = node->next;
|
||||
index = getStringTill (indexStart, "]", NULL);
|
||||
tmpIndex = (size_t)strtoull (index, &indexEnd, 0);
|
||||
if(indexEnd != index)
|
||||
{
|
||||
if (indexEnd != index) {
|
||||
free (index);
|
||||
node->next->index = tmpIndex;
|
||||
node->next->isIndex = true;
|
||||
return;
|
||||
}
|
||||
|
||||
opChars = strpbrk (index, "<>=~");
|
||||
if(opChars == NULL)
|
||||
{
|
||||
if (opChars == NULL) {
|
||||
// TODO handle last() and position()
|
||||
node->next->op = strdup ("exists");
|
||||
node->next->propName = index;
|
||||
return;
|
||||
}
|
||||
|
||||
node->next->propName = (char *)malloc ((opChars - index)+1);
|
||||
memcpy (node->next->propName, index, (opChars - index));
|
||||
node->next->propName[(opChars - index)] = 0;
|
||||
|
||||
tmpIndex = 1;
|
||||
while(1)
|
||||
{
|
||||
if(opChars[tmpIndex] == '=' || opChars[tmpIndex] == '<' || opChars[tmpIndex] == '>' || opChars[tmpIndex] == '~')
|
||||
{
|
||||
while (1) {
|
||||
if ((opChars[tmpIndex] == '=') || (opChars[tmpIndex] == '<') || (opChars[tmpIndex] == '>') || (opChars[tmpIndex] == '~')) {
|
||||
tmpIndex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -171,20 +197,26 @@ static void parseNode(const char* path, redPathNode* node, redPathNode** end)
|
||||
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 *end;
|
||||
|
||||
end = strstr ((char *)string, terminator);
|
||||
if(retEnd)
|
||||
{
|
||||
if (retEnd) {
|
||||
*retEnd = end;
|
||||
}
|
||||
if(end == NULL)
|
||||
{
|
||||
|
||||
if (end == NULL) {
|
||||
// No terminator
|
||||
return strdup (string);
|
||||
}
|
||||
|
||||
ret = (char *)malloc ((end-string)+1);
|
||||
memcpy (ret, string, (end-string));
|
||||
ret[(end-string)] = 0;
|
||||
|
@ -19,16 +19,64 @@
|
||||
#include <redfishPayload.h>
|
||||
#include <redpath.h>
|
||||
|
||||
static int initRest(redfishService* service, void * restProtocol);
|
||||
static redfishService* createServiceEnumeratorNoAuth(const char* host, const char* rootUri, bool enumerate, unsigned int flags, void * restProtocol);
|
||||
static redfishService* createServiceEnumeratorBasicAuth(const char* host, const char* rootUri, const char* username, const char* password, unsigned int flags, void * restProtocol);
|
||||
static redfishService* createServiceEnumeratorSessionAuth(const char* host, const char* rootUri, const char* username, const char* password, unsigned int flags, void * restProtocol);
|
||||
static char* makeUrlForService(redfishService* service, const char* uri);
|
||||
static json_t* getVersions(redfishService* service, const char* rootUri);
|
||||
static void addStringToJsonObject(json_t* object, const char* key, const char* value);
|
||||
static int
|
||||
initRest (
|
||||
redfishService *service,
|
||||
void *restProtocol
|
||||
);
|
||||
|
||||
static redfishService *
|
||||
createServiceEnumeratorNoAuth (
|
||||
const char *host,
|
||||
const char *rootUri,
|
||||
bool enumerate,
|
||||
unsigned int flags,
|
||||
void *restProtocol
|
||||
);
|
||||
|
||||
static redfishService *
|
||||
createServiceEnumeratorBasicAuth (
|
||||
const char *host,
|
||||
const char *rootUri,
|
||||
const char *username,
|
||||
const char *password,
|
||||
unsigned int flags,
|
||||
void *restProtocol
|
||||
);
|
||||
|
||||
static redfishService *
|
||||
createServiceEnumeratorSessionAuth (
|
||||
const char *host,
|
||||
const char *rootUri,
|
||||
const char *username,
|
||||
const char *password,
|
||||
unsigned int flags,
|
||||
void *restProtocol
|
||||
);
|
||||
|
||||
static char *
|
||||
makeUrlForService (
|
||||
redfishService *service,
|
||||
const char *uri
|
||||
);
|
||||
|
||||
static json_t *
|
||||
getVersions (
|
||||
redfishService *service,
|
||||
const char *rootUri
|
||||
);
|
||||
|
||||
static void
|
||||
addStringToJsonObject (
|
||||
json_t *object,
|
||||
const char *key,
|
||||
const char *value
|
||||
);
|
||||
|
||||
CHAR16 *
|
||||
C8ToC16 (CHAR8 *AsciiStr)
|
||||
C8ToC16 (
|
||||
CHAR8 *AsciiStr
|
||||
)
|
||||
{
|
||||
CHAR16 *Str;
|
||||
UINTN BufLen;
|
||||
@ -82,6 +130,7 @@ RestConfigFreeHttpMessage (
|
||||
FreePool (Message->Headers);
|
||||
Message->Headers = NULL;
|
||||
}
|
||||
|
||||
if (Message->Body != NULL) {
|
||||
FreePool (Message->Body);
|
||||
Message->Body = NULL;
|
||||
@ -96,7 +145,6 @@ RestConfigFreeHttpMessage (
|
||||
@return Buffer points to ASCII string, or NULL if error happens.
|
||||
|
||||
**/
|
||||
|
||||
CHAR8 *
|
||||
UnicodeStrDupToAsciiStr (
|
||||
CONST CHAR16 *String
|
||||
@ -119,6 +167,7 @@ UnicodeStrDupToAsciiStr (
|
||||
|
||||
return AsciiStr;
|
||||
}
|
||||
|
||||
/**
|
||||
This function encodes the content.
|
||||
|
||||
@ -144,9 +193,10 @@ EncodeRequestContent (
|
||||
VOID *EncodedPointer;
|
||||
UINTN EncodedLength;
|
||||
|
||||
if (OriginalContent == NULL || EncodedContent == NULL || EncodedContentLength == NULL) {
|
||||
if ((OriginalContent == NULL) || (EncodedContent == NULL) || (EncodedContentLength == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = RedfishContentEncode (
|
||||
ContentEncodedValue,
|
||||
OriginalContent,
|
||||
@ -159,6 +209,7 @@ EncodeRequestContent (
|
||||
*EncodedContentLength = EncodedLength;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -192,6 +243,7 @@ DecodeResponseContent (
|
||||
if (ContentEncodedValue == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = RedfishContentDecode (
|
||||
ContentEncodedValue,
|
||||
*ContentPointer,
|
||||
@ -204,6 +256,7 @@ DecodeResponseContent (
|
||||
*ContentPointer = DecodedPointer;
|
||||
*ContentLength = DecodedLength;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -248,6 +301,7 @@ RedfishBuildUrl (
|
||||
} else {
|
||||
PathLen = StrLen (RelativePath);
|
||||
}
|
||||
|
||||
UrlLength = StrLen (HTTPS_FLAG) + StrLen (REDFISH_FIRST_URL) + 1 + StrLen (RedfishConfigServiceInfo->RedfishServiceLocation) + PathLen;
|
||||
Url = AllocateZeroPool (UrlLength * sizeof (CHAR16));
|
||||
if (Url == NULL) {
|
||||
@ -272,14 +326,21 @@ RedfishBuildUrl (
|
||||
//
|
||||
// Copy abs_path
|
||||
//
|
||||
if (RelativePath != NULL && PathLen != 0 ) {
|
||||
if ((RelativePath != NULL) && (PathLen != 0)) {
|
||||
StrnCpyS (Url, UrlLength, RelativePath, PathLen);
|
||||
}
|
||||
|
||||
*HttpUrl = UrlHead;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
redfishService* createServiceEnumerator(REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo, const char* rootUri, enumeratorAuthentication* auth, unsigned int flags)
|
||||
redfishService *
|
||||
createServiceEnumerator (
|
||||
REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo,
|
||||
const char *rootUri,
|
||||
enumeratorAuthentication *auth,
|
||||
unsigned int flags
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
CHAR16 *HttpUrl;
|
||||
@ -295,6 +356,7 @@ redfishService* createServiceEnumerator(REDFISH_CONFIG_SERVICE_INFORMATION *Redf
|
||||
if (RedfishConfigServiceInfo->RedfishServiceRestExHandle == NULL) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Status = RedfishBuildUrl (RedfishConfigServiceInfo, NULL, &HttpUrl);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
@ -315,6 +377,7 @@ redfishService* createServiceEnumerator(REDFISH_CONFIG_SERVICE_INFORMATION *Redf
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if (auth == NULL) {
|
||||
ret = createServiceEnumeratorNoAuth (AsciiHost, rootUri, true, flags, RestEx);
|
||||
} else if (auth->authType == REDFISH_AUTH_BASIC) {
|
||||
@ -338,7 +401,12 @@ ON_EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
json_t* getUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
json_t *
|
||||
getUriFromService (
|
||||
redfishService *service,
|
||||
const char *uri,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
char *url;
|
||||
json_t *ret;
|
||||
@ -349,16 +417,14 @@ json_t* getUriFromService(redfishService* service, const char* uri, EFI_HTTP_STA
|
||||
EFI_HTTP_MESSAGE ResponseMsg;
|
||||
EFI_HTTP_HEADER *ContentEncodedHeader;
|
||||
|
||||
if(service == NULL || uri == NULL || StatusCode == NULL)
|
||||
{
|
||||
if ((service == NULL) || (uri == NULL) || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
|
||||
url = makeUrlForService (service, uri);
|
||||
if(!url)
|
||||
{
|
||||
if (!url) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -373,8 +439,7 @@ json_t* getUriFromService(redfishService* service, const char* uri, EFI_HTTP_STA
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if(service->sessionToken)
|
||||
{
|
||||
if (service->sessionToken) {
|
||||
Status = HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->sessionToken);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
} else if (service->basicAuthStr) {
|
||||
@ -445,7 +510,7 @@ json_t* getUriFromService(redfishService* service, const char* uri, EFI_HTTP_STA
|
||||
**StatusCode = ResponseMsg.Data.Response->StatusCode;
|
||||
}
|
||||
|
||||
if (ResponseMsg.BodyLength != 0 && ResponseMsg.Body != NULL) {
|
||||
if ((ResponseMsg.BodyLength != 0) && (ResponseMsg.Body != NULL)) {
|
||||
//
|
||||
// Check if data is encoded.
|
||||
//
|
||||
@ -461,6 +526,7 @@ json_t* getUriFromService(redfishService* service, const char* uri, EFI_HTTP_STA
|
||||
goto ON_EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
ret = json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL);
|
||||
} else {
|
||||
//
|
||||
@ -491,7 +557,13 @@ ON_EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
json_t* patchUriFromService(redfishService* service, const char* uri, const char* content, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
json_t *
|
||||
patchUriFromService (
|
||||
redfishService *service,
|
||||
const char *uri,
|
||||
const char *content,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
char *url;
|
||||
json_t *ret;
|
||||
@ -504,16 +576,14 @@ json_t* patchUriFromService(redfishService* service, const char* uri, const char
|
||||
CHAR8 *EncodedContent;
|
||||
UINTN EncodedContentLen;
|
||||
|
||||
if(service == NULL || uri == NULL || content == NULL || StatusCode == NULL)
|
||||
{
|
||||
if ((service == NULL) || (uri == NULL) || (content == NULL) || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
|
||||
url = makeUrlForService (service, uri);
|
||||
if(!url)
|
||||
{
|
||||
if (!url) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -528,8 +598,7 @@ json_t* patchUriFromService(redfishService* service, const char* uri, const char
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if(service->sessionToken)
|
||||
{
|
||||
if (service->sessionToken) {
|
||||
Status = HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->sessionToken);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
} else if (service->basicAuthStr) {
|
||||
@ -636,8 +705,7 @@ json_t* patchUriFromService(redfishService* service, const char* uri, const char
|
||||
FreePool (EncodedContent);
|
||||
}
|
||||
|
||||
|
||||
if (ResponseMsg.BodyLength != 0 && ResponseMsg.Body != NULL) {
|
||||
if ((ResponseMsg.BodyLength != 0) && (ResponseMsg.Body != NULL)) {
|
||||
ret = json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL);
|
||||
} else {
|
||||
//
|
||||
@ -668,7 +736,15 @@ ON_EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
json_t* postUriFromService(redfishService* service, const char* uri, const char* content, size_t contentLength, const char* contentType, 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
|
||||
)
|
||||
{
|
||||
char *url = NULL;
|
||||
json_t *ret;
|
||||
@ -682,23 +758,20 @@ json_t* postUriFromService(redfishService* service, const char* uri, const char*
|
||||
|
||||
ret = NULL;
|
||||
|
||||
if(service == NULL || uri == NULL || content == NULL || StatusCode == NULL)
|
||||
{
|
||||
if ((service == NULL) || (uri == NULL) || (content == NULL) || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
|
||||
url = makeUrlForService (service, uri);
|
||||
if(!url)
|
||||
{
|
||||
if (!url) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "libredfish: postUriFromService(): %a\n", url));
|
||||
|
||||
if(contentLength == 0)
|
||||
{
|
||||
if (contentLength == 0) {
|
||||
contentLength = strlen (content);
|
||||
}
|
||||
|
||||
@ -710,8 +783,7 @@ json_t* postUriFromService(redfishService* service, const char* uri, const char*
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if(service->sessionToken)
|
||||
{
|
||||
if (service->sessionToken) {
|
||||
Status = HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->sessionToken);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
} else if (service->basicAuthStr) {
|
||||
@ -726,6 +798,7 @@ json_t* postUriFromService(redfishService* service, const char* uri, const char*
|
||||
Status = HttpIoSetHeader (HttpIoHeader, "Content-Type", (CHAR8 *)contentType);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
Status = HttpIoSetHeader (HttpIoHeader, "Host", service->HostHeaderValue);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = HttpIoSetHeader (HttpIoHeader, "Accept", "application/json");
|
||||
@ -795,21 +868,22 @@ json_t* postUriFromService(redfishService* service, const char* uri, const char*
|
||||
**StatusCode = ResponseMsg.Data.Response->StatusCode;
|
||||
}
|
||||
|
||||
if (ResponseMsg.BodyLength != 0 && ResponseMsg.Body != NULL) {
|
||||
if ((ResponseMsg.BodyLength != 0) && (ResponseMsg.Body != NULL)) {
|
||||
ret = json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL);
|
||||
}
|
||||
|
||||
//
|
||||
// Step 6: Parsing the HttpHeader to retrive the X-Auth-Token if the HTTP StatusCode is correct.
|
||||
//
|
||||
if (ResponseMsg.Data.Response->StatusCode == HTTP_STATUS_200_OK ||
|
||||
ResponseMsg.Data.Response->StatusCode == HTTP_STATUS_204_NO_CONTENT) {
|
||||
if ((ResponseMsg.Data.Response->StatusCode == HTTP_STATUS_200_OK) ||
|
||||
(ResponseMsg.Data.Response->StatusCode == HTTP_STATUS_204_NO_CONTENT))
|
||||
{
|
||||
HttpHeader = HttpFindHeader (ResponseMsg.HeaderCount, ResponseMsg.Headers, "X-Auth-Token");
|
||||
if (HttpHeader != NULL) {
|
||||
if(service->sessionToken)
|
||||
{
|
||||
if (service->sessionToken) {
|
||||
free (service->sessionToken);
|
||||
}
|
||||
|
||||
service->sessionToken = AllocateCopyPool (AsciiStrSize (HttpHeader->FieldValue), HttpHeader->FieldValue);
|
||||
}
|
||||
|
||||
@ -849,7 +923,12 @@ ON_EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
json_t* deleteUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
json_t *
|
||||
deleteUriFromService (
|
||||
redfishService *service,
|
||||
const char *uri,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
char *url;
|
||||
json_t *ret;
|
||||
@ -861,16 +940,14 @@ json_t* deleteUriFromService(redfishService* service, const char* uri, EFI_HTTP_
|
||||
|
||||
ret = NULL;
|
||||
|
||||
if(service == NULL || uri == NULL || StatusCode == NULL)
|
||||
{
|
||||
if ((service == NULL) || (uri == NULL) || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
|
||||
url = makeUrlForService (service, uri);
|
||||
if(!url)
|
||||
{
|
||||
if (!url) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -885,14 +962,14 @@ json_t* deleteUriFromService(redfishService* service, const char* uri, EFI_HTTP_
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if(service->sessionToken)
|
||||
{
|
||||
if (service->sessionToken) {
|
||||
Status = HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->sessionToken);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
} else if (service->basicAuthStr) {
|
||||
Status = HttpIoSetHeader (HttpIoHeader, "Authorization", service->basicAuthStr);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
Status = HttpIoSetHeader (HttpIoHeader, "Host", service->HostHeaderValue);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = HttpIoSetHeader (HttpIoHeader, "User-Agent", "libredfish");
|
||||
@ -954,7 +1031,7 @@ json_t* deleteUriFromService(redfishService* service, const char* uri, EFI_HTTP_
|
||||
**StatusCode = ResponseMsg.Data.Response->StatusCode;
|
||||
}
|
||||
|
||||
if (ResponseMsg.BodyLength != 0 && ResponseMsg.Body != NULL) {
|
||||
if ((ResponseMsg.BodyLength != 0) && (ResponseMsg.Body != NULL)) {
|
||||
ret = json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL);
|
||||
}
|
||||
|
||||
@ -980,72 +1057,78 @@ ON_EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
redfishPayload* getRedfishServiceRoot(redfishService* service, const char* version, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
redfishPayload *
|
||||
getRedfishServiceRoot (
|
||||
redfishService *service,
|
||||
const char *version,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
json_t *value;
|
||||
json_t *versionNode;
|
||||
const char *verUrl;
|
||||
|
||||
if(version == NULL)
|
||||
{
|
||||
if (version == NULL) {
|
||||
versionNode = json_object_get (service->versions, "v1");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
versionNode = json_object_get (service->versions, version);
|
||||
}
|
||||
if(versionNode == NULL)
|
||||
{
|
||||
|
||||
if (versionNode == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
verUrl = json_string_value (versionNode);
|
||||
if(verUrl == NULL)
|
||||
{
|
||||
if (verUrl == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
value = getUriFromService (service, verUrl, StatusCode);
|
||||
if(value == NULL)
|
||||
{
|
||||
if((service->flags & REDFISH_FLAG_SERVICE_NO_VERSION_DOC) == 0)
|
||||
{
|
||||
if (value == NULL) {
|
||||
if ((service->flags & REDFISH_FLAG_SERVICE_NO_VERSION_DOC) == 0) {
|
||||
json_decref (versionNode);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return createRedfishPayload (value, service);
|
||||
}
|
||||
|
||||
redfishPayload* getPayloadByPath(redfishService* service, const char* path, EFI_HTTP_STATUS_CODE** StatusCode)
|
||||
redfishPayload *
|
||||
getPayloadByPath (
|
||||
redfishService *service,
|
||||
const char *path,
|
||||
EFI_HTTP_STATUS_CODE **StatusCode
|
||||
)
|
||||
{
|
||||
redPathNode *redpath;
|
||||
redfishPayload *root;
|
||||
redfishPayload *ret;
|
||||
|
||||
if(!service || !path || StatusCode == NULL)
|
||||
{
|
||||
if (!service || !path || (StatusCode == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*StatusCode = NULL;
|
||||
|
||||
redpath = parseRedPath (path);
|
||||
if(!redpath)
|
||||
{
|
||||
if (!redpath) {
|
||||
return NULL;
|
||||
}
|
||||
if(!redpath->isRoot)
|
||||
{
|
||||
|
||||
if (!redpath->isRoot) {
|
||||
cleanupRedPath (redpath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
root = getRedfishServiceRoot (service, redpath->version, StatusCode);
|
||||
if (*StatusCode == NULL || **StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT) {
|
||||
if ((*StatusCode == NULL) || (**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT)) {
|
||||
cleanupRedPath (redpath);
|
||||
return root;
|
||||
}
|
||||
|
||||
if(redpath->next == NULL)
|
||||
{
|
||||
if (redpath->next == NULL) {
|
||||
cleanupRedPath (redpath);
|
||||
return root;
|
||||
}
|
||||
@ -1054,7 +1137,7 @@ redfishPayload* getPayloadByPath(redfishService* service, const char* path, EFI_
|
||||
*StatusCode = NULL;
|
||||
|
||||
ret = getPayloadForPath (root, redpath->next, StatusCode);
|
||||
if (*StatusCode == NULL && ret != NULL) {
|
||||
if ((*StatusCode == NULL) && (ret != NULL)) {
|
||||
//
|
||||
// In such a case, the Redfish resource is parsed from the input payload (root) directly.
|
||||
// So, we still return HTTP_STATUS_200_OK.
|
||||
@ -1066,57 +1149,73 @@ redfishPayload* getPayloadByPath(redfishService* service, const char* path, EFI_
|
||||
**StatusCode = HTTP_STATUS_200_OK;
|
||||
}
|
||||
}
|
||||
|
||||
cleanupPayload (root);
|
||||
cleanupRedPath (redpath);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void cleanupServiceEnumerator(redfishService* service)
|
||||
{
|
||||
if(!service)
|
||||
void
|
||||
cleanupServiceEnumerator (
|
||||
redfishService *service
|
||||
)
|
||||
{
|
||||
if (!service) {
|
||||
return;
|
||||
}
|
||||
|
||||
free (service->host);
|
||||
json_decref (service->versions);
|
||||
if(service->sessionToken != NULL)
|
||||
{
|
||||
if (service->sessionToken != NULL) {
|
||||
ZeroMem (service->sessionToken, (UINTN)strlen (service->sessionToken));
|
||||
FreePool (service->sessionToken);
|
||||
}
|
||||
|
||||
if (service->basicAuthStr != NULL) {
|
||||
ZeroMem (service->basicAuthStr, (UINTN)strlen (service->basicAuthStr));
|
||||
FreePool (service->basicAuthStr);
|
||||
}
|
||||
|
||||
free (service);
|
||||
}
|
||||
|
||||
static int initRest(redfishService* service, void * restProtocol)
|
||||
static int
|
||||
initRest (
|
||||
redfishService *service,
|
||||
void *restProtocol
|
||||
)
|
||||
{
|
||||
service->RestEx = restProtocol;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static redfishService* createServiceEnumeratorNoAuth(const char* host, const char* rootUri, bool enumerate, unsigned int flags, void * restProtocol)
|
||||
static redfishService *
|
||||
createServiceEnumeratorNoAuth (
|
||||
const char *host,
|
||||
const char *rootUri,
|
||||
bool enumerate,
|
||||
unsigned int flags,
|
||||
void *restProtocol
|
||||
)
|
||||
{
|
||||
redfishService *ret;
|
||||
char *HostStart;
|
||||
|
||||
ret = (redfishService *)calloc (1, sizeof (redfishService));
|
||||
ZeroMem (ret, sizeof (redfishService));
|
||||
if(initRest(ret, restProtocol) != 0)
|
||||
{
|
||||
if (initRest (ret, restProtocol) != 0) {
|
||||
free (ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret->host = AllocateCopyPool (AsciiStrSize (host), host);
|
||||
ret->flags = flags;
|
||||
if(enumerate)
|
||||
{
|
||||
if (enumerate) {
|
||||
ret->versions = getVersions (ret, rootUri);
|
||||
}
|
||||
|
||||
HostStart = strstr (ret->host, "//");
|
||||
if (HostStart != NULL && (*(HostStart + 2) != '\0')) {
|
||||
if ((HostStart != NULL) && (*(HostStart + 2) != '\0')) {
|
||||
ret->HostHeaderValue = HostStart + 2;
|
||||
}
|
||||
|
||||
@ -1220,7 +1319,15 @@ Exit:
|
||||
return Status;
|
||||
}
|
||||
|
||||
static redfishService* createServiceEnumeratorBasicAuth(const char* host, const char* rootUri, const char* username, const char* password, unsigned int flags, void * restProtocol)
|
||||
static redfishService *
|
||||
createServiceEnumeratorBasicAuth (
|
||||
const char *host,
|
||||
const char *rootUri,
|
||||
const char *username,
|
||||
const char *password,
|
||||
unsigned int flags,
|
||||
void *restProtocol
|
||||
)
|
||||
{
|
||||
redfishService *ret;
|
||||
EFI_STATUS Status;
|
||||
@ -1238,7 +1345,15 @@ static redfishService* createServiceEnumeratorBasicAuth(const char* host, const
|
||||
return ret;
|
||||
}
|
||||
|
||||
static redfishService* createServiceEnumeratorSessionAuth(const char* host, const char* rootUri, const char* username, const char* password, unsigned int flags, void * restProtocol)
|
||||
static redfishService *
|
||||
createServiceEnumeratorSessionAuth (
|
||||
const char *host,
|
||||
const char *rootUri,
|
||||
const char *username,
|
||||
const char *password,
|
||||
unsigned int flags,
|
||||
void *restProtocol
|
||||
)
|
||||
{
|
||||
redfishService *ret;
|
||||
redfishPayload *payload;
|
||||
@ -1255,13 +1370,12 @@ static redfishService* createServiceEnumeratorSessionAuth(const char* host, cons
|
||||
StatusCode = NULL;
|
||||
|
||||
ret = createServiceEnumeratorNoAuth (host, rootUri, true, flags, restProtocol);
|
||||
if(ret == NULL)
|
||||
{
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
payload = getRedfishServiceRoot (ret, NULL, &StatusCode);
|
||||
if(StatusCode == NULL || *StatusCode < HTTP_STATUS_200_OK || *StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT)
|
||||
{
|
||||
if ((StatusCode == NULL) || (*StatusCode < HTTP_STATUS_200_OK) || (*StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT)) {
|
||||
if (StatusCode != NULL) {
|
||||
FreePool (StatusCode);
|
||||
}
|
||||
@ -1269,6 +1383,7 @@ static redfishService* createServiceEnumeratorSessionAuth(const char* host, cons
|
||||
if (payload != NULL) {
|
||||
cleanupPayload (payload);
|
||||
}
|
||||
|
||||
cleanupServiceEnumerator (ret);
|
||||
return NULL;
|
||||
}
|
||||
@ -1280,25 +1395,25 @@ static redfishService* createServiceEnumeratorSessionAuth(const char* host, cons
|
||||
|
||||
links = getPayloadByNodeName (payload, "Links", &StatusCode);
|
||||
cleanupPayload (payload);
|
||||
if(links == NULL)
|
||||
{
|
||||
if (links == NULL) {
|
||||
cleanupServiceEnumerator (ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
session = json_object_get (links->json, "Sessions");
|
||||
if(session == NULL)
|
||||
{
|
||||
if (session == NULL) {
|
||||
cleanupPayload (links);
|
||||
cleanupServiceEnumerator (ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
odataId = json_object_get (session, "@odata.id");
|
||||
if(odataId == NULL)
|
||||
{
|
||||
if (odataId == NULL) {
|
||||
cleanupPayload (links);
|
||||
cleanupServiceEnumerator (ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uri = json_string_value (odataId);
|
||||
post = json_object ();
|
||||
addStringToJsonObject (post, "UserName", username);
|
||||
@ -1312,8 +1427,7 @@ static redfishService* createServiceEnumeratorSessionAuth(const char* host, cons
|
||||
free (content);
|
||||
}
|
||||
|
||||
if(sessionPayload == NULL || StatusCode == NULL || *StatusCode < HTTP_STATUS_200_OK || *StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT)
|
||||
{
|
||||
if ((sessionPayload == NULL) || (StatusCode == NULL) || (*StatusCode < HTTP_STATUS_200_OK) || (*StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT)) {
|
||||
// Failed to create session!
|
||||
|
||||
cleanupPayload (links);
|
||||
@ -1329,53 +1443,61 @@ static redfishService* createServiceEnumeratorSessionAuth(const char* host, cons
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
json_decref (sessionPayload);
|
||||
cleanupPayload (links);
|
||||
FreePool (StatusCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char* makeUrlForService(redfishService* service, const char* uri)
|
||||
static char *
|
||||
makeUrlForService (
|
||||
redfishService *service,
|
||||
const char *uri
|
||||
)
|
||||
{
|
||||
char *url;
|
||||
if(service->host == NULL)
|
||||
{
|
||||
|
||||
if (service->host == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
url = (char *)malloc (strlen (service->host)+strlen (uri)+1);
|
||||
strcpy (url, service->host);
|
||||
strcat (url, uri);
|
||||
return url;
|
||||
}
|
||||
|
||||
static json_t* getVersions(redfishService* service, const char* rootUri)
|
||||
static json_t *
|
||||
getVersions (
|
||||
redfishService *service,
|
||||
const char *rootUri
|
||||
)
|
||||
{
|
||||
json_t *ret = NULL;
|
||||
EFI_HTTP_STATUS_CODE *StatusCode = NULL;
|
||||
|
||||
if(service->flags & REDFISH_FLAG_SERVICE_NO_VERSION_DOC)
|
||||
{
|
||||
if (service->flags & REDFISH_FLAG_SERVICE_NO_VERSION_DOC) {
|
||||
service->versions = json_object ();
|
||||
if(service->versions == NULL)
|
||||
{
|
||||
if (service->versions == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
addStringToJsonObject (service->versions, "v1", "/redfish/v1");
|
||||
return service->versions;
|
||||
}
|
||||
if(rootUri != NULL)
|
||||
{
|
||||
|
||||
if (rootUri != NULL) {
|
||||
ret = getUriFromService (service, rootUri, &StatusCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ret = getUriFromService (service, "/redfish", &StatusCode);
|
||||
}
|
||||
|
||||
if (ret == NULL || StatusCode == NULL || *StatusCode < HTTP_STATUS_200_OK || *StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT) {
|
||||
if ((ret == NULL) || (StatusCode == NULL) || (*StatusCode < HTTP_STATUS_200_OK) || (*StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT)) {
|
||||
if (ret != NULL) {
|
||||
json_decref (ret);
|
||||
}
|
||||
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
@ -1386,7 +1508,12 @@ static json_t* getVersions(redfishService* service, const char* rootUri)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void addStringToJsonObject(json_t* object, const char* key, const char* value)
|
||||
static void
|
||||
addStringToJsonObject (
|
||||
json_t *object,
|
||||
const char *key,
|
||||
const char *value
|
||||
)
|
||||
{
|
||||
json_t *jValue = json_string (value);
|
||||
|
||||
|
@ -33,7 +33,7 @@ RedfishConfigOnEndOfDxe (
|
||||
EFI_STATUS Status;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ RedfishConfigOnExitBootService (
|
||||
EFI_STATUS Status;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
@ -114,6 +114,7 @@ RedfishConfigCommonInit (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Locate Redfish Credential Protocol to get credential for
|
||||
// accessing to Redfish service.
|
||||
@ -123,6 +124,7 @@ RedfishConfigCommonInit (
|
||||
DEBUG ((DEBUG_INFO, "%a: No Redfish Credential Protocol is installed on system.", __FUNCTION__));
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Create EndOfDxe Event.
|
||||
//
|
||||
@ -138,6 +140,7 @@ RedfishConfigCommonInit (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Fail to register End Of DXE event.", __FUNCTION__));
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Create Exit Boot Service event.
|
||||
//
|
||||
@ -155,8 +158,10 @@ RedfishConfigCommonInit (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Fail to register Exit Boot Service event.", __FUNCTION__));
|
||||
return Status;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
This is the common code to stop EDK2 Redfish feature driver.
|
||||
|
||||
@ -182,7 +187,7 @@ RedfishConfigCommonStop (
|
||||
&NumberOfHandles,
|
||||
&HandleBuffer
|
||||
);
|
||||
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -196,13 +201,15 @@ RedfishConfigCommonStop (
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
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));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Callback function executed when a Redfish Config Handler Protocol is installed
|
||||
by EDK2 Redfish Feature Drivers.
|
||||
@ -248,9 +255,10 @@ RedfishConfigHandlerInitialization (
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
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));
|
||||
}
|
||||
|
||||
//
|
||||
// Install caller ID to indicate Redfish Configure Handler is initialized.
|
||||
//
|
||||
|
@ -57,6 +57,7 @@ RedfishConfigStopRedfishDiscovery (
|
||||
if (gEfiRedfishDiscoverProtocolEvent != NULL) {
|
||||
gBS->CloseEvent (gEfiRedfishDiscoverProtocolEvent);
|
||||
}
|
||||
|
||||
//
|
||||
// Stop Redfish service discovery.
|
||||
//
|
||||
@ -172,6 +173,7 @@ RedfishConfigDriverBindingSupported (
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
NetLibDestroyServiceChild (
|
||||
ControllerHandle,
|
||||
This->ImageHandle,
|
||||
@ -278,6 +280,7 @@ RedfishConfigDriverBindingStop (
|
||||
if (ControllerHandle == gEfiRedfishDiscoverControllerHandle) {
|
||||
RedfishConfigStopRedfishDiscovery ();
|
||||
}
|
||||
|
||||
gBS->CloseProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiRedfishDiscoverProtocolGuid,
|
||||
@ -294,6 +297,7 @@ RedfishConfigDriverBindingStop (
|
||||
gBS->CloseEvent (gRedfishConfigData.Event);
|
||||
gRedfishConfigData.Event = NULL;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -381,6 +385,7 @@ RedfishDiscoverProtocolInstalled (
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Can't locate handle with EFI_REDFISH_DISCOVER_PROTOCOL installed.\n", __FUNCTION__));
|
||||
}
|
||||
|
||||
gRedfishDiscoverActivated = TRUE;
|
||||
if (gEfiRedfishDiscoverProtocol == NULL) {
|
||||
gEfiRedfishDiscoverControllerHandle = HandleBuffer;
|
||||
@ -402,19 +407,21 @@ RedfishDiscoverProtocolInstalled (
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check the new found network interface.
|
||||
//
|
||||
if (gNetworkInterfaceInstances != NULL) {
|
||||
FreePool (gNetworkInterfaceInstances);
|
||||
}
|
||||
|
||||
Status = gEfiRedfishDiscoverProtocol->GetNetworkInterfaceList (
|
||||
gEfiRedfishDiscoverProtocol,
|
||||
gRedfishConfigData.Image,
|
||||
&gNumberOfNetworkInterfaces,
|
||||
&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__));
|
||||
return;
|
||||
}
|
||||
@ -445,6 +452,7 @@ RedfishDiscoverProtocolInstalled (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered token.\n", __FUNCTION__));
|
||||
goto ErrorReturn;
|
||||
}
|
||||
|
||||
ThisRedfishDiscoveredToken->Signature = REDFISH_DISCOVER_TOKEN_SIGNATURE;
|
||||
ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound = 0;
|
||||
ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances = NULL;
|
||||
@ -462,10 +470,12 @@ RedfishDiscoverProtocolInstalled (
|
||||
ThisNetworkInterface++;
|
||||
ThisRedfishDiscoveredToken++;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Acquire Redfish service fail.\n", __FUNCTION__));
|
||||
goto ErrorReturn;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
ErrorReturn:
|
||||
@ -500,11 +510,14 @@ RedfishConfigHandlerDriverUnload (
|
||||
if (ThisRedfishDiscoveredToken->Event != NULL) {
|
||||
gBS->CloseEvent (ThisRedfishDiscoveredToken->Event);
|
||||
}
|
||||
|
||||
FreePool (ThisRedfishDiscoveredToken);
|
||||
ThisRedfishDiscoveredToken++;
|
||||
}
|
||||
|
||||
gRedfishDiscoveredToken = NULL;
|
||||
}
|
||||
|
||||
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__));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->RegisterProtocolNotify (
|
||||
&gEfiRedfishDiscoverProtocolGuid,
|
||||
gEfiRedfishDiscoverProtocolEvent,
|
||||
@ -582,6 +596,6 @@ RedfishConfigHandlerDriverEntryPoint (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI Binding Protocol of EFI Redfish Config driver.", __FUNCTION__));
|
||||
return Status;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -156,4 +156,5 @@ RedfishConfigDriverBindingStop (
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -85,7 +85,7 @@ RedfishCredentialGetAuthInfo (
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef 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_STOP_SERVICE_TYPE ServiceStopType
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -13,6 +13,7 @@
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user-readable name of the EFI Driver.
|
||||
|
||||
@ -93,7 +94,6 @@ RedfishDiscoverComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
///
|
||||
/// Component Name Protocol instance
|
||||
///
|
||||
|
@ -119,20 +119,25 @@ GetInstanceByOwner (
|
||||
if (IsListEmpty (&mRedfishDiscoverList)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ThisInstance =
|
||||
(EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *)GetFirstNode (&mRedfishDiscoverList);
|
||||
while (TRUE) {
|
||||
if ((ThisInstance->Owner == ImageHandle) &&
|
||||
(ThisInstance->DiscoverFlags == DiscoverFlags) &&
|
||||
(ThisInstance->NetworkInterface == TargetNetworkInterface)) {
|
||||
(ThisInstance->NetworkInterface == TargetNetworkInterface))
|
||||
{
|
||||
return ThisInstance;
|
||||
}
|
||||
|
||||
if (IsNodeAtEnd (&mRedfishDiscoverList, &ThisInstance->Entry)) {
|
||||
break;
|
||||
}
|
||||
|
||||
ThisInstance =
|
||||
(EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *)GetNextNode (&mRedfishDiscoverList, &ThisInstance->Entry);
|
||||
};
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -164,6 +169,7 @@ Tcp4GetSubnetInfo (
|
||||
if (Instance == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Tcp4 = (EFI_TCP4_PROTOCOL *)Instance->NetworkInterfaceProtocolInfo.NetworkProtocolInterface;
|
||||
|
||||
ZeroMem ((VOID *)&Tcp4CfgData, sizeof (EFI_TCP4_CONFIG_DATA));
|
||||
@ -193,11 +199,13 @@ Tcp4GetSubnetInfo (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Can't get subnet information\n", __FUNCTION__));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Tcp4->GetModeData (Tcp4, NULL, NULL, &IpModedata, NULL, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Can't get IP mode data information\n", __FUNCTION__));
|
||||
return Status;
|
||||
}
|
||||
|
||||
IP4_COPY_ADDRESS (&Instance->SubnetMask, &IpModedata.ConfigData.SubnetMask);
|
||||
Instance->SubnetAddr.v4.Addr[0] = IpModedata.ConfigData.StationAddress.Addr[0] & Instance->SubnetMask.v4.Addr[0];
|
||||
Instance->SubnetAddr.v4.Addr[1] = IpModedata.ConfigData.StationAddress.Addr[1] & Instance->SubnetMask.v4.Addr[1];
|
||||
@ -218,10 +226,13 @@ Tcp4GetSubnetInfo (
|
||||
GotPrefixLength = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
BitMask = BitMask >> 1;
|
||||
};
|
||||
}
|
||||
|
||||
SubnetMaskIndex++;
|
||||
};
|
||||
}
|
||||
|
||||
Instance->SubnetPrefixLength = PrefixLength;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -248,6 +259,7 @@ Tcp6GetSubnetInfo (
|
||||
if (Instance == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Tcp6 = (EFI_TCP6_PROTOCOL *)Instance->NetworkInterfaceProtocolInfo.NetworkProtocolInterface;
|
||||
|
||||
Status = Tcp6->GetModeData (Tcp6, NULL, NULL, &IpModedata, NULL, NULL);
|
||||
@ -255,17 +267,21 @@ Tcp6GetSubnetInfo (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Can't get IP mode data information\n"));
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (IpModedata.AddressCount == 0) {
|
||||
DEBUG ((DEBUG_INFO, "%a: No IPv6 address configured.\n"));
|
||||
}
|
||||
|
||||
if (Instance->SubnetAddrInfoIPv6 != NULL) {
|
||||
FreePool (Instance->SubnetAddrInfoIPv6);
|
||||
}
|
||||
|
||||
Instance->SubnetAddrInfoIPv6 = AllocateZeroPool (IpModedata.AddressCount * sizeof (EFI_IP6_ADDRESS_INFO));
|
||||
if (Instance->SubnetAddrInfoIPv6 == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Failed to allocate memory fir IPv6 subnet address information\n"));
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Instance->SubnetAddrInfoIPv6Number = IpModedata.AddressCount;
|
||||
CopyMem (
|
||||
(VOID *)Instance->SubnetAddrInfoIPv6,
|
||||
@ -298,11 +314,14 @@ GetTargetNetworkInterfaceInternal (
|
||||
if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
|
||||
return ThisNetworkInterface;
|
||||
}
|
||||
|
||||
if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterface->Entry)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterface->Entry);
|
||||
};
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -325,9 +344,10 @@ ValidateTargetNetworkInterface (
|
||||
{
|
||||
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface;
|
||||
|
||||
if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface) && TargetNetworkInterface == NULL) {
|
||||
if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface) && (TargetNetworkInterface == NULL)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (TargetNetworkInterface == NULL) {
|
||||
return EFI_SUCCESS; // Return EFI_SUCCESS if no network interface is specified.
|
||||
}
|
||||
@ -337,29 +357,37 @@ ValidateTargetNetworkInterface (
|
||||
if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterface->Entry)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterface->Entry);
|
||||
};
|
||||
}
|
||||
|
||||
if ((Flags & EFI_REDFISH_DISCOVER_SSDP) != 0) {
|
||||
// Validate if UDP4/6 is supported on the given network interface.
|
||||
// SSDP is not supported.
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (ThisNetworkInterface->NetworkInterfaceProtocolInfo.ProtocolControllerHandle == NULL) {
|
||||
return EFI_UNSUPPORTED; // The required protocol on this network interface is not found.
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
This function returns number of network interface instance.
|
||||
|
||||
@retval UINTN Number of network interface instances.
|
||||
**/
|
||||
UINTN
|
||||
NumberOfNetworkInterface (VOID)
|
||||
NumberOfNetworkInterface (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Num;
|
||||
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface;
|
||||
@ -374,9 +402,11 @@ NumberOfNetworkInterface (VOID)
|
||||
if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterface->Entry)) {
|
||||
break;
|
||||
}
|
||||
|
||||
ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterface->Entry);
|
||||
Num++;
|
||||
};
|
||||
}
|
||||
|
||||
return Num;
|
||||
}
|
||||
|
||||
@ -397,6 +427,7 @@ CheckIsIpVersion6 (
|
||||
if (ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -410,7 +441,9 @@ CheckIsIpVersion6 (
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
DiscoverRedfishHostInterface (IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Instance)
|
||||
DiscoverRedfishHostInterface (
|
||||
IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Instance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
REDFISH_OVER_IP_PROTOCOL_DATA *Data;
|
||||
@ -431,8 +464,9 @@ DiscoverRedfishHostInterface (IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Insta
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
|
||||
if (!EFI_ERROR (Status) && Data != NULL && DeviceDescriptor != NULL) {
|
||||
if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
|
||||
//
|
||||
// Chceck if we can reach out Redfish service using this network interface.
|
||||
// Check with MAC address using Device Descroptor Data Device Type 04 and Type 05.
|
||||
@ -445,6 +479,7 @@ DiscoverRedfishHostInterface (IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Insta
|
||||
} else {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (MacCompareStstus != 0) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@ -467,6 +502,7 @@ DiscoverRedfishHostInterface (IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Insta
|
||||
if (Data->RedfishServiceIpPort == 443) {
|
||||
IsHttps = TRUE;
|
||||
}
|
||||
|
||||
StrSize = sizeof (UuidStr);
|
||||
AsciiSPrint (UuidStr, StrSize, "%g", &Data->ServiceUuid);
|
||||
//
|
||||
@ -474,7 +510,7 @@ DiscoverRedfishHostInterface (IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Insta
|
||||
//
|
||||
if (Data->RedfishServiceIpAddressFormat == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) {
|
||||
NetLibIp6ToStr ((IPv6_ADDRESS *)&Data->RedfishServiceIpAddress, Ipv6Str, sizeof (Ipv6Str));
|
||||
if (Data->RedfishServiceIpPort == 0 || IsHttps == TRUE) {
|
||||
if ((Data->RedfishServiceIpPort == 0) || (IsHttps == TRUE)) {
|
||||
AsciiSPrintUnicodeFormat (
|
||||
RedfishServiceLocateStr,
|
||||
sizeof (RedfishServiceLocateStr),
|
||||
@ -491,7 +527,7 @@ DiscoverRedfishHostInterface (IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Insta
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (Data->RedfishServiceIpPort == 0 || IsHttps == TRUE) {
|
||||
if ((Data->RedfishServiceIpPort == 0) || (IsHttps == TRUE)) {
|
||||
AsciiSPrint (
|
||||
RedfishServiceLocateStr,
|
||||
sizeof (RedfishServiceLocateStr),
|
||||
@ -514,6 +550,7 @@ DiscoverRedfishHostInterface (IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Insta
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Status = AddAndSignalNewRedfishService (
|
||||
Instance,
|
||||
NULL,
|
||||
@ -527,6 +564,7 @@ DiscoverRedfishHostInterface (IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Insta
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -583,6 +621,7 @@ AddAndSignalNewRedfishService (
|
||||
Char16Uuid = (CHAR16 *)AllocateZeroPool (AsciiStrSize ((const CHAR8 *)Uuid) * sizeof (CHAR16));
|
||||
AsciiStrToUnicodeStrS ((const CHAR8 *)Uuid, Char16Uuid, AsciiStrSize ((const CHAR8 *)Uuid) * sizeof (CHAR16));
|
||||
}
|
||||
|
||||
DiscoveredList = NULL;
|
||||
DiscoveredInstance = NULL;
|
||||
RestExHttpConfigData = NULL;
|
||||
@ -595,27 +634,31 @@ AddAndSignalNewRedfishService (
|
||||
DiscoveredList = (EFI_REDFISH_DISCOVERED_INTERNAL_LIST *)GetFirstNode (&mRedfishInstanceList);
|
||||
NewFound = FALSE;
|
||||
do {
|
||||
if (Char16Uuid == NULL || DiscoveredList->Instance->Information.Uuid == NULL) {
|
||||
if ((Char16Uuid == NULL) || (DiscoveredList->Instance->Information.Uuid == NULL)) {
|
||||
//
|
||||
// Check if this Redfish instance already found using IP addrress.
|
||||
//
|
||||
if (!CheckIsIpVersion6 (NetworkInterface)) {
|
||||
if (CompareMem ((VOID *)&Instance->TargetIpAddress.v4,
|
||||
if (CompareMem (
|
||||
(VOID *)&Instance->TargetIpAddress.v4,
|
||||
(VOID *)&DiscoveredList->Instance->Information.RedfishHostIpAddress.v4,
|
||||
sizeof (EFI_IPv4_ADDRESS)
|
||||
) == 0)
|
||||
{
|
||||
DiscoveredInstance = DiscoveredList->Instance;
|
||||
if (DiscoveredList->Instance->Information.Uuid == NULL &&
|
||||
Char16Uuid != NULL) {
|
||||
if ((DiscoveredList->Instance->Information.Uuid == NULL) &&
|
||||
(Char16Uuid != NULL))
|
||||
{
|
||||
InfoRefresh = TRUE;
|
||||
DiscoveredInstance = DiscoveredList->Instance;
|
||||
DEBUG ((DEBUG_INFO, "*** This Redfish Service information refresh ***\n"));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (CompareMem ((VOID *)&Instance->TargetIpAddress.v6,
|
||||
if (CompareMem (
|
||||
(VOID *)&Instance->TargetIpAddress.v6,
|
||||
(VOID *)&DiscoveredList->Instance->Information.RedfishHostIpAddress.v6,
|
||||
sizeof (EFI_IPv6_ADDRESS)
|
||||
) == 0)
|
||||
@ -633,19 +676,23 @@ AddAndSignalNewRedfishService (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsNodeAtEnd (&mRedfishInstanceList, &DiscoveredList->NextInstance)) {
|
||||
NewFound = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
DiscoveredList = (EFI_REDFISH_DISCOVERED_INTERNAL_LIST *)GetNextNode (&mRedfishInstanceList, &DiscoveredList->NextInstance);
|
||||
} while (TRUE);
|
||||
}
|
||||
|
||||
if (NewFound || InfoRefresh) {
|
||||
if (!InfoRefresh) {
|
||||
DiscoveredList = (EFI_REDFISH_DISCOVERED_INTERNAL_LIST *)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVERED_INTERNAL_LIST));
|
||||
if (DiscoveredList == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
InitializeListHead (&DiscoveredList->NextInstance);
|
||||
DiscoveredInstance = (EFI_REDFISH_DISCOVERED_INSTANCE *)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVERED_INSTANCE));
|
||||
if (DiscoveredInstance == NULL) {
|
||||
@ -653,6 +700,7 @@ AddAndSignalNewRedfishService (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "*** Redfish Service Information ***\n"));
|
||||
|
||||
DiscoveredInstance->Information.UseHttps = UseHttps;
|
||||
@ -660,26 +708,31 @@ AddAndSignalNewRedfishService (
|
||||
DiscoveredInstance->Information.RedfishVersion = *RedfishVersion;
|
||||
DEBUG ((DEBUG_INFO, "Redfish service version: %d.\n", DiscoveredInstance->Information.RedfishVersion));
|
||||
}
|
||||
|
||||
if (RedfishLocation != NULL) {
|
||||
DiscoveredInstance->Information.Location = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)RedfishLocation) * sizeof (CHAR16));
|
||||
AsciiStrToUnicodeStrS ((const CHAR8 *)RedfishLocation, DiscoveredInstance->Information.Location, AsciiStrSize ((const CHAR8 *)RedfishLocation) * sizeof (CHAR16));
|
||||
DEBUG ((DEBUG_INFO, "Redfish service location: %s.\n", DiscoveredInstance->Information.Location));
|
||||
}
|
||||
|
||||
if (Uuid != NULL) {
|
||||
DiscoveredInstance->Information.Uuid = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)Uuid) * sizeof (CHAR16));
|
||||
AsciiStrToUnicodeStrS ((const CHAR8 *)Uuid, DiscoveredInstance->Information.Uuid, AsciiStrSize ((const CHAR8 *)Uuid) * sizeof (CHAR16));
|
||||
DEBUG ((DEBUG_INFO, "Service UUID: %s.\n", DiscoveredInstance->Information.Uuid));
|
||||
}
|
||||
|
||||
if (Os != NULL) {
|
||||
DiscoveredInstance->Information.Os = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)Os) * sizeof (CHAR16));
|
||||
AsciiStrToUnicodeStrS ((const CHAR8 *)Os, DiscoveredInstance->Information.Os, AsciiStrSize ((const CHAR8 *)Os) * sizeof (CHAR16));
|
||||
DEBUG ((DEBUG_INFO, "Redfish service OS: %s, Version:%s.\n", DiscoveredInstance->Information.Os, DiscoveredInstance->Information.OsVersion));
|
||||
}
|
||||
|
||||
if (OsVer != NULL) {
|
||||
DiscoveredInstance->Information.OsVersion = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)OsVer) * sizeof (CHAR16));
|
||||
AsciiStrToUnicodeStrS ((const CHAR8 *)OsVer, DiscoveredInstance->Information.OsVersion, AsciiStrSize ((const CHAR8 *)OsVer) * sizeof (CHAR16));
|
||||
}
|
||||
if (Product != NULL && ProductVer != NULL) {
|
||||
|
||||
if ((Product != NULL) && (ProductVer != NULL)) {
|
||||
DiscoveredInstance->Information.Product = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)Product) * sizeof (CHAR16));
|
||||
AsciiStrToUnicodeStrS ((const CHAR8 *)Product, DiscoveredInstance->Information.Product, AsciiStrSize ((const CHAR8 *)Product) * sizeof (CHAR16));
|
||||
DiscoveredInstance->Information.ProductVer = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)ProductVer) * sizeof (CHAR16));
|
||||
@ -693,10 +746,12 @@ AddAndSignalNewRedfishService (
|
||||
|
||||
IP4_COPY_ADDRESS ((VOID *)&DiscoveredInstance->Information.RedfishHostIpAddress.v4, (VOID *)&Instance->TargetIpAddress.v4);
|
||||
}
|
||||
|
||||
if (!InfoRefresh) {
|
||||
DiscoveredList->Instance = DiscoveredInstance;
|
||||
InsertTailList (&mRedfishInstanceList, &DiscoveredList->NextInstance);
|
||||
}
|
||||
|
||||
DiscoveredInstance->Status = EFI_SUCCESS;
|
||||
} else {
|
||||
if (DiscoveredList != NULL) {
|
||||
@ -708,6 +763,7 @@ AddAndSignalNewRedfishService (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Char16Uuid != NULL) {
|
||||
FreePool ((VOID *)Char16Uuid);
|
||||
}
|
||||
@ -726,7 +782,9 @@ AddAndSignalNewRedfishService (
|
||||
DEBUG ((DEBUG_ERROR, "%a:Can't create REST EX child instance.\n", __FUNCTION__));
|
||||
goto ON_EXIT;
|
||||
}
|
||||
Status = gBS->OpenProtocol ( // Configure local host information.
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
// Configure local host information.
|
||||
Instance->DiscoverToken->DiscoverList.RedfishInstances->Information.RedfishRestExHandle,
|
||||
&gEfiRestExProtocolGuid,
|
||||
(VOID **)&RestEx,
|
||||
@ -738,6 +796,7 @@ AddAndSignalNewRedfishService (
|
||||
DeleteRestEx = TRUE;
|
||||
goto ERROR_EXIT;
|
||||
}
|
||||
|
||||
RestExOpened = TRUE;
|
||||
RestExHttpConfigData = AllocateZeroPool (sizeof (EFI_REST_EX_HTTP_CONFIG_DATA));
|
||||
if (RestExHttpConfigData == NULL) {
|
||||
@ -745,6 +804,7 @@ AddAndSignalNewRedfishService (
|
||||
DeleteRestEx = TRUE;
|
||||
goto EXIT_FREE_CONFIG_DATA;
|
||||
}
|
||||
|
||||
RestExHttpConfigData->SendReceiveTimeout = 5000;
|
||||
RestExHttpConfigData->HttpConfigData.HttpVersion = HttpVersion11;
|
||||
RestExHttpConfigData->HttpConfigData.LocalAddressIsIPv6 = CheckIsIpVersion6 (NetworkInterface);
|
||||
@ -760,8 +820,10 @@ AddAndSignalNewRedfishService (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto EXIT_FREE_CONFIG_DATA;
|
||||
}
|
||||
|
||||
RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node->UseDefaultAddress = TRUE;
|
||||
}
|
||||
|
||||
Status = RestEx->Configure (
|
||||
RestEx,
|
||||
(EFI_REST_EX_CONFIG_DATA)(UINT8 *)RestExHttpConfigData
|
||||
@ -771,6 +833,7 @@ AddAndSignalNewRedfishService (
|
||||
DeleteRestEx = TRUE;
|
||||
goto EXIT_FREE_ALL;
|
||||
}
|
||||
|
||||
//
|
||||
// Signal client, close REST EX before signaling client.
|
||||
//
|
||||
@ -784,6 +847,7 @@ AddAndSignalNewRedfishService (
|
||||
RestExOpened = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
Status = gBS->SignalEvent (Instance->DiscoverToken->Event);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a:No event to signal!\n", __FUNCTION__));
|
||||
@ -791,7 +855,7 @@ AddAndSignalNewRedfishService (
|
||||
}
|
||||
|
||||
EXIT_FREE_ALL:;
|
||||
if (RestExHttpConfigData != NULL && RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node != NULL) {
|
||||
if ((RestExHttpConfigData != NULL) && (RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node != NULL)) {
|
||||
FreePool (RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node);
|
||||
}
|
||||
|
||||
@ -799,6 +863,7 @@ EXIT_FREE_CONFIG_DATA:;
|
||||
if (RestExHttpConfigData != NULL) {
|
||||
FreePool ((VOID *)RestExHttpConfigData);
|
||||
}
|
||||
|
||||
if (RestExOpened) {
|
||||
gBS->CloseProtocol (
|
||||
Instance->DiscoverToken->DiscoverList.RedfishInstances->Information.RedfishRestExHandle,
|
||||
@ -807,6 +872,7 @@ EXIT_FREE_CONFIG_DATA:;
|
||||
Instance->NetworkInterface->OpenDriverControllerHandle
|
||||
);
|
||||
}
|
||||
|
||||
ERROR_EXIT:;
|
||||
if (DeleteRestEx && RestExOpened) {
|
||||
gBS->CloseProtocol (
|
||||
@ -816,6 +882,7 @@ ERROR_EXIT:;
|
||||
Instance->NetworkInterface->OpenDriverControllerHandle
|
||||
);
|
||||
}
|
||||
|
||||
ON_EXIT:;
|
||||
return Status;
|
||||
}
|
||||
@ -847,7 +914,7 @@ NetworkInterfaceGetSubnetInfo (
|
||||
}
|
||||
|
||||
ProtocolType = Instance->NetworkProtocolType;
|
||||
if (gRequiredProtocol [ProtocolType].GetSubnetInfo != NULL && Instance->GotSubnetInfo == FALSE) {
|
||||
if ((gRequiredProtocol[ProtocolType].GetSubnetInfo != NULL) && (Instance->GotSubnetInfo == FALSE)) {
|
||||
Status = gRequiredProtocol[ProtocolType].GetSubnetInfo (
|
||||
ImageHandle,
|
||||
Instance
|
||||
@ -862,12 +929,16 @@ NetworkInterfaceGetSubnetInfo (
|
||||
DEBUG ((DEBUG_ERROR, "%a: There is no Subnet infomation for IPv6 network interface.\n", __FUNCTION__));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
ThisSubnetAddrInfoIPv6 = Instance->SubnetAddrInfoIPv6; // First IPv6 address information.
|
||||
IP6_COPY_ADDRESS (&Instance->SubnetAddr.v6, &ThisSubnetAddrInfoIPv6->Address);
|
||||
Instance->SubnetPrefixLength = ThisSubnetAddrInfoIPv6->PrefixLength;
|
||||
DEBUG((DEBUG_INFO," IPv6 Subnet ID:%d, Prefix length: %d.\n",
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
" IPv6 Subnet ID:%d, Prefix length: %d.\n",
|
||||
ThisSubnetAddrInfoIPv6->Address.Addr[7] + (UINT16)ThisSubnetAddrInfoIPv6->Address.Addr[6] * 256,
|
||||
ThisSubnetAddrInfoIPv6->PrefixLength)
|
||||
ThisSubnetAddrInfoIPv6->PrefixLength
|
||||
)
|
||||
);
|
||||
//
|
||||
// If this is IPv6, then we may have to propagate network interface for IPv6 network scopes
|
||||
@ -887,16 +958,21 @@ NetworkInterfaceGetSubnetInfo (
|
||||
InsertTailList (&mEfiRedfishDiscoverNetworkInterface, &NewNetworkInterface->Entry);
|
||||
ThisSubnetAddrInfoIPv6++;
|
||||
mNumNetworkInterface++;
|
||||
DEBUG((DEBUG_INFO," IPv6 Subnet ID:%d, Prefix length: %d.\n",
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
" IPv6 Subnet ID:%d, Prefix length: %d.\n",
|
||||
ThisSubnetAddrInfoIPv6->Address.Addr[7] + (UINT16)ThisSubnetAddrInfoIPv6->Address.Addr[6] * 256,
|
||||
ThisSubnetAddrInfoIPv6->PrefixLength)
|
||||
ThisSubnetAddrInfoIPv6->PrefixLength
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DEBUG ((DEBUG_INFO," IPv4 Subnet:%d.%d.%d.%d Subnet mask: %d.%d.%d.%d.\n",
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
" IPv4 Subnet:%d.%d.%d.%d Subnet mask: %d.%d.%d.%d.\n",
|
||||
Instance->SubnetAddr.v4.Addr[0],
|
||||
Instance->SubnetAddr.v4.Addr[1],
|
||||
Instance->SubnetAddr.v4.Addr[2],
|
||||
@ -909,6 +985,7 @@ NetworkInterfaceGetSubnetInfo (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Instance->GotSubnetInfo = TRUE; // Only try to get Subnet Info once.
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -942,7 +1019,7 @@ RedfishServiceGetNetworkInterface (
|
||||
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterfaceIntn;
|
||||
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface;
|
||||
|
||||
if (NetworkIntfInstances == NULL || NumberOfNetworkIntfs == NULL || ImageHandle == NULL) {
|
||||
if ((NetworkIntfInstances == NULL) || (NumberOfNetworkIntfs == NULL) || (ImageHandle == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -957,6 +1034,7 @@ RedfishServiceGetNetworkInterface (
|
||||
if (ThisNetworkInterface == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
*NetworkIntfInstances = ThisNetworkInterface;
|
||||
ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
|
||||
while (TRUE) {
|
||||
@ -964,6 +1042,7 @@ RedfishServiceGetNetworkInterface (
|
||||
if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
|
||||
ThisNetworkInterface->IsIpv6 = TRUE;
|
||||
}
|
||||
|
||||
CopyMem ((VOID *)&ThisNetworkInterface->MacAddress, &ThisNetworkInterfaceIntn->MacAddress, ThisNetworkInterfaceIntn->HwAddressSize);
|
||||
NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info.
|
||||
if (!ThisNetworkInterface->IsIpv6) {
|
||||
@ -971,17 +1050,21 @@ RedfishServiceGetNetworkInterface (
|
||||
} else {
|
||||
IP6_COPY_ADDRESS (&ThisNetworkInterface->SubnetId.v6, &ThisNetworkInterfaceIntn->SubnetAddr.v6); // IPv6 subnet information in IPv6 address information.
|
||||
}
|
||||
|
||||
ThisNetworkInterface->SubnetPrefixLength = ThisNetworkInterfaceIntn->SubnetPrefixLength;
|
||||
ThisNetworkInterface->VlanId = ThisNetworkInterfaceIntn->VlanId;
|
||||
(*NumberOfNetworkIntfs)++;
|
||||
if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
|
||||
break;
|
||||
}
|
||||
|
||||
ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
|
||||
ThisNetworkInterface++;
|
||||
};
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
This function acquires Redfish services by discovering static Redfish setting
|
||||
according to Redfish Host Interface or through SSDP. Returns a list of EFI
|
||||
@ -1029,16 +1112,18 @@ RedfishServiceAcquireService (
|
||||
//
|
||||
// Validate parameters.
|
||||
//
|
||||
if (ImageHandle == NULL || Token == NULL || ((Flags & ~EFI_REDFISH_DISCOVER_VALIDATION) == 0)) {
|
||||
if ((ImageHandle == NULL) || (Token == NULL) || ((Flags & ~EFI_REDFISH_DISCOVER_VALIDATION) == 0)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a:Invalid parameters.\n", __FUNCTION__));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate target network interface.
|
||||
//
|
||||
if (EFI_ERROR (ValidateTargetNetworkInterface (TargetNetworkInterface, Flags))) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (TargetNetworkInterface != NULL) {
|
||||
TargetNetworkInterfaceInternal = GetTargetNetworkInterfaceInternal (TargetNetworkInterface);
|
||||
NumNetworkInterfaces = 1;
|
||||
@ -1050,6 +1135,7 @@ RedfishServiceAcquireService (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
for (NetworkInterfacesIndex = 0; NetworkInterfacesIndex < NumNetworkInterfaces; NetworkInterfacesIndex++) {
|
||||
Status1 = EFI_SUCCESS;
|
||||
Status2 = EFI_SUCCESS;
|
||||
@ -1061,6 +1147,7 @@ RedfishServiceAcquireService (
|
||||
if (Instance == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "%a:Memory allocation fail.\n", __FUNCTION__));
|
||||
}
|
||||
|
||||
InitializeListHead (&Instance->Entry);
|
||||
Instance->Owner = ImageHandle;
|
||||
Instance->DiscoverFlags = Flags & ~EFI_REDFISH_DISCOVER_VALIDATION;
|
||||
@ -1072,6 +1159,7 @@ RedfishServiceAcquireService (
|
||||
NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
|
||||
NewInstance = TRUE;
|
||||
}
|
||||
|
||||
if (TargetNetworkInterfaceInternal->StrMacAddr != NULL) {
|
||||
DEBUG ((DEBUG_INFO, "%a:Acquire Redfish service on network interface MAC address:%s.\n", __FUNCTION__, TargetNetworkInterfaceInternal->StrMacAddr));
|
||||
} else {
|
||||
@ -1085,8 +1173,10 @@ RedfishServiceAcquireService (
|
||||
if ((Flags & EFI_REDFISH_DISCOVER_VALIDATION) != 0) {
|
||||
Instance->HostIntfValidation = TRUE;
|
||||
}
|
||||
|
||||
Status1 = DiscoverRedfishHostInterface (Instance); // Discover Redfish service through Redfish Host Interface.
|
||||
}
|
||||
|
||||
if ((Flags & EFI_REDFISH_DISCOVER_SSDP) != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a:Redfish service discovery through SSDP is not supported\n", __FUNCTION__));
|
||||
return EFI_UNSUPPORTED;
|
||||
@ -1100,6 +1190,7 @@ RedfishServiceAcquireService (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TargetNetworkInterface == NULL) {
|
||||
//
|
||||
// Discover Redfish services on all of network interfaces.
|
||||
@ -1107,6 +1198,7 @@ RedfishServiceAcquireService (
|
||||
TargetNetworkInterfaceInternal = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &TargetNetworkInterfaceInternal->Entry);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1160,6 +1252,7 @@ RedfishServiceReleaseService (
|
||||
DEBUG ((DEBUG_ERROR, "%a:No any discovered Redfish service.\n", __FUNCTION__));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
AnyFailRelease = FALSE;
|
||||
ThisRedfishInstance = InstanceList->RedfishInstances;
|
||||
for (NumService = 0; NumService < InstanceList->NumberOfServiceFound; NumService++) {
|
||||
@ -1170,21 +1263,27 @@ RedfishServiceReleaseService (
|
||||
if (ThisRedfishInstance->Information.Location != NULL) {
|
||||
FreePool (ThisRedfishInstance->Information.Location);
|
||||
}
|
||||
|
||||
if (ThisRedfishInstance->Information.Uuid != NULL) {
|
||||
FreePool (ThisRedfishInstance->Information.Uuid);
|
||||
}
|
||||
|
||||
if (ThisRedfishInstance->Information.Os != NULL) {
|
||||
FreePool (ThisRedfishInstance->Information.Os);
|
||||
}
|
||||
|
||||
if (ThisRedfishInstance->Information.OsVersion != NULL) {
|
||||
FreePool (ThisRedfishInstance->Information.OsVersion);
|
||||
}
|
||||
|
||||
if (ThisRedfishInstance->Information.Product != NULL) {
|
||||
FreePool (ThisRedfishInstance->Information.Product);
|
||||
}
|
||||
|
||||
if (ThisRedfishInstance->Information.ProductVer != NULL) {
|
||||
FreePool (ThisRedfishInstance->Information.ProductVer);
|
||||
}
|
||||
|
||||
FreePool ((VOID *)ThisRedfishInstance);
|
||||
goto ReleaseNext;
|
||||
}
|
||||
@ -1192,8 +1291,10 @@ RedfishServiceReleaseService (
|
||||
if (IsNodeAtEnd (&mRedfishInstanceList, &DiscoveredRedfishInstance->NextInstance)) {
|
||||
break;
|
||||
}
|
||||
|
||||
DiscoveredRedfishInstance = (EFI_REDFISH_DISCOVERED_INTERNAL_LIST *)GetNextNode (&mRedfishInstanceList, &DiscoveredRedfishInstance->NextInstance);
|
||||
} while (TRUE);
|
||||
|
||||
AnyFailRelease = TRUE;
|
||||
ReleaseNext:;
|
||||
//
|
||||
@ -1201,6 +1302,7 @@ ReleaseNext:;
|
||||
//
|
||||
ThisRedfishInstance = (EFI_REDFISH_DISCOVERED_INSTANCE *)((UINT8 *)ThisRedfishInstance + sizeof (EFI_REDFISH_DISCOVERED_INSTANCE));
|
||||
}
|
||||
|
||||
if (AnyFailRelease) {
|
||||
return EFI_NOT_FOUND;
|
||||
} else {
|
||||
@ -1251,19 +1353,23 @@ CreateRedfishDiscoverNetworkInterface (
|
||||
if (ThisNetworkInterface != NULL) {
|
||||
while (TRUE) {
|
||||
if ((CompareMem ((CONST VOID *)&ThisNetworkInterface->MacAddress.Addr, (CONST VOID *)&MacAddress.Addr, HwAddressSize) == 0) &&
|
||||
(ThisNetworkInterface->NetworkProtocolType == NetworkProtocolType)){
|
||||
(ThisNetworkInterface->NetworkProtocolType == NetworkProtocolType))
|
||||
{
|
||||
NewNetworkInterface = ThisNetworkInterface;
|
||||
*IsNewInstance = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterface->Entry)) {
|
||||
NewNetworkInterface = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterface->Entry);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NewNetworkInterface == NULL) {
|
||||
//
|
||||
// Create a new instance.
|
||||
@ -1272,11 +1378,13 @@ CreateRedfishDiscoverNetworkInterface (
|
||||
if (NewNetworkInterface == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
NewNetworkInterface->HwAddressSize = HwAddressSize;
|
||||
CopyMem (&NewNetworkInterface->MacAddress.Addr, &MacAddress.Addr, NewNetworkInterface->HwAddressSize);
|
||||
NetLibGetMacString (ControllerHandle, NULL, &NewNetworkInterface->StrMacAddr);
|
||||
NewNetworkInterface->VlanId = NetLibGetVlanId (ControllerHandle);
|
||||
}
|
||||
|
||||
*NetworkInterface = NewNetworkInterface;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -1352,6 +1460,7 @@ TestForRequiredProtocols (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -1391,7 +1500,8 @@ BuildupNetworkInterface (
|
||||
NewNetworkInterfaceInstalled = FALSE;
|
||||
Index = 0;
|
||||
do {
|
||||
Status = gBS->OpenProtocol ( // Already in list?
|
||||
Status = gBS->OpenProtocol (
|
||||
// Already in list?
|
||||
ControllerHandle,
|
||||
gRequiredProtocol[Index].DiscoveredProtocolGuid,
|
||||
(VOID **)&Id,
|
||||
@ -1404,6 +1514,7 @@ BuildupNetworkInterface (
|
||||
if (Index == (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1420,8 +1531,10 @@ BuildupNetworkInterface (
|
||||
if (Index == (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gRequiredProtocol[Index].ProtocolType != ProtocolTypeRestEx) {
|
||||
OldTpl = gBS->RaiseTPL (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL);
|
||||
Status = CreateRedfishDiscoverNetworkInterface (ControllerHandle, gRequiredProtocol[Index].ProtocolType, &IsNew, &NetworkInterface);
|
||||
@ -1429,6 +1542,7 @@ BuildupNetworkInterface (
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
NetworkInterface->NetworkProtocolType = gRequiredProtocol[Index].ProtocolType;
|
||||
NetworkInterface->OpenDriverAgentHandle = This->DriverBindingHandle;
|
||||
NetworkInterface->OpenDriverControllerHandle = ControllerHandle;
|
||||
@ -1446,6 +1560,7 @@ BuildupNetworkInterface (
|
||||
InsertTailList (&mEfiRedfishDiscoverNetworkInterface, &NetworkInterface->Entry);
|
||||
mNumNetworkInterface++;
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
} else {
|
||||
// Record REST_EX instance. REST_EX is created when clinet asks for Redfish service discovery.
|
||||
@ -1456,6 +1571,7 @@ BuildupNetworkInterface (
|
||||
if (RestExInstance == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
RestExInstance->OpenDriverAgentHandle = This->DriverBindingHandle;
|
||||
RestExInstance->OpenDriverControllerHandle = ControllerHandle;
|
||||
RestExInstance->RestExControllerHandle = ControllerHandle;
|
||||
@ -1468,6 +1584,7 @@ BuildupNetworkInterface (
|
||||
HandleOfProtocolInterfacePtr = &RestExInstance->RestExChildHandle;
|
||||
Interface = (VOID **)&RestExInstance->RestExProtocolInterface;
|
||||
}
|
||||
|
||||
Status = gBS->InstallProtocolInterface (
|
||||
&ControllerHandle,
|
||||
gRequiredProtocol[Index].DiscoveredProtocolGuid,
|
||||
@ -1479,8 +1596,10 @@ BuildupNetworkInterface (
|
||||
if (Index == (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Create service binding child and open it BY_DRIVER.
|
||||
//
|
||||
@ -1500,10 +1619,11 @@ BuildupNetworkInterface (
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (EfiRedfishDiscoverProtocolHandle == NULL &&
|
||||
if ((EfiRedfishDiscoverProtocolHandle == NULL) &&
|
||||
(gRequiredProtocol[Index].ProtocolType == ProtocolTypeRestEx) &&
|
||||
!IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)
|
||||
) {
|
||||
)
|
||||
{
|
||||
// Install the fisrt Redfish Discover Protocol when EFI REST EX protcol is discovered.
|
||||
// This ensures EFI REST EX is ready while EFI_REDFISH_DISCOVER_PROTOCOL consumer acquires
|
||||
// Redfish serivce over network interface.
|
||||
@ -1514,7 +1634,7 @@ BuildupNetworkInterface (
|
||||
EFI_NATIVE_INTERFACE,
|
||||
(VOID *)&mRedfishDiscover
|
||||
);
|
||||
} else if (EfiRedfishDiscoverProtocolHandle != NULL && NewNetworkInterfaceInstalled) {
|
||||
} else if ((EfiRedfishDiscoverProtocolHandle != NULL) && NewNetworkInterfaceInstalled) {
|
||||
Status = gBS->ReinstallProtocolInterface (
|
||||
EfiRedfishDiscoverProtocolHandle,
|
||||
&gEfiRedfishDiscoverProtocolGuid,
|
||||
@ -1524,17 +1644,21 @@ BuildupNetworkInterface (
|
||||
NewNetworkInterfaceInstalled = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
} else {
|
||||
Index++;
|
||||
if (Index == (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
} while (Index < (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL)));
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
Close the protocol opened for Redfish discovery. This function also destories
|
||||
the network services.
|
||||
@ -1576,8 +1700,10 @@ CloseProtocolService (
|
||||
ControllerHandle
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Stop the services on network interface.
|
||||
|
||||
@ -1612,12 +1738,13 @@ StopServiceOnNetworkInterface (
|
||||
if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL);
|
||||
ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
|
||||
while (TRUE) {
|
||||
if (ThisNetworkInterface->NetworkInterfaceProtocolInfo.ProtocolControllerHandle == ControllerHandle) {
|
||||
|
||||
Status = CloseProtocolService ( // Close protocol and destroy service.
|
||||
Status = CloseProtocolService (
|
||||
// Close protocol and destroy service.
|
||||
ThisBindingProtocol,
|
||||
ControllerHandle,
|
||||
&gRequiredProtocol[Index],
|
||||
@ -1627,6 +1754,7 @@ StopServiceOnNetworkInterface (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = DestroyRedfishNetwrokInterface (ThisNetworkInterface);
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
// Reinstall Redfish Discover protocol to notify network
|
||||
// interface change.
|
||||
@ -1640,23 +1768,29 @@ StopServiceOnNetworkInterface (
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Reinstall gEfiRedfishDiscoverProtocolGuid fail.", __FUNCTION__));
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterface->Entry)) {
|
||||
break;
|
||||
}
|
||||
|
||||
ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterface->Entry);
|
||||
};
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
} else {
|
||||
if (IsListEmpty (&mEfiRedfishDiscoverRestExInstance)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL);
|
||||
RestExInstance = (EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverRestExInstance);
|
||||
while (TRUE) {
|
||||
if (RestExInstance->RestExChildHandle == ControllerHandle) {
|
||||
Status = CloseProtocolService ( // Close REST_EX protocol.
|
||||
Status = CloseProtocolService (
|
||||
// Close REST_EX protocol.
|
||||
ThisBindingProtocol,
|
||||
ControllerHandle,
|
||||
&gRequiredProtocol[Index],
|
||||
@ -1669,17 +1803,22 @@ StopServiceOnNetworkInterface (
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (IsNodeAtEnd (&mEfiRedfishDiscoverRestExInstance, &RestExInstance->Entry)) {
|
||||
break;
|
||||
}
|
||||
|
||||
RestExInstance = (EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverRestExInstance, &RestExInstance->Entry);
|
||||
};
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
Tests to see if this driver supports a given controller. If a child device is provided,
|
||||
it further tests to see if this driver supports creating a handle for the specified child device.
|
||||
@ -1891,7 +2030,8 @@ RedfishDiscoverUnload (
|
||||
while (!IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) {
|
||||
ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
|
||||
StopServiceOnNetworkInterface (&gRedfishDiscoverDriverBinding, ThisNetworkInterface->NetworkInterfaceProtocolInfo.ProtocolControllerHandle);
|
||||
};
|
||||
}
|
||||
|
||||
// Disconnect EFI Redfish discover driver controller to notify the
|
||||
// clinet which uses .EFI Redfish discover protocol.
|
||||
|
||||
@ -1906,5 +2046,6 @@ RedfishDiscoverUnload (
|
||||
(VOID *)&mRedfishDiscover
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -104,12 +104,14 @@ RedfishGetHostInterfaceProtocolData (
|
||||
if (Offset > mType42Record->Hdr.Length) {
|
||||
return EFI_SECURITY_VIOLATION;
|
||||
}
|
||||
|
||||
*ProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)RecordTmp;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
|
||||
}
|
||||
|
||||
|
@ -57,20 +57,25 @@ RedfishCreateSmbiosTable42 (
|
||||
DEBUG ((DEBUG_ERROR, "%a: No Redfish host interface descriptor is provided on this platform.", __FUNCTION__));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "%a: Fail to get device descriptor, %r.", __FUNCTION__, 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__));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
|
||||
DeviceDataLength = DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.Length;
|
||||
} else {
|
||||
DeviceDataLength = DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.Length;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop to get platform Redfish host interface protocol type data.
|
||||
//
|
||||
@ -86,16 +91,20 @@ RedfishCreateSmbiosTable42 (
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Fail to get Redfish host interafce protocol type data.", __FUNCTION__));
|
||||
if (ProtocolRecords != NULL) {
|
||||
FreePool (ProtocolRecords);
|
||||
}
|
||||
|
||||
if (ProtocolRecord != NULL) {
|
||||
FreePool (ProtocolRecord);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
ProtocolDataSize = sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - sizeof (ProtocolRecord->ProtocolTypeData) + ProtocolRecord->ProtocolTypeDataLen;
|
||||
NewProtocolsDataLength += ProtocolDataSize;
|
||||
if (ProtocolRecords == NULL) {
|
||||
@ -104,6 +113,7 @@ RedfishCreateSmbiosTable42 (
|
||||
FreePool (ProtocolRecord);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem ((VOID *)ProtocolRecords, (VOID *)ProtocolRecord, ProtocolDataSize);
|
||||
NewProtocolRecords = ProtocolRecords;
|
||||
} else {
|
||||
@ -114,19 +124,23 @@ RedfishCreateSmbiosTable42 (
|
||||
FreePool (ProtocolRecord);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
(VOID *)((UINT8 *)NewProtocolRecords + CurrentProtocolsDataLength),
|
||||
(VOID *)ProtocolRecord,
|
||||
ProtocolDataSize
|
||||
);
|
||||
}
|
||||
|
||||
FreePool (ProtocolRecord);
|
||||
CurrentProtocolsDataLength = NewProtocolsDataLength;
|
||||
ProtocolCount++;
|
||||
};
|
||||
}
|
||||
|
||||
if (ProtocolCount == 0) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Construct SMBIOS Type 42h for Redfish host inteface.
|
||||
//
|
||||
@ -205,18 +219,22 @@ RedfishCreateSmbiosTable42 (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
ON_EXIT:
|
||||
if (DeviceDescriptor != NULL) {
|
||||
FreePool (DeviceDescriptor);
|
||||
}
|
||||
|
||||
if (NewProtocolRecords != NULL) {
|
||||
FreePool (NewProtocolRecords);
|
||||
}
|
||||
|
||||
if (Type42Record != NULL) {
|
||||
FreePool (Type42Record);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user-readable name of the EFI Driver.
|
||||
|
||||
|
@ -47,7 +47,7 @@ RestExDestroyChildEntryInHandleBuffer (
|
||||
UINTN NumberOfChildren;
|
||||
EFI_HANDLE *ChildHandleBuffer;
|
||||
|
||||
if (Entry == NULL || Context == NULL) {
|
||||
if ((Entry == NULL) || (Context == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -354,7 +354,6 @@ RedfishRestExDriverBindingSupported (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
)
|
||||
{
|
||||
|
||||
//
|
||||
// Test for the HttpServiceBinding Protocol.
|
||||
//
|
||||
@ -366,7 +365,6 @@ RedfishRestExDriverBindingSupported (
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -565,7 +563,7 @@ RedfishRestExDriverBindingStop (
|
||||
);
|
||||
}
|
||||
|
||||
if (NumberOfChildren == 0 && IsListEmpty (&RestExSb->RestExChildrenList)) {
|
||||
if ((NumberOfChildren == 0) && IsListEmpty (&RestExSb->RestExChildrenList)) {
|
||||
gBS->UninstallProtocolInterface (
|
||||
NicHandle,
|
||||
&gEfiRestExServiceBindingProtocolGuid,
|
||||
@ -627,6 +625,7 @@ RedfishRestExServiceBindingCreateChild (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (Instance != NULL);
|
||||
|
||||
//
|
||||
@ -800,7 +799,6 @@ RedfishRestExServiceBindingDestroyChild (
|
||||
ChildHandle
|
||||
);
|
||||
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
//
|
||||
@ -828,4 +826,3 @@ RedfishRestExServiceBindingDestroyChild (
|
||||
RestExDestroyInstance (Instance);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,6 @@ typedef struct _RESTEX_INSTANCE RESTEX_INSTANCE;
|
||||
#define RESTEX_INSTANCE_FROM_THIS(a) \
|
||||
CR (a, RESTEX_INSTANCE, RestEx, RESTEX_INSTANCE_SIGNATURE)
|
||||
|
||||
|
||||
#define RESTEX_STATE_UNCONFIGED 0
|
||||
#define RESTEX_STATE_CONFIGED 1
|
||||
|
||||
@ -359,6 +358,7 @@ RedfishRestExEventService (
|
||||
IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL,
|
||||
IN EFI_REST_EX_TOKEN *RestExToken
|
||||
);
|
||||
|
||||
/**
|
||||
Create a new TLS session becuase the previous on is closed.
|
||||
status.
|
||||
@ -374,7 +374,6 @@ ResetHttpTslSession (
|
||||
IN RESTEX_INSTANCE *Instance
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Callback function which provided by user to remove one node in NetDestroyLinkList process.
|
||||
|
||||
@ -419,7 +418,6 @@ RestExCreateInstance (
|
||||
OUT RESTEX_INSTANCE **Instance
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Release all the resource used the RestEx service binding instance.
|
||||
|
||||
@ -647,4 +645,5 @@ RedfishRestExServiceBindingDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -34,12 +34,15 @@ ResetHttpTslSession (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Error to reset HTTP instance.\n", __FUNCTION__));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = Instance->HttpIo.Http->Configure (Instance->HttpIo.Http, &((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Error to re-initiate HTTP instance.\n", __FUNCTION__));
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
This function check
|
||||
|
||||
@ -64,7 +67,7 @@ RedfishCheckHttpReceiveStatus (
|
||||
|
||||
if (!EFI_ERROR (HttpIoReceiveStatus)) {
|
||||
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) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: TCP error, reset HTTP session.\n", __FUNCTION__));
|
||||
Instance->Flags |= RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY;
|
||||
@ -85,15 +88,18 @@ RedfishCheckHttpReceiveStatus (
|
||||
DEBUG ((DEBUG_ERROR, "%a: REST_EX Send and receive fail even with a new TLS session.\n", __FUNCTION__));
|
||||
ReturnStatus = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
Instance->Flags |= RESTEX_INSTANCE_FLAGS_TLS_RETRY;
|
||||
Status = ResetHttpTslSession (Instance);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Reset HTTP instance fail.\n", __FUNCTION__));
|
||||
ReturnStatus = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Clean TLS new session retry and error try flags.
|
||||
//
|
||||
@ -132,7 +138,7 @@ RedfishHttpAddExpectation (
|
||||
{
|
||||
EFI_HTTP_HEADER *NewHeaders;
|
||||
|
||||
if (This == NULL || RequestMessage == NULL) {
|
||||
if ((This == NULL) || (RequestMessage == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -142,9 +148,11 @@ RedfishHttpAddExpectation (
|
||||
}
|
||||
|
||||
if ((RequestMessage->Data.Request->Method != HttpMethodPut) && (RequestMessage->Data.Request->Method != HttpMethodPost) &&
|
||||
(RequestMessage->Data.Request->Method != HttpMethodPatch)) {
|
||||
(RequestMessage->Data.Request->Method != HttpMethodPatch))
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
*ItsWrite = TRUE;
|
||||
|
||||
NewHeaders = AllocateZeroPool ((RequestMessage->HeaderCount + 1) * sizeof (EFI_HTTP_HEADER));
|
||||
@ -154,4 +162,3 @@ RedfishHttpAddExpectation (
|
||||
RequestMessage->Headers = NewHeaders;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -320,6 +320,7 @@ RedfishRestExEventService (
|
||||
IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL,
|
||||
IN EFI_REST_EX_TOKEN *RestExToken
|
||||
);
|
||||
|
||||
/**
|
||||
Create a new TLS session becuase the previous on is closed.
|
||||
status.
|
||||
@ -335,7 +336,6 @@ ResetHttpTslSession (
|
||||
IN RESTEX_INSTANCE *Instance
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Callback function which provided by user to remove one node in NetDestroyLinkList process.
|
||||
|
||||
@ -380,7 +380,6 @@ RestExCreateInstance (
|
||||
OUT RESTEX_INSTANCE **Instance
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Release all the resource used the RestEx service binding instance.
|
||||
|
||||
@ -608,4 +607,5 @@ RedfishRestExServiceBindingDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -75,7 +75,7 @@ RedfishRestExSendReceive (
|
||||
//
|
||||
// Validate the parameters
|
||||
//
|
||||
if ((This == NULL) || (RequestMessage == NULL) || ResponseMessage == NULL) {
|
||||
if ((This == NULL) || (RequestMessage == NULL) || (ResponseMessage == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -101,6 +101,7 @@ RedfishRestExSendReceive (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (ItsWrite == TRUE) {
|
||||
if (RequestMessage->BodyLength > HTTP_IO_MAX_SEND_PAYLOAD) {
|
||||
//
|
||||
@ -112,6 +113,7 @@ RedfishRestExSendReceive (
|
||||
SendNonChunkProcess++;
|
||||
}
|
||||
}
|
||||
|
||||
ReSendRequest:;
|
||||
//
|
||||
// Send out the request to REST service.
|
||||
@ -163,6 +165,7 @@ ReSendRequest:;
|
||||
RequestMessage->Body
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -206,6 +209,7 @@ ReSendRequest:;
|
||||
} else if (Status == EFI_DEVICE_ERROR) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Restore the headers if it ever changed in RedfishHttpAddExpectation().
|
||||
//
|
||||
@ -251,18 +255,21 @@ ReSendRequest:;
|
||||
SendChunkProcess++;
|
||||
goto ReSendRequest;
|
||||
}
|
||||
|
||||
if (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) {
|
||||
DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for non chunk transfer...\n"));
|
||||
SendNonChunkProcess++;
|
||||
goto ReSendRequest;
|
||||
}
|
||||
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
if (ResponseData->Headers != NULL && ResponseData->HeaderCount != 0) {
|
||||
if ((ResponseData->Headers != NULL) && (ResponseData->HeaderCount != 0)) {
|
||||
FreePool (ResponseData->Headers);
|
||||
}
|
||||
|
||||
ZeroMem (ResponseData, sizeof (HTTP_IO_RESPONSE_DATA));
|
||||
Status = HttpIoRecvResponse (
|
||||
&(Instance->HttpIo),
|
||||
@ -296,7 +303,7 @@ ReSendRequest:;
|
||||
//
|
||||
if (ResponseMessage->HeaderCount > 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -315,13 +322,15 @@ ReSendRequest:;
|
||||
&ChunkListLink,
|
||||
&ResponseMessage->BodyLength
|
||||
);
|
||||
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
if (Status == EFI_SUCCESS &&
|
||||
ChunkListLink != NULL &&
|
||||
|
||||
if ((Status == EFI_SUCCESS) &&
|
||||
(ChunkListLink != NULL) &&
|
||||
!IsListEmpty (ChunkListLink) &&
|
||||
ResponseMessage->BodyLength != 0) {
|
||||
(ResponseMessage->BodyLength != 0))
|
||||
{
|
||||
IsGetChunkedTransfer = TRUE;
|
||||
//
|
||||
// Copy data to Message body.
|
||||
@ -332,6 +341,7 @@ ReSendRequest:;
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
CopyChunkData = FALSE;
|
||||
}
|
||||
|
||||
Index = 0;
|
||||
while (!IsListEmpty (ChunkListLink)) {
|
||||
ThisChunk = (HTTP_IO_CHUNKS *)GetFirstNode (ChunkListLink);
|
||||
@ -339,20 +349,23 @@ ReSendRequest:;
|
||||
CopyMem (((UINT8 *)ResponseMessage->Body + Index), (UINT8 *)ThisChunk->Data, ThisChunk->Length);
|
||||
Index += ThisChunk->Length;
|
||||
}
|
||||
|
||||
RemoveEntryList (&ThisChunk->NextChunk);
|
||||
FreePool ((VOID *)ThisChunk->Data);
|
||||
FreePool ((VOID *)ThisChunk);
|
||||
};
|
||||
}
|
||||
|
||||
FreePool ((VOID *)ChunkListLink);
|
||||
}
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// 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->Headers = NULL;
|
||||
|
||||
@ -380,8 +393,10 @@ ReSendRequest:;
|
||||
|
||||
TotalReceivedSize += ResponseData->BodyLength;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Total of lengh of Response :%d\n", TotalReceivedSize));
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "RedfishRestExSendReceive()- EFI_STATUS: %r\n", Status));
|
||||
|
||||
ON_EXIT:
|
||||
@ -401,6 +416,7 @@ ON_EXIT:
|
||||
ResponseMessage->Body = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -480,7 +496,7 @@ RedfishRestExGetService (
|
||||
|
||||
ServiceInfo = NULL;
|
||||
|
||||
if (This == NULL || RestExServiceInfo == NULL) {
|
||||
if ((This == NULL) || (RestExServiceInfo == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -603,6 +619,7 @@ RedfishRestExConfigure (
|
||||
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 (Instance->ConfigData);
|
||||
Instance->ConfigData = NULL;
|
||||
}
|
||||
@ -614,6 +631,7 @@ RedfishRestExConfigure (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Instance->HttpIo.Timeout = ((EFI_REST_EX_HTTP_CONFIG_DATA *)RestExConfigData)->SendReceiveTimeout;
|
||||
|
||||
Instance->ConfigData = AllocateZeroPool (sizeof (EFI_REST_EX_HTTP_CONFIG_DATA));
|
||||
@ -621,6 +639,7 @@ RedfishRestExConfigure (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
CopyMem (Instance->ConfigData, RestExConfigData, sizeof (EFI_REST_EX_HTTP_CONFIG_DATA));
|
||||
if (HttpConfigData->LocalAddressIsIPv6 == TRUE) {
|
||||
((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;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node,
|
||||
HttpConfigData->AccessPoint.IPv6Node,
|
||||
@ -639,12 +659,14 @@ RedfishRestExConfigure (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node,
|
||||
HttpConfigData->AccessPoint.IPv4Node,
|
||||
sizeof (EFI_HTTPv4_ACCESS_POINT)
|
||||
);
|
||||
}
|
||||
|
||||
Instance->State = RESTEX_STATE_CONFIGED;
|
||||
}
|
||||
|
||||
@ -732,4 +754,3 @@ RedfishRestExEventService (
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -48,12 +48,13 @@ RestJsonStructureRegister (
|
||||
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *CloneSupportedInterpId;
|
||||
EFI_REST_JSON_STRUCTURE_SUPPORTED *ThisSupportedInterp;
|
||||
|
||||
if (This == NULL ||
|
||||
ToStructure == NULL ||
|
||||
ToJson == NULL ||
|
||||
DestroyStructure == NULL ||
|
||||
JsonStructureSupported == NULL
|
||||
) {
|
||||
if ((This == NULL) ||
|
||||
(ToStructure == NULL) ||
|
||||
(ToJson == NULL) ||
|
||||
(DestroyStructure == NULL) ||
|
||||
(JsonStructureSupported == NULL)
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -69,13 +70,14 @@ RestJsonStructureRegister (
|
||||
ThisList = ThisList->ForwardLink;
|
||||
NumberOfNS++;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Instance =
|
||||
(REST_JSON_STRUCTURE_INSTANCE *)AllocateZeroPool (sizeof (REST_JSON_STRUCTURE_INSTANCE) + NumberOfNS * sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER));
|
||||
if (Instance == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
InitializeListHead (&Instance->NextRestJsonStructureInstance);
|
||||
Instance->NumberOfNameSpaceToConvert = NumberOfNS;
|
||||
Instance->SupportedRsrcIndentifier = (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *)((REST_JSON_STRUCTURE_INSTANCE *)Instance + 1);
|
||||
@ -89,6 +91,7 @@ RestJsonStructureRegister (
|
||||
ThisSupportedInterp = (EFI_REST_JSON_STRUCTURE_SUPPORTED *)ThisSupportedInterp->NextSupportedRsrcInterp.ForwardLink;
|
||||
CloneSupportedInterpId++;
|
||||
}
|
||||
|
||||
Instance->JsonToStructure = ToStructure;
|
||||
Instance->StructureToJson = ToJson;
|
||||
Instance->DestroyStructure = DestroyStructure;
|
||||
@ -122,11 +125,12 @@ InterpreterInstanceToStruct (
|
||||
EFI_STATUS Status;
|
||||
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
|
||||
|
||||
if (This == NULL ||
|
||||
InterpreterInstance == NULL ||
|
||||
ResourceRaw == NULL ||
|
||||
RestJSonHeader == NULL
|
||||
) {
|
||||
if ((This == NULL) ||
|
||||
(InterpreterInstance == NULL) ||
|
||||
(ResourceRaw == NULL) ||
|
||||
(RestJSonHeader == NULL)
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -150,11 +154,14 @@ InterpreterInstanceToStruct (
|
||||
for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
|
||||
if (AsciiStrCmp (
|
||||
RsrcTypeIdentifier->NameSpace.ResourceTypeName,
|
||||
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0){
|
||||
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
|
||||
) == 0)
|
||||
{
|
||||
if ((RsrcTypeIdentifier->NameSpace.MajorVersion == NULL) &&
|
||||
(RsrcTypeIdentifier->NameSpace.MinorVersion == NULL) &&
|
||||
(RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Don't check version of this resource type identifier.
|
||||
//
|
||||
@ -171,13 +178,17 @@ InterpreterInstanceToStruct (
|
||||
//
|
||||
if ((AsciiStrCmp (
|
||||
RsrcTypeIdentifier->NameSpace.MajorVersion,
|
||||
ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) &&
|
||||
ThisSupportedRsrcTypeId->NameSpace.MajorVersion
|
||||
) == 0) &&
|
||||
(AsciiStrCmp (
|
||||
RsrcTypeIdentifier->NameSpace.MinorVersion,
|
||||
ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) &&
|
||||
ThisSupportedRsrcTypeId->NameSpace.MinorVersion
|
||||
) == 0) &&
|
||||
(AsciiStrCmp (
|
||||
RsrcTypeIdentifier->NameSpace.ErrataVersion,
|
||||
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) {
|
||||
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
|
||||
) == 0))
|
||||
{
|
||||
Status = InterpreterInstance->JsonToStructure (
|
||||
This,
|
||||
RsrcTypeIdentifier,
|
||||
@ -188,11 +199,14 @@ InterpreterInstanceToStruct (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ThisSupportedRsrcTypeId++;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
This function converts JSON C structure to JSON property.
|
||||
|
||||
@ -218,20 +232,23 @@ InterpreterEfiStructToInstance (
|
||||
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
|
||||
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier;
|
||||
|
||||
if (This == NULL ||
|
||||
InterpreterInstance == NULL ||
|
||||
RestJSonHeader == NULL ||
|
||||
ResourceRaw == NULL
|
||||
) {
|
||||
if ((This == NULL) ||
|
||||
(InterpreterInstance == NULL) ||
|
||||
(RestJSonHeader == NULL) ||
|
||||
(ResourceRaw == NULL)
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
RsrcTypeIdentifier = &RestJSonHeader->JsonRsrcIdentifier;
|
||||
if (RsrcTypeIdentifier == NULL ||
|
||||
RsrcTypeIdentifier->NameSpace.ResourceTypeName == NULL ||
|
||||
RsrcTypeIdentifier->NameSpace.MajorVersion == NULL ||
|
||||
RsrcTypeIdentifier->NameSpace.MinorVersion == NULL ||
|
||||
RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL
|
||||
) {
|
||||
if ((RsrcTypeIdentifier == NULL) ||
|
||||
(RsrcTypeIdentifier->NameSpace.ResourceTypeName == NULL) ||
|
||||
(RsrcTypeIdentifier->NameSpace.MajorVersion == NULL) ||
|
||||
(RsrcTypeIdentifier->NameSpace.MinorVersion == NULL) ||
|
||||
(RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL)
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -243,19 +260,25 @@ InterpreterEfiStructToInstance (
|
||||
for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
|
||||
if (AsciiStrCmp (
|
||||
RsrcTypeIdentifier->NameSpace.ResourceTypeName,
|
||||
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0){
|
||||
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
|
||||
) == 0)
|
||||
{
|
||||
//
|
||||
// Check version.
|
||||
//
|
||||
if ((AsciiStrCmp (
|
||||
RsrcTypeIdentifier->NameSpace.MajorVersion,
|
||||
ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) &&
|
||||
ThisSupportedRsrcTypeId->NameSpace.MajorVersion
|
||||
) == 0) &&
|
||||
(AsciiStrCmp (
|
||||
RsrcTypeIdentifier->NameSpace.MinorVersion,
|
||||
ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) &&
|
||||
ThisSupportedRsrcTypeId->NameSpace.MinorVersion
|
||||
) == 0) &&
|
||||
(AsciiStrCmp (
|
||||
RsrcTypeIdentifier->NameSpace.ErrataVersion,
|
||||
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) {
|
||||
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
|
||||
) == 0))
|
||||
{
|
||||
Status = InterpreterInstance->StructureToJson (
|
||||
This,
|
||||
RestJSonHeader,
|
||||
@ -264,8 +287,10 @@ InterpreterEfiStructToInstance (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ThisSupportedRsrcTypeId++;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -291,10 +316,11 @@ InterpreterInstanceDestoryJsonStruct (
|
||||
EFI_STATUS Status;
|
||||
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
|
||||
|
||||
if (This == NULL ||
|
||||
InterpreterInstance == NULL ||
|
||||
RestJSonHeader == NULL
|
||||
) {
|
||||
if ((This == NULL) ||
|
||||
(InterpreterInstance == NULL) ||
|
||||
(RestJSonHeader == NULL)
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -306,11 +332,14 @@ InterpreterInstanceDestoryJsonStruct (
|
||||
for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
|
||||
if (AsciiStrCmp (
|
||||
RestJSonHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName,
|
||||
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0) {
|
||||
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
|
||||
) == 0)
|
||||
{
|
||||
if ((RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion == NULL) &&
|
||||
(RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion == NULL) &&
|
||||
(RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion == NULL)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Don't check version of this resource type identifier.
|
||||
//
|
||||
@ -325,13 +354,17 @@ InterpreterInstanceDestoryJsonStruct (
|
||||
//
|
||||
if ((AsciiStrCmp (
|
||||
RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion,
|
||||
ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) &&
|
||||
ThisSupportedRsrcTypeId->NameSpace.MajorVersion
|
||||
) == 0) &&
|
||||
(AsciiStrCmp (
|
||||
RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion,
|
||||
ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) &&
|
||||
ThisSupportedRsrcTypeId->NameSpace.MinorVersion
|
||||
) == 0) &&
|
||||
(AsciiStrCmp (
|
||||
RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion,
|
||||
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) {
|
||||
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
|
||||
) == 0))
|
||||
{
|
||||
Status = InterpreterInstance->DestroyStructure (
|
||||
This,
|
||||
RestJSonHeader
|
||||
@ -340,8 +373,10 @@ InterpreterInstanceDestoryJsonStruct (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ThisSupportedRsrcTypeId++;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -369,16 +404,18 @@ RestJsonStructureToStruct (
|
||||
EFI_STATUS Status;
|
||||
REST_JSON_STRUCTURE_INSTANCE *Instance;
|
||||
|
||||
if (This == NULL ||
|
||||
ResourceJsonText == NULL ||
|
||||
JsonStructure == NULL
|
||||
) {
|
||||
if ((This == NULL) ||
|
||||
(ResourceJsonText == NULL) ||
|
||||
(JsonStructure == NULL)
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (IsListEmpty (&mRestJsonStructureList)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
|
||||
while (TRUE) {
|
||||
@ -392,12 +429,15 @@ RestJsonStructureToStruct (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
|
||||
};
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -422,13 +462,14 @@ RestJsonStructureDestroyStruct (
|
||||
EFI_STATUS Status;
|
||||
REST_JSON_STRUCTURE_INSTANCE *Instance;
|
||||
|
||||
if (This == NULL || RestJSonHeader == NULL) {
|
||||
if ((This == NULL) || (RestJSonHeader == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (IsListEmpty (&mRestJsonStructureList)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
|
||||
while (TRUE) {
|
||||
@ -440,12 +481,15 @@ RestJsonStructureDestroyStruct (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
|
||||
};
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -471,13 +515,14 @@ RestJsonStructureToJson (
|
||||
EFI_STATUS Status;
|
||||
REST_JSON_STRUCTURE_INSTANCE *Instance;
|
||||
|
||||
if (This == NULL || RestJSonHeader == NULL || ResourceRaw == NULL) {
|
||||
if ((This == NULL) || (RestJSonHeader == NULL) || (ResourceRaw == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (IsListEmpty (&mRestJsonStructureList)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
|
||||
while (TRUE) {
|
||||
@ -490,12 +535,15 @@ RestJsonStructureToJson (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
|
||||
};
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -569,6 +617,7 @@ RestJsonStructureUnload (
|
||||
if (IsListEmpty (&mRestJsonStructureList)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Free memory of REST_JSON_STRUCTURE_INSTANCE instance.
|
||||
//
|
||||
@ -578,6 +627,7 @@ RestJsonStructureUnload (
|
||||
if (!IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
|
||||
NextInstance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
|
||||
}
|
||||
|
||||
FreePool ((VOID *)Instance);
|
||||
Instance = NextInstance;
|
||||
} while (Instance != NULL);
|
||||
|
Reference in New Issue
Block a user