diff --git a/chassishandler.cpp b/chassishandler.cpp
index 2ad9948..6002e7a 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -1,72 +1,78 @@
 #include "chassishandler.h"
-#include "host-ipmid/ipmid-api.h"
-#include "types.hpp"
+
 #include "ipmid.hpp"
 #include "settings.hpp"
+#include "types.hpp"
 #include "utils.hpp"
 
+#include <arpa/inet.h>
+#include <endian.h>
+#include <limits.h>
+#include <mapper.h>
+#include <netinet/in.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdint.h>
-#include <mapper.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <limits.h>
 #include <string.h>
-#include <endian.h>
-#include <sstream>
+
 #include <array>
+#include <chrono>
 #include <fstream>
 #include <future>
-#include <chrono>
+#include <sstream>
+
+#include "host-ipmid/ipmid-api.h"
 #if __has_include(<filesystem>)
 #include <filesystem>
 #elif __has_include(<experimental/filesystem>)
 #include <experimental/filesystem>
-namespace std {
-  // splice experimental::filesystem into std
-  namespace filesystem = std::experimental::filesystem;
-}
+namespace std
+{
+// splice experimental::filesystem into std
+namespace filesystem = std::experimental::filesystem;
+} // namespace std
 #else
-#  error filesystem not available
+#error filesystem not available
 #endif
-#include <string>
+#include "config.h"
+
+#include "timer.hpp"
+
 #include <map>
-
-#include <phosphor-logging/log.hpp>
 #include <phosphor-logging/elog-errors.hpp>
-#include <xyz/openbmc_project/State/Host/server.hpp>
-#include "xyz/openbmc_project/Common/error.hpp"
-
+#include <phosphor-logging/log.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server/object.hpp>
-#include <xyz/openbmc_project/Control/Boot/Source/server.hpp>
+#include <string>
+#include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/Control/Boot/Mode/server.hpp>
+#include <xyz/openbmc_project/Control/Boot/Source/server.hpp>
 #include <xyz/openbmc_project/Control/Power/RestorePolicy/server.hpp>
+#include <xyz/openbmc_project/State/Host/server.hpp>
 #include <xyz/openbmc_project/State/PowerOnHours/server.hpp>
-
-#include "config.h"
-#include "timer.hpp"
-//Defines
-#define SET_PARM_VERSION                     0x01
-#define SET_PARM_BOOT_FLAGS_PERMANENT        0x40 //boot flags data1 7th bit on
-#define SET_PARM_BOOT_FLAGS_VALID_ONE_TIME   0x80 //boot flags data1 8th bit on
-#define SET_PARM_BOOT_FLAGS_VALID_PERMANENT  0xC0 //boot flags data1 7 & 8 bit on
+// Defines
+#define SET_PARM_VERSION 0x01
+#define SET_PARM_BOOT_FLAGS_PERMANENT 0x40      // boot flags data1 7th bit on
+#define SET_PARM_BOOT_FLAGS_VALID_ONE_TIME 0x80 // boot flags data1 8th bit on
+#define SET_PARM_BOOT_FLAGS_VALID_PERMANENT                                    \
+    0xC0 // boot flags data1 7 & 8 bit
+         // on
 
 std::unique_ptr<phosphor::ipmi::Timer> identifyTimer = nullptr;
 
-constexpr size_t SIZE_MAC  = 18;
-constexpr size_t SIZE_BOOT_OPTION = (uint8_t)BootOptionResponseSize::
-        OPAL_NETWORK_SETTINGS;//Maximum size of the boot option parametrs
+constexpr size_t SIZE_MAC = 18;
+constexpr size_t SIZE_BOOT_OPTION = (uint8_t)
+    BootOptionResponseSize::OPAL_NETWORK_SETTINGS; // Maximum size of the boot
+                                                   // option parametrs
 constexpr size_t SIZE_PREFIX = 7;
 constexpr size_t MAX_PREFIX_VALUE = 32;
 constexpr size_t SIZE_COOKIE = 4;
 constexpr size_t SIZE_VERSION = 2;
 constexpr size_t DEFAULT_IDENTIFY_TIME_OUT = 15;
 
-//PetiBoot-Specific
+// PetiBoot-Specific
 static constexpr uint8_t net_conf_initial_bytes[] = {0x80, 0x21, 0x70, 0x62,
-        0x21, 0x00, 0x01, 0x06};
+                                                     0x21, 0x00, 0x01, 0x06};
 
 static constexpr size_t COOKIE_OFFSET = 1;
 static constexpr size_t VERSION_OFFSET = 5;
@@ -84,10 +90,10 @@
 
 // Host settings in dbus
 // Service name should be referenced by connection name got via object mapper
-const char *settings_object_name  =  "/org/openbmc/settings/host0";
-const char *settings_intf_name    =  "org.freedesktop.DBus.Properties";
-const char *host_intf_name        =  "org.openbmc.settings.Host";
-const char *identify_led_object_name =
+const char* settings_object_name = "/org/openbmc/settings/host0";
+const char* settings_intf_name = "org.freedesktop.DBus.Properties";
+const char* host_intf_name = "org.openbmc.settings.Host";
+const char* identify_led_object_name =
     "/xyz/openbmc_project/led/groups/enclosure_identify";
 
 constexpr auto SETTINGS_ROOT = "/";
@@ -98,7 +104,7 @@
 
 static constexpr auto chassisStateRoot = "/xyz/openbmc_project/state";
 static constexpr auto chassisPOHStateIntf =
-                                    "xyz.openbmc_project.State.PowerOnHours";
+    "xyz.openbmc_project.State.PowerOnHours";
 static constexpr auto pOHCounterProperty = "POHCounter";
 static constexpr auto match = "chassis0";
 
@@ -110,7 +116,7 @@
     uint8_t sel_dev_addr;
     uint8_t system_management_dev_addr;
     uint8_t bridge_dev_addr;
-}__attribute__((packed)) ipmi_chassis_cap_t;
+} __attribute__((packed)) ipmi_chassis_cap_t;
 
 typedef struct
 {
@@ -118,16 +124,16 @@
     uint8_t last_power_event;
     uint8_t misc_power_state;
     uint8_t front_panel_button_cap_status;
-}__attribute__((packed)) ipmi_get_chassis_status_t;
+} __attribute__((packed)) ipmi_get_chassis_status_t;
 
 /**
  * @struct Get POH counter command response data
  */
 struct GetPOHCountResponse
 {
-    uint8_t minPerCount; ///< Minutes per count
+    uint8_t minPerCount;       ///< Minutes per count
     uint8_t counterReading[4]; ///< Counter reading
-}__attribute__((packed));
+} __attribute__((packed));
 
 // Phosphor Host State manager
 namespace State = sdbusplus::xyz::openbmc_project::State::server;
@@ -165,98 +171,25 @@
 
 } // namespace poh
 
-//TODO : Can remove the below function as we have
+// TODO : Can remove the below function as we have
 //       new functions which uses sdbusplus.
 //
 //       openbmc/openbmc#1489
