libpldmresponder: enable DBus change notification

This commit enables libpldmresponder to subscribe to DBus
property change signal for the BIOS properties which are fetched from
DBus. The new DBus value is received and the relevant entry in the
attributeValueTable is updated.

test result:

root@rainier:/tmp# pldmtool bios GetBIOSTable -t 0
Parsed Response Msg:
PLDM StringTable:
BIOSStringHandle : BIOSString
0 : Allowed
1 : Disabled
2 : Enabled
3 : IPv4DHCP
4 : IPv4Static
5 : Not Allowed
6 : Perm
7 : Temp
8 : pvm-fw-boot-side
9 : pvm-inband-code-update
10 : pvm-os-boot-side
11 : pvm-pcie-error-inject
12 : pvm-surveillance
13 : pvm-system-name
14 : vmi-hostname
15 : vmi-if-count
16 : vmi-if0-ipv4-ipaddr
17 : vmi-if0-ipv4-method
18 : vmi-if0-ipv4-prefix-length
19 : vmi-if1-ipv4-ipaddr
20 : vmi-if1-ipv4-method
21 : vmi-if1-ipv4-prefix-length
22 : vmi-ipv4-gateway
root@rainier:/tmp#

root@rainier:/tmp# pldmtool bios GetBIOSTable -t 1
Parsed Response Msg:
PLDM AttributeTable:
AttributeHandle: 0, AttributeNameHandle: 13(pvm-system-name)
        AttributeType: BIOSStringReadOnly
        StringType: 0x01
        MinimumStringLength: 1
        MaximumStringLength: 100
        DefaultStringLength: 15
        DefaultString: witherspoon-128
AttributeHandle: 1, AttributeNameHandle: 14(vmi-hostname)
        AttributeType: BIOSString
        StringType: 0x01
        MinimumStringLength: 0
        MaximumStringLength: 255
        DefaultStringLength: 0
        DefaultString:
AttributeHandle: 2, AttributeNameHandle: 22(vmi-ipv4-gateway)
        AttributeType: BIOSString
        StringType: 0x01
        MinimumStringLength: 7
        MaximumStringLength: 15
        DefaultStringLength: 7
        DefaultString: 0.0.0.0
AttributeHandle: 3, AttributeNameHandle: 16(vmi-if0-ipv4-ipaddr)
        AttributeType: BIOSString
        StringType: 0x01
        MinimumStringLength: 7
        MaximumStringLength: 15
        DefaultStringLength: 7
        DefaultString: 0.0.0.0
AttributeHandle: 4, AttributeNameHandle: 19(vmi-if1-ipv4-ipaddr)
        AttributeType: BIOSString
        StringType: 0x01
        MinimumStringLength: 7
        MaximumStringLength: 15
        DefaultStringLength: 7
        DefaultString: 0.0.0.0
AttributeHandle: 5, AttributeNameHandle: 15(vmi-if-count)
        AttributeType: BIOSIntegerReadOnly
        LowerBound: 0
        UpperBound: 2
        ScalarIncrement: 1
        DefaultValue: 1
AttributeHandle: 6, AttributeNameHandle: 18(vmi-if0-ipv4-prefix-length)
        AttributeType: BIOSInteger
        LowerBound: 0
        UpperBound: 32
        ScalarIncrement: 1
        DefaultValue: 0
AttributeHandle: 7, AttributeNameHandle: 21(vmi-if1-ipv4-prefix-length)
        AttributeType: BIOSInteger
        LowerBound: 0
        UpperBound: 32
        ScalarIncrement: 1
        DefaultValue: 0
