]> git.proxmox.com Git - mirror_edk2.git/blame - RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishService.h
RedfishPkg/RefishCrtLib: Public RefishCrtLib
[mirror_edk2.git] / RedfishPkg / PrivateLibrary / RedfishLib / edk2libredfish / include / redfishService.h
CommitLineData
4751a48a
AC
1/** @file\r
2 This file is cloned from DMTF libredfish library tag v1.0.0 and maintained\r
3 by EDKII.\r
4\r
5//----------------------------------------------------------------------------\r
6// Copyright Notice:\r
7// Copyright 2017 Distributed Management Task Force, Inc. All rights reserved.\r
8// License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libredfish/LICENSE.md\r
9//----------------------------------------------------------------------------\r
10\r
11 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
12 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>\r
13\r
14 SPDX-License-Identifier: BSD-2-Clause-Patent\r
15\r
16**/\r
17\r
18#ifndef LIBREDFISH_REDFISH_SERVICE_H_\r
19#define LIBREDFISH_REDFISH_SERVICE_H_\r
20\r
21#include <IndustryStandard/Http11.h>\r
22\r
23#include <Library/BaseLib.h>\r
24#include <Library/BaseMemoryLib.h>\r
25#include <Library/DebugLib.h>\r
26#include <Library/HttpLib.h>\r
27#include <Library/MemoryAllocationLib.h>\r
28#include <Library/NetLib.h>\r
29#include <Library/RedfishContentCodingLib.h>\r
30#include <Library/UefiRuntimeServicesTableLib.h>\r
31#include <Library/UefiBootServicesTableLib.h>\r
32\r
7311e964 33#include <Include/Library/RedfishCrtLib.h>\r
4751a48a
AC
34\r
35#include <Protocol/EdkIIRedfishConfigHandler.h>\r
36#include <Protocol/RestEx.h>\r
37\r
38#include <jansson.h>\r
39\r
40typedef struct {\r
41 char* host;\r
42 json_t* versions;\r
43 unsigned int flags;\r
44 char* sessionToken;\r
45 char* basicAuthStr;\r
46 //\r
47 // point to the <HOST> part in above "host" field, which will be put into\r
48 // the "Host" header of HTTP request message.\r
49 //\r
50 char* HostHeaderValue;\r
51 EFI_REST_EX_PROTOCOL *RestEx;\r
52} redfishService;\r
53\r
54typedef struct {\r
55 json_t* json;\r
56 redfishService* service;\r
57} redfishPayload;\r
58\r
59#define REDFISH_AUTH_BASIC 0\r
60#define REDFISH_AUTH_BEARER_TOKEN 1\r
61#define REDFISH_AUTH_SESSION 2\r
62\r
63#define REDFISH_HTTP_RESPONSE_TIMEOUT 5000 /// 5 seconds in uints of millisecond.\r
64\r
65///\r
66/// Library class public defines\r
67///\r
68#define HTTP_FLAG L"http://"\r
69#define HTTPS_FLAG L"https://"\r
70\r
71///\r
72/// The redfish first URL should be "/redfish/v1/", while we use "/redfish/v1" here without "/"\r
73/// in the end is to avoid the 301 Perment redirect response from Redfish profile simulator.\r
74///\r
75#define REDFISH_FIRST_URL L"/redfish/v1"\r
76\r
77typedef struct {\r
78 unsigned int authType;\r
79 union {\r
80 struct {\r
81 char* username;\r
82 char* password;\r
83 } userPass;\r
84 struct {\r
85 char* token;\r
86 } authToken;\r
87 } authCodes;\r
88} enumeratorAuthentication;\r
89\r
90//Values for flags\r
91#define REDFISH_FLAG_SERVICE_NO_VERSION_DOC 0x00000001 //The Redfish Service lacks the version document (in violation of the Redfish spec)\r
92redfishService* createServiceEnumerator(REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo, const char* rootUri, enumeratorAuthentication* auth, unsigned int flags);\r
93json_t* getUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode);\r
94json_t* patchUriFromService(redfishService* service, const char* uri, const char* content, EFI_HTTP_STATUS_CODE** StatusCode);\r
95json_t* postUriFromService(redfishService* service, const char* uri, const char* content, size_t contentLength, const char* contentType, EFI_HTTP_STATUS_CODE** StatusCode);\r
96json_t* deleteUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode);\r
97redfishPayload* getRedfishServiceRoot(redfishService* service, const char* version, EFI_HTTP_STATUS_CODE** StatusCode);\r
98redfishPayload* getPayloadByPath(redfishService* service, const char* path, EFI_HTTP_STATUS_CODE** StatusCode);\r
99void cleanupServiceEnumerator(redfishService* service);\r
100\r
101#endif\r