-int dbus_get_property(const char *name, char **buf)
+int dbus_get_property(const char* name, char** buf)
 {
     sd_bus_error error = SD_BUS_ERROR_NULL;
-    sd_bus_message *m = NULL;
-    sd_bus *bus = NULL;
-    char *temp_buf = NULL;
-    char *connection = NULL;
+    sd_bus_message* m = NULL;
+    sd_bus* bus = NULL;
+    char* temp_buf = NULL;
+    char* connection = NULL;
     int r;
 
     // Get the system bus where most system services are provided.
     bus = ipmid_get_sd_bus_connection();
 
     r = mapper_get_service(bus, settings_object_name, &connection);
-    if (r < 0) {
-    log<level::ERR>("Failed to get connection",
-                    entry("OBJ_NAME=%s", settings_object_name),
-                    entry("ERRNO=0x%X", -r));
-        goto finish;
-    }
-
-    /*
-     * Bus, service, object path, interface and method are provided to call
-     * the method.
-     * Signatures and input arguments are provided by the arguments at the
-     * end.
-     */
-    r = sd_bus_call_method(bus,
-                           connection,                                 /* service to contact */
-                           settings_object_name,                       /* object path */
-                           settings_intf_name,                         /* interface name */
-                           "Get",                                      /* method name */
-                           &error,                                     /* object to return error in */
-                           &m,                                         /* return message on success */
-                           "ss",                                       /* input signature */
-                           host_intf_name,                             /* first argument */
-                           name);                                      /* second argument */
-
-    if (r < 0) {
-        log<level::ERR>("Failed to issue Get method call",
-                        entry("ERRNO=0x%X", r));
-        goto finish;
-    }
-
-    /*
-     * The output should be parsed exactly the same as the output formatting
-     * specified.
-     */
-    r = sd_bus_message_read(m, "v", "s", &temp_buf);
-    if (r < 0) {
-        log<level::ERR>("Failed to parse response message",
-                        entry("ERRNO=0x%X", -r));
-        goto finish;
-    }
-
-    *buf = strdup(temp_buf);
-    /*    *buf = (char*) malloc(strlen(temp_buf));
-    if (*buf) {
-        strcpy(*buf, temp_buf);
-    }
-     */
-
-
-finish:
-    sd_bus_error_free(&error);
-    sd_bus_message_unref(m);
-    free(connection);
-
-    return r;
-}
-
-//TODO : Can remove the below function as we have
-//       new functions which uses sdbusplus.
-//
-//       openbmc/openbmc#1489
-
-int dbus_set_property(const char * name, const char *value)
-{
-    sd_bus_error error = SD_BUS_ERROR_NULL;
-    sd_bus_message *m = NULL;
-    sd_bus *bus = NULL;
-    char *connection = NULL;
-    int r;
-
-    // Get the system bus where most system services are provided.
-    bus = ipmid_get_sd_bus_connection();
-
-    r = mapper_get_service(bus, settings_object_name, &connection);
-    if (r < 0) {
+    if (r < 0)
+    {
         log<level::ERR>("Failed to get connection",
                         entry("OBJ_NAME=%s", settings_object_name),
                         entry("ERRNO=0x%X", -r));
@@ -269,26 +202,43 @@
      * Signatures and input arguments are provided by the arguments at the
      * end.
      */
-    r = sd_bus_call_method(bus,
-                           connection,                                 /* service to contact */
-                           settings_object_name,                       /* object path */
-                           settings_intf_name,                         /* interface name */
-                           "Set",                                      /* method name */
-                           &error,                                     /* object to return error in */
-                           &m,                                         /* return message on success */
-                           "ssv",                                      /* input signature */
-                           host_intf_name,                             /* first argument */
-                           name,                                       /* second argument */
-                           "s",                                        /* third argument */
-                           value);                                     /* fourth argument */
+    r = sd_bus_call_method(bus, connection,      /* service to contact */
+                           settings_object_name, /* object path */
+                           settings_intf_name,   /* interface name */
+                           "Get",                /* method name */
+                           &error,               /* object to return error in */
+                           &m,                   /* return message on success */
+                           "ss",                 /* input signature */
+                           host_intf_name,       /* first argument */
+                           name);                /* second argument */
 
-    if (r < 0) {
-        log<level::ERR>("Failed to issue Set method call",
+    if (r < 0)
+    {
+        log<level::ERR>("Failed to issue Get method call",
                         entry("ERRNO=0x%X", r));
         goto finish;
     }
 
-    finish:
+    /*
+     * The output should be parsed exactly the same as the output formatting
+     * specified.
+     */
+    r = sd_bus_message_read(m, "v", "s", &temp_buf);
+    if (r < 0)
+    {
+        log<level::ERR>("Failed to parse response message",
+                        entry("ERRNO=0x%X", -r));
+        goto finish;
+    }
+
+    *buf = strdup(temp_buf);
+    /*    *buf = (char*) malloc(strlen(temp_buf));
+    if (*buf) {
+        strcpy(*buf, temp_buf);
+    }
+     */
+
+finish:
     sd_bus_error_free(&error);
     sd_bus_message_unref(m);
     free(connection);
@@ -296,23 +246,83 @@
     return r;
 }
 
-struct get_sys_boot_options_t {
+// TODO : Can remove the below function as we have
+//       new functions which uses sdbusplus.
+//
+//       openbmc/openbmc#1489
+
+int dbus_set_property(const char* name, const char* value)
+{
+    sd_bus_error error = SD_BUS_ERROR_NULL;
+    sd_bus_message* m = NULL;
+    sd_bus* bus = NULL;
+    char* connection = NULL;
+    int r;
+
+    // Get the system bus where most system services are provided.
+    bus = ipmid_get_sd_bus_connection();
+
+    r = mapper_get_service(bus, settings_object_name, &connection);
+    if (r < 0)
+    {
+        log<level::ERR>("Failed to get connection",
+                        entry("OBJ_NAME=%s", settings_object_name),
+                        entry("ERRNO=0x%X", -r));
+        goto finish;
+    }
+
+    /*
+     * Bus, service, object path, interface and method are provided to call
+     * the method.
+     * Signatures and input arguments are provided by the arguments at the
+     * end.
+     */
+    r = sd_bus_call_method(bus, connection,      /* service to contact */
+                           settings_object_name, /* object path */
+                           settings_intf_name,   /* interface name */
+                           "Set",                /* method name */
+                           &error,               /* object to return error in */
+                           &m,                   /* return message on success */
+                           "ssv",                /* input signature */
+                           host_intf_name,       /* first argument */
+                           name,                 /* second argument */
+                           "s",                  /* third argument */
+                           value);               /* fourth argument */
+
+    if (r < 0)
+    {
+        log<level::ERR>("Failed to issue Set method call",
+                        entry("ERRNO=0x%X", r));
+        goto finish;
+    }
+
+finish:
+    sd_bus_error_free(&error);
+    sd_bus_message_unref(m);
+    free(connection);
+
+    return r;
+}
+
+struct get_sys_boot_options_t
+{
     uint8_t parameter;
     uint8_t set;
     uint8_t block;
-}  __attribute__ ((packed));
+} __attribute__((packed));
 
-struct get_sys_boot_options_response_t {
+struct get_sys_boot_options_response_t
+{
     uint8_t version;
     uint8_t parm;
     uint8_t data[SIZE_BOOT_OPTION];
-}  __attribute__ ((packed));
+} __attribute__((packed));
 
-struct set_sys_boot_options_t {
+struct set_sys_boot_options_t
+{
     uint8_t parameter;
     uint8_t data[SIZE_BOOT_OPTION];
-}  __attribute__ ((packed));
-
+} __attribute__((packed));
 
 int getHostNetworkData(get_sys_boot_options_response_t* respptr)
 {
@@ -322,7 +332,7 @@
 
     try
     {
-        //TODO There may be cases where an interface is implemented by multiple
+        // TODO There may be cases where an interface is implemented by multiple
         // objects,to handle such cases we are interested on that object
         //  which are on interested busname.
         //  Currenlty mapper doesn't give the readable busname(gives busid)
@@ -338,22 +348,23 @@
         auto macObjectInfo = ipmi::getDbusObject(bus, MAC_INTERFACE,
                                                  SETTINGS_ROOT, SETTINGS_MATCH);
 
-        properties  = ipmi::getAllDbusProperties(bus, ipObjectInfo.second,
-                                            ipObjectInfo.first, IP_INTERFACE);
-        auto variant =
-            ipmi::getDbusProperty(bus, macObjectInfo.second,
-                                  macObjectInfo.first,
-                                  MAC_INTERFACE, "MACAddress");
+        properties = ipmi::getAllDbusProperties(
+            bus, ipObjectInfo.second, ipObjectInfo.first, IP_INTERFACE);
+        auto variant = ipmi::getDbusProperty(bus, macObjectInfo.second,
+                                             macObjectInfo.first, MAC_INTERFACE,
+                                             "MACAddress");
 
-       auto ipAddress = properties["Address"].get<std::string>();
+        auto ipAddress = properties["Address"].get<std::string>();
 
         auto gateway = properties["Gateway"].get<std::string>();
 
         auto prefix = properties["PrefixLength"].get<uint8_t>();
 
-        uint8_t isStatic = (properties["Origin"].get<std::string>() ==
-            "xyz.openbmc_project.Network.IP.AddressOrigin.Static")
-                ? 1 : 0;
+        uint8_t isStatic =
+            (properties["Origin"].get<std::string>() ==
+             "xyz.openbmc_project.Network.IP.AddressOrigin.Static")
+                ? 1
+                : 0;
 
         auto MACAddress = variant.get<std::string>();
 
@@ -373,9 +384,8 @@
         // should not be default one,don't send blank override.
         if (isStatic)
         {
-            if((ipAddress == ipmi::network::DEFAULT_ADDRESS) ||
-               (gateway == ipmi::network::DEFAULT_ADDRESS) ||
-               (!prefix))
+            if ((ipAddress == ipmi::network::DEFAULT_ADDRESS) ||
+                (gateway == ipmi::network::DEFAULT_ADDRESS) || (!prefix))
             {
                 memset(respptr->data, 0, SIZE_BOOT_OPTION);
                 rc = -1;
@@ -383,30 +393,28 @@
             }
         }
 
-        sscanf(MACAddress.c_str(), ipmi::network::MAC_ADDRESS_FORMAT,
-               (respptr->data + MAC_OFFSET),
-               (respptr->data + MAC_OFFSET + 1),
-               (respptr->data + MAC_OFFSET + 2),
-               (respptr->data + MAC_OFFSET + 3),
-               (respptr->data + MAC_OFFSET + 4),
-               (respptr->data + MAC_OFFSET + 5));
+        sscanf(
+            MACAddress.c_str(), ipmi::network::MAC_ADDRESS_FORMAT,
+            (respptr->data + MAC_OFFSET), (respptr->data + MAC_OFFSET + 1),
+            (respptr->data + MAC_OFFSET + 2), (respptr->data + MAC_OFFSET + 3),
+            (respptr->data + MAC_OFFSET + 4), (respptr->data + MAC_OFFSET + 5));
 
         respptr->data[MAC_OFFSET + 6] = 0x00;
 
-        memcpy(respptr->data + ADDRTYPE_OFFSET, &isStatic,
-               sizeof(isStatic));
+        memcpy(respptr->data + ADDRTYPE_OFFSET, &isStatic, sizeof(isStatic));
 
         uint8_t addressFamily = (properties["Type"].get<std::string>() ==
-            "xyz.openbmc_project.Network.IP.Protocol.IPv4") ?
-                AF_INET : AF_INET6;
+                                 "xyz.openbmc_project.Network.IP.Protocol.IPv4")
+                                    ? AF_INET
+                                    : AF_INET6;
 
-        addrSize = (addressFamily == AF_INET) ?
-                       ipmi::network::IPV4_ADDRESS_SIZE_BYTE :
-                       ipmi::network::IPV6_ADDRESS_SIZE_BYTE;
+        addrSize = (addressFamily == AF_INET)
+                       ? ipmi::network::IPV4_ADDRESS_SIZE_BYTE
+                       : ipmi::network::IPV6_ADDRESS_SIZE_BYTE;
 
         // ipaddress and gateway would be in IPv4 format
         inet_pton(addressFamily, ipAddress.c_str(),
-                 (respptr->data + IPADDR_OFFSET));
+                  (respptr->data + IPADDR_OFFSET));
 
         uint8_t prefixOffset = IPADDR_OFFSET + addrSize;
 
@@ -415,8 +423,7 @@
         uint8_t gatewayOffset = prefixOffset + sizeof(decltype(prefix));
 
         inet_pton(addressFamily, gateway.c_str(),
-                 (respptr->data + gatewayOffset));
-
+                  (respptr->data + gatewayOffset));
     }
     catch (InternalFailure& e)
     {
@@ -426,8 +433,8 @@
         return rc;
     }
 
-    //PetiBoot-Specific
-    //If success then copy the first 9 bytes to the data
+    // PetiBoot-Specific
+    // If success then copy the first 9 bytes to the data
     memcpy(respptr->data, net_conf_initial_bytes,
            sizeof(net_conf_initial_bytes));
 
@@ -453,30 +460,32 @@
  *  @returns address in text form.
  */
 
-std::string getAddrStr(uint8_t family, uint8_t* data,
-                       uint8_t offset, uint8_t addrSize)
+std::string getAddrStr(uint8_t family, uint8_t* data, uint8_t offset,
+                       uint8_t addrSize)
 {
     char ipAddr[INET6_ADDRSTRLEN] = {};
 
-    switch(family)
+    switch (family)
     {
         case AF_INET:
         {
-            struct sockaddr_in addr4 {};
+            struct sockaddr_in addr4
+            {
+            };
             memcpy(&addr4.sin_addr.s_addr, &data[offset], addrSize);
 
-            inet_ntop(AF_INET, &addr4.sin_addr,
-                      ipAddr, INET_ADDRSTRLEN);
+            inet_ntop(AF_INET, &addr4.sin_addr, ipAddr, INET_ADDRSTRLEN);
 
             break;
         }
         case AF_INET6:
         {
-            struct sockaddr_in6 addr6 {};
+            struct sockaddr_in6 addr6
+            {
+            };
             memcpy(&addr6.sin6_addr.s6_addr, &data[offset], addrSize);
 
-            inet_ntop(AF_INET6, &addr6.sin6_addr,
-                      ipAddr, INET6_ADDRSTRLEN);
+            inet_ntop(AF_INET6, &addr6.sin6_addr, ipAddr, INET6_ADDRSTRLEN);
 
             break;
         }
@@ -493,19 +502,18 @@
 {
     using namespace std::string_literals;
     std::string host_network_config;
-    char mac[] {"00:00:00:00:00:00"};
+    char mac[]{"00:00:00:00:00:00"};
     std::string ipAddress, gateway;
-    char addrOrigin {0};
-    uint8_t addrSize {0};
+    char addrOrigin{0};
+    uint8_t addrSize{0};
     std::string addressOrigin =
         "xyz.openbmc_project.Network.IP.AddressOrigin.DHCP";
-    std::string addressType =
-        "xyz.openbmc_project.Network.IP.Protocol.IPv4";
-    uint8_t prefix {0};
+    std::string addressType = "xyz.openbmc_project.Network.IP.Protocol.IPv4";
+    uint8_t prefix{0};
     uint32_t zeroCookie = 0;
     uint8_t family = AF_INET;
 
-    //cookie starts from second byte
+    // cookie starts from second byte
     // version starts from sixth byte
 
     try
@@ -514,13 +522,12 @@
         {
             // cookie ==  0x21 0x70 0x62 0x21
             if (memcmp(&(reqptr->data[COOKIE_OFFSET]),
-                        (net_conf_initial_bytes + COOKIE_OFFSET),
-                        SIZE_COOKIE) != 0)
+                       (net_conf_initial_bytes + COOKIE_OFFSET),
+                       SIZE_COOKIE) != 0)
             {
-                //cookie == 0
-                if (memcmp(&(reqptr->data[COOKIE_OFFSET]),
-                            &zeroCookie,
-                            SIZE_COOKIE) == 0)
+                // cookie == 0
+                if (memcmp(&(reqptr->data[COOKIE_OFFSET]), &zeroCookie,
+                           SIZE_COOKIE) == 0)
                 {
                     // need to zero out the network settings.
                     break;
@@ -532,8 +539,8 @@
 
             // vesion == 0x00 0x01
             if (memcmp(&(reqptr->data[VERSION_OFFSET]),
-                        (net_conf_initial_bytes + VERSION_OFFSET),
-                        SIZE_VERSION) != 0)
+                       (net_conf_initial_bytes + VERSION_OFFSET),
+                       SIZE_VERSION) != 0)
             {
 
                 log<level::ERR>("Invalid Version");
@@ -541,10 +548,8 @@
             }
 
             snprintf(mac, SIZE_MAC, ipmi::network::MAC_ADDRESS_FORMAT,
-                     reqptr->data[MAC_OFFSET],
-                     reqptr->data[MAC_OFFSET + 1],
-                     reqptr->data[MAC_OFFSET + 2],
-                     reqptr->data[MAC_OFFSET + 3],
+                     reqptr->data[MAC_OFFSET], reqptr->data[MAC_OFFSET + 1],
+                     reqptr->data[MAC_OFFSET + 2], reqptr->data[MAC_OFFSET + 3],
                      reqptr->data[MAC_OFFSET + 4],
                      reqptr->data[MAC_OFFSET + 5]);
 
@@ -558,7 +563,8 @@
             }
 
             // Get the address size
-            memcpy(&addrSize ,&reqptr->data[ADDR_SIZE_OFFSET], sizeof(addrSize));
+            memcpy(&addrSize, &reqptr->data[ADDR_SIZE_OFFSET],
+                   sizeof(addrSize));
 
             uint8_t prefixOffset = IPADDR_OFFSET + addrSize;
 
@@ -573,17 +579,18 @@
                 family = AF_INET6;
             }
 
-            ipAddress = getAddrStr(family, reqptr->data, IPADDR_OFFSET, addrSize);
+            ipAddress =
+                getAddrStr(family, reqptr->data, IPADDR_OFFSET, addrSize);
 
             gateway = getAddrStr(family, reqptr->data, gatewayOffset, addrSize);
 
-        } while(0);
+        } while (0);
 
