1 | /** @file
|
---|
2 | Internal Functions for RedfishLib.
|
---|
3 |
|
---|
4 | Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
|
---|
5 | (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
|
---|
6 |
|
---|
7 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
8 |
|
---|
9 | **/
|
---|
10 |
|
---|
11 | #ifndef DXE_REDFISH_MISC_LIB_H_
|
---|
12 | #define DXE_REDFISH_MISC_LIB_H_
|
---|
13 |
|
---|
14 | #include <Library/BaseLib.h>
|
---|
15 | #include <Library/BaseMemoryLib.h>
|
---|
16 | #include <Library/DebugLib.h>
|
---|
17 | #include <Library/JsonLib.h>
|
---|
18 | #include <Library/MemoryAllocationLib.h>
|
---|
19 | #include <Library/PrintLib.h>
|
---|
20 | #include <Library/RedfishLib.h>
|
---|
21 | #include <Library/UefiLib.h>
|
---|
22 | #include <Protocol/EdkIIRedfishCredential.h>
|
---|
23 | #include <redfish.h>
|
---|
24 |
|
---|
25 | #define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0]))
|
---|
26 |
|
---|
27 | /**
|
---|
28 | Creates a REDFISH_SERVICE which can be later used to access the Redfish resources.
|
---|
29 |
|
---|
30 | This function will configure REST EX child according to parameters described in
|
---|
31 | Redfish network host interface in SMBIOS type 42 record. The service enumerator will also
|
---|
32 | handle the authentication flow automatically if HTTP basic auth or Redfish session
|
---|
33 | login is configured to use.
|
---|
34 |
|
---|
35 | @param[in] RedfishConfigServiceInfo Redfish service information the EFI Redfish
|
---|
36 | feature driver communicates with.
|
---|
37 | @param[in] AuthMethod None, HTTP basic auth, or Redfish session login.
|
---|
38 | @param[in] UserId User Name used for authentication.
|
---|
39 | @param[in] Password Password used for authentication.
|
---|
40 |
|
---|
41 | @return New created Redfish service, or NULL if error happens.
|
---|
42 |
|
---|
43 | **/
|
---|
44 | REDFISH_SERVICE
|
---|
45 | RedfishCreateLibredfishService (
|
---|
46 | IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo,
|
---|
47 | IN EDKII_REDFISH_AUTH_METHOD AuthMethod,
|
---|
48 | IN CHAR8 *UserId,
|
---|
49 | IN CHAR8 *Password
|
---|
50 | );
|
---|
51 |
|
---|
52 | /**
|
---|
53 | Retrieve platform's Redfish authentication information.
|
---|
54 |
|
---|
55 | This functions returns the Redfish authentication method together with the user
|
---|
56 | Id and password.
|
---|
57 | For AuthMethodNone, UserId and Password will point to NULL which means authentication
|
---|
58 | is not required to access the Redfish service.
|
---|
59 | For AuthMethodHttpBasic, the UserId and Password could be used for
|
---|
60 | HTTP header authentication as defined by RFC7235. For AuthMethodRedfishSession,
|
---|
61 | the UserId and Password could be used for Redfish session login as defined by
|
---|
62 | Redfish API specification (DSP0266).
|
---|
63 |
|
---|
64 | Callers are responsible for freeing the returned string storage pointed by UserId
|
---|
65 | and Password.
|
---|
66 |
|
---|
67 | @param[out] AuthMethod Type of Redfish authentication method.
|
---|
68 | @param[out] UserId The pointer to store the returned UserId string.
|
---|
69 | @param[out] Password The pointer to store the returned Password string.
|
---|
70 |
|
---|
71 | @retval EFI_SUCCESS Get the authentication information successfully.
|
---|
72 | @retval EFI_INVALID_PARAMETER AuthMethod or UserId or Password is NULL.
|
---|
73 | @retval EFI_UNSUPPORTED Unsupported authentication method is found.
|
---|
74 | **/
|
---|
75 | EFI_STATUS
|
---|
76 | RedfishGetAuthInfo (
|
---|
77 | OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
|
---|
78 | OUT CHAR8 **UserId,
|
---|
79 | OUT CHAR8 **Password
|
---|
80 | );
|
---|
81 |
|
---|
82 | #endif
|
---|