transporthandler: lan_set_in_progress to per channel

The IPMI specification indicates that this value is
per channel, therefore goes in the channelconfig
object.

Change-Id: Iab5861651518ac80d797faa9d9f092933cc1886e
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/transporthandler.cpp b/transporthandler.cpp
index b62bf9c..a90891a 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -25,14 +25,6 @@
 
 struct ChannelConfig_t channelConfig;
 
-const uint8_t SET_COMPLETE = 0;
-const uint8_t SET_IN_PROGRESS = 1;
-const uint8_t SET_COMMIT_WRITE = 2; //Optional
-const uint8_t SET_IN_PROGRESS_RESERVED = 3; //Reserved
-
-// Status of Set-In-Progress Parameter (# 0)
-uint8_t lan_set_in_progress = SET_COMPLETE;
-
 using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
 namespace fs = std::experimental::filesystem;
@@ -53,7 +45,7 @@
             case LAN_PARM_IP:
             {
                 std::string ipaddress;
-                if (lan_set_in_progress == SET_COMPLETE)
+                if (channelConfig.lan_set_in_progress == SET_COMPLETE)
                 {
                     try
                     {
@@ -70,7 +62,7 @@
                         // nothing to do.
                     }
                 }
-                else if (lan_set_in_progress == SET_IN_PROGRESS)
+                else if (channelConfig.lan_set_in_progress == SET_IN_PROGRESS)
                 {
                     ipaddress = channelConfig.ipaddr;
                 }
@@ -84,7 +76,7 @@
             {
                 std::string networkInterfacePath;
 
-                if (lan_set_in_progress == SET_COMPLETE)
+                if (channelConfig.lan_set_in_progress == SET_COMPLETE)
                 {
                     try
                     {
@@ -151,7 +143,7 @@
 
                     memcpy(data, &ipsrc, ipmi::network::IPSRC_SIZE_BYTE);
                 }
-                else if (lan_set_in_progress == SET_IN_PROGRESS)
+                else if (channelConfig.lan_set_in_progress == SET_IN_PROGRESS)
                 {
                    memcpy(data, &(channelConfig.ipsrc),
                           ipmi::network::IPSRC_SIZE_BYTE);
@@ -162,7 +154,7 @@
             case LAN_PARM_SUBNET:
             {
                 unsigned long mask {};
-                if (lan_set_in_progress == SET_COMPLETE)
+                if (channelConfig.lan_set_in_progress == SET_COMPLETE)
                 {
                     try
                     {
@@ -190,7 +182,7 @@
                     }
                     memcpy(data, &mask, ipmi::network::IPV4_ADDRESS_SIZE_BYTE);
                 }
-                else if (lan_set_in_progress == SET_IN_PROGRESS)
+                else if (channelConfig.lan_set_in_progress == SET_IN_PROGRESS)
                 {
                     inet_pton(AF_INET, channelConfig.netmask.c_str(),
                               reinterpret_cast<void*>(data));
@@ -203,7 +195,7 @@
             {
                 std::string gateway;
 
-                if (lan_set_in_progress == SET_COMPLETE)
+                if (channelConfig.lan_set_in_progress == SET_COMPLETE)
                 {
                     try
                     {
@@ -229,7 +221,7 @@
                     }
 
                 }
-                else if (lan_set_in_progress == SET_IN_PROGRESS)
+                else if (channelConfig.lan_set_in_progress == SET_IN_PROGRESS)
                 {
                     gateway = channelConfig.gateway;
                 }
@@ -242,7 +234,7 @@
             case LAN_PARM_MAC:
             {
                 std::string macAddress;
-                if (lan_set_in_progress == SET_COMPLETE)
+                if (channelConfig.lan_set_in_progress == SET_COMPLETE)
                 {
                     auto macObjectInfo = ipmi::getDbusObject(
                                              bus,
@@ -259,7 +251,7 @@
                     macAddress = variant.get<std::string>();
 
                 }
-                else if (lan_set_in_progress == SET_IN_PROGRESS)
+                else if (channelConfig.lan_set_in_progress == SET_IN_PROGRESS)
                 {
                     macAddress = channelConfig.macAddress;
                 }
@@ -277,7 +269,7 @@
             case LAN_PARM_VLAN:
             {
                 uint16_t vlanID {};
-                if (lan_set_in_progress == SET_COMPLETE)
+                if (channelConfig.lan_set_in_progress == SET_COMPLETE)
                 {
                     try
                     {
@@ -307,7 +299,7 @@
 
                     memcpy(data, &vlanID, ipmi::network::VLAN_SIZE_BYTE);
                 }
-                else if (lan_set_in_progress == SET_IN_PROGRESS)
+                else if (channelConfig.lan_set_in_progress == SET_IN_PROGRESS)
                 {
                     memcpy(data, &(channelConfig.vlanID),
                            ipmi::network::VLAN_SIZE_BYTE);
@@ -449,7 +441,7 @@
         {
             if (reqptr->data[0] == SET_COMPLETE)
             {
-                lan_set_in_progress = SET_COMPLETE;
+                channelConfig.lan_set_in_progress = SET_COMPLETE;
 
                 log<level::INFO>("Network data from Cache",
                                  entry("PREFIX=%s", channelConfig.netmask.c_str()),
@@ -462,7 +454,7 @@
             }
             else if (reqptr->data[0] == SET_IN_PROGRESS) // Set In Progress
             {
-                lan_set_in_progress = SET_IN_PROGRESS;
+                channelConfig.lan_set_in_progress = SET_IN_PROGRESS;
             }
 
         }
@@ -509,7 +501,7 @@
 
     if (reqptr->parameter == LAN_PARM_INPROGRESS)
     {
-        uint8_t buf[] = {current_revision, lan_set_in_progress};
+        uint8_t buf[] = {current_revision, channelConfig.lan_set_in_progress};
         *data_len = sizeof(buf);
         memcpy(response, &buf, *data_len);
     }
diff --git a/transporthandler.hpp b/transporthandler.hpp
index 4894190..a101794 100644
--- a/transporthandler.hpp
+++ b/transporthandler.hpp
@@ -27,6 +27,11 @@
 static const int LAN_PARM_GATEWAY     = 12;
 static const int LAN_PARM_VLAN        = 20;
 
+constexpr uint8_t SET_COMPLETE = 0;
+constexpr uint8_t SET_IN_PROGRESS = 1;
+constexpr uint8_t SET_COMMIT_WRITE = 2; //Optional
+constexpr uint8_t SET_IN_PROGRESS_RESERVED = 3; //Reserved
+
 struct ChannelConfig_t
 {
     std::string ipaddr;
@@ -38,6 +43,7 @@
     // with phosphor-dbus interfaces.
     // vlan id is in 12 bits and the 16th bit is for enable mask.
     uint32_t vlanID = ipmi::network::VLAN_ID_MASK;
+    uint8_t lan_set_in_progress = SET_COMPLETE;
 
     void clear()
     {
@@ -47,5 +53,6 @@
         macAddress.clear();
         vlanID = ipmi::network::VLAN_ID_MASK;
         ipsrc = ipmi::network::IPOrigin::UNSPECIFIED;
+        lan_set_in_progress = SET_COMPLETE;
     }
 };