-        //Cookie == 0 or it is a valid cookie
-        host_network_config += "ipaddress="s + ipAddress +
-            ",prefix="s + std::to_string(prefix) + ",gateway="s + gateway +
-            ",mac="s + mac + ",addressOrigin="s + addressOrigin;
-
+        // Cookie == 0 or it is a valid cookie
+        host_network_config += "ipaddress="s + ipAddress + ",prefix="s +
+                               std::to_string(prefix) + ",gateway="s + gateway +
+                               ",mac="s + mac + ",addressOrigin="s +
+                               addressOrigin;
 
         sdbusplus::bus::bus bus(ipmid_get_sd_bus_connection());
 
@@ -593,22 +600,22 @@
                                                  SETTINGS_ROOT, SETTINGS_MATCH);
         // set the dbus property
         ipmi::setDbusProperty(bus, ipObjectInfo.second, ipObjectInfo.first,
-                IP_INTERFACE, "Address", std::string(ipAddress));
+                              IP_INTERFACE, "Address", std::string(ipAddress));
         ipmi::setDbusProperty(bus, ipObjectInfo.second, ipObjectInfo.first,
-                IP_INTERFACE, "PrefixLength", prefix);
+                              IP_INTERFACE, "PrefixLength", prefix);
         ipmi::setDbusProperty(bus, ipObjectInfo.second, ipObjectInfo.first,
-                IP_INTERFACE, "Origin", addressOrigin);
+                              IP_INTERFACE, "Origin", addressOrigin);
         ipmi::setDbusProperty(bus, ipObjectInfo.second, ipObjectInfo.first,
-                IP_INTERFACE, "Gateway", std::string(gateway));
-        ipmi::setDbusProperty(bus, ipObjectInfo.second, ipObjectInfo.first,
-                IP_INTERFACE, "Type",
-                std::string("xyz.openbmc_project.Network.IP.Protocol.IPv4"));
+                              IP_INTERFACE, "Gateway", std::string(gateway));
+        ipmi::setDbusProperty(
+            bus, ipObjectInfo.second, ipObjectInfo.first, IP_INTERFACE, "Type",
+            std::string("xyz.openbmc_project.Network.IP.Protocol.IPv4"));
         ipmi::setDbusProperty(bus, macObjectInfo.second, macObjectInfo.first,
-                MAC_INTERFACE,"MACAddress", std::string(mac));
+                              MAC_INTERFACE, "MACAddress", std::string(mac));
 