AttributeHandle: 8, AttributeNameHandle: 8(pvm-fw-boot-side)
        AttributeType: BIOSEnumerationReadOnly
        NumberOfPossibleValues: 2
                PossibleValueStringHandle[0] = 6(Perm)
                PossibleValueStringHandle[1] = 7(Temp)
        NumberOfDefaultValues: 1
                DefaultValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 9, AttributeNameHandle: 10(pvm-os-boot-side)
        AttributeType: BIOSEnumerationReadOnly
        NumberOfPossibleValues: 2
                PossibleValueStringHandle[0] = 6(Perm)
                PossibleValueStringHandle[1] = 7(Temp)
        NumberOfDefaultValues: 1
                DefaultValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 10, AttributeNameHandle: 9(pvm-inband-code-update)
        AttributeType: BIOSEnumerationReadOnly
        NumberOfPossibleValues: 2
                PossibleValueStringHandle[0] = 0(Allowed)
                PossibleValueStringHandle[1] = 5(Not Allowed)
        NumberOfDefaultValues: 1
                DefaultValueStringHandleIndex[0] = 0, StringHandle = 0(Allowed)
AttributeHandle: 11, AttributeNameHandle: 12(pvm-surveillance)
        AttributeType: BIOSEnumerationReadOnly
        NumberOfPossibleValues: 2
                PossibleValueStringHandle[0] = 1(Disabled)
                PossibleValueStringHandle[1] = 2(Enabled)
        NumberOfDefaultValues: 1
                DefaultValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 12, AttributeNameHandle: 11(pvm-pcie-error-inject)
        AttributeType: BIOSEnumerationReadOnly
        NumberOfPossibleValues: 2
                PossibleValueStringHandle[0] = 1(Disabled)
                PossibleValueStringHandle[1] = 2(Enabled)
        NumberOfDefaultValues: 1
                DefaultValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 13, AttributeNameHandle: 17(vmi-if0-ipv4-method)
        AttributeType: BIOSEnumeration
        NumberOfPossibleValues: 2
                PossibleValueStringHandle[0] = 4(IPv4Static)
                PossibleValueStringHandle[1] = 3(IPv4DHCP)
        NumberOfDefaultValues: 1
                DefaultValueStringHandleIndex[0] = 0, StringHandle = 4(IPv4Static)
AttributeHandle: 14, AttributeNameHandle: 20(vmi-if1-ipv4-method)
        AttributeType: BIOSEnumeration
        NumberOfPossibleValues: 2
                PossibleValueStringHandle[0] = 4(IPv4Static)
                PossibleValueStringHandle[1] = 3(IPv4DHCP)
        NumberOfDefaultValues: 1
                DefaultValueStringHandleIndex[0] = 0, StringHandle = 4(IPv4Static)
root@rainier:/tmp#

root@rainier:/tmp# pldmtool bios GetBIOSTable -t 2
Parsed Response Msg:
PLDM AttributeValueTable:
AttributeHandle: 0
        AttributeType: BIOSStringReadOnly
        CurrentStringLength: 15
        CurrentString: witherspoon-128
AttributeHandle: 1
        AttributeType: BIOSString
        CurrentStringLength: 0
        CurrentString:
AttributeHandle: 2
        AttributeType: BIOSString
        CurrentStringLength: 7
        CurrentString: 0.0.0.0
AttributeHandle: 3
        AttributeType: BIOSString
        CurrentStringLength: 7
        CurrentString: 0.0.0.0
AttributeHandle: 4
        AttributeType: BIOSString
        CurrentStringLength: 7
        CurrentString: 0.0.0.0
AttributeHandle: 5
        AttributeType: BIOSIntegerReadOnly
        CurrentValue: 1
AttributeHandle: 6
        AttributeType: BIOSInteger
        CurrentValue: 0
AttributeHandle: 7
        AttributeType: BIOSInteger
        CurrentValue: 0
AttributeHandle: 8
        AttributeType: BIOSEnumerationReadOnly
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 9
        AttributeType: BIOSEnumerationReadOnly
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 10
        AttributeType: BIOSEnumerationReadOnly
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 0, StringHandle = 0(Allowed)
AttributeHandle: 11
        AttributeType: BIOSEnumerationReadOnly
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 12
        AttributeType: BIOSEnumerationReadOnly
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 13
        AttributeType: BIOSEnumeration
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 0, StringHandle = 4(IPv4Static)
AttributeHandle: 14
        AttributeType: BIOSEnumeration
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 0, StringHandle = 4(IPv4Static)
root@rainier:/tmp#

