libpldmresponder: Implement SetBIOSTable

Register the setBIOSTable method and set separately string table,
attribute table, and attribute value table.
When the attribute value table is set, the corresponding D-Bus
property value needs to updated.

Tested:
test with JSON:
https://gist.github.com/lxwinspur/2afffff2e445fddf90dfed6eceef4014

~# pldmtool raw -d 0x80 0x03 0x02 0x00 0x00 0x00 0x00 0x05 0x00 0x00 0x00 0x03 0x00 0x4c 0x65 0x64 0x01 0x00 0x03 0x00 0x4f 0x66 0x66 0x02 0x00 0x02 0x00 0x4f 0x6e 0x23 0x4d 0x50 0x09
Request Message:
08 01 80 03 02 00 00 00 00 05 00 00 00 03 00 4c 65 64 01 00 03 00 4f 66 66 02 00 02 00 4f 6e 23 4d 50 09
Response Message:
08 01 00 03 02 00 00 00 00 00

~# pldmtool raw -d 0x80 0x03 0x02 0x00 0x00 0x00 0x00 0x05 0x01 0x00 0x00 0x00 0x00 0x00 0x02 0x02 0x00 0x01 0x00 0x01 0x01 0xff 0x10 0x22 0x77
Request Message:
08 01 80 03 02 00 00 00 00 05 01 00 00 00 00 00 02 02 00 01 00 01 01 ff 10 22 77
Response Message:
08 01 00 03 02 00 00 00 00 00

~# pldmtool raw -d 0x80 0x03 0x02 0x00 0x00 0x00 0x00 0x05 0x02 0x00 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0xbc 0x91 0xfe 0xe0
Request Message:
08 01 80 03 02 00 00 00 00 05 02 00 00 00 01 01 00 00 00 bc 91 fe e0
Response Message:
08 01 00 03 02 00 00 00 00 00

~# pldmtool bios GetBIOSTable -t 0
PLDM StringTable:
BIOSStringHandle : BIOSString
0 : Led
1 : Off
2 : On

~# pldmtool bios GetBIOSTable -t 1
PLDM AttributeTable:
AttributeHandle: 0, AttributeNameHandle: 0(Led)
	AttributeType: BIOSEnumeration
	NumberOfPossibleValues: 2
		PossibleValueStringHandle[0] = 2(On)
		PossibleValueStringHandle[1] = 1(Off)
	NumberOfDefaultValues: 1
		DefaultValueStringHandleIndex[0] = 1, StringHandle = 1(Off)

~# pldmtool bios GetBIOSTable -t 2
PLDM AttributeValueTable:
AttributeHandle: 0
	AttributeType: BIOSEnumeration
	NumberOfCurrentValues: 1
	CurrentValueStringHandleIndex[0] = 1, StringHandle = Off

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I0ff88961afdfe0835c9fd0b56e37f7ed75f2fb45
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index 4bfef06..a62d978 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -84,6 +84,10 @@
                      [this](const pldm_msg* request, size_t payloadLength) {
                          return this->getBIOSTable(request, payloadLength);
                      });
+    handlers.emplace(PLDM_SET_BIOS_TABLE,
+                     [this](const pldm_msg* request, size_t payloadLength) {
+                         return this->setBIOSTable(request, payloadLength);
+                     });
     handlers.emplace(PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE,
                      [this](const pldm_msg* request, size_t payloadLength) {
                          return this->getBIOSAttributeCurrentValueByHandle(
@@ -222,6 +226,40 @@
     return response;
 }
 
+Response Handler::setBIOSTable(const pldm_msg* request, size_t payloadLength)
+{
+    uint32_t transferHandle{};
+    uint8_t transferOpFlag{};
+    uint8_t tableType{};
+    struct variable_field field;
+
+    auto rc = decode_set_bios_table_req(request, payloadLength, &transferHandle,
+                                        &transferOpFlag, &tableType, &field);
+    if (rc != PLDM_SUCCESS)
+    {
+        return ccOnlyResponse(request, rc);
+    }
+
+    Table table(field.ptr, field.ptr + field.length);
+    rc = biosConfig.setBIOSTable(tableType, table);
+    if (rc != PLDM_SUCCESS)
+    {
+        return ccOnlyResponse(request, rc);
+    }
+
+    Response response(sizeof(pldm_msg_hdr) + PLDM_SET_BIOS_TABLE_RESP_BYTES);
+    auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
+
+    rc = encode_set_bios_table_resp(request->hdr.instance_id, PLDM_SUCCESS,
+                                    0 /* nxtTransferHandle */, responsePtr);
+    if (rc != PLDM_SUCCESS)
+    {
+        return ccOnlyResponse(request, rc);
+    }
+
+    return response;
+}
+
 Response Handler::getBIOSAttributeCurrentValueByHandle(const pldm_msg* request,
                                                        size_t payloadLength)
 {