-        log<level::DEBUG>("Network configuration changed",
-                entry("NETWORKCONFIG=%s", host_network_config.c_str()));
-
+        log<level::DEBUG>(
+            "Network configuration changed",
+            entry("NETWORKCONFIG=%s", host_network_config.c_str()));
     }
     catch (InternalFailure& e)
     {
@@ -623,15 +630,15 @@
 {
     sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
 
-    auto chassisStateObj = ipmi::getDbusObject(bus, chassisPOHStateIntf,
-                                               chassisStateRoot, match);
+    auto chassisStateObj =
+        ipmi::getDbusObject(bus, chassisPOHStateIntf, chassisStateRoot, match);
 
-    auto service = ipmi::getService(bus, chassisPOHStateIntf,
-                                    chassisStateObj.first);
+    auto service =
+        ipmi::getService(bus, chassisPOHStateIntf, chassisStateObj.first);
 
-    auto propValue = ipmi::getDbusProperty(bus, service, chassisStateObj.first,
-                                           chassisPOHStateIntf,
-                                           pOHCounterProperty);
+    auto propValue =
+        ipmi::getDbusProperty(bus, service, chassisStateObj.first,
+                              chassisPOHStateIntf, pOHCounterProperty);
 
     return propValue.get<uint32_t>();
 }
@@ -649,8 +656,10 @@
 }
 
 ipmi_ret_t ipmi_get_chassis_cap(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
-                                ipmi_request_t request, ipmi_response_t response,
-                                ipmi_data_len_t data_len, ipmi_context_t context)
+                                ipmi_request_t request,
+                                ipmi_response_t response,
+                                ipmi_data_len_t data_len,
+                                ipmi_context_t context)
 {
     // sd_bus error
     ipmi_ret_t rc = IPMI_CC_OK;
@@ -665,9 +674,11 @@
     // [7..4] - reserved
     // [3] – 1b = provides power interlock  (IPM 1.5)
     // [2] – 1b = provides Diagnostic Interrupt (FP NMI)
-    // [1] – 1b = provides “Front Panel Lockout” (indicates that the chassis has capabilities
-    //            to lock out external power control and reset button or front panel interfaces
-    //            and/or detect tampering with those interfaces).
+    // [1] – 1b = provides “Front Panel Lockout” (indicates that the chassis has
+    // capabilities
+    //            to lock out external power control and reset button or front
+    //            panel interfaces and/or detect tampering with those
+    //            interfaces).
     // [0] -1b = Chassis provides intrusion (physical security) sensor.
     // set to default value 0x0.
     chassis_cap.cap_flags = 0x0;
@@ -700,26 +711,26 @@
 int initiate_state_transition(State::Host::Transition transition)
 {
     // OpenBMC Host State Manager dbus framework
-    constexpr auto HOST_STATE_MANAGER_ROOT  = "/xyz/openbmc_project/state/host0";
+    constexpr auto HOST_STATE_MANAGER_ROOT = "/xyz/openbmc_project/state/host0";
     constexpr auto HOST_STATE_MANAGER_IFACE = "xyz.openbmc_project.State.Host";
-    constexpr auto DBUS_PROPERTY_IFACE      = "org.freedesktop.DBus.Properties";
-    constexpr auto PROPERTY                 = "RequestedHostTransition";
+    constexpr auto DBUS_PROPERTY_IFACE = "org.freedesktop.DBus.Properties";
+    constexpr auto PROPERTY = "RequestedHostTransition";
 
     // sd_bus error
     int rc = 0;
-    char  *busname = NULL;
+    char* busname = NULL;
 
     // SD Bus error report mechanism.
     sd_bus_error bus_error = SD_BUS_ERROR_NULL;
 
     // Gets a hook onto either a SYSTEM or SESSION bus
-    sd_bus *bus_type = ipmid_get_sd_bus_connection();
+    sd_bus* bus_type = ipmid_get_sd_bus_connection();
     rc = mapper_get_service(bus_type, HOST_STATE_MANAGER_ROOT, &busname);
     if (rc < 0)
     {
-        log<level::ERR>("Failed to get bus name",
-                        entry("ERRNO=0x%X, OBJPATH=%s",
-                              -rc, HOST_STATE_MANAGER_ROOT));
+        log<level::ERR>(
+            "Failed to get bus name",
+            entry("ERRNO=0x%X, OBJPATH=%s", -rc, HOST_STATE_MANAGER_ROOT));
         return rc;
     }
 
@@ -734,10 +745,9 @@
                             &bus_error,              // object to return error
                             nullptr,                 // Response buffer if any
                             "ssv",                   // Takes 3 arguments
-                            HOST_STATE_MANAGER_IFACE,
-                            PROPERTY,
-                            "s", request.c_str());
-    if(rc < 0)
+                            HOST_STATE_MANAGER_IFACE, PROPERTY, "s",
+                            request.c_str());
+    if (rc < 0)
     {
         log<level::ERR>("Failed to initiate transition",
                         entry("ERRNO=0x%X, REQUEST=%s", -rc, request.c_str()));
@@ -760,12 +770,10 @@
 using IpmiValue = uint8_t;
 using DbusValue = RestorePolicy::Policy;
 
-std::map<DbusValue, IpmiValue> dbusToIpmi =
-{
+std::map<DbusValue, IpmiValue> dbusToIpmi = {
     {RestorePolicy::Policy::AlwaysOff, 0x00},
     {RestorePolicy::Policy::Restore, 0x01},
-    {RestorePolicy::Policy::AlwaysOn, 0x02}
-};
+    {RestorePolicy::Policy::AlwaysOn, 0x02}};
 
 } // namespace power_policy
 
