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