root@rainier:/tmp# busctl get-property  xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
PrefixLength
y 0

root@rainier:/tmp# busctl set-property  xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
PrefixLength y 6

root@rainier:/tmp# busctl get-property  xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
Origin
s "xyz.openbmc_project.Network.IP.AddressOrigin.Static"

root@rainier:/tmp# busctl set-property  xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
Origin s "xyz.openbmc_project.Network.IP.AddressOrigin.DHCP"

root@rainier:/tmp# busctl get-property  xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
Address
s "0.0.0.0"

root@rainier:/tmp# busctl set-property  xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
Address s "1.2.3.4"

root@rainier:/tmp# pldmtool bios GetBIOSTable -t 2
Parsed Response Msg:
PLDM AttributeValueTable:
AttributeHandle: 0
        AttributeType: BIOSStringReadOnly
        CurrentStringLength: 15
        CurrentString: witherspoon-128
AttributeHandle: 1
        AttributeType: BIOSString
        CurrentStringLength: 0
        CurrentString:
AttributeHandle: 2
        AttributeType: BIOSString
        CurrentStringLength: 7
        CurrentString: 0.0.0.0
AttributeHandle: 3
        AttributeType: BIOSString
        CurrentStringLength: 7
        CurrentString: 0.0.0.0
AttributeHandle: 4
        AttributeType: BIOSString
        CurrentStringLength: 7
        CurrentString: 1.2.3.4
AttributeHandle: 5
        AttributeType: BIOSIntegerReadOnly
        CurrentValue: 1
AttributeHandle: 6
        AttributeType: BIOSInteger
        CurrentValue: 0
AttributeHandle: 7
        AttributeType: BIOSInteger
        CurrentValue: 6
AttributeHandle: 8
        AttributeType: BIOSEnumerationReadOnly
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 9
        AttributeType: BIOSEnumerationReadOnly
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 10
        AttributeType: BIOSEnumerationReadOnly
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 0, StringHandle = 0(Allowed)
AttributeHandle: 11
        AttributeType: BIOSEnumerationReadOnly
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 12
        AttributeType: BIOSEnumerationReadOnly
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 13
        AttributeType: BIOSEnumeration
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 0, StringHandle = 4(IPv4Static)
AttributeHandle: 14
        AttributeType: BIOSEnumeration
        NumberOfCurrentValues: 1
        CurrentValueStringHandleIndex[0] = 1, StringHandle = 3(IPv4DHCP)

Change-Id: I60e8f916a82bda0ef27c8c482fafb755b65210b4
Signed-off-by: Sampa Misra <sampmisr@in.ibm.com>
diff --git a/libpldmresponder/bios_string_attribute.cpp b/libpldmresponder/bios_string_attribute.cpp
index 1d9ec5d..1b6ba75 100644
--- a/libpldmresponder/bios_string_attribute.cpp
+++ b/libpldmresponder/bios_string_attribute.cpp
@@ -110,6 +110,25 @@
                                                  attrType, currStr);
 }
 
+int BIOSStringAttribute::updateAttrVal(Table& newValue, uint16_t attrHdl,
+                                       uint8_t attrType,
+                                       const PropertyValue& newPropVal)
+{
+    try
+    {
+        const auto& newStringValue = std::get<std::string>(newPropVal);
+        table::attribute_value::constructStringEntry(newValue, attrHdl,
+                                                     attrType, newStringValue);
+    }
+    catch (const std::bad_variant_access& e)
+    {
+        std::cerr << "invalid value passed for the property, error: "
+                  << e.what() << "\n";
+        return PLDM_ERROR;
+    }
+    return PLDM_SUCCESS;
+}
+
 } // namespace bios
 } // namespace responder
 } // namespace pldm