29 if ((Service ==
NULL) || IS_EMPTY_STRING (Token)) {
30 return EFI_INVALID_PARAMETER;
33 if (Service->SessionToken !=
NULL) {
37 Service->SessionToken = ASCII_STR_DUPLICATE (Token);
38 if (Service->SessionToken ==
NULL) {
39 return EFI_OUT_OF_RESOURCES;
59 if (Service ==
NULL) {
60 return EFI_INVALID_PARAMETER;
63 if (Service->Host !=
NULL) {
67 if (Service->HostName !=
NULL) {
71 if (Service->BasicAuth !=
NULL) {
76 if (Service->SessionToken !=
NULL) {
104 IN CHAR8 *BasicAuth OPTIONAL,
105 IN CHAR8 *SessionToken OPTIONAL,
112 if (IS_EMPTY_STRING (Host) || IS_EMPTY_STRING (HostName) || (RestEx ==
NULL)) {
117 if (NewService ==
NULL) {
121 NewService->Signature = REDFISH_HTTP_SERVICE_SIGNATURE;
122 NewService->Host = ASCII_STR_DUPLICATE (Host);
123 if (NewService->Host ==
NULL) {
127 NewService->HostName = ASCII_STR_DUPLICATE (HostName);
128 if (NewService->HostName ==
NULL) {
132 if (!IS_EMPTY_STRING (BasicAuth)) {
135 if (NewService->BasicAuth ==
NULL) {
139 AsciiSPrint (NewService->BasicAuth, AuthStrSize,
"%a%a", REDFISH_HTTP_BASIC_AUTH_STR, BasicAuth);
142 if (!IS_EMPTY_STRING (SessionToken)) {
143 NewService->SessionToken = ASCII_STR_DUPLICATE (SessionToken);
144 if (NewService->SessionToken ==
NULL) {
149 NewService->RestEx = RestEx;
174 if (Payload ==
NULL) {
175 return EFI_INVALID_PARAMETER;
178 if (Payload->Service !=
NULL) {
182 if (Payload->JsonValue !=
NULL) {
205 IN EDKII_JSON_VALUE JsonValue
210 if ((Service ==
NULL) || (JsonValue ==
NULL)) {
215 if (NewPayload ==
NULL) {
219 NewPayload->Signature = REDFISH_HTTP_PAYLOAD_SIGNATURE;
220 NewPayload->Service =
CreateRedfishService (Service->Host, Service->HostName, Service->BasicAuth, Service->SessionToken, Service->RestEx);
221 if (NewPayload->Service ==
NULL) {
226 if (NewPayload->JsonValue ==
NULL) {
258 if ((SrcResponse ==
NULL) || (DstResponse ==
NULL)) {
259 return EFI_INVALID_PARAMETER;
262 if (SrcResponse == DstResponse) {
269 if (SrcResponse->StatusCode !=
NULL) {
271 if (DstResponse->StatusCode ==
NULL) {
279 if ((SrcResponse->HeaderCount > 0) && (SrcResponse->Headers !=
NULL)) {
280 DstResponse->HeaderCount = 0;
282 if (DstResponse->Headers ==
NULL) {
286 DstResponse->HeaderCount = SrcResponse->HeaderCount;
288 for (Index = 0; Index < SrcResponse->HeaderCount; Index++) {
289 DstResponse->Headers[Index].FieldName = ASCII_STR_DUPLICATE (SrcResponse->Headers[Index].FieldName);
290 if (DstResponse->Headers[Index].FieldName ==
NULL) {
294 DstResponse->Headers[Index].FieldValue = ASCII_STR_DUPLICATE (SrcResponse->Headers[Index].FieldValue);
295 if (DstResponse->Headers[Index].FieldValue ==
NULL) {
304 if (SrcResponse->Payload !=
NULL) {
306 if (Payload->Signature != REDFISH_HTTP_PAYLOAD_SIGNATURE) {
307 DEBUG ((DEBUG_ERROR,
"%a: signature check failure\n", __func__));
312 if (DstResponse->Payload ==
NULL) {
323 return EFI_OUT_OF_RESOURCES;
343 if (Response ==
NULL) {
348 if (NewResponse ==
NULL) {
353 if (EFI_ERROR (Status)) {
376 return EFI_INVALID_PARAMETER;
379 if (Data->Uri !=
NULL) {
383 if (Data->Response !=
NULL) {
412 if (IS_EMPTY_STRING (Uri) || (Response ==
NULL)) {
417 if (NewData ==
NULL) {
421 NewData->Signature = REDFISH_HTTP_CACHE_SIGNATURE;
424 if (NewData->Uri ==
NULL) {
428 NewData->Response = Response;
429 NewData->HitCount = 1;
435 if (NewData !=
NULL) {
461 if (IS_EMPTY_STRING (Uri)) {
471 while (!
IsNull (ListHeader, List)) {
472 Data = REDFISH_HTTP_CACHE_FROM_LIST (List);
474 if (
StrCmp (Data->Uri, Uri) == 0) {
512 Data = REDFISH_HTTP_CACHE_FROM_LIST (List);
514 HitCount = Data->HitCount;
517 while (!
IsNull (ListHeader, List)) {
518 Data = REDFISH_HTTP_CACHE_FROM_LIST (List);
520 if (Data->HitCount < HitCount) {
521 HitCount = Data->HitCount;
547 if ((List ==
NULL) || (Data ==
NULL)) {
548 return EFI_INVALID_PARAMETER;
551 DEBUG ((REDFISH_HTTP_CACHE_DEBUG,
"%a: delete: %s\n", __func__, Data->Uri));
582 if ((List ==
NULL) || IS_EMPTY_STRING (Uri) || (Response ==
NULL)) {
583 return EFI_INVALID_PARAMETER;
590 if (OldData !=
NULL) {
597 if (List->Count >= List->Capacity) {
598 DEBUG ((REDFISH_HTTP_CACHE_DEBUG,
"%a: list is full and retire unused cache\n", __func__));
600 if (UnusedData ==
NULL) {
601 return EFI_OUT_OF_RESOURCES;
611 if (NewResponse ==
NULL) {
612 return EFI_OUT_OF_RESOURCES;
616 if (NewData ==
NULL) {
617 return EFI_OUT_OF_RESOURCES;
623 DEBUG ((REDFISH_HTTP_CACHE_DEBUG,
"%a: cache(%d/%d) %s\n", __func__, List->Count, List->Capacity, NewData->Uri));
646 if (CacheList ==
NULL) {
647 return EFI_INVALID_PARAMETER;
657 while (!
IsNull (&CacheList->Head, List)) {
658 Data = REDFISH_HTTP_CACHE_FROM_LIST (List);
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
VOID EFIAPI JsonValueFree(IN EDKII_JSON_VALUE Json)
EDKII_JSON_VALUE EFIAPI JsonValueClone(IN EDKII_JSON_VALUE Json)
UINTN EFIAPI AsciiSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...)
#define DEBUG(Expression)
EFI_STATUS AddHttpCacheData(IN REDFISH_HTTP_CACHE_LIST *List, IN EFI_STRING Uri, IN REDFISH_RESPONSE *Response)
EFI_STATUS ReleaseRedfishPayload(IN REDFISH_PAYLOAD_PRIVATE *Payload)
REDFISH_HTTP_CACHE_DATA * FindUnusedHttpCacheData(IN LIST_ENTRY *ListHeader)
REDFISH_SERVICE_PRIVATE * CreateRedfishService(IN CHAR8 *Host, IN CHAR8 *HostName, IN CHAR8 *BasicAuth OPTIONAL, IN CHAR8 *SessionToken OPTIONAL, IN EFI_REST_EX_PROTOCOL *RestEx)
EFI_STATUS CopyRedfishResponse(IN REDFISH_RESPONSE *SrcResponse, OUT REDFISH_RESPONSE *DstResponse)
REDFISH_RESPONSE * CloneRedfishResponse(IN REDFISH_RESPONSE *Response)
EFI_STATUS UpdateSessionToken(IN REDFISH_SERVICE_PRIVATE *Service, IN CHAR8 *Token)
EFI_STATUS ReleaseRedfishService(IN REDFISH_SERVICE_PRIVATE *Service)
REDFISH_HTTP_CACHE_DATA * NewHttpCacheData(IN EFI_STRING Uri, IN REDFISH_RESPONSE *Response)
EFI_STATUS ReleaseCacheList(IN REDFISH_HTTP_CACHE_LIST *CacheList)
EFI_STATUS DeleteHttpCacheData(IN REDFISH_HTTP_CACHE_LIST *List, IN REDFISH_HTTP_CACHE_DATA *Data)
REDFISH_HTTP_CACHE_DATA * FindHttpCacheData(IN LIST_ENTRY *ListHeader, IN EFI_STRING Uri)
REDFISH_PAYLOAD_PRIVATE * CreateRedfishPayload(IN REDFISH_SERVICE_PRIVATE *Service, IN EDKII_JSON_VALUE JsonValue)
EFI_STATUS ReleaseHttpCacheData(IN REDFISH_HTTP_CACHE_DATA *Data)
EFI_STATUS ReleaseRedfishResponse(IN REDFISH_RESPONSE *Response)