summaryrefslogtreecommitdiffstats
path: root/transporthandler.cpp
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-07-30 10:39:22 +0530
committerRatan Gupta <ratagupt@in.ibm.com>2017-08-13 22:26:01 +0530
commit533d03b5f923e6c59ca1ffb16b6a5eb14e3f96c6 (patch)
tree54b2119d2fbc24774d214f48a5e0ff327d23bf0e /transporthandler.cpp
parentb8e9955db5216a0b170a2fb99125d1f22bb9d1c0 (diff)
downloadphosphor-host-ipmid-533d03b5f923e6c59ca1ffb16b6a5eb14e3f96c6.tar.gz
phosphor-host-ipmid-533d03b5f923e6c59ca1ffb16b6a5eb14e3f96c6.zip
Add support for vlan(set lan command)
Resolves openbmc/openbmc#1899 Change-Id: I3c436045676bc96e5d91fd9420509bc991549a13 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'transporthandler.cpp')
-rw-r--r--transporthandler.cpp61
1 files changed, 58 insertions, 3 deletions
diff --git a/transporthandler.cpp b/transporthandler.cpp
index 4de9400..30526b3 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -49,6 +49,7 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
{
ipmi_ret_t rc = IPMI_CC_OK;
sdbusplus::bus::bus bus(ipmid_get_sd_bus_connection());
+
try
{
switch (lan_param)
@@ -180,6 +181,37 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data)
}
break;
+ case LAN_PARM_VLAN:
+ {
+ if (lan_set_in_progress == SET_COMPLETE)
+ {
+ auto ipObjectInfo = ipmi::getDbusObject(
+ bus,
+ ipmi::network::IP_INTERFACE,
+ ipmi::network::ROOT,
+ ipmi::network::IP_TYPE);
+
+ auto vlanID = static_cast<uint16_t>(
+ ipmi::network::getVLAN(ipObjectInfo.first));
+
+ vlanID = htole16(vlanID);
+
+ if (vlanID)
+ {
+ //Enable the 16th bit
+ vlanID |= htole16(ipmi::network::VLAN_ENABLE_MASK);
+ }
+
+ memcpy(data, &vlanID, ipmi::network::VLAN_SIZE_BYTE);
+ }
+ else if (lan_set_in_progress == SET_IN_PROGRESS)
+ {
+ memcpy(data, &(channelConfig.vlanID),
+ ipmi::network::VLAN_SIZE_BYTE);
+ }
+ }
+ break;
+
default:
rc = IPMI_CC_PARM_OUT_OF_RANGE;
}
@@ -290,6 +322,18 @@ ipmi_ret_t ipmi_transport_set_lan(ipmi_netfn_t netfn,
}
break;
+ case LAN_PARM_VLAN:
+ {
+ uint16_t vlan {};
+ memcpy(&vlan, reqptr->data, ipmi::network::VLAN_SIZE_BYTE);
+ // We are not storing the enable bit
+ // We assume that ipmitool always send enable
+ // bit as 1.
+ vlan = le16toh(vlan);
+ channelConfig.vlanID = vlan;
+ }
+ break;
+
case LAN_PARM_INPROGRESS:
{
if (reqptr->data[0] == SET_COMPLETE)
@@ -299,7 +343,8 @@ ipmi_ret_t ipmi_transport_set_lan(ipmi_netfn_t netfn,
log<level::INFO>("Network data from Cache",
entry("PREFIX=%s", channelConfig.netmask.c_str()),
entry("ADDRESS=%s", channelConfig.ipaddr.c_str()),
- entry("GATEWAY=%s", channelConfig.gateway.c_str()));
+ entry("GATEWAY=%s", channelConfig.gateway.c_str()),
+ entry("VLAN=%d", channelConfig.vlanID));
log<level::INFO>("Use Set Channel Access command to apply");
@@ -314,8 +359,6 @@ ipmi_ret_t ipmi_transport_set_lan(ipmi_netfn_t netfn,
default:
{
- log<level::ERR>("Unsupported parameter",
- entry("PARAMETER=0x%x", reqptr->parameter));
rc = IPMI_CC_PARM_NOT_SUPPORTED;
}
@@ -398,6 +441,18 @@ ipmi_ret_t ipmi_transport_get_lan(ipmi_netfn_t netfn,
rc = IPMI_CC_UNSPECIFIED_ERROR;
}
}
+ else if (reqptr->parameter == LAN_PARM_VLAN)
+ {
+ uint8_t buf[ipmi::network::VLAN_SIZE_BYTE + 1];
+
+ *data_len = sizeof(current_revision);
+ memcpy(buf, &current_revision, *data_len);
+ if (getNetworkData(reqptr->parameter, &buf[1]) == IPMI_CC_OK)
+ {
+ *data_len = sizeof(buf);
+ memcpy(response, &buf, *data_len);
+ }
+ }
else
{
log<level::ERR>("Unsupported parameter",
OpenPOWER on IntegriCloud