@@ -778,14 +786,14 @@
                                    ipmi_data_len_t data_len,
                                    ipmi_context_t context)
 {
-    const char  *objname = "/org/openbmc/control/power0";
-    const char  *intf = "org.openbmc.control.Power";
+    const char* objname = "/org/openbmc/control/power0";
+    const char* intf = "org.openbmc.control.Power";
 
-    sd_bus *bus = NULL;
-    sd_bus_message *reply = NULL;
+    sd_bus* bus = NULL;
+    sd_bus_message* reply = NULL;
     int r = 0;
     int pgood = 0;
-    char *busname = NULL;
+    char* busname = NULL;
     ipmi_ret_t rc = IPMI_CC_OK;
     ipmi_get_chassis_status_t chassis_status{};
 
@@ -796,12 +804,9 @@
     using namespace power_policy;
 
     const auto& powerRestoreSetting = objects.map.at(powerRestoreIntf).front();
-    auto method =
-        dbus.new_method_call(
-            objects.service(powerRestoreSetting, powerRestoreIntf).c_str(),
-            powerRestoreSetting.c_str(),
-            ipmi::PROP_INTF,
-            "Get");
+    auto method = dbus.new_method_call(
+        objects.service(powerRestoreSetting, powerRestoreIntf).c_str(),
+        powerRestoreSetting.c_str(), ipmi::PROP_INTF, "Get");
     method.append(powerRestoreIntf, "PowerRestorePolicy");
     auto resp = dbus.call(method);
     if (resp.is_method_error())
@@ -821,29 +826,29 @@
     bus = ipmid_get_sd_bus_connection();
 
     r = mapper_get_service(bus, objname, &busname);
-    if (r < 0) {
-        log<level::ERR>("Failed to get bus name",
-                        entry("ERRNO=0x%X", -r));
+    if (r < 0)
+    {
+        log<level::ERR>("Failed to get bus name", entry("ERRNO=0x%X", -r));
         rc = IPMI_CC_UNSPECIFIED_ERROR;
         goto finish;
     }
 
-    r = sd_bus_get_property(bus, busname, objname, intf, "pgood", NULL, &reply, "i");
-    if (r < 0) {
+    r = sd_bus_get_property(bus, busname, objname, intf, "pgood", NULL, &reply,
+                            "i");
+    if (r < 0)
+    {
         log<level::ERR>("Failed to call sd_bus_get_property",
-                        entry("PROPERTY=%s","pgood"),
-                        entry("ERRNO=0x%X", -r),
-                        entry("BUS=%s", busname),
-                        entry("PATH=%s", objname),
+                        entry("PROPERTY=%s", "pgood"), entry("ERRNO=0x%X", -r),
+                        entry("BUS=%s", busname), entry("PATH=%s", objname),
                         entry("INTERFACE=%s", intf));
         rc = IPMI_CC_UNSPECIFIED_ERROR;
         goto finish;
     }
 
     r = sd_bus_message_read(reply, "i", &pgood);
-    if (r < 0) {
-        log<level::ERR>("Failed to read sensor:",
-                        entry("ERRNO=0x%X", -r));
+    if (r < 0)
+    {
+        log<level::ERR>("Failed to read sensor:", entry("ERRNO=0x%X", -r));
         rc = IPMI_CC_UNSPECIFIED_ERROR;
         goto finish;
     }
@@ -859,7 +864,8 @@
     //          10b = chassis always powers up after AC/mains returns
     //          11b = unknow
     //        Set to 00b, by observing the hardware behavior.
-    //        Do we need to define a dbus property to identify the restore policy?
+    //        Do we need to define a dbus property to identify the restore
+    //        policy?
 
     // [4] power control fault
     //       1b = controller attempted to turn system power on or off, but
@@ -882,7 +888,7 @@
     //       1b = system power is on
     //       0b = system power is off(soft-off S4/S5, or mechanical off)
 
-    chassis_status.cur_power_state = ((s & 0x3)<<5) | (pgood & 0x1);
+    chassis_status.cur_power_state = ((s & 0x3) << 5) | (pgood & 0x1);
 
     // Last Power Event
     // [7..5] – reserved
@@ -901,7 +907,8 @@
     //       0b = Chassis Identify command support unspecified via this command.
     //       (The Get Command Support command , if implemented, would still
     //       indicate support for the Chassis Identify command)
-    // [5..4] – Chassis Identify State. Mandatory when bit[6] =1b, reserved (return
+    // [5..4] – Chassis Identify State. Mandatory when bit[6] =1b, reserved
+    // (return
     //          as 00b) otherwise. Returns the present chassis identify state.
     //           Refer to the Chassis Identify command for more info.
     //         00b = chassis identify state = Off
@@ -935,13 +942,13 @@
 //-------------------------------------------------------------
 int stop_soft_off_timer()
 {
-    constexpr auto iface            = "org.freedesktop.DBus.Properties";
-    constexpr auto soft_off_iface   = "xyz.openbmc_project.Ipmi.Internal."
-            "SoftPowerOff";
+    constexpr auto iface = "org.freedesktop.DBus.Properties";
+    constexpr auto soft_off_iface = "xyz.openbmc_project.Ipmi.Internal."
+                                    "SoftPowerOff";
 
-    constexpr auto property         = "ResponseReceived";
-    constexpr auto value            = "xyz.openbmc_project.Ipmi.Internal."
-            "SoftPowerOff.HostResponse.HostShutdown";
+    constexpr auto property = "ResponseReceived";
+    constexpr auto value = "xyz.openbmc_project.Ipmi.Internal."
+                           "SoftPowerOff.HostResponse.HostShutdown";
 
     // Get the system bus where most system services are provided.
     auto bus = ipmid_get_sd_bus_connection();
@@ -953,9 +960,9 @@
     // for now the code will directly call the soft off interface due to a
     // race condition with mapper usage
     //
-    //char *busname = nullptr;
-    //auto r = mapper_get_service(bus, SOFTOFF_OBJPATH, &busname);
-    //if (r < 0)
+    // char *busname = nullptr;
+    // auto r = mapper_get_service(bus, SOFTOFF_OBJPATH, &busname);
+    // if (r < 0)
     //{
     //    fprintf(stderr, "Failed to get %s bus name: %s\n",
     //            SOFTOFF_OBJPATH, -r);
@@ -964,16 +971,16 @@
 
     // No error object or reply expected.
     int rc = sd_bus_call_method(bus, SOFTOFF_BUSNAME, SOFTOFF_OBJPATH, iface,
-                                "Set", nullptr, nullptr, "ssv",
-                                soft_off_iface, property, "s", value);
+                                "Set", nullptr, nullptr, "ssv", soft_off_iface,
+                                property, "s", value);
     if (rc < 0)
     {
         log<level::ERR>("Failed to set property in SoftPowerOff object",
                         entry("ERRNO=0x%X", -rc));
     }
 
-    //TODO openbmc/openbmc#1661 - Mapper refactor
-    //free(busname);
+    // TODO openbmc/openbmc#1661 - Mapper refactor
+    // free(busname);
     return rc;
 }
 
@@ -990,10 +997,10 @@
 
     // Add the host instance (default 0 for now) to the file name
     std::string file{HOST_INBAND_REQUEST_FILE};
-    auto size = std::snprintf(nullptr,0,file.c_str(),0);
+    auto size = std::snprintf(nullptr, 0, file.c_str(), 0);
     size++; // null
     std::unique_ptr<char[]> buf(new char[size]);
-    std::snprintf(buf.get(),size,file.c_str(),0);
+    std::snprintf(buf.get(), size, file.c_str(), 0);
 
     // Append file name to directory and create it
     path /= buf.get();
@@ -1016,9 +1023,9 @@
     *data_len = 0;
 
     // Catch the actual operaton by peeking into request buffer
-    uint8_t chassis_ctrl_cmd = *(uint8_t *)request;
+    uint8_t chassis_ctrl_cmd = *(uint8_t*)request;
 
-    switch(chassis_ctrl_cmd)
+    switch (chassis_ctrl_cmd)
     {
         case CMD_POWER_ON:
             rc = initiate_state_transition(State::Host::Transition::On);
@@ -1086,7 +1093,7 @@
         }
     }
 
-    return ( (rc < 0) ? IPMI_CC_INVALID : IPMI_CC_OK);
+    return ((rc < 0) ? IPMI_CC_INVALID : IPMI_CC_OK);
 }
 
 /** @brief Return D-Bus connection string to enclosure identify LED object
@@ -1098,16 +1105,12 @@
 {
     // lookup enclosure_identify group owner(s) in mapper
     auto mapperCall = chassis::internal::dbus.new_method_call(
-                          ipmi::MAPPER_BUS_NAME,
-                          ipmi::MAPPER_OBJ,
-                          ipmi::MAPPER_INTF,
-                          "GetObject");
+        ipmi::MAPPER_BUS_NAME, ipmi::MAPPER_OBJ, ipmi::MAPPER_INTF,
+        "GetObject");
 
     mapperCall.append(identify_led_object_name);
-    static const std::vector<std::string> interfaces =
-    {
-        "xyz.openbmc_project.Led.Group"
-    };
+    static const std::vector<std::string> interfaces = {
+        "xyz.openbmc_project.Led.Group"};
     mapperCall.append(interfaces);
     auto mapperReply = chassis::internal::dbus.call(mapperCall);
     if (mapperReply.is_method_error())
@@ -1120,8 +1123,9 @@
 
     if (mapperResp.size() != encIdentifyObjectsSize)
     {
-        log<level::ERR>("Invalid number of enclosure identify objects.",
-                entry("ENC_IDENTITY_OBJECTS_SIZE=%d", mapperResp.size()));
+        log<level::ERR>(
+            "Invalid number of enclosure identify objects.",
+            entry("ENC_IDENTITY_OBJECTS_SIZE=%d", mapperResp.size()));
         elog<InternalFailure>();
     }
     auto pair = mapperResp[encIdentifyObjectsSize - 1];
@@ -1137,15 +1141,16 @@
 {
     using namespace chassis::internal;
     std::string connection = std::move(getEnclosureIdentifyConnection());
-    auto led = dbus.new_method_call(connection.c_str(),
-        identify_led_object_name, "org.freedesktop.DBus.Properties", "Set");
+    auto led =
+        dbus.new_method_call(connection.c_str(), identify_led_object_name,
+                             "org.freedesktop.DBus.Properties", "Set");
     led.append("xyz.openbmc_project.Led.Group", "Asserted",
-    sdbusplus::message::variant<bool>(flag));
+               sdbusplus::message::variant<bool>(flag));
     auto ledReply = dbus.call(led);
     if (ledReply.is_method_error())
     {
         log<level::ERR>("Chassis Identify: Error Setting State On/Off\n",
-                entry("LED_STATE=%d", flag));
+                        entry("LED_STATE=%d", flag));
         elog<InternalFailure>();
     }
 }
@@ -1185,11 +1190,14 @@
     {
         return IPMI_CC_REQ_DATA_LEN_INVALID;
     }
-    uint8_t identifyInterval = *data_len > identifyIntervalPos ?
-            (static_cast<uint8_t*>(request))[identifyIntervalPos] :
-                DEFAULT_IDENTIFY_TIME_OUT;
-    bool forceIdentify = (*data_len == chassisIdentifyReqLength) ?
-            (static_cast<uint8_t*>(request))[forceIdentifyPos] & 0x01 : false;
+    uint8_t identifyInterval =
+        *data_len > identifyIntervalPos
+            ? (static_cast<uint8_t*>(request))[identifyIntervalPos]
+            : DEFAULT_IDENTIFY_TIME_OUT;
+    bool forceIdentify =
+        (*data_len == chassisIdentifyReqLength)
+            ? (static_cast<uint8_t*>(request))[forceIdentifyPos] & 0x01
+            : false;
 
     if (identifyInterval || forceIdentify)
     {
@@ -1212,7 +1220,7 @@
         }
         // start the timer
         auto time = std::chrono::duration_cast<std::chrono::microseconds>(
-                        std::chrono::seconds(identifyInterval));
+            std::chrono::seconds(identifyInterval));
         identifyTimer->startTimer(time);
     }
     else if (!identifyInterval)
@@ -1230,39 +1238,30 @@
 using IpmiValue = uint8_t;
 constexpr auto ipmiDefault = 0;
 
-std::map<IpmiValue, Source::Sources> sourceIpmiToDbus =
-{
+std::map<IpmiValue, Source::Sources> sourceIpmiToDbus = {
     {0x01, Source::Sources::Network},
     {0x02, Source::Sources::Disk},
     {0x05, Source::Sources::ExternalMedia},
-    {ipmiDefault, Source::Sources::Default}
-};
+    {ipmiDefault, Source::Sources::Default}};
 
-std::map<IpmiValue, Mode::Modes> modeIpmiToDbus =
-{
+std::map<IpmiValue, Mode::Modes> modeIpmiToDbus = {
     {0x03, Mode::Modes::Safe},
     {0x06, Mode::Modes::Setup},
-    {ipmiDefault, Mode::Modes::Regular}
-};
+    {ipmiDefault, Mode::Modes::Regular}};
 
-std::map<Source::Sources, IpmiValue> sourceDbusToIpmi =
-{
+std::map<Source::Sources, IpmiValue> sourceDbusToIpmi = {
     {Source::Sources::Network, 0x01},
     {Source::Sources::Disk, 0x02},
     {Source::Sources::ExternalMedia, 0x05},
-    {Source::Sources::Default, ipmiDefault}
-};
+    {Source::Sources::Default, ipmiDefault}};
 
-std::map<Mode::Modes, IpmiValue> modeDbusToIpmi =
-{
+std::map<Mode::Modes, IpmiValue> modeDbusToIpmi = {
     {Mode::Modes::Safe, 0x03},
     {Mode::Modes::Setup, 0x06},
-    {Mode::Modes::Regular, ipmiDefault}
-};
+    {Mode::Modes::Regular, ipmiDefault}};
 
 } // namespace boot_options
 
-
 /** @brief Set the property value for boot source
  *  @param[in] source - boot source value
  *  @return On failure return IPMI error.
@@ -1275,10 +1274,9 @@
         convertForMessage(source);
     auto bootSetting = settings::boot::setting(objects, bootSourceIntf);
     const auto& bootSourceSetting = std::get<settings::Path>(bootSetting);
-    auto method =
-        dbus.new_method_call(
-             objects.service(bootSourceSetting, bootSourceIntf).c_str(),
-             bootSourceSetting.c_str(), ipmi::PROP_INTF, "Set");
+    auto method = dbus.new_method_call(
+        objects.service(bootSourceSetting, bootSourceIntf).c_str(),
+        bootSourceSetting.c_str(), ipmi::PROP_INTF, "Set");
     method.append(bootSourceIntf, "BootSource", property);
     auto reply = dbus.call(method);
     if (reply.is_method_error())
@@ -1290,7 +1288,7 @@
     return IPMI_CC_OK;
 }
 
- /** @brief Set the property value for boot mode
+/** @brief Set the property value for boot mode
  *  @param[in] mode - boot mode value
  *  @return On failure return IPMI error.
  */
@@ -1298,14 +1296,12 @@
 {
     using namespace chassis::internal;
     using namespace chassis::internal::cache;
-    sdbusplus::message::variant<std::string> property =
-        convertForMessage(mode);
+    sdbusplus::message::variant<std::string> property = convertForMessage(mode);
     auto bootSetting = settings::boot::setting(objects, bootModeIntf);
     const auto& bootModeSetting = std::get<settings::Path>(bootSetting);
-    auto method =
-        dbus.new_method_call(
-             objects.service(bootModeSetting, bootModeIntf).c_str(),
-             bootModeSetting.c_str(), ipmi::PROP_INTF, "Set");
+    auto method = dbus.new_method_call(
+        objects.service(bootModeSetting, bootModeIntf).c_str(),
+        bootModeSetting.c_str(), ipmi::PROP_INTF, "Set");
     method.append(bootModeIntf, "BootMode", property);
     auto reply = dbus.call(method);
     if (reply.is_method_error())
@@ -1325,23 +1321,24 @@
 {
     using namespace boot_options;
     ipmi_ret_t rc = IPMI_CC_PARM_NOT_SUPPORTED;
-    char *p = NULL;
-    get_sys_boot_options_response_t *resp = (get_sys_boot_options_response_t *) response;
-    get_sys_boot_options_t *reqptr = (get_sys_boot_options_t*) request;
+    char* p = NULL;
+    get_sys_boot_options_response_t* resp =
+        (get_sys_boot_options_response_t*)response;
+    get_sys_boot_options_t* reqptr = (get_sys_boot_options_t*)request;
     IpmiValue bootOption = ipmiDefault;
 
-    memset(resp,0,sizeof(*resp));
-    resp->version   = SET_PARM_VERSION;
-    resp->parm      = 5;
-    resp->data[0]   = SET_PARM_BOOT_FLAGS_VALID_ONE_TIME;
-
+    memset(resp, 0, sizeof(*resp));
+    resp->version = SET_PARM_VERSION;
+    resp->parm = 5;
+    resp->data[0] = SET_PARM_BOOT_FLAGS_VALID_ONE_TIME;
 
     /*
      * Parameter #5 means boot flags. Please refer to 28.13 of ipmi doc.
      * This is the only parameter used by petitboot.
      */
-    if ( reqptr->parameter == static_cast<uint8_t>
-    ( BootOptionParameter::BOOT_FLAGS )) {
+    if (reqptr->parameter ==
+        static_cast<uint8_t>(BootOptionParameter::BOOT_FLAGS))
+    {
 
         *data_len = static_cast<uint8_t>(BootOptionResponseSize::BOOT_FLAGS);
         using namespace chassis::internal;
@@ -1354,12 +1351,9 @@
                 std::get<settings::Path>(bootSetting);
             auto oneTimeEnabled =
                 std::get<settings::boot::OneTimeEnabled>(bootSetting);
-            auto method =
-                dbus.new_method_call(
-                     objects.service(bootSourceSetting, bootSourceIntf).c_str(),
-                     bootSourceSetting.c_str(),
-                     ipmi::PROP_INTF,
-                     "Get");
+            auto method = dbus.new_method_call(
+                objects.service(bootSourceSetting, bootSourceIntf).c_str(),
+                bootSourceSetting.c_str(), ipmi::PROP_INTF, "Get");
             method.append(bootSourceIntf, "BootSource");
             auto reply = dbus.call(method);
             if (reply.is_method_error())
@@ -1377,11 +1371,8 @@
             bootSetting = settings::boot::setting(objects, bootModeIntf);
             const auto& bootModeSetting = std::get<settings::Path>(bootSetting);
             method = dbus.new_method_call(
-                          objects.service(bootModeSetting, bootModeIntf).
-                              c_str(),
-                          bootModeSetting.c_str(),
-                          ipmi::PROP_INTF,
-                          "Get");
+                objects.service(bootModeSetting, bootModeIntf).c_str(),
+                bootModeSetting.c_str(), ipmi::PROP_INTF, "Get");
             method.append(bootModeIntf, "BootMode");
             reply = dbus.call(method);
             if (reply.is_method_error())
@@ -1407,9 +1398,9 @@
             }
             resp->data[1] = (bootOption << 2);
 
-            resp->data[0] = oneTimeEnabled ?
-                SET_PARM_BOOT_FLAGS_VALID_ONE_TIME:
-                SET_PARM_BOOT_FLAGS_VALID_PERMANENT;
+            resp->data[0] = oneTimeEnabled
+                                ? SET_PARM_BOOT_FLAGS_VALID_ONE_TIME
+                                : SET_PARM_BOOT_FLAGS_VALID_PERMANENT;
 
             rc = IPMI_CC_OK;
         }
@@ -1419,28 +1410,34 @@
             *data_len = 0;
             return IPMI_CC_UNSPECIFIED_ERROR;
         }
-    } else if ( reqptr->parameter == static_cast<uint8_t>
-    ( BootOptionParameter::OPAL_NETWORK_SETTINGS )) {
+    }
+    else if (reqptr->parameter ==
+             static_cast<uint8_t>(BootOptionParameter::OPAL_NETWORK_SETTINGS))
+    {
 
-        *data_len = static_cast<uint8_t>(BootOptionResponseSize::OPAL_NETWORK_SETTINGS);
+        *data_len =
+            static_cast<uint8_t>(BootOptionResponseSize::OPAL_NETWORK_SETTINGS);
 
-        resp->parm = static_cast<uint8_t>(BootOptionParameter::OPAL_NETWORK_SETTINGS);
+        resp->parm =
+            static_cast<uint8_t>(BootOptionParameter::OPAL_NETWORK_SETTINGS);
 
         int ret = getHostNetworkData(resp);
 
-        if (ret < 0) {
+        if (ret < 0)
+        {
 
             log<level::ERR>(
-                        "getHostNetworkData failed for get_sys_boot_options.");
+                "getHostNetworkData failed for get_sys_boot_options.");
             rc = IPMI_CC_UNSPECIFIED_ERROR;
-
-        }else
+        }
+        else
             rc = IPMI_CC_OK;
     }
 
