2 This file is cloned from DMTF libredfish library tag v1.0.0 and maintained
5 //----------------------------------------------------------------------------
7 // Copyright 2017 Distributed Management Task Force, Inc. All rights reserved.
8 // License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libredfish/LICENSE.md
9 //----------------------------------------------------------------------------
11 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
12 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
14 SPDX-License-Identifier: BSD-2-Clause-Patent
18 #ifndef LIBREDFISH_REDFISH_SERVICE_H_
19 #define LIBREDFISH_REDFISH_SERVICE_H_
21 #include <IndustryStandard/Http11.h>
23 #include <Library/BaseLib.h>
24 #include <Library/BaseMemoryLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/HttpLib.h>
27 #include <Library/MemoryAllocationLib.h>
28 #include <Library/NetLib.h>
29 #include <Library/RedfishContentCodingLib.h>
30 #include <Library/UefiRuntimeServicesTableLib.h>
31 #include <Library/UefiBootServicesTableLib.h>
33 #include <Include/Library/RedfishCrtLib.h>
35 #include <Protocol/EdkIIRedfishConfigHandler.h>
36 #include <Protocol/RestEx.h>
47 // point to the <HOST> part in above "host" field, which will be put into
48 // the "Host" header of HTTP request message.
50 char* HostHeaderValue
;
51 EFI_REST_EX_PROTOCOL
*RestEx
;
56 redfishService
* service
;
59 #define REDFISH_AUTH_BASIC 0
60 #define REDFISH_AUTH_BEARER_TOKEN 1
61 #define REDFISH_AUTH_SESSION 2
63 #define REDFISH_HTTP_RESPONSE_TIMEOUT 5000 /// 5 seconds in uints of millisecond.
66 /// Library class public defines
68 #define HTTP_FLAG L"http://"
69 #define HTTPS_FLAG L"https://"
72 /// The redfish first URL should be "/redfish/v1/", while we use "/redfish/v1" here without "/"
73 /// in the end is to avoid the 301 Perment redirect response from Redfish profile simulator.
75 #define REDFISH_FIRST_URL L"/redfish/v1"
78 unsigned int authType
;
88 } enumeratorAuthentication
;
91 #define REDFISH_FLAG_SERVICE_NO_VERSION_DOC 0x00000001 //The Redfish Service lacks the version document (in violation of the Redfish spec)
92 redfishService
* createServiceEnumerator(REDFISH_CONFIG_SERVICE_INFORMATION
*RedfishConfigServiceInfo
, const char* rootUri
, enumeratorAuthentication
* auth
, unsigned int flags
);
93 json_t
* getUriFromService(redfishService
* service
, const char* uri
, EFI_HTTP_STATUS_CODE
** StatusCode
);
94 json_t
* patchUriFromService(redfishService
* service
, const char* uri
, const char* content
, EFI_HTTP_STATUS_CODE
** StatusCode
);
95 json_t
* postUriFromService(redfishService
* service
, const char* uri
, const char* content
, size_t contentLength
, const char* contentType
, EFI_HTTP_STATUS_CODE
** StatusCode
);
96 json_t
* deleteUriFromService(redfishService
* service
, const char* uri
, EFI_HTTP_STATUS_CODE
** StatusCode
);
97 redfishPayload
* getRedfishServiceRoot(redfishService
* service
, const char* version
, EFI_HTTP_STATUS_CODE
** StatusCode
);
98 redfishPayload
* getPayloadByPath(redfishService
* service
, const char* path
, EFI_HTTP_STATUS_CODE
** StatusCode
);
99 void cleanupServiceEnumerator(redfishService
* service
);