| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1 | /* | 
|  | 2 | // Copyright (c) 2018 Intel Corporation | 
|  | 3 | // | 
|  | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | // you may not use this file except in compliance with the License. | 
|  | 6 | // You may obtain a copy of the License at | 
|  | 7 | // | 
|  | 8 | //      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | // | 
|  | 10 | // Unless required by applicable law or agreed to in writing, software | 
|  | 11 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | // See the License for the specific language governing permissions and | 
|  | 14 | // limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #include "channel_mgmt.hpp" | 
|  | 18 |  | 
| Johnathan Mantey | fd61fc3 | 2021-04-08 11:05:38 -0700 | [diff] [blame] | 19 | #include "user_layer.hpp" | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 20 |  | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 21 | #include <ifaddrs.h> | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 22 | #include <sys/stat.h> | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 23 | #include <sys/types.h> | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 24 | #include <unistd.h> | 
|  | 25 |  | 
|  | 26 | #include <boost/interprocess/sync/scoped_lock.hpp> | 
| George Liu | 42f64ef | 2024-02-05 15:03:18 +0800 | [diff] [blame] | 27 | #include <ipmid/utils.hpp> | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 28 | #include <phosphor-logging/lg2.hpp> | 
| Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 29 | #include <sdbusplus/bus/match.hpp> | 
|  | 30 | #include <sdbusplus/server/object.hpp> | 
|  | 31 |  | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 32 | #include <cerrno> | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 33 | #include <exception> | 
| Patrick Williams | 3d8d793 | 2022-06-16 12:01:28 -0500 | [diff] [blame] | 34 | #include <filesystem> | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 35 | #include <fstream> | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 36 | #include <unordered_map> | 
|  | 37 |  | 
|  | 38 | namespace ipmi | 
|  | 39 | { | 
|  | 40 |  | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 41 | static constexpr const char* channelAccessDefaultFilename = | 
|  | 42 | "/usr/share/ipmi-providers/channel_access.json"; | 
|  | 43 | static constexpr const char* channelConfigDefaultFilename = | 
|  | 44 | "/usr/share/ipmi-providers/channel_config.json"; | 
|  | 45 | static constexpr const char* channelNvDataFilename = | 
|  | 46 | "/var/lib/ipmi/channel_access_nv.json"; | 
|  | 47 | static constexpr const char* channelVolatileDataFilename = | 
|  | 48 | "/run/ipmi/channel_access_volatile.json"; | 
|  | 49 |  | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 50 | // TODO: Get the service name dynamically.. | 
|  | 51 | static constexpr const char* networkIntfServiceName = | 
|  | 52 | "xyz.openbmc_project.Network"; | 
|  | 53 | static constexpr const char* networkIntfObjectBasePath = | 
|  | 54 | "/xyz/openbmc_project/network"; | 
|  | 55 | static constexpr const char* networkChConfigIntfName = | 
|  | 56 | "xyz.openbmc_project.Channel.ChannelAccess"; | 
|  | 57 | static constexpr const char* privilegePropertyString = "MaxPrivilege"; | 
|  | 58 | static constexpr const char* dBusPropertiesInterface = | 
|  | 59 | "org.freedesktop.DBus.Properties"; | 
|  | 60 | static constexpr const char* propertiesChangedSignal = "PropertiesChanged"; | 
| Willy Tu | ac05aa1 | 2021-11-16 21:15:58 -0800 | [diff] [blame] | 61 | static constexpr const char* interfaceAddedSignal = "InterfacesAdded"; | 
|  | 62 | static constexpr const char* interfaceRemovedSignal = "InterfacesRemoved"; | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 63 |  | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 64 | // STRING DEFINES: Should sync with key's in JSON | 
|  | 65 | static constexpr const char* nameString = "name"; | 
|  | 66 | static constexpr const char* isValidString = "is_valid"; | 
|  | 67 | static constexpr const char* activeSessionsString = "active_sessions"; | 
| Vernon Mauery | 5831712 | 2018-11-28 11:02:43 -0800 | [diff] [blame] | 68 | static constexpr const char* maxTransferSizeString = "max_transfer_size"; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 69 | static constexpr const char* channelInfoString = "channel_info"; | 
|  | 70 | static constexpr const char* mediumTypeString = "medium_type"; | 
|  | 71 | static constexpr const char* protocolTypeString = "protocol_type"; | 
|  | 72 | static constexpr const char* sessionSupportedString = "session_supported"; | 
|  | 73 | static constexpr const char* isIpmiString = "is_ipmi"; | 
| Johnathan Mantey | fd61fc3 | 2021-04-08 11:05:38 -0700 | [diff] [blame] | 74 | static constexpr const char* isManagementNIC = "is_management_nic"; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 75 | static constexpr const char* accessModeString = "access_mode"; | 
|  | 76 | static constexpr const char* userAuthDisabledString = "user_auth_disabled"; | 
|  | 77 | static constexpr const char* perMsgAuthDisabledString = "per_msg_auth_disabled"; | 
|  | 78 | static constexpr const char* alertingDisabledString = "alerting_disabled"; | 
|  | 79 | static constexpr const char* privLimitString = "priv_limit"; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 80 |  | 
|  | 81 | // Default values | 
|  | 82 | static constexpr const char* defaultChannelName = "RESERVED"; | 
|  | 83 | static constexpr const uint8_t defaultMediumType = | 
|  | 84 | static_cast<uint8_t>(EChannelMediumType::reserved); | 
|  | 85 | static constexpr const uint8_t defaultProtocolType = | 
|  | 86 | static_cast<uint8_t>(EChannelProtocolType::reserved); | 
|  | 87 | static constexpr const uint8_t defaultSessionSupported = | 
|  | 88 | static_cast<uint8_t>(EChannelSessSupported::none); | 
|  | 89 | static constexpr const uint8_t defaultAuthType = | 
|  | 90 | static_cast<uint8_t>(EAuthType::none); | 
|  | 91 | static constexpr const bool defaultIsIpmiState = false; | 
| Vernon Mauery | 5831712 | 2018-11-28 11:02:43 -0800 | [diff] [blame] | 92 | static constexpr size_t smallChannelSize = 64; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 93 |  | 
| Lei YU | 4b0ddb6 | 2019-01-25 16:43:50 +0800 | [diff] [blame] | 94 | std::unique_ptr<sdbusplus::bus::match_t> chPropertiesSignal | 
|  | 95 | __attribute__((init_priority(101))); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 96 |  | 
| Willy Tu | ac05aa1 | 2021-11-16 21:15:58 -0800 | [diff] [blame] | 97 | std::unique_ptr<sdbusplus::bus::match_t> chInterfaceAddedSignal | 
|  | 98 | __attribute__((init_priority(101))); | 
|  | 99 |  | 
|  | 100 | std::unique_ptr<sdbusplus::bus::match_t> chInterfaceRemovedSignal | 
|  | 101 | __attribute__((init_priority(101))); | 
|  | 102 |  | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 103 | // String mappings use in JSON config file | 
|  | 104 | static std::unordered_map<std::string, EChannelMediumType> mediumTypeMap = { | 
|  | 105 | {"reserved", EChannelMediumType::reserved}, | 
|  | 106 | {"ipmb", EChannelMediumType::ipmb}, | 
|  | 107 | {"icmb-v1.0", EChannelMediumType::icmbV10}, | 
|  | 108 | {"icmb-v0.9", EChannelMediumType::icmbV09}, | 
|  | 109 | {"lan-802.3", EChannelMediumType::lan8032}, | 
|  | 110 | {"serial", EChannelMediumType::serial}, | 
|  | 111 | {"other-lan", EChannelMediumType::otherLan}, | 
|  | 112 | {"pci-smbus", EChannelMediumType::pciSmbus}, | 
|  | 113 | {"smbus-v1.0", EChannelMediumType::smbusV11}, | 
|  | 114 | {"smbus-v2.0", EChannelMediumType::smbusV20}, | 
|  | 115 | {"usb-1x", EChannelMediumType::usbV1x}, | 
|  | 116 | {"usb-2x", EChannelMediumType::usbV2x}, | 
|  | 117 | {"system-interface", EChannelMediumType::systemInterface}, | 
|  | 118 | {"oem", EChannelMediumType::oem}, | 
|  | 119 | {"unknown", EChannelMediumType::unknown}}; | 
|  | 120 |  | 
| ssekar | f4b2b09 | 2018-07-25 18:49:08 +0530 | [diff] [blame] | 121 | static std::unordered_map<EInterfaceIndex, std::string> interfaceMap = { | 
| Richard Marian Thomaiyar | 43cb128 | 2018-12-08 17:22:53 +0530 | [diff] [blame] | 122 | {interfaceKCS, "SMS"}, | 
| Richard Marian Thomaiyar | 73906b9 | 2019-01-04 23:48:02 +0530 | [diff] [blame] | 123 | {interfaceLAN1, "eth0"}, | 
| ssekar | f4b2b09 | 2018-07-25 18:49:08 +0530 | [diff] [blame] | 124 | {interfaceUnknown, "unknown"}}; | 
|  | 125 |  | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 126 | static std::unordered_map<std::string, EChannelProtocolType> protocolTypeMap = { | 
|  | 127 | {"na", EChannelProtocolType::na}, | 
|  | 128 | {"ipmb-1.0", EChannelProtocolType::ipmbV10}, | 
|  | 129 | {"icmb-2.0", EChannelProtocolType::icmbV11}, | 
|  | 130 | {"reserved", EChannelProtocolType::reserved}, | 
|  | 131 | {"ipmi-smbus", EChannelProtocolType::ipmiSmbus}, | 
|  | 132 | {"kcs", EChannelProtocolType::kcs}, | 
|  | 133 | {"smic", EChannelProtocolType::smic}, | 
|  | 134 | {"bt-10", EChannelProtocolType::bt10}, | 
|  | 135 | {"bt-15", EChannelProtocolType::bt15}, | 
|  | 136 | {"tmode", EChannelProtocolType::tMode}, | 
|  | 137 | {"oem", EChannelProtocolType::oem}}; | 
|  | 138 |  | 
|  | 139 | static std::array<std::string, 4> accessModeList = { | 
|  | 140 | "disabled", "pre-boot", "always_available", "shared"}; | 
|  | 141 |  | 
|  | 142 | static std::array<std::string, 4> sessionSupportList = { | 
|  | 143 | "session-less", "single-session", "multi-session", "session-based"}; | 
|  | 144 |  | 
| Sumanth Bhat | e4e633e | 2019-05-14 12:13:57 +0000 | [diff] [blame] | 145 | const std::array<std::string, PRIVILEGE_OEM + 1> privList = { | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 146 | "priv-reserved", "priv-callback", "priv-user", | 
|  | 147 | "priv-operator", "priv-admin",    "priv-oem"}; | 
|  | 148 |  | 
| Richard Marian Thomaiyar | 55768e3 | 2019-03-02 22:54:37 +0530 | [diff] [blame] | 149 | std::string ChannelConfig::getChannelName(const uint8_t chNum) | 
| Johnathan Mantey | 74a2102 | 2018-12-13 13:17:56 -0800 | [diff] [blame] | 150 | { | 
|  | 151 | if (!isValidChannel(chNum)) | 
|  | 152 | { | 
| George Liu | a0e545d | 2025-01-24 09:50:22 +0800 | [diff] [blame] | 153 | lg2::error("Get channel name - Invalid channel number: {CHANNEL_ID}", | 
|  | 154 | "CHANNEL_ID", chNum); | 
| Prithvi Pai | 1dd18d2 | 2025-09-19 14:27:03 +0530 | [diff] [blame] | 155 | return ""; | 
| Johnathan Mantey | 74a2102 | 2018-12-13 13:17:56 -0800 | [diff] [blame] | 156 | } | 
|  | 157 |  | 
|  | 158 | return channelData[chNum].chName; | 
|  | 159 | } | 
|  | 160 |  | 
|  | 161 | int ChannelConfig::convertToChannelNumberFromChannelName( | 
|  | 162 | const std::string& chName) | 
|  | 163 | { | 
|  | 164 | for (const auto& it : channelData) | 
|  | 165 | { | 
|  | 166 | if (it.chName == chName) | 
|  | 167 | { | 
|  | 168 | return it.chID; | 
|  | 169 | } | 
|  | 170 | } | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 171 | lg2::error("Invalid channel name: {CHANNEL}", "CHANNEL", chName); | 
| Johnathan Mantey | 74a2102 | 2018-12-13 13:17:56 -0800 | [diff] [blame] | 172 | throw std::invalid_argument("Invalid channel name"); | 
|  | 173 |  | 
|  | 174 | return -1; | 
|  | 175 | } | 
|  | 176 |  | 
|  | 177 | std::string ChannelConfig::getChannelNameFromPath(const std::string& path) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 178 | { | 
| Peter Foley | 1214d6c | 2023-11-01 11:12:42 -0400 | [diff] [blame] | 179 | const size_t length = strlen(networkIntfObjectBasePath); | 
| Richard Marian Thomaiyar | bbbc395 | 2020-01-17 12:13:28 +0530 | [diff] [blame] | 180 | if (((length + 1) >= path.size()) || | 
|  | 181 | path.compare(0, length, networkIntfObjectBasePath)) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 182 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 183 | lg2::error("Invalid object path: {PATH}", "PATH", path); | 
| Richard Marian Thomaiyar | bbbc395 | 2020-01-17 12:13:28 +0530 | [diff] [blame] | 184 | throw std::invalid_argument("Invalid object path"); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 185 | } | 
| Richard Marian Thomaiyar | bbbc395 | 2020-01-17 12:13:28 +0530 | [diff] [blame] | 186 | std::string chName(path, length + 1); | 
| Johnathan Mantey | 74a2102 | 2018-12-13 13:17:56 -0800 | [diff] [blame] | 187 | return chName; | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 188 | } | 
|  | 189 |  | 
| Johnathan Mantey | e5c4f1d | 2018-12-10 16:24:26 -0800 | [diff] [blame] | 190 | void ChannelConfig::processChAccessPropChange( | 
|  | 191 | const std::string& path, const DbusChObjProperties& chProperties) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 192 | { | 
|  | 193 | // Get interface name from path. ex: '/xyz/openbmc_project/network/eth0' | 
| Johnathan Mantey | 74a2102 | 2018-12-13 13:17:56 -0800 | [diff] [blame] | 194 | std::string chName; | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 195 | try | 
|  | 196 | { | 
| Johnathan Mantey | 74a2102 | 2018-12-13 13:17:56 -0800 | [diff] [blame] | 197 | chName = getChannelNameFromPath(path); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 198 | } | 
|  | 199 | catch (const std::invalid_argument& e) | 
|  | 200 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 201 | lg2::error("Exception: {MSG}", "MSG", e.what()); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 202 | return; | 
|  | 203 | } | 
|  | 204 |  | 
|  | 205 | // Get the MaxPrivilege property value from the signal | 
|  | 206 | std::string intfPrivStr; | 
|  | 207 | std::string propName; | 
|  | 208 | for (const auto& prop : chProperties) | 
|  | 209 | { | 
|  | 210 | if (prop.first == privilegePropertyString) | 
|  | 211 | { | 
|  | 212 | propName = privilegePropertyString; | 
| Vernon Mauery | f442e11 | 2019-04-09 11:44:36 -0700 | [diff] [blame] | 213 | intfPrivStr = std::get<std::string>(prop.second); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 214 | break; | 
|  | 215 | } | 
|  | 216 | } | 
|  | 217 |  | 
|  | 218 | if (propName != privilegePropertyString) | 
|  | 219 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 220 | lg2::error("Unknown signal caught."); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 221 | return; | 
|  | 222 | } | 
|  | 223 |  | 
|  | 224 | if (intfPrivStr.empty()) | 
|  | 225 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 226 | lg2::error("Invalid privilege string for intf {INTF}", "INTF", chName); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 227 | return; | 
|  | 228 | } | 
|  | 229 |  | 
|  | 230 | uint8_t intfPriv = 0; | 
| Johnathan Mantey | 74a2102 | 2018-12-13 13:17:56 -0800 | [diff] [blame] | 231 | int chNum; | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 232 | try | 
|  | 233 | { | 
| Johnathan Mantey | e5c4f1d | 2018-12-10 16:24:26 -0800 | [diff] [blame] | 234 | intfPriv = static_cast<uint8_t>(convertToPrivLimitIndex(intfPrivStr)); | 
| Johnathan Mantey | 74a2102 | 2018-12-13 13:17:56 -0800 | [diff] [blame] | 235 | chNum = convertToChannelNumberFromChannelName(chName); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 236 | } | 
|  | 237 | catch (const std::invalid_argument& e) | 
|  | 238 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 239 | lg2::error("Exception: {MSG}", "MSG", e.what()); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 240 | return; | 
|  | 241 | } | 
|  | 242 |  | 
|  | 243 | boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex> | 
| Johnathan Mantey | e5c4f1d | 2018-12-10 16:24:26 -0800 | [diff] [blame] | 244 | channelLock{*channelMutex}; | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 245 | // skip updating the values, if this property change originated from IPMI. | 
| Johnathan Mantey | e5c4f1d | 2018-12-10 16:24:26 -0800 | [diff] [blame] | 246 | if (signalFlag & (1 << chNum)) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 247 | { | 
| Johnathan Mantey | e5c4f1d | 2018-12-10 16:24:26 -0800 | [diff] [blame] | 248 | signalFlag &= ~(1 << chNum); | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 249 | lg2::debug("Request originated from IPMI so ignoring signal"); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 250 | return; | 
|  | 251 | } | 
|  | 252 |  | 
|  | 253 | // Update both volatile & Non-volatile, if there is mismatch. | 
|  | 254 | // as property change other than IPMI, has to update both volatile & | 
|  | 255 | // non-volatile data. | 
| Johnathan Mantey | e5c4f1d | 2018-12-10 16:24:26 -0800 | [diff] [blame] | 256 | checkAndReloadVolatileData(); | 
|  | 257 | checkAndReloadNVData(); | 
|  | 258 | if (channelData[chNum].chAccess.chNonVolatileData.privLimit != intfPriv) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 259 | { | 
|  | 260 | // Update NV data | 
| Johnathan Mantey | e5c4f1d | 2018-12-10 16:24:26 -0800 | [diff] [blame] | 261 | channelData[chNum].chAccess.chNonVolatileData.privLimit = intfPriv; | 
|  | 262 | if (writeChannelPersistData() != 0) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 263 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 264 | lg2::error("Failed to update the persist data file"); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 265 | return; | 
|  | 266 | } | 
|  | 267 |  | 
|  | 268 | // Update Volatile data | 
| Johnathan Mantey | e5c4f1d | 2018-12-10 16:24:26 -0800 | [diff] [blame] | 269 | if (channelData[chNum].chAccess.chVolatileData.privLimit != intfPriv) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 270 | { | 
| Johnathan Mantey | e5c4f1d | 2018-12-10 16:24:26 -0800 | [diff] [blame] | 271 | channelData[chNum].chAccess.chVolatileData.privLimit = intfPriv; | 
|  | 272 | if (writeChannelVolatileData() != 0) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 273 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 274 | lg2::error("Failed to update the volatile data file"); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 275 | return; | 
|  | 276 | } | 
|  | 277 | } | 
|  | 278 | } | 
|  | 279 |  | 
|  | 280 | return; | 
|  | 281 | } | 
|  | 282 |  | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 283 | ChannelConfig& getChannelConfigObject() | 
|  | 284 | { | 
|  | 285 | static ChannelConfig channelConfig; | 
|  | 286 | return channelConfig; | 
|  | 287 | } | 
|  | 288 |  | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 289 | ChannelConfig::~ChannelConfig() | 
|  | 290 | { | 
|  | 291 | if (signalHndlrObjectState) | 
|  | 292 | { | 
|  | 293 | chPropertiesSignal.reset(); | 
| Willy Tu | ac05aa1 | 2021-11-16 21:15:58 -0800 | [diff] [blame] | 294 | chInterfaceAddedSignal.reset(); | 
|  | 295 | chInterfaceRemovedSignal.reset(); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 296 | sigHndlrLock.unlock(); | 
|  | 297 | } | 
|  | 298 | } | 
|  | 299 |  | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 300 | ChannelConfig::ChannelConfig() : bus(ipmid_get_sd_bus_connection()) | 
|  | 301 | { | 
|  | 302 | std::ofstream mutexCleanUpFile; | 
|  | 303 | mutexCleanUpFile.open(ipmiChMutexCleanupLockFile, | 
|  | 304 | std::ofstream::out | std::ofstream::app); | 
|  | 305 | if (!mutexCleanUpFile.good()) | 
|  | 306 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 307 | lg2::debug("Unable to open mutex cleanup file"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 308 | return; | 
|  | 309 | } | 
|  | 310 | mutexCleanUpFile.close(); | 
|  | 311 | mutexCleanupLock = | 
|  | 312 | boost::interprocess::file_lock(ipmiChMutexCleanupLockFile); | 
|  | 313 | if (mutexCleanupLock.try_lock()) | 
|  | 314 | { | 
|  | 315 | boost::interprocess::named_recursive_mutex::remove(ipmiChannelMutex); | 
|  | 316 | channelMutex = | 
|  | 317 | std::make_unique<boost::interprocess::named_recursive_mutex>( | 
|  | 318 | boost::interprocess::open_or_create, ipmiChannelMutex); | 
|  | 319 | mutexCleanupLock.lock_sharable(); | 
|  | 320 | } | 
|  | 321 | else | 
|  | 322 | { | 
|  | 323 | mutexCleanupLock.lock_sharable(); | 
|  | 324 | channelMutex = | 
|  | 325 | std::make_unique<boost::interprocess::named_recursive_mutex>( | 
|  | 326 | boost::interprocess::open_or_create, ipmiChannelMutex); | 
|  | 327 | } | 
|  | 328 |  | 
|  | 329 | initChannelPersistData(); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 330 |  | 
|  | 331 | sigHndlrLock = boost::interprocess::file_lock(channelNvDataFilename); | 
| George Liu | 1a2e150 | 2022-07-08 12:20:19 +0800 | [diff] [blame] | 332 | // Register it for single object and single process either netipmid / | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 333 | // host-ipmid | 
|  | 334 | if (chPropertiesSignal == nullptr && sigHndlrLock.try_lock()) | 
|  | 335 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 336 | lg2::debug("Registering channel signal handler."); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 337 | chPropertiesSignal = std::make_unique<sdbusplus::bus::match_t>( | 
|  | 338 | bus, | 
|  | 339 | sdbusplus::bus::match::rules::path_namespace( | 
|  | 340 | networkIntfObjectBasePath) + | 
|  | 341 | sdbusplus::bus::match::rules::type::signal() + | 
|  | 342 | sdbusplus::bus::match::rules::member(propertiesChangedSignal) + | 
|  | 343 | sdbusplus::bus::match::rules::interface( | 
|  | 344 | dBusPropertiesInterface) + | 
|  | 345 | sdbusplus::bus::match::rules::argN(0, networkChConfigIntfName), | 
| Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 346 | [&](sdbusplus::message_t& msg) { | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 347 | DbusChObjProperties props; | 
|  | 348 | std::string iface; | 
|  | 349 | std::string path = msg.get_path(); | 
|  | 350 | msg.read(iface, props); | 
|  | 351 | processChAccessPropChange(path, props); | 
|  | 352 | }); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 353 | signalHndlrObjectState = true; | 
| Willy Tu | ac05aa1 | 2021-11-16 21:15:58 -0800 | [diff] [blame] | 354 |  | 
|  | 355 | chInterfaceAddedSignal = std::make_unique<sdbusplus::bus::match_t>( | 
|  | 356 | bus, | 
|  | 357 | sdbusplus::bus::match::rules::type::signal() + | 
|  | 358 | sdbusplus::bus::match::rules::member(interfaceAddedSignal) + | 
|  | 359 | sdbusplus::bus::match::rules::argNpath( | 
|  | 360 | 0, std::string(networkIntfObjectBasePath) + "/"), | 
| Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 361 | [&](sdbusplus::message_t&) { initChannelPersistData(); }); | 
| Willy Tu | ac05aa1 | 2021-11-16 21:15:58 -0800 | [diff] [blame] | 362 |  | 
|  | 363 | chInterfaceRemovedSignal = std::make_unique<sdbusplus::bus::match_t>( | 
|  | 364 | bus, | 
|  | 365 | sdbusplus::bus::match::rules::type::signal() + | 
|  | 366 | sdbusplus::bus::match::rules::member(interfaceRemovedSignal) + | 
|  | 367 | sdbusplus::bus::match::rules::argNpath( | 
|  | 368 | 0, std::string(networkIntfObjectBasePath) + "/"), | 
| Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 369 | [&](sdbusplus::message_t&) { initChannelPersistData(); }); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 370 | } | 
|  | 371 | } | 
|  | 372 |  | 
| Richard Marian Thomaiyar | a45cb34 | 2018-12-03 15:08:59 +0530 | [diff] [blame] | 373 | bool ChannelConfig::isValidChannel(const uint8_t chNum) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 374 | { | 
| Meera-Katta | c178948 | 2021-05-18 09:53:26 +0000 | [diff] [blame] | 375 | if (chNum >= maxIpmiChannels) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 376 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 377 | lg2::debug("Invalid channel ID - Out of range"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 378 | return false; | 
|  | 379 | } | 
|  | 380 |  | 
| Johnathan Mantey | e5c4f1d | 2018-12-10 16:24:26 -0800 | [diff] [blame] | 381 | return channelData[chNum].isChValid; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 382 | } | 
|  | 383 |  | 
| Patrick Williams | 69b4c28 | 2025-03-03 11:19:13 -0500 | [diff] [blame] | 384 | EChannelSessSupported ChannelConfig::getChannelSessionSupport( | 
|  | 385 | const uint8_t chNum) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 386 | { | 
|  | 387 | EChannelSessSupported chSessSupport = | 
|  | 388 | (EChannelSessSupported)channelData[chNum].chInfo.sessionSupported; | 
|  | 389 | return chSessSupport; | 
|  | 390 | } | 
|  | 391 |  | 
| Richard Marian Thomaiyar | a45cb34 | 2018-12-03 15:08:59 +0530 | [diff] [blame] | 392 | bool ChannelConfig::isValidAuthType(const uint8_t chNum, | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 393 | const EAuthType& authType) | 
|  | 394 | { | 
|  | 395 | if ((authType < EAuthType::md2) || (authType > EAuthType::oem)) | 
|  | 396 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 397 | lg2::debug("Invalid authentication type"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 398 | return false; | 
|  | 399 | } | 
|  | 400 |  | 
|  | 401 | uint8_t authTypeSupported = channelData[chNum].chInfo.authTypeSupported; | 
|  | 402 | if (!(authTypeSupported & (1 << static_cast<uint8_t>(authType)))) | 
|  | 403 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 404 | lg2::debug("Authentication type is not supported."); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 405 | return false; | 
|  | 406 | } | 
|  | 407 |  | 
|  | 408 | return true; | 
|  | 409 | } | 
|  | 410 |  | 
| Richard Marian Thomaiyar | a45cb34 | 2018-12-03 15:08:59 +0530 | [diff] [blame] | 411 | int ChannelConfig::getChannelActiveSessions(const uint8_t chNum) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 412 | { | 
|  | 413 | // TODO: TEMPORARY FIX | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 414 | // Channels active session count is managed separately | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 415 | // by monitoring channel session which includes LAN and | 
|  | 416 | // RAKP layer changes. This will be updated, once the | 
|  | 417 | // authentication part is implemented. | 
|  | 418 | return channelData[chNum].activeSessCount; | 
|  | 419 | } | 
|  | 420 |  | 
| Vernon Mauery | 5831712 | 2018-11-28 11:02:43 -0800 | [diff] [blame] | 421 | size_t ChannelConfig::getChannelMaxTransferSize(uint8_t chNum) | 
|  | 422 | { | 
|  | 423 | return channelData[chNum].maxTransferSize; | 
|  | 424 | } | 
|  | 425 |  | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 426 | Cc ChannelConfig::getChannelInfo(const uint8_t chNum, ChannelInfo& chInfo) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 427 | { | 
|  | 428 | if (!isValidChannel(chNum)) | 
|  | 429 | { | 
| George Liu | a0e545d | 2025-01-24 09:50:22 +0800 | [diff] [blame] | 430 | lg2::debug("Get channel info - Invalid channel: {CHANNEL}", "CHANNEL", | 
|  | 431 | chNum); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 432 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 433 | } | 
|  | 434 |  | 
|  | 435 | std::copy_n(reinterpret_cast<uint8_t*>(&channelData[chNum].chInfo), | 
|  | 436 | sizeof(channelData[chNum].chInfo), | 
|  | 437 | reinterpret_cast<uint8_t*>(&chInfo)); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 438 | return ccSuccess; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 439 | } | 
|  | 440 |  | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 441 | Cc ChannelConfig::getChannelAccessData(const uint8_t chNum, | 
|  | 442 | ChannelAccess& chAccessData) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 443 | { | 
|  | 444 | if (!isValidChannel(chNum)) | 
|  | 445 | { | 
| George Liu | a0e545d | 2025-01-24 09:50:22 +0800 | [diff] [blame] | 446 | lg2::debug("Get channel access data - Invalid channel: {CHANNEL}", | 
|  | 447 | "CHANNEL", chNum); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 448 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 449 | } | 
|  | 450 |  | 
|  | 451 | if (getChannelSessionSupport(chNum) == EChannelSessSupported::none) | 
|  | 452 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 453 | lg2::debug("Session-less channel doesn't have access data."); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 454 | return ccActionNotSupportedForChannel; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 455 | } | 
|  | 456 |  | 
|  | 457 | if (checkAndReloadVolatileData() != 0) | 
|  | 458 | { | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 459 | return ccUnspecifiedError; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 460 | } | 
|  | 461 |  | 
|  | 462 | std::copy_n( | 
|  | 463 | reinterpret_cast<uint8_t*>(&channelData[chNum].chAccess.chVolatileData), | 
|  | 464 | sizeof(channelData[chNum].chAccess.chVolatileData), | 
|  | 465 | reinterpret_cast<uint8_t*>(&chAccessData)); | 
|  | 466 |  | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 467 | return ccSuccess; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 468 | } | 
|  | 469 |  | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 470 | Cc ChannelConfig::setChannelAccessData(const uint8_t chNum, | 
|  | 471 | const ChannelAccess& chAccessData, | 
|  | 472 | const uint8_t setFlag) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 473 | { | 
|  | 474 | if (!isValidChannel(chNum)) | 
|  | 475 | { | 
| George Liu | a0e545d | 2025-01-24 09:50:22 +0800 | [diff] [blame] | 476 | lg2::debug("Set channel info - Invalid channel: {CHANNEL}", "CHANNEL", | 
|  | 477 | chNum); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 478 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 479 | } | 
|  | 480 |  | 
|  | 481 | if (getChannelSessionSupport(chNum) == EChannelSessSupported::none) | 
|  | 482 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 483 | lg2::debug("Session-less channel doesn't have access data."); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 484 | return ccActionNotSupportedForChannel; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 485 | } | 
|  | 486 |  | 
| jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 487 | if ((setFlag & setAccessMode) && | 
|  | 488 | (!isValidAccessMode(chAccessData.accessMode))) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 489 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 490 | lg2::debug("Invalid access mode specified"); | 
| jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 491 | return ccAccessModeNotSupportedForChannel; | 
|  | 492 | } | 
|  | 493 | if ((setFlag & setPrivLimit) && (!isValidPrivLimit(chAccessData.privLimit))) | 
|  | 494 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 495 | lg2::debug("Invalid privilege limit specified"); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 496 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 497 | } | 
|  | 498 |  | 
|  | 499 | boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex> | 
|  | 500 | channelLock{*channelMutex}; | 
|  | 501 |  | 
|  | 502 | if (checkAndReloadVolatileData() != 0) | 
|  | 503 | { | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 504 | return ccUnspecifiedError; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 505 | } | 
|  | 506 |  | 
|  | 507 | if (setFlag & setAccessMode) | 
|  | 508 | { | 
|  | 509 | channelData[chNum].chAccess.chVolatileData.accessMode = | 
|  | 510 | chAccessData.accessMode; | 
|  | 511 | } | 
|  | 512 | if (setFlag & setUserAuthEnabled) | 
|  | 513 | { | 
|  | 514 | channelData[chNum].chAccess.chVolatileData.userAuthDisabled = | 
|  | 515 | chAccessData.userAuthDisabled; | 
|  | 516 | } | 
|  | 517 | if (setFlag & setMsgAuthEnabled) | 
|  | 518 | { | 
|  | 519 | channelData[chNum].chAccess.chVolatileData.perMsgAuthDisabled = | 
|  | 520 | chAccessData.perMsgAuthDisabled; | 
|  | 521 | } | 
|  | 522 | if (setFlag & setAlertingEnabled) | 
|  | 523 | { | 
|  | 524 | channelData[chNum].chAccess.chVolatileData.alertingDisabled = | 
|  | 525 | chAccessData.alertingDisabled; | 
|  | 526 | } | 
|  | 527 | if (setFlag & setPrivLimit) | 
|  | 528 | { | 
|  | 529 | channelData[chNum].chAccess.chVolatileData.privLimit = | 
|  | 530 | chAccessData.privLimit; | 
|  | 531 | } | 
|  | 532 |  | 
|  | 533 | // Write Volatile data to file | 
|  | 534 | if (writeChannelVolatileData() != 0) | 
|  | 535 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 536 | lg2::debug("Failed to update the channel volatile data"); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 537 | return ccUnspecifiedError; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 538 | } | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 539 | return ccSuccess; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 540 | } | 
|  | 541 |  | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 542 | Cc ChannelConfig::getChannelAccessPersistData(const uint8_t chNum, | 
|  | 543 | ChannelAccess& chAccessData) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 544 | { | 
|  | 545 | if (!isValidChannel(chNum)) | 
|  | 546 | { | 
| George Liu | a0e545d | 2025-01-24 09:50:22 +0800 | [diff] [blame] | 547 | lg2::debug( | 
|  | 548 | "Get channel access persist data - Invalid channel: {CHANNEL}", | 
|  | 549 | "CHANNEL", chNum); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 550 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 551 | } | 
|  | 552 |  | 
|  | 553 | if (getChannelSessionSupport(chNum) == EChannelSessSupported::none) | 
|  | 554 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 555 | lg2::debug("Session-less channel doesn't have access data."); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 556 | return ccActionNotSupportedForChannel; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 557 | } | 
|  | 558 |  | 
|  | 559 | if (checkAndReloadNVData() != 0) | 
|  | 560 | { | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 561 | return ccUnspecifiedError; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 562 | } | 
|  | 563 |  | 
|  | 564 | std::copy_n(reinterpret_cast<uint8_t*>( | 
|  | 565 | &channelData[chNum].chAccess.chNonVolatileData), | 
|  | 566 | sizeof(channelData[chNum].chAccess.chNonVolatileData), | 
|  | 567 | reinterpret_cast<uint8_t*>(&chAccessData)); | 
|  | 568 |  | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 569 | return ccSuccess; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 570 | } | 
|  | 571 |  | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 572 | Cc ChannelConfig::setChannelAccessPersistData(const uint8_t chNum, | 
|  | 573 | const ChannelAccess& chAccessData, | 
|  | 574 | const uint8_t setFlag) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 575 | { | 
|  | 576 | if (!isValidChannel(chNum)) | 
|  | 577 | { | 
| George Liu | a0e545d | 2025-01-24 09:50:22 +0800 | [diff] [blame] | 578 | lg2::debug( | 
|  | 579 | "Set channel access persist data - Invalid channel: {CHANNEL}", | 
|  | 580 | "CHANNEL", chNum); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 581 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 582 | } | 
|  | 583 |  | 
|  | 584 | if (getChannelSessionSupport(chNum) == EChannelSessSupported::none) | 
|  | 585 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 586 | lg2::debug("Session-less channel doesn't have access data."); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 587 | return ccActionNotSupportedForChannel; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 588 | } | 
|  | 589 |  | 
| jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 590 | if ((setFlag & setAccessMode) && | 
|  | 591 | (!isValidAccessMode(chAccessData.accessMode))) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 592 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 593 | lg2::debug("Invalid access mode specified"); | 
| jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 594 | return ccAccessModeNotSupportedForChannel; | 
|  | 595 | } | 
|  | 596 | if ((setFlag & setPrivLimit) && (!isValidPrivLimit(chAccessData.privLimit))) | 
|  | 597 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 598 | lg2::debug("Invalid privilege limit specified"); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 599 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 600 | } | 
|  | 601 |  | 
|  | 602 | boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex> | 
|  | 603 | channelLock{*channelMutex}; | 
|  | 604 |  | 
|  | 605 | if (checkAndReloadNVData() != 0) | 
|  | 606 | { | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 607 | return ccUnspecifiedError; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 608 | } | 
|  | 609 |  | 
|  | 610 | if (setFlag & setAccessMode) | 
|  | 611 | { | 
|  | 612 | channelData[chNum].chAccess.chNonVolatileData.accessMode = | 
|  | 613 | chAccessData.accessMode; | 
|  | 614 | } | 
|  | 615 | if (setFlag & setUserAuthEnabled) | 
|  | 616 | { | 
|  | 617 | channelData[chNum].chAccess.chNonVolatileData.userAuthDisabled = | 
|  | 618 | chAccessData.userAuthDisabled; | 
|  | 619 | } | 
|  | 620 | if (setFlag & setMsgAuthEnabled) | 
|  | 621 | { | 
|  | 622 | channelData[chNum].chAccess.chNonVolatileData.perMsgAuthDisabled = | 
|  | 623 | chAccessData.perMsgAuthDisabled; | 
|  | 624 | } | 
|  | 625 | if (setFlag & setAlertingEnabled) | 
|  | 626 | { | 
|  | 627 | channelData[chNum].chAccess.chNonVolatileData.alertingDisabled = | 
|  | 628 | chAccessData.alertingDisabled; | 
|  | 629 | } | 
|  | 630 | if (setFlag & setPrivLimit) | 
|  | 631 | { | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 632 | // Send Update to network channel config interfaces over dbus | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 633 | std::string privStr = convertToPrivLimitString(chAccessData.privLimit); | 
| Richard Marian Thomaiyar | 73906b9 | 2019-01-04 23:48:02 +0530 | [diff] [blame] | 634 | std::string networkIntfObj = std::string(networkIntfObjectBasePath) + | 
|  | 635 | "/" + channelData[chNum].chName; | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 636 | try | 
|  | 637 | { | 
| Johnathan Mantey | f92261d | 2018-12-10 15:49:34 -0800 | [diff] [blame] | 638 | if (0 != setDbusProperty(networkIntfServiceName, networkIntfObj, | 
|  | 639 | networkChConfigIntfName, | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 640 | privilegePropertyString, privStr)) | 
|  | 641 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 642 | lg2::debug("Network interface '{INTERFACE}' does not exist", | 
|  | 643 | "INTERFACE", channelData[chNum].chName); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 644 | return ccUnspecifiedError; | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 645 | } | 
|  | 646 | } | 
| Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 647 | catch (const sdbusplus::exception_t& e) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 648 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 649 | lg2::error("Exception: Network interface does not exist"); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 650 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 651 | } | 
|  | 652 | signalFlag |= (1 << chNum); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 653 | channelData[chNum].chAccess.chNonVolatileData.privLimit = | 
|  | 654 | chAccessData.privLimit; | 
|  | 655 | } | 
|  | 656 |  | 
|  | 657 | // Write persistent data to file | 
|  | 658 | if (writeChannelPersistData() != 0) | 
|  | 659 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 660 | lg2::debug("Failed to update the presist data file"); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 661 | return ccUnspecifiedError; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 662 | } | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 663 | return ccSuccess; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 664 | } | 
|  | 665 |  | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 666 | Cc ChannelConfig::getChannelAuthTypeSupported(const uint8_t chNum, | 
|  | 667 | uint8_t& authTypeSupported) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 668 | { | 
|  | 669 | if (!isValidChannel(chNum)) | 
|  | 670 | { | 
| George Liu | a0e545d | 2025-01-24 09:50:22 +0800 | [diff] [blame] | 671 | lg2::debug( | 
|  | 672 | "Get channel auth type supported - Invalid channel: {CHANNEL}", | 
|  | 673 | "CHANNEL", chNum); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 674 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 675 | } | 
|  | 676 |  | 
|  | 677 | authTypeSupported = channelData[chNum].chInfo.authTypeSupported; | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 678 | return ccSuccess; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 679 | } | 
|  | 680 |  | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 681 | Cc ChannelConfig::getChannelEnabledAuthType( | 
|  | 682 | const uint8_t chNum, const uint8_t priv, EAuthType& authType) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 683 | { | 
|  | 684 | if (!isValidChannel(chNum)) | 
|  | 685 | { | 
| George Liu | a0e545d | 2025-01-24 09:50:22 +0800 | [diff] [blame] | 686 | lg2::debug("Get channel enabled auth type - Invalid channel: {CHANNEL}", | 
|  | 687 | "CHANNEL", chNum); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 688 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 689 | } | 
|  | 690 |  | 
|  | 691 | if (getChannelSessionSupport(chNum) == EChannelSessSupported::none) | 
|  | 692 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 693 | lg2::debug("Sessionless channel doesn't have access data."); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 694 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 695 | } | 
|  | 696 |  | 
|  | 697 | if (!isValidPrivLimit(priv)) | 
|  | 698 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 699 | lg2::debug("Invalid privilege specified."); | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 700 | return ccInvalidFieldRequest; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 701 | } | 
|  | 702 |  | 
|  | 703 | // TODO: Hardcoded for now. Need to implement. | 
|  | 704 | authType = EAuthType::none; | 
|  | 705 |  | 
| NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 706 | return ccSuccess; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 707 | } | 
|  | 708 |  | 
|  | 709 | std::time_t ChannelConfig::getUpdatedFileTime(const std::string& fileName) | 
|  | 710 | { | 
|  | 711 | struct stat fileStat; | 
|  | 712 | if (stat(fileName.c_str(), &fileStat) != 0) | 
|  | 713 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 714 | lg2::debug("Error in getting last updated time stamp"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 715 | return -EIO; | 
|  | 716 | } | 
|  | 717 | return fileStat.st_mtime; | 
|  | 718 | } | 
|  | 719 |  | 
| Patrick Williams | 69b4c28 | 2025-03-03 11:19:13 -0500 | [diff] [blame] | 720 | EChannelAccessMode ChannelConfig::convertToAccessModeIndex( | 
|  | 721 | const std::string& mode) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 722 | { | 
|  | 723 | auto iter = std::find(accessModeList.begin(), accessModeList.end(), mode); | 
|  | 724 | if (iter == accessModeList.end()) | 
|  | 725 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 726 | lg2::error("Invalid access mode: {MODE_STR}", "MODE_STR", mode); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 727 | throw std::invalid_argument("Invalid access mode."); | 
|  | 728 | } | 
|  | 729 |  | 
|  | 730 | return static_cast<EChannelAccessMode>( | 
|  | 731 | std::distance(accessModeList.begin(), iter)); | 
|  | 732 | } | 
|  | 733 |  | 
| Richard Marian Thomaiyar | a45cb34 | 2018-12-03 15:08:59 +0530 | [diff] [blame] | 734 | std::string ChannelConfig::convertToAccessModeString(const uint8_t value) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 735 | { | 
|  | 736 | if (accessModeList.size() <= value) | 
|  | 737 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 738 | lg2::error("Invalid access mode: {MODE_IDX}", "MODE_IDX", value); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 739 | throw std::invalid_argument("Invalid access mode."); | 
|  | 740 | } | 
|  | 741 |  | 
|  | 742 | return accessModeList.at(value); | 
|  | 743 | } | 
|  | 744 |  | 
| Patrick Williams | 69b4c28 | 2025-03-03 11:19:13 -0500 | [diff] [blame] | 745 | CommandPrivilege ChannelConfig::convertToPrivLimitIndex( | 
|  | 746 | const std::string& value) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 747 | { | 
|  | 748 | auto iter = std::find(privList.begin(), privList.end(), value); | 
|  | 749 | if (iter == privList.end()) | 
|  | 750 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 751 | lg2::error("Invalid privilege: {PRIV_STR}", "PRIV_STR", value); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 752 | throw std::invalid_argument("Invalid privilege."); | 
|  | 753 | } | 
|  | 754 |  | 
|  | 755 | return static_cast<CommandPrivilege>(std::distance(privList.begin(), iter)); | 
|  | 756 | } | 
|  | 757 |  | 
| Richard Marian Thomaiyar | a45cb34 | 2018-12-03 15:08:59 +0530 | [diff] [blame] | 758 | std::string ChannelConfig::convertToPrivLimitString(const uint8_t value) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 759 | { | 
|  | 760 | if (privList.size() <= value) | 
|  | 761 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 762 | lg2::error("Invalid privilege: {PRIV_IDX.", "PRIV_IDX", value); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 763 | throw std::invalid_argument("Invalid privilege."); | 
|  | 764 | } | 
|  | 765 |  | 
|  | 766 | return privList.at(value); | 
|  | 767 | } | 
|  | 768 |  | 
| Patrick Williams | 69b4c28 | 2025-03-03 11:19:13 -0500 | [diff] [blame] | 769 | EChannelSessSupported ChannelConfig::convertToSessionSupportIndex( | 
|  | 770 | const std::string& value) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 771 | { | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 772 | auto iter = | 
|  | 773 | std::find(sessionSupportList.begin(), sessionSupportList.end(), value); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 774 | if (iter == sessionSupportList.end()) | 
|  | 775 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 776 | lg2::error("Invalid session supported: {SESS_STR}", "SESS_STR", value); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 777 | throw std::invalid_argument("Invalid session supported."); | 
|  | 778 | } | 
|  | 779 |  | 
|  | 780 | return static_cast<EChannelSessSupported>( | 
|  | 781 | std::distance(sessionSupportList.begin(), iter)); | 
|  | 782 | } | 
|  | 783 |  | 
| Patrick Williams | 69b4c28 | 2025-03-03 11:19:13 -0500 | [diff] [blame] | 784 | EChannelMediumType ChannelConfig::convertToMediumTypeIndex( | 
|  | 785 | const std::string& value) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 786 | { | 
|  | 787 | std::unordered_map<std::string, EChannelMediumType>::iterator it = | 
|  | 788 | mediumTypeMap.find(value); | 
|  | 789 | if (it == mediumTypeMap.end()) | 
|  | 790 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 791 | lg2::error("Invalid medium type: {MEDIUM_STR}", "MEDIUM_STR", value); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 792 | throw std::invalid_argument("Invalid medium type."); | 
|  | 793 | } | 
|  | 794 |  | 
|  | 795 | return static_cast<EChannelMediumType>(it->second); | 
|  | 796 | } | 
|  | 797 |  | 
| Patrick Williams | 69b4c28 | 2025-03-03 11:19:13 -0500 | [diff] [blame] | 798 | EChannelProtocolType ChannelConfig::convertToProtocolTypeIndex( | 
|  | 799 | const std::string& value) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 800 | { | 
|  | 801 | std::unordered_map<std::string, EChannelProtocolType>::iterator it = | 
|  | 802 | protocolTypeMap.find(value); | 
|  | 803 | if (it == protocolTypeMap.end()) | 
|  | 804 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 805 | lg2::error("Invalid protocol type: {PROTO_STR}", "PROTO_STR", value); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 806 | throw std::invalid_argument("Invalid protocol type."); | 
|  | 807 | } | 
|  | 808 |  | 
|  | 809 | return static_cast<EChannelProtocolType>(it->second); | 
|  | 810 | } | 
|  | 811 |  | 
|  | 812 | Json ChannelConfig::readJsonFile(const std::string& configFile) | 
|  | 813 | { | 
|  | 814 | std::ifstream jsonFile(configFile); | 
|  | 815 | if (!jsonFile.good()) | 
|  | 816 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 817 | lg2::info("JSON file '{FILE_NAME}' not found", "FILE_NAME", configFile); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 818 | return nullptr; | 
|  | 819 | } | 
|  | 820 |  | 
|  | 821 | Json data = nullptr; | 
|  | 822 | try | 
|  | 823 | { | 
|  | 824 | data = Json::parse(jsonFile, nullptr, false); | 
|  | 825 | } | 
| Patrick Williams | a2ad2da | 2021-10-06 12:21:46 -0500 | [diff] [blame] | 826 | catch (const Json::parse_error& e) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 827 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 828 | lg2::debug("Corrupted channel config: {MSG}", "MSG", e.what()); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 829 | throw std::runtime_error("Corrupted channel config file"); | 
|  | 830 | } | 
|  | 831 |  | 
|  | 832 | return data; | 
|  | 833 | } | 
|  | 834 |  | 
|  | 835 | int ChannelConfig::writeJsonFile(const std::string& configFile, | 
|  | 836 | const Json& jsonData) | 
|  | 837 | { | 
| Richard Marian Thomaiyar | 687df40 | 2019-05-09 00:16:53 +0530 | [diff] [blame] | 838 | const std::string tmpFile = configFile + "_tmp"; | 
|  | 839 | int fd = open(tmpFile.c_str(), O_CREAT | O_WRONLY | O_TRUNC | O_SYNC, | 
|  | 840 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); | 
|  | 841 | if (fd < 0) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 842 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 843 | lg2::error("Error in creating json file '{FILE_NAME}'", "FILE_NAME", | 
|  | 844 | tmpFile); | 
| Richard Marian Thomaiyar | 687df40 | 2019-05-09 00:16:53 +0530 | [diff] [blame] | 845 | return -EIO; | 
|  | 846 | } | 
| George Liu | a37edf1 | 2025-09-19 14:28:26 +0800 | [diff] [blame] | 847 | const auto& writeData = jsonData.dump(4); | 
| Richard Marian Thomaiyar | 687df40 | 2019-05-09 00:16:53 +0530 | [diff] [blame] | 848 | if (write(fd, writeData.c_str(), writeData.size()) != | 
|  | 849 | static_cast<ssize_t>(writeData.size())) | 
|  | 850 | { | 
|  | 851 | close(fd); | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 852 | lg2::error("Error in writing configuration file '{FILE_NAME}'", | 
|  | 853 | "FILE_NAME", tmpFile); | 
| Richard Marian Thomaiyar | 687df40 | 2019-05-09 00:16:53 +0530 | [diff] [blame] | 854 | return -EIO; | 
|  | 855 | } | 
|  | 856 | close(fd); | 
|  | 857 |  | 
|  | 858 | if (std::rename(tmpFile.c_str(), configFile.c_str()) != 0) | 
|  | 859 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 860 | lg2::error("Error in renaming temporary data file '{FILE_NAME}'", | 
|  | 861 | "FILE_NAME", tmpFile); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 862 | return -EIO; | 
|  | 863 | } | 
|  | 864 |  | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 865 | return 0; | 
|  | 866 | } | 
|  | 867 |  | 
| Richard Marian Thomaiyar | a45cb34 | 2018-12-03 15:08:59 +0530 | [diff] [blame] | 868 | void ChannelConfig::setDefaultChannelConfig(const uint8_t chNum, | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 869 | const std::string& chName) | 
|  | 870 | { | 
|  | 871 | channelData[chNum].chName = chName; | 
|  | 872 | channelData[chNum].chID = chNum; | 
|  | 873 | channelData[chNum].isChValid = false; | 
|  | 874 | channelData[chNum].activeSessCount = 0; | 
| Johnathan Mantey | fd61fc3 | 2021-04-08 11:05:38 -0700 | [diff] [blame] | 875 | channelData[chNum].isManagementNIC = false; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 876 |  | 
|  | 877 | channelData[chNum].chInfo.mediumType = defaultMediumType; | 
|  | 878 | channelData[chNum].chInfo.protocolType = defaultProtocolType; | 
|  | 879 | channelData[chNum].chInfo.sessionSupported = defaultSessionSupported; | 
|  | 880 | channelData[chNum].chInfo.isIpmi = defaultIsIpmiState; | 
|  | 881 | channelData[chNum].chInfo.authTypeSupported = defaultAuthType; | 
|  | 882 | } | 
|  | 883 |  | 
| Johnathan Mantey | fd61fc3 | 2021-04-08 11:05:38 -0700 | [diff] [blame] | 884 | uint8_t ChannelConfig::getManagementNICID() | 
|  | 885 | { | 
|  | 886 | static bool idFound = false; | 
|  | 887 | static uint8_t id = 0; | 
|  | 888 |  | 
|  | 889 | if (idFound) | 
|  | 890 | { | 
|  | 891 | return id; | 
|  | 892 | } | 
|  | 893 |  | 
|  | 894 | for (uint8_t chIdx = 0; chIdx < maxIpmiChannels; chIdx++) | 
|  | 895 | { | 
|  | 896 | if (channelData[chIdx].isManagementNIC) | 
|  | 897 | { | 
|  | 898 | id = chIdx; | 
|  | 899 | idFound = true; | 
|  | 900 | break; | 
|  | 901 | } | 
|  | 902 | } | 
|  | 903 |  | 
|  | 904 | if (!idFound) | 
|  | 905 | { | 
|  | 906 | id = static_cast<uint8_t>(EChannelID::chanLan1); | 
|  | 907 | idFound = true; | 
|  | 908 | } | 
|  | 909 | return id; | 
|  | 910 | } | 
|  | 911 |  | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 912 | int ChannelConfig::loadChannelConfig() | 
|  | 913 | { | 
|  | 914 | boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex> | 
|  | 915 | channelLock{*channelMutex}; | 
|  | 916 |  | 
|  | 917 | Json data = readJsonFile(channelConfigDefaultFilename); | 
| Johnathan Mantey | e5c4f1d | 2018-12-10 16:24:26 -0800 | [diff] [blame] | 918 | if (data.empty()) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 919 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 920 | lg2::debug("Error in opening IPMI Channel data file"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 921 | return -EIO; | 
|  | 922 | } | 
|  | 923 |  | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 924 | channelData.fill(ChannelProperties{}); | 
|  | 925 |  | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 926 | // Collect the list of NIC interfaces connected to the BMC. Use this | 
|  | 927 | // information to only add IPMI channels that have active NIC interfaces. | 
| Snehalatha Venkatesh | 55f5d53 | 2021-07-13 11:06:36 +0000 | [diff] [blame] | 928 | struct ifaddrs *ifaddr = nullptr, *ifa = nullptr; | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 929 | if (int err = getifaddrs(&ifaddr); err < 0) | 
|  | 930 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 931 | lg2::debug("Unable to acquire network interfaces"); | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 932 | return -EIO; | 
|  | 933 | } | 
|  | 934 |  | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 935 | for (int chNum = 0; chNum < maxIpmiChannels; chNum++) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 936 | { | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 937 | try | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 938 | { | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 939 | std::string chKey = std::to_string(chNum); | 
|  | 940 | Json jsonChData = data[chKey].get<Json>(); | 
|  | 941 | if (jsonChData.is_null()) | 
|  | 942 | { | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 943 | // If user didn't want to configure specific channel (say | 
|  | 944 | // reserved channel), then load that index with default values. | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 945 | setDefaultChannelConfig(chNum, defaultChannelName); | 
|  | 946 | continue; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 947 | } | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 948 | Json jsonChInfo = jsonChData[channelInfoString].get<Json>(); | 
|  | 949 | if (jsonChInfo.is_null()) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 950 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 951 | lg2::error("Invalid/corrupted channel config file"); | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 952 | freeifaddrs(ifaddr); | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 953 | return -EBADMSG; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 954 | } | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 955 |  | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 956 | bool channelFound = true; | 
|  | 957 | // Confirm the LAN channel is present | 
|  | 958 | if (jsonChInfo[mediumTypeString].get<std::string>() == "lan-802.3") | 
|  | 959 | { | 
|  | 960 | channelFound = false; | 
| Jayanth Othayoth | a6fb32d | 2024-12-15 10:55:22 -0600 | [diff] [blame] | 961 | for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 962 | { | 
|  | 963 | if (jsonChData[nameString].get<std::string>() == | 
|  | 964 | ifa->ifa_name) | 
|  | 965 | { | 
|  | 966 | channelFound = true; | 
|  | 967 | break; | 
|  | 968 | } | 
|  | 969 | } | 
|  | 970 | } | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 971 | ChannelProperties& chData = channelData[chNum]; | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 972 | chData.chID = chNum; | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 973 | chData.chName = jsonChData[nameString].get<std::string>(); | 
| Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 974 | chData.isChValid = channelFound && | 
|  | 975 | jsonChData[isValidString].get<bool>(); | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 976 | chData.activeSessCount = jsonChData.value(activeSessionsString, 0); | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 977 | chData.maxTransferSize = | 
|  | 978 | jsonChData.value(maxTransferSizeString, smallChannelSize); | 
| Johnathan Mantey | fd61fc3 | 2021-04-08 11:05:38 -0700 | [diff] [blame] | 979 | if (jsonChData.count(isManagementNIC) != 0) | 
|  | 980 | { | 
|  | 981 | chData.isManagementNIC = | 
|  | 982 | jsonChData[isManagementNIC].get<bool>(); | 
|  | 983 | } | 
|  | 984 |  | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 985 | std::string medTypeStr = | 
|  | 986 | jsonChInfo[mediumTypeString].get<std::string>(); | 
|  | 987 | chData.chInfo.mediumType = | 
|  | 988 | static_cast<uint8_t>(convertToMediumTypeIndex(medTypeStr)); | 
|  | 989 | std::string protoTypeStr = | 
|  | 990 | jsonChInfo[protocolTypeString].get<std::string>(); | 
|  | 991 | chData.chInfo.protocolType = | 
|  | 992 | static_cast<uint8_t>(convertToProtocolTypeIndex(protoTypeStr)); | 
|  | 993 | std::string sessStr = | 
|  | 994 | jsonChInfo[sessionSupportedString].get<std::string>(); | 
|  | 995 | chData.chInfo.sessionSupported = | 
|  | 996 | static_cast<uint8_t>(convertToSessionSupportIndex(sessStr)); | 
|  | 997 | chData.chInfo.isIpmi = jsonChInfo[isIpmiString].get<bool>(); | 
|  | 998 | chData.chInfo.authTypeSupported = defaultAuthType; | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 999 | } | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 1000 | catch (const Json::exception& e) | 
|  | 1001 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1002 | lg2::debug("Json Exception caught: {MSG}", "MSG", e.what()); | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 1003 | freeifaddrs(ifaddr); | 
|  | 1004 |  | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 1005 | return -EBADMSG; | 
|  | 1006 | } | 
|  | 1007 | catch (const std::invalid_argument& e) | 
|  | 1008 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1009 | lg2::error("Corrupted config: {MSG}", "MSG", e.what()); | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 1010 | freeifaddrs(ifaddr); | 
| Johnathan Mantey | 4c0435a | 2018-12-11 13:17:55 -0800 | [diff] [blame] | 1011 | return -EBADMSG; | 
|  | 1012 | } | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1013 | } | 
| Johnathan Mantey | 0a2abc8 | 2021-02-18 12:39:12 -0800 | [diff] [blame] | 1014 | freeifaddrs(ifaddr); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1015 |  | 
|  | 1016 | return 0; | 
|  | 1017 | } | 
|  | 1018 |  | 
|  | 1019 | int ChannelConfig::readChannelVolatileData() | 
|  | 1020 | { | 
|  | 1021 | boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex> | 
|  | 1022 | channelLock{*channelMutex}; | 
|  | 1023 |  | 
|  | 1024 | Json data = readJsonFile(channelVolatileDataFilename); | 
|  | 1025 | if (data == nullptr) | 
|  | 1026 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1027 | lg2::debug("Error in opening IPMI Channel data file"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1028 | return -EIO; | 
|  | 1029 | } | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1030 | try | 
|  | 1031 | { | 
|  | 1032 | // Fill in global structure | 
|  | 1033 | for (auto it = data.begin(); it != data.end(); ++it) | 
|  | 1034 | { | 
|  | 1035 | std::string chKey = it.key(); | 
|  | 1036 | uint8_t chNum = std::stoi(chKey, nullptr, 10); | 
| Meera-Katta | c178948 | 2021-05-18 09:53:26 +0000 | [diff] [blame] | 1037 | if (chNum >= maxIpmiChannels) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1038 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1039 | lg2::debug("Invalid channel access entry in config file"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1040 | throw std::out_of_range("Out of range - channel number"); | 
|  | 1041 | } | 
|  | 1042 | Json jsonChData = it.value(); | 
|  | 1043 | if (!jsonChData.is_null()) | 
|  | 1044 | { | 
|  | 1045 | std::string accModeStr = | 
|  | 1046 | jsonChData[accessModeString].get<std::string>(); | 
|  | 1047 | channelData[chNum].chAccess.chVolatileData.accessMode = | 
|  | 1048 | static_cast<uint8_t>(convertToAccessModeIndex(accModeStr)); | 
|  | 1049 | channelData[chNum].chAccess.chVolatileData.userAuthDisabled = | 
|  | 1050 | jsonChData[userAuthDisabledString].get<bool>(); | 
|  | 1051 | channelData[chNum].chAccess.chVolatileData.perMsgAuthDisabled = | 
|  | 1052 | jsonChData[perMsgAuthDisabledString].get<bool>(); | 
|  | 1053 | channelData[chNum].chAccess.chVolatileData.alertingDisabled = | 
|  | 1054 | jsonChData[alertingDisabledString].get<bool>(); | 
|  | 1055 | std::string privStr = | 
|  | 1056 | jsonChData[privLimitString].get<std::string>(); | 
|  | 1057 | channelData[chNum].chAccess.chVolatileData.privLimit = | 
|  | 1058 | static_cast<uint8_t>(convertToPrivLimitIndex(privStr)); | 
|  | 1059 | } | 
|  | 1060 | else | 
|  | 1061 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1062 | lg2::error( | 
|  | 1063 | "Invalid/corrupted volatile channel access file '{FILE}'", | 
|  | 1064 | "FILE", channelVolatileDataFilename); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1065 | throw std::runtime_error( | 
|  | 1066 | "Corrupted volatile channel access file"); | 
|  | 1067 | } | 
|  | 1068 | } | 
|  | 1069 | } | 
|  | 1070 | catch (const Json::exception& e) | 
|  | 1071 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1072 | lg2::debug("Json Exception caught: {MSG}", "MSG", e.what()); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1073 | throw std::runtime_error("Corrupted volatile channel access file"); | 
|  | 1074 | } | 
|  | 1075 | catch (const std::invalid_argument& e) | 
|  | 1076 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1077 | lg2::error("Corrupted config: {MSG}", "MSG", e.what()); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1078 | throw std::runtime_error("Corrupted volatile channel access file"); | 
|  | 1079 | } | 
|  | 1080 |  | 
|  | 1081 | // Update the timestamp | 
|  | 1082 | voltFileLastUpdatedTime = getUpdatedFileTime(channelVolatileDataFilename); | 
|  | 1083 | return 0; | 
|  | 1084 | } | 
|  | 1085 |  | 
|  | 1086 | int ChannelConfig::readChannelPersistData() | 
|  | 1087 | { | 
|  | 1088 | boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex> | 
|  | 1089 | channelLock{*channelMutex}; | 
|  | 1090 |  | 
|  | 1091 | Json data = readJsonFile(channelNvDataFilename); | 
|  | 1092 | if (data == nullptr) | 
|  | 1093 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1094 | lg2::debug("Error in opening IPMI Channel data file"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1095 | return -EIO; | 
|  | 1096 | } | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1097 | try | 
|  | 1098 | { | 
|  | 1099 | // Fill in global structure | 
|  | 1100 | for (auto it = data.begin(); it != data.end(); ++it) | 
|  | 1101 | { | 
|  | 1102 | std::string chKey = it.key(); | 
|  | 1103 | uint8_t chNum = std::stoi(chKey, nullptr, 10); | 
| Meera-Katta | c178948 | 2021-05-18 09:53:26 +0000 | [diff] [blame] | 1104 | if (chNum >= maxIpmiChannels) | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1105 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1106 | lg2::debug("Invalid channel access entry in config file"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1107 | throw std::out_of_range("Out of range - channel number"); | 
|  | 1108 | } | 
|  | 1109 | Json jsonChData = it.value(); | 
|  | 1110 | if (!jsonChData.is_null()) | 
|  | 1111 | { | 
|  | 1112 | std::string accModeStr = | 
|  | 1113 | jsonChData[accessModeString].get<std::string>(); | 
|  | 1114 | channelData[chNum].chAccess.chNonVolatileData.accessMode = | 
|  | 1115 | static_cast<uint8_t>(convertToAccessModeIndex(accModeStr)); | 
|  | 1116 | channelData[chNum].chAccess.chNonVolatileData.userAuthDisabled = | 
|  | 1117 | jsonChData[userAuthDisabledString].get<bool>(); | 
|  | 1118 | channelData[chNum] | 
|  | 1119 | .chAccess.chNonVolatileData.perMsgAuthDisabled = | 
|  | 1120 | jsonChData[perMsgAuthDisabledString].get<bool>(); | 
|  | 1121 | channelData[chNum].chAccess.chNonVolatileData.alertingDisabled = | 
|  | 1122 | jsonChData[alertingDisabledString].get<bool>(); | 
|  | 1123 | std::string privStr = | 
|  | 1124 | jsonChData[privLimitString].get<std::string>(); | 
|  | 1125 | channelData[chNum].chAccess.chNonVolatileData.privLimit = | 
|  | 1126 | static_cast<uint8_t>(convertToPrivLimitIndex(privStr)); | 
|  | 1127 | } | 
|  | 1128 | else | 
|  | 1129 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1130 | lg2::error("Invalid/corrupted nv channel access file {FILE}", | 
|  | 1131 | "FILE", channelNvDataFilename); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1132 | throw std::runtime_error("Corrupted nv channel access file"); | 
|  | 1133 | } | 
|  | 1134 | } | 
|  | 1135 | } | 
|  | 1136 | catch (const Json::exception& e) | 
|  | 1137 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1138 | lg2::debug("Json Exception caught: {MSG}", "MSG", e.what()); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1139 | throw std::runtime_error("Corrupted nv channel access file"); | 
|  | 1140 | } | 
|  | 1141 | catch (const std::invalid_argument& e) | 
|  | 1142 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1143 | lg2::error("Corrupted config: {MSG}", "MSG", e.what()); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1144 | throw std::runtime_error("Corrupted nv channel access file"); | 
|  | 1145 | } | 
|  | 1146 |  | 
|  | 1147 | // Update the timestamp | 
|  | 1148 | nvFileLastUpdatedTime = getUpdatedFileTime(channelNvDataFilename); | 
|  | 1149 | return 0; | 
|  | 1150 | } | 
|  | 1151 |  | 
|  | 1152 | int ChannelConfig::writeChannelVolatileData() | 
|  | 1153 | { | 
|  | 1154 | boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex> | 
|  | 1155 | channelLock{*channelMutex}; | 
|  | 1156 | Json outData; | 
|  | 1157 |  | 
|  | 1158 | try | 
|  | 1159 | { | 
|  | 1160 | for (uint8_t chNum = 0; chNum < maxIpmiChannels; chNum++) | 
|  | 1161 | { | 
|  | 1162 | if (getChannelSessionSupport(chNum) != EChannelSessSupported::none) | 
|  | 1163 | { | 
|  | 1164 | Json jsonObj; | 
|  | 1165 | std::string chKey = std::to_string(chNum); | 
|  | 1166 | std::string accModeStr = convertToAccessModeString( | 
|  | 1167 | channelData[chNum].chAccess.chVolatileData.accessMode); | 
|  | 1168 | jsonObj[accessModeString] = accModeStr; | 
|  | 1169 | jsonObj[userAuthDisabledString] = | 
|  | 1170 | channelData[chNum].chAccess.chVolatileData.userAuthDisabled; | 
|  | 1171 | jsonObj[perMsgAuthDisabledString] = | 
|  | 1172 | channelData[chNum] | 
|  | 1173 | .chAccess.chVolatileData.perMsgAuthDisabled; | 
|  | 1174 | jsonObj[alertingDisabledString] = | 
|  | 1175 | channelData[chNum].chAccess.chVolatileData.alertingDisabled; | 
|  | 1176 | std::string privStr = convertToPrivLimitString( | 
|  | 1177 | channelData[chNum].chAccess.chVolatileData.privLimit); | 
|  | 1178 | jsonObj[privLimitString] = privStr; | 
|  | 1179 |  | 
|  | 1180 | outData[chKey] = jsonObj; | 
|  | 1181 | } | 
|  | 1182 | } | 
|  | 1183 | } | 
|  | 1184 | catch (const std::invalid_argument& e) | 
|  | 1185 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1186 | lg2::error("Corrupted config: {MSG}", "MSG", e.what()); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1187 | return -EINVAL; | 
|  | 1188 | } | 
|  | 1189 |  | 
|  | 1190 | if (writeJsonFile(channelVolatileDataFilename, outData) != 0) | 
|  | 1191 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1192 | lg2::debug("Error in write JSON data to file"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1193 | return -EIO; | 
|  | 1194 | } | 
|  | 1195 |  | 
|  | 1196 | // Update the timestamp | 
|  | 1197 | voltFileLastUpdatedTime = getUpdatedFileTime(channelVolatileDataFilename); | 
|  | 1198 | return 0; | 
|  | 1199 | } | 
|  | 1200 |  | 
|  | 1201 | int ChannelConfig::writeChannelPersistData() | 
|  | 1202 | { | 
|  | 1203 | boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex> | 
|  | 1204 | channelLock{*channelMutex}; | 
|  | 1205 | Json outData; | 
|  | 1206 |  | 
|  | 1207 | try | 
|  | 1208 | { | 
|  | 1209 | for (uint8_t chNum = 0; chNum < maxIpmiChannels; chNum++) | 
|  | 1210 | { | 
|  | 1211 | if (getChannelSessionSupport(chNum) != EChannelSessSupported::none) | 
|  | 1212 | { | 
|  | 1213 | Json jsonObj; | 
|  | 1214 | std::string chKey = std::to_string(chNum); | 
|  | 1215 | std::string accModeStr = convertToAccessModeString( | 
|  | 1216 | channelData[chNum].chAccess.chNonVolatileData.accessMode); | 
|  | 1217 | jsonObj[accessModeString] = accModeStr; | 
|  | 1218 | jsonObj[userAuthDisabledString] = | 
|  | 1219 | channelData[chNum] | 
|  | 1220 | .chAccess.chNonVolatileData.userAuthDisabled; | 
|  | 1221 | jsonObj[perMsgAuthDisabledString] = | 
|  | 1222 | channelData[chNum] | 
|  | 1223 | .chAccess.chNonVolatileData.perMsgAuthDisabled; | 
|  | 1224 | jsonObj[alertingDisabledString] = | 
|  | 1225 | channelData[chNum] | 
|  | 1226 | .chAccess.chNonVolatileData.alertingDisabled; | 
|  | 1227 | std::string privStr = convertToPrivLimitString( | 
|  | 1228 | channelData[chNum].chAccess.chNonVolatileData.privLimit); | 
|  | 1229 | jsonObj[privLimitString] = privStr; | 
|  | 1230 |  | 
|  | 1231 | outData[chKey] = jsonObj; | 
|  | 1232 | } | 
|  | 1233 | } | 
|  | 1234 | } | 
|  | 1235 | catch (const std::invalid_argument& e) | 
|  | 1236 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1237 | lg2::error("Corrupted config: {MSG}", "MSG", e.what()); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1238 | return -EINVAL; | 
|  | 1239 | } | 
|  | 1240 |  | 
|  | 1241 | if (writeJsonFile(channelNvDataFilename, outData) != 0) | 
|  | 1242 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1243 | lg2::debug("Error in write JSON data to file"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1244 | return -EIO; | 
|  | 1245 | } | 
|  | 1246 |  | 
|  | 1247 | // Update the timestamp | 
|  | 1248 | nvFileLastUpdatedTime = getUpdatedFileTime(channelNvDataFilename); | 
|  | 1249 | return 0; | 
|  | 1250 | } | 
|  | 1251 |  | 
|  | 1252 | int ChannelConfig::checkAndReloadNVData() | 
|  | 1253 | { | 
|  | 1254 | std::time_t updateTime = getUpdatedFileTime(channelNvDataFilename); | 
|  | 1255 | int ret = 0; | 
|  | 1256 | if (updateTime != nvFileLastUpdatedTime || updateTime == -EIO) | 
|  | 1257 | { | 
|  | 1258 | try | 
|  | 1259 | { | 
|  | 1260 | ret = readChannelPersistData(); | 
|  | 1261 | } | 
|  | 1262 | catch (const std::exception& e) | 
|  | 1263 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1264 | lg2::error("Exception caught in readChannelPersistData: {MSG}", | 
|  | 1265 | "MSG", e.what()); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1266 | ret = -EIO; | 
|  | 1267 | } | 
|  | 1268 | } | 
|  | 1269 | return ret; | 
|  | 1270 | } | 
|  | 1271 |  | 
|  | 1272 | int ChannelConfig::checkAndReloadVolatileData() | 
|  | 1273 | { | 
|  | 1274 | std::time_t updateTime = getUpdatedFileTime(channelVolatileDataFilename); | 
|  | 1275 | int ret = 0; | 
|  | 1276 | if (updateTime != voltFileLastUpdatedTime || updateTime == -EIO) | 
|  | 1277 | { | 
|  | 1278 | try | 
|  | 1279 | { | 
|  | 1280 | ret = readChannelVolatileData(); | 
|  | 1281 | } | 
|  | 1282 | catch (const std::exception& e) | 
|  | 1283 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1284 | lg2::error("Exception caught in readChannelVolatileData: {MSG}", | 
|  | 1285 | "MSG", e.what()); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1286 | ret = -EIO; | 
|  | 1287 | } | 
|  | 1288 | } | 
|  | 1289 | return ret; | 
|  | 1290 | } | 
|  | 1291 |  | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 1292 | int ChannelConfig::setDbusProperty( | 
|  | 1293 | const std::string& service, const std::string& objPath, | 
|  | 1294 | const std::string& interface, const std::string& property, | 
|  | 1295 | const DbusVariant& value) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1296 | { | 
|  | 1297 | try | 
|  | 1298 | { | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 1299 | auto method = | 
|  | 1300 | bus.new_method_call(service.c_str(), objPath.c_str(), | 
|  | 1301 | "org.freedesktop.DBus.Properties", "Set"); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1302 |  | 
|  | 1303 | method.append(interface, property, value); | 
|  | 1304 |  | 
|  | 1305 | auto reply = bus.call(method); | 
|  | 1306 | } | 
| Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 1307 | catch (const sdbusplus::exception_t& e) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1308 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1309 | lg2::debug( | 
|  | 1310 | "set-property {SERVICE}:{OBJPATH}/{INTERFACE}.{PROP} failed: {MSG}", | 
|  | 1311 | "SERVICE", service, "OBJPATH", objPath, "INTERFACE", interface, | 
| George Liu | 5a39894 | 2025-01-24 09:16:43 +0800 | [diff] [blame] | 1312 | "PROP", property, "MSG", e); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1313 | return -EIO; | 
|  | 1314 | } | 
|  | 1315 |  | 
|  | 1316 | return 0; | 
|  | 1317 | } | 
|  | 1318 |  | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1319 | int ChannelConfig::syncNetworkChannelConfig() | 
|  | 1320 | { | 
|  | 1321 | boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex> | 
|  | 1322 | channelLock{*channelMutex}; | 
|  | 1323 | bool isUpdated = false; | 
|  | 1324 | for (uint8_t chNum = 0; chNum < maxIpmiChannels; chNum++) | 
|  | 1325 | { | 
|  | 1326 | if (getChannelSessionSupport(chNum) != EChannelSessSupported::none) | 
|  | 1327 | { | 
|  | 1328 | std::string intfPrivStr; | 
| Jiaqing Zhao | 826bf66 | 2022-11-07 14:33:00 +0800 | [diff] [blame] | 1329 | uint8_t intfPriv = 0; | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1330 | try | 
|  | 1331 | { | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1332 | std::string networkIntfObj = | 
| Richard Marian Thomaiyar | 73906b9 | 2019-01-04 23:48:02 +0530 | [diff] [blame] | 1333 | std::string(networkIntfObjectBasePath) + "/" + | 
|  | 1334 | channelData[chNum].chName; | 
| George Liu | 42f64ef | 2024-02-05 15:03:18 +0800 | [diff] [blame] | 1335 | auto propValue = ipmi::getDbusProperty( | 
|  | 1336 | bus, networkIntfServiceName, networkIntfObj, | 
|  | 1337 | networkChConfigIntfName, privilegePropertyString); | 
|  | 1338 |  | 
|  | 1339 | intfPrivStr = std::get<std::string>(propValue); | 
| Jiaqing Zhao | 826bf66 | 2022-11-07 14:33:00 +0800 | [diff] [blame] | 1340 | intfPriv = | 
|  | 1341 | static_cast<uint8_t>(convertToPrivLimitIndex(intfPrivStr)); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1342 | } | 
| Vernon Mauery | f442e11 | 2019-04-09 11:44:36 -0700 | [diff] [blame] | 1343 | catch (const std::bad_variant_access& e) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1344 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1345 | lg2::debug("Network interface '{INTERFACE}' does not exist", | 
|  | 1346 | "INTERFACE", channelData[chNum].chName); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1347 | continue; | 
|  | 1348 | } | 
| Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 1349 | catch (const sdbusplus::exception_t& e) | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1350 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1351 | lg2::debug("Network interface '{INTERFACE}' does not exist", | 
|  | 1352 | "INTERFACE", channelData[chNum].chName); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1353 | continue; | 
|  | 1354 | } | 
| Jiaqing Zhao | 826bf66 | 2022-11-07 14:33:00 +0800 | [diff] [blame] | 1355 | catch (const std::invalid_argument& e) | 
|  | 1356 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1357 | lg2::debug("exception: Invalid privilege"); | 
| Jiaqing Zhao | 826bf66 | 2022-11-07 14:33:00 +0800 | [diff] [blame] | 1358 | continue; | 
|  | 1359 | } | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1360 |  | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1361 | if (channelData[chNum].chAccess.chNonVolatileData.privLimit != | 
|  | 1362 | intfPriv) | 
|  | 1363 | { | 
|  | 1364 | isUpdated = true; | 
|  | 1365 | channelData[chNum].chAccess.chNonVolatileData.privLimit = | 
|  | 1366 | intfPriv; | 
|  | 1367 | channelData[chNum].chAccess.chVolatileData.privLimit = intfPriv; | 
|  | 1368 | } | 
|  | 1369 | } | 
|  | 1370 | } | 
|  | 1371 |  | 
|  | 1372 | if (isUpdated) | 
|  | 1373 | { | 
|  | 1374 | // Write persistent data to file | 
|  | 1375 | if (writeChannelPersistData() != 0) | 
|  | 1376 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1377 | lg2::debug("Failed to update the persistent data file"); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1378 | return -EIO; | 
|  | 1379 | } | 
|  | 1380 | // Write Volatile data to file | 
|  | 1381 | if (writeChannelVolatileData() != 0) | 
|  | 1382 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1383 | lg2::debug("Failed to update the channel volatile data"); | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1384 | return -EIO; | 
|  | 1385 | } | 
|  | 1386 | } | 
|  | 1387 |  | 
|  | 1388 | return 0; | 
|  | 1389 | } | 
|  | 1390 |  | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1391 | void ChannelConfig::initChannelPersistData() | 
|  | 1392 | { | 
| Richard Marian Thomaiyar | e91474c | 2019-09-01 23:02:47 +0530 | [diff] [blame] | 1393 | boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex> | 
|  | 1394 | channelLock{*channelMutex}; | 
|  | 1395 |  | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1396 | /* Always read the channel config */ | 
|  | 1397 | if (loadChannelConfig() != 0) | 
|  | 1398 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1399 | lg2::error("Failed to read channel config file"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1400 | throw std::ios_base::failure("Failed to load channel configuration"); | 
|  | 1401 | } | 
|  | 1402 |  | 
|  | 1403 | /* Populate the channel persist data */ | 
|  | 1404 | if (readChannelPersistData() != 0) | 
|  | 1405 | { | 
|  | 1406 | // Copy default NV data to RW location | 
| Patrick Williams | 3d8d793 | 2022-06-16 12:01:28 -0500 | [diff] [blame] | 1407 | std::filesystem::copy_file(channelAccessDefaultFilename, | 
|  | 1408 | channelNvDataFilename); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1409 |  | 
|  | 1410 | // Load the channel access NV data | 
|  | 1411 | if (readChannelPersistData() != 0) | 
|  | 1412 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1413 | lg2::error("Failed to read channel access NV data"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1414 | throw std::ios_base::failure( | 
|  | 1415 | "Failed to read channel access NV configuration"); | 
|  | 1416 | } | 
|  | 1417 | } | 
|  | 1418 |  | 
|  | 1419 | // First check the volatile data file | 
|  | 1420 | // If not present, load the default values | 
|  | 1421 | if (readChannelVolatileData() != 0) | 
|  | 1422 | { | 
|  | 1423 | // Copy default volatile data to temporary location | 
|  | 1424 | // NV file(channelNvDataFilename) must have created by now. | 
| Patrick Williams | 3d8d793 | 2022-06-16 12:01:28 -0500 | [diff] [blame] | 1425 | std::filesystem::copy_file(channelNvDataFilename, | 
|  | 1426 | channelVolatileDataFilename); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1427 |  | 
|  | 1428 | // Load the channel access volatile data | 
|  | 1429 | if (readChannelVolatileData() != 0) | 
|  | 1430 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1431 | lg2::error("Failed to read channel access volatile data"); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1432 | throw std::ios_base::failure( | 
|  | 1433 | "Failed to read channel access volatile configuration"); | 
|  | 1434 | } | 
|  | 1435 | } | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1436 |  | 
|  | 1437 | // Synchronize the channel config(priv) with network channel | 
|  | 1438 | // configuration(priv) over dbus | 
|  | 1439 | if (syncNetworkChannelConfig() != 0) | 
|  | 1440 | { | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1441 | lg2::error( | 
| AppaRao Puli | 9613ed7 | 2018-09-01 23:46:44 +0530 | [diff] [blame] | 1442 | "Failed to synchronize data with network channel config over dbus"); | 
|  | 1443 | throw std::ios_base::failure( | 
|  | 1444 | "Failed to synchronize data with network channel config over dbus"); | 
|  | 1445 | } | 
|  | 1446 |  | 
| Vernon Mauery | 1e3ed2c | 2024-03-11 12:53:55 -0700 | [diff] [blame] | 1447 | lg2::debug("Successfully completed channel data initialization."); | 
| AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1448 | return; | 
|  | 1449 | } | 
|  | 1450 |  | 
|  | 1451 | } // namespace ipmi |