-    else {
-        log<level::ERR>("Unsupported parameter", entry(
-                        "PARAM=0x%x", reqptr->parameter));
+    else
+    {
+        log<level::ERR>("Unsupported parameter",
+                        entry("PARAM=0x%x", reqptr->parameter));
     }
 
     if (p)
@@ -1454,8 +1451,6 @@
     return rc;
 }
 
-
-
 ipmi_ret_t ipmi_chassis_set_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
                                              ipmi_request_t request,
                                              ipmi_response_t response,
@@ -1464,9 +1459,10 @@
 {
     using namespace boot_options;
     ipmi_ret_t rc = IPMI_CC_OK;
-    set_sys_boot_options_t *reqptr = (set_sys_boot_options_t *) request;
+    set_sys_boot_options_t* reqptr = (set_sys_boot_options_t*)request;
 
-    printf("IPMI SET_SYS_BOOT_OPTIONS reqptr->parameter =[%d]\n",reqptr->parameter);
+    printf("IPMI SET_SYS_BOOT_OPTIONS reqptr->parameter =[%d]\n",
+           reqptr->parameter);
 
     // This IPMI command does not have any resposne data
     *data_len = 0;
@@ -1484,7 +1480,7 @@
         auto oneTimeEnabled = false;
         constexpr auto enabledIntf = "xyz.openbmc_project.Object.Enable";
         constexpr auto oneTimePath =
-                "/xyz/openbmc_project/control/host0/boot/one_time";
+            "/xyz/openbmc_project/control/host0/boot/one_time";
 
         try
         {
@@ -1492,8 +1488,7 @@
                 (reqptr->data[0] & SET_PARM_BOOT_FLAGS_PERMANENT) ==
                 SET_PARM_BOOT_FLAGS_PERMANENT;
 
-            auto bootSetting =
-                settings::boot::setting(objects, bootSourceIntf);
+            auto bootSetting = settings::boot::setting(objects, bootSourceIntf);
 
             oneTimeEnabled =
                 std::get<settings::boot::OneTimeEnabled>(bootSetting);
@@ -1512,12 +1507,8 @@
             {
                 auto service = ipmi::getService(dbus, enabledIntf, oneTimePath);
 
-                ipmi::setDbusProperty(dbus,
-                                      service,
-                                      oneTimePath,
-                                      enabledIntf,
-                                      "Enabled",
-                                      !permanent);
+                ipmi::setDbusProperty(dbus, service, oneTimePath, enabledIntf,
+                                      "Enabled", !permanent);
             }
 
             auto modeItr = modeIpmiToDbus.find(bootOption);
@@ -1534,7 +1525,7 @@
                 // the boot mode D-Bus property to default.
                 // This way the ipmid code can determine which property is not
                 // at the default value
-                if(sourceItr->second != Source::Sources::Default)
+                if (sourceItr->second != Source::Sources::Default)
                 {
                     setBootMode(Mode::Modes::Regular);
                 }
@@ -1551,7 +1542,7 @@
                 // the boot source D-Bus property to default.
                 // This way the ipmid code can determine which property is not
                 // at the default value
-                if(modeItr->second != Mode::Modes::Regular)
+                if (modeItr->second != Mode::Modes::Regular)
                 {
                     setBootSource(Source::Sources::Default);
                 }
@@ -1563,26 +1554,33 @@
             *data_len = 0;
             return IPMI_CC_UNSPECIFIED_ERROR;
         }
-    } else if (reqptr->parameter ==
-            (uint8_t)BootOptionParameter::OPAL_NETWORK_SETTINGS) {
+    }
+    else if (reqptr->parameter ==
+             (uint8_t)BootOptionParameter::OPAL_NETWORK_SETTINGS)
+    {
 
         int ret = setHostNetworkData(reqptr);
-        if (ret < 0) {
+        if (ret < 0)
+        {
             log<level::ERR>(
-                        "setHostNetworkData failed for set_sys_boot_options");
+                "setHostNetworkData failed for set_sys_boot_options");
             rc = IPMI_CC_UNSPECIFIED_ERROR;
         }
-    } else if (reqptr->parameter ==
-             static_cast<uint8_t>(BootOptionParameter::BOOT_INFO)) {
+    }
+    else if (reqptr->parameter ==
+             static_cast<uint8_t>(BootOptionParameter::BOOT_INFO))
+    {
         // Handle parameter #4 and return command completed normally
         // (IPMI_CC_OK). There is no implementation in OpenBMC for this
         // parameter. This is added to support the ipmitool command `chassis
         // bootdev` which sends set on parameter #4, before setting the boot
         // flags.
         rc = IPMI_CC_OK;
-    } else {
-        log<level::ERR>("Unsupported parameter", entry(
-            "PARAM=0x%x", reqptr->parameter));
+    }
+    else
+    {
+        log<level::ERR>("Unsupported parameter",
+                        entry("PARAM=0x%x", reqptr->parameter));
         rc = IPMI_CC_PARM_NOT_SUPPORTED;
     }
 
