]> xenbits.xensource.com Git - people/aperard/ovmf.git/commitdiff
RedfishPkg/RedfishContentCodingLib: EDKII Redfish En/Decode library
authorAbner Chang <abner.chang@hpe.com>
Mon, 18 Jan 2021 02:58:25 +0000 (10:58 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 24 Feb 2021 10:53:08 +0000 (10:53 +0000)
BZ#:3174
Platform library to provide the encoding/decoding algorithms for
the Redfish packets.
The supported value could be one of below or any which is
platform-specific.
  - HTTP_CONTENT_ENCODING_IDENTITY "identity"
  - HTTP_CONTENT_ENCODING_GZIP     "gzip"
  - HTTP_CONTENT_ENCODING_COMPRESS "compress"
  - HTTP_CONTENT_ENCODING_DEFLATE  "deflate"
  - HTTP_CONTENT_ENCODING_BROTLI   "br"

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
RedfishPkg/Include/Library/RedfishContentCodingLib.h [new file with mode: 0644]
RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.c [new file with mode: 0644]
RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.inf [new file with mode: 0644]
RedfishPkg/RedfishPkg.dec
RedfishPkg/RedfishPkg.dsc

diff --git a/RedfishPkg/Include/Library/RedfishContentCodingLib.h b/RedfishPkg/Include/Library/RedfishContentCodingLib.h
new file mode 100644 (file)
index 0000000..71a8adc
--- /dev/null
@@ -0,0 +1,78 @@
+/** @file\r
+  Definitinos of RedfishContentCodingLib.\r
+\r
+  (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+#ifndef REDFISH_CONTENT_CODING_LIB_H_\r
+#define REDFISH_CONTENT_CODING_LIB_H_\r
+\r
+/**\r
+  This is the function to encode the content use the\r
+  algorithm indicated in ContentEncodedValue. The naming of\r
+  ContentEncodedValue is follow HTTP spec or could be a\r
+  platform-specific value.\r
+\r
+  @param[in]   ContentEncodedValue   HTTP conent encoded value.\r
+                                     The value could be one of below\r
+                                     or any which is platform-specific.\r
+                                       - HTTP_CONTENT_ENCODING_IDENTITY "identity"\r
+                                       - HTTP_CONTENT_ENCODING_GZIP     "gzip"\r
+                                       - HTTP_CONTENT_ENCODING_COMPRESS "compress"\r
+                                       - HTTP_CONTENT_ENCODING_DEFLATE  "deflate"\r
+                                       - HTTP_CONTENT_ENCODING_BROTLI   "br"\r
+  @param[in]   OriginalContent       Original content.\r
+  @param[in]   OriginalContentLength The length of original content.\r
+  @param[out]  EncodedContentPointer Pointer to receive the encoded content pointer.\r
+  @param[out]  EncodedContentLength  Length of encoded content.\r
+\r
+  @retval EFI_SUCCESS              Content is encoded successfully.\r
+  @retval EFI_UNSUPPORTED          No supported encoding funciton,\r
+  @retval EFI_INVALID_PARAMETER    One of the given parameter is invalid.\r
+\r
+**/\r
+\r
+EFI_STATUS\r
+RedfishContentEncode  (\r
+  IN CHAR8  *ContentEncodedValue,\r
+  IN CHAR8  *OriginalContent,\r
+  IN UINTN  OriginalContentLength,\r
+  OUT VOID  **EncodedContentPointer,\r
+  OUT UINTN *EncodedLength\r
+  );\r
+\r
+/**\r
+  This is the function to decode the content use the\r
+  algorithm indicated in ContentEncodedValue. The naming of\r
+  ContentEncodedValue is follow HTTP spec or could be a\r
+  platform-specific value.\r
+\r
+  @param[in]   ContentDecodedValue   HTTP conent decoded value.\r
+                                     The value could be one of below\r
+                                     or any which is platform-specific.\r
+                                       - HTTP_CONTENT_ENCODING_IDENTITY "identity"\r
+                                       - HTTP_CONTENT_ENCODING_GZIP     "gzip"\r
+                                       - HTTP_CONTENT_ENCODING_COMPRESS "compress"\r
+                                       - HTTP_CONTENT_ENCODING_DEFLATE  "deflate"\r
+                                       - HTTP_CONTENT_ENCODING_BROTLI   "br"\r
+  @param[in]   ContentPointer        Original content.\r
+  @param[in]   ContentLength         The length of original content.\r
+  @param[out]  DecodedContentPointer Pointer to receive decoded content pointer.\r
+  @param[out]  DecodedContentLength  Length of decoded content.\r
+\r
+  @retval EFI_SUCCESS              Content is decoded successfully.\r
+  @retval EFI_UNSUPPORTED          No supported decoding funciton,\r
+  @retval EFI_INVALID_PARAMETER    One of the given parameter is invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+RedfishContentDecode (\r
+  IN CHAR8  *ContentEncodedValue,\r
+  IN VOID   *ContentPointer,\r
+  IN UINTN  ContentLength,\r
+  OUT VOID  **DecodedContentPointer,\r
+  OUT UINTN *DecodedLength\r
+  );\r
+#endif\r
diff --git a/RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.c b/RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.c
new file mode 100644 (file)
index 0000000..6d13256
--- /dev/null
@@ -0,0 +1,81 @@
+/** @file\r
+  NULL instace of RedfishContentCodingLib\r
+\r
+  (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+#include <Uefi.h>\r
+\r
+/**\r
+  This is the function to encode the content use the\r
+  algorithm indicated in ContentEncodedValue. The naming of\r
+  ContentEncodedValue is follow HTTP spec or could be a\r
+  platform-specific value.\r
+\r
+  @param[in]   ContentEncodedValue   HTTP conent encoded value.\r
+                                     The value could be one of below\r
+                                     or any which is platform-specific.\r
+                                       - HTTP_CONTENT_ENCODING_IDENTITY "identity"\r
+                                       - HTTP_CONTENT_ENCODING_GZIP     "gzip"\r
+                                       - HTTP_CONTENT_ENCODING_COMPRESS "compress"\r
+                                       - HTTP_CONTENT_ENCODING_DEFLATE  "deflate"\r
+                                       - HTTP_CONTENT_ENCODING_BROTLI   "br"\r
+  @param[in]   OriginalContent       Original content.\r
+  @param[in]   OriginalContentLength The length of original content.\r
+  @param[out]  EncodedContentPointer Pointer to receive the encoded content pointer.\r
+  @param[out]  EncodedContentLength  Length of encoded content.\r
+\r
+  @retval EFI_SUCCESS              Content is encoded successfully.\r
+  @retval EFI_UNSUPPORTED          No supported encoding funciton,\r
+  @retval EFI_INVALID_PARAMETER    One of the given parameter is invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+RedfishContentEncode  (\r
+  IN CHAR8  *ContentEncodedValue,\r
+  IN CHAR8  *OriginalContent,\r
+  IN UINTN  OriginalContentLength,\r
+  OUT VOID  **EncodedContentPointer,\r
+  OUT UINTN *EncodedContentLength\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  This is the function to decode the content use the\r
+  algorithm indicated in ContentEncodedValue. The naming of\r
+  ContentEncodedValue is follow HTTP spec or could be a\r
+  platform-specific value.\r
+\r
+  @param[in]   ContentDecodedValue   HTTP conent decoded value.\r
+                                     The value could be one of below\r
+                                     or any which is platform-specific.\r
+                                       - HTTP_CONTENT_ENCODING_IDENTITY "identity"\r
+                                       - HTTP_CONTENT_ENCODING_GZIP     "gzip"\r
+                                       - HTTP_CONTENT_ENCODING_COMPRESS "compress"\r
+                                       - HTTP_CONTENT_ENCODING_DEFLATE  "deflate"\r
+                                       - HTTP_CONTENT_ENCODING_BROTLI   "br"\r
+  @param[in]   ContentPointer        Original content.\r
+  @param[in]   ContentLength         The length of original content.\r
+  @param[out]  DecodedContentPointer Pointer to receive decoded content pointer.\r
+  @param[out]  DecodedContentLength  Length of decoded content.\r
+\r
+  @retval EFI_SUCCESS              Content is decoded successfully.\r
+  @retval EFI_UNSUPPORTED          No supported decoding funciton,\r
+  @retval EFI_INVALID_PARAMETER    One of the given parameter is invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+RedfishContentDecode (\r
+  IN CHAR8  *ContentDecodedValue,\r
+  IN VOID   *ContentPointer,\r
+  IN UINTN  ContentLength,\r
+  OUT VOID  **DecodedContentPointer,\r
+  OUT UINTN *DecodedContentLength\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.inf b/RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.inf
new file mode 100644 (file)
index 0000000..d8c5cb5
--- /dev/null
@@ -0,0 +1,31 @@
+## @file\r
+#  NULL instance of RedfishContentCodingLibNull\r
+#  This library is used to encode/decode Redfish payload.\r
+#\r
+#  (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x0001000b\r
+  BASE_NAME                      = RedfishContentCodingLibNull\r
+  FILE_GUID                      = 06B10249-4D38-FF37-0CA5-13AFB6D625CC\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = RedfishContentCodingLib\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64 RISCV64\r
+#\r
+\r
+[Sources]\r
+  RedfishContentCodingLibNull.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  RedfishPkg/RedfishPkg.dec\r
+\r
+\r
index b8ff98eb13726762524da1fa24ea6ec7ab834467..a6fd81cdae00a08bd0b34dffa9d4419efb563cf2 100644 (file)
@@ -2,7 +2,7 @@
 # Redfish Package\r
 #\r
 # Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
-# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>\r
+# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>\r
 #\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 ##\r
   #\r
   JsonLib|Include/Library/JsonLib.h\r
 \r
+  ##  @libraryclass  Provides the library functions to encode/decode\r
+  #   Redfish packet.\r
+  #\r
+  RedfishContentCodingLib|Include/Library/RedfishContentCodingLib.h\r
+\r
 [LibraryClasses.Common.Private]\r
   ##  @libraryclass  Provides the private C runtime library functions.\r
   #   CRT library is currently used by edk2 JsonLib (open source\r
index bffa8f1f898e96ecc9d7340f35442a4ac3393c60..2cae8a46d8cf1abaae3e6a600bfa0ca763cb0ac2 100644 (file)
@@ -2,7 +2,7 @@
 # Redfish Package\r
 #\r
 # Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
-# (C) Copyright 2020 Hewlett-Packard Enterprise Development LP.\r
+# (C) Copyright 2021 Hewlett-Packard Enterprise Development LP.\r
 #\r
 #    SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
@@ -37,6 +37,7 @@
   NetLib|NetworkPkg/Library/DxeNetLib/DxeNetLib.inf\r
   DpcLib|NetworkPkg/Library/DxeDpcLib/DxeDpcLib.inf\r
   RedfishPlatformCredentialLib|RedfishPkg/Library/PlatformCredentialLibNull/PlatformCredentialLibNull.inf\r
+  RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.inf\r
 \r
 [LibraryClasses.ARM, LibraryClasses.AARCH64]\r
   #\r
@@ -49,6 +50,7 @@
 [Components]\r
   RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.inf\r
   RedfishPkg/Library/PlatformCredentialLibNull/PlatformCredentialLibNull.inf\r
+  RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.inf\r
   RedfishPkg/Library/DxeRestExLib/DxeRestExLib.inf\r
   RedfishPkg/Library/BaseUcs2Utf8Lib/BaseUcs2Utf8Lib.inf\r
   RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.inf\r