20#define REDFISH_JSON_STRING_LENGTH 200
21#define REDFISH_JSON_OUTPUT_FORMAT (EDKII_JSON_COMPACT | EDKII_JSON_INDENT(2))
22#define REDFISH_PRINT_BUFFER_BYTES_PER_ROW 16
35 IN UINT64 RedfishDebugCategory
41 return ((DebugCategory & RedfishDebugCategory) != 0);
61 if (RedfishValue ==
NULL) {
62 return EFI_INVALID_PARAMETER;
65 DEBUG ((ErrorLevel,
"Type: 0x%x\n", RedfishValue->Type));
66 DEBUG ((ErrorLevel,
"ArrayCount: 0x%x\n", RedfishValue->ArrayCount));
68 switch (RedfishValue->Type) {
69 case RedfishValueTypeInteger:
70 DEBUG ((ErrorLevel,
"Value: 0x%x\n", RedfishValue->Value.Integer));
72 case RedfishValueTypeBoolean:
73 DEBUG ((ErrorLevel,
"Value: %a\n", (RedfishValue->Value.Boolean ?
"true" :
"false")));
75 case RedfishValueTypeString:
76 DEBUG ((ErrorLevel,
"Value: %a\n", RedfishValue->Value.Buffer));
78 case RedfishValueTypeStringArray:
79 for (Index = 0; Index < RedfishValue->ArrayCount; Index++) {
80 DEBUG ((ErrorLevel,
"Value[%d]: %a\n", Index, RedfishValue->Value.StringArray[Index]));
84 case RedfishValueTypeIntegerArray:
85 for (Index = 0; Index < RedfishValue->ArrayCount; Index++) {
86 DEBUG ((ErrorLevel,
"Value[%d]: 0x%x\n", Index, RedfishValue->Value.IntegerArray[Index]));
90 case RedfishValueTypeBooleanArray:
91 for (Index = 0; Index < RedfishValue->ArrayCount; Index++) {
92 DEBUG ((ErrorLevel,
"Value[%d]: %a\n", Index, (RedfishValue->Value.BooleanArray[Index] ?
"true" :
"false")));
96 case RedfishValueTypeUnknown:
97 case RedfishValueTypeMax:
119 IN EDKII_JSON_VALUE JsonValue
124 CHAR8 Buffer[REDFISH_JSON_STRING_LENGTH + 1];
129 if (JsonValue ==
NULL) {
130 return EFI_INVALID_PARAMETER;
134 if (String ==
NULL) {
135 return EFI_UNSUPPORTED;
140 return EFI_UNSUPPORTED;
143 Count =
StrLen / REDFISH_JSON_STRING_LENGTH;
145 for (Index = 0; Index < Count; Index++) {
146 AsciiStrnCpyS (Buffer, (REDFISH_JSON_STRING_LENGTH + 1), Runner, REDFISH_JSON_STRING_LENGTH);
147 Buffer[REDFISH_JSON_STRING_LENGTH] =
'\0';
148 DEBUG ((ErrorLevel,
"%a", Buffer));
149 Runner += REDFISH_JSON_STRING_LENGTH;
152 Count =
StrLen % REDFISH_JSON_STRING_LENGTH;
154 DEBUG ((ErrorLevel,
"%a", Runner));
157 DEBUG ((ErrorLevel,
"\n"));
178 IN REDFISH_PAYLOAD Payload
181 EDKII_JSON_VALUE JsonValue;
183 if (Payload ==
NULL) {
184 return EFI_INVALID_PARAMETER;
188 if (JsonValue !=
NULL) {
189 DEBUG ((ErrorLevel,
"Payload:\n"));
212 switch (HttpStatusCode) {
213 case HTTP_STATUS_100_CONTINUE:
214 DEBUG ((ErrorLevel,
"Status code: 100 CONTINUE\n"));
216 case HTTP_STATUS_200_OK:
217 DEBUG ((ErrorLevel,
"Status code: 200 OK\n"));
219 case HTTP_STATUS_201_CREATED:
220 DEBUG ((ErrorLevel,
"Status code: 201 CREATED\n"));
222 case HTTP_STATUS_202_ACCEPTED:
223 DEBUG ((ErrorLevel,
"Status code: 202 ACCEPTED\n"));
225 case HTTP_STATUS_304_NOT_MODIFIED:
226 DEBUG ((ErrorLevel,
"Status code: 304 NOT MODIFIED\n"));
228 case HTTP_STATUS_400_BAD_REQUEST:
229 DEBUG ((ErrorLevel,
"Status code: 400 BAD REQUEST\n"));
231 case HTTP_STATUS_401_UNAUTHORIZED:
232 DEBUG ((ErrorLevel,
"Status code: 401 UNAUTHORIZED\n"));
234 case HTTP_STATUS_403_FORBIDDEN:
235 DEBUG ((ErrorLevel,
"Status code: 403 FORBIDDEN\n"));
237 case HTTP_STATUS_404_NOT_FOUND:
238 DEBUG ((ErrorLevel,
"Status code: 404 NOT FOUND\n"));
240 case HTTP_STATUS_405_METHOD_NOT_ALLOWED:
241 DEBUG ((ErrorLevel,
"Status code: 405 METHOD NOT ALLOWED\n"));
243 case HTTP_STATUS_500_INTERNAL_SERVER_ERROR:
244 DEBUG ((ErrorLevel,
"Status code: 500 INTERNAL SERVER ERROR\n"));
247 DEBUG ((ErrorLevel,
"Status code: 0x%x\n", HttpStatusCode));
276 if (Response ==
NULL) {
277 return EFI_INVALID_PARAMETER;
280 if (!IS_EMPTY_STRING (Message)) {
281 DEBUG ((ErrorLevel,
"%a\n", Message));
287 if (Response->StatusCode !=
NULL) {
294 if (Response->HeaderCount > 0) {
295 DEBUG ((ErrorLevel,
"Header: %d\n", Response->HeaderCount));
296 for (Index = 0; Index < Response->HeaderCount; Index++) {
297 DEBUG ((ErrorLevel,
" %a: %a\n", Response->Headers[Index].FieldName, Response->Headers[Index].FieldValue));
304 if (Response->Payload !=
NULL) {
328 if (Ipv4Address ==
NULL) {
329 return EFI_INVALID_PARAMETER;
332 DEBUG ((ErrorLevel,
"%d.%d.%d.%d\n", Ipv4Address->Addr[0], Ipv4Address->Addr[1], Ipv4Address->Addr[2], Ipv4Address->Addr[3]));
357 if (Buffer ==
NULL) {
358 return EFI_INVALID_PARAMETER;
361 DEBUG ((ErrorLevel,
"Address: 0x%p size: %d\n", Buffer, BufferSize));
362 for (Index = 0; Index < BufferSize; Index++) {
363 if (Index % REDFISH_PRINT_BUFFER_BYTES_PER_ROW == 0) {
364 DEBUG ((ErrorLevel,
"\n%04X: ", Index));
367 DEBUG ((ErrorLevel,
"%02X ", Buffer[Index]));
370 DEBUG ((ErrorLevel,
"\n"));
RETURN_STATUS EFIAPI AsciiStrnCpyS(OUT CHAR8 *Destination, IN UINTN DestMax, IN CONST CHAR8 *Source, IN UINTN Length)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
VOID EFIAPI FreePool(IN VOID *Buffer)
CHAR8 *EFIAPI JsonDumpString(IN EDKII_JSON_VALUE JsonValue, IN UINTN Flags)
#define DEBUG(Expression)
#define FixedPcdGet64(TokenName)
EFI_STATUS DumpRedfishValue(IN UINTN ErrorLevel, IN EDKII_REDFISH_VALUE *RedfishValue)
EFI_STATUS DumpJsonValue(IN UINTN ErrorLevel, IN EDKII_JSON_VALUE JsonValue)
EFI_STATUS DumpHttpStatusCode(IN UINTN ErrorLevel, IN EFI_HTTP_STATUS_CODE HttpStatusCode)
EFI_STATUS DumpBuffer(IN UINTN ErrorLevel, IN UINT8 *Buffer, IN UINTN BufferSize)
EFI_STATUS DumpRedfishPayload(IN UINTN ErrorLevel, IN REDFISH_PAYLOAD Payload)
BOOLEAN DebugRedfishComponentEnabled(IN UINT64 RedfishDebugCategory)
EFI_STATUS DumpRedfishResponse(IN CONST CHAR8 *Message, IN UINTN ErrorLevel, IN REDFISH_RESPONSE *Response)
EFI_STATUS DumpIpv4Address(IN UINTN ErrorLevel, IN EFI_IPv4_ADDRESS *Ipv4Address)
EDKII_JSON_VALUE RedfishJsonInPayload(IN REDFISH_PAYLOAD RedfishPayload)