@@ -1623,24 +1621,25 @@
     createIdentifyTimer();
 
     // <Wildcard Command>
-    ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_WILDCARD, NULL, ipmi_chassis_wildcard,
-                           PRIVILEGE_USER);
+    ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_WILDCARD, NULL,
+                           ipmi_chassis_wildcard, PRIVILEGE_USER);
 
     // Get Chassis Capabilities
-    ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_GET_CHASSIS_CAP, NULL, ipmi_get_chassis_cap,
-                           PRIVILEGE_USER);
+    ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_GET_CHASSIS_CAP, NULL,
+                           ipmi_get_chassis_cap, PRIVILEGE_USER);
 
     // <Get System Boot Options>
     ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_GET_SYS_BOOT_OPTIONS, NULL,
-                           ipmi_chassis_get_sys_boot_options, PRIVILEGE_OPERATOR);
+                           ipmi_chassis_get_sys_boot_options,
+                           PRIVILEGE_OPERATOR);
 
     // <Get Chassis Status>
-    ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_CHASSIS_STATUS, NULL, ipmi_get_chassis_status,
-                           PRIVILEGE_USER);
+    ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_CHASSIS_STATUS, NULL,
+                           ipmi_get_chassis_status, PRIVILEGE_USER);
 
     // <Chassis Control>
-    ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_CHASSIS_CONTROL, NULL, ipmi_chassis_control,
-                           PRIVILEGE_OPERATOR);
+    ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_CHASSIS_CONTROL, NULL,
+                           ipmi_chassis_control, PRIVILEGE_OPERATOR);
 
     // <Chassis Identify>
     ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_CHASSIS_IDENTIFY, NULL,
@@ -1648,7 +1647,8 @@
 
     // <Set System Boot Options>
     ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_SET_SYS_BOOT_OPTIONS, NULL,
-                           ipmi_chassis_set_sys_boot_options, PRIVILEGE_OPERATOR);
+                           ipmi_chassis_set_sys_boot_options,
+                           PRIVILEGE_OPERATOR);
     // <Get POH Counter>
     ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_GET_POH_COUNTER, NULL,
                            ipmiGetPOHCounter, PRIVILEGE_USER);
