summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--transporthandler.cpp38
-rw-r--r--transporthandler.hpp7
2 files changed, 22 insertions, 23 deletions
diff --git a/transporthandler.cpp b/transporthandler.cpp
index b62bf9c..a90891a 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -25,14 +25,6 @@ const int SIZE_MAC = 18; //xx:xx:xx:xx:xx:xx
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 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
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 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
// 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 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
{
std::string networkInterfacePath;
- if (lan_set_in_progress == SET_COMPLETE)
+ if (channelConfig.lan_set_in_progress == SET_COMPLETE)
{
try
{
@@ -151,7 +143,7 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
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 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
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 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
}
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 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
{
std::string gateway;
- if (lan_set_in_progress == SET_COMPLETE)
+ if (channelConfig.lan_set_in_progress == SET_COMPLETE)
{
try
{
@@ -229,7 +221,7 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
}
}
- 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 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
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 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
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 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
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 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
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 @@ ipmi_ret_t ipmi_transport_set_lan(ipmi_netfn_t netfn,
{
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 @@ ipmi_ret_t ipmi_transport_set_lan(ipmi_netfn_t netfn,
}
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 @@ ipmi_ret_t ipmi_transport_get_lan(ipmi_netfn_t netfn,
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_SUBNET = 6;
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 @@ struct ChannelConfig_t
// 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 @@ struct ChannelConfig_t
macAddress.clear();
vlanID = ipmi::network::VLAN_ID_MASK;
ipsrc = ipmi::network::IPOrigin::UNSPECIFIED;
+ lan_set_in_progress = SET_COMPLETE;
}
};
OpenPOWER on IntegriCloud