Patrick Venture | 690a234 | 2020-05-17 11:51:31 -0700 | [diff] [blame] | 1 | #include "transporthandler.hpp" |
| 2 | |
George Liu | c1c7eac | 2024-02-04 17:24:19 +0800 | [diff] [blame] | 3 | #include <ipmid/utils.hpp> |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 4 | #include <phosphor-logging/lg2.hpp> |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 5 | #include <stdplus/net/addr/subnet.hpp> |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 6 | #include <stdplus/raw.hpp> |
| 7 | |
| 8 | #include <array> |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 9 | #include <fstream> |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 10 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 11 | using phosphor::logging::commit; |
| 12 | using phosphor::logging::elog; |
| 13 | using phosphor::logging::entry; |
| 14 | using phosphor::logging::level; |
| 15 | using phosphor::logging::log; |
Willy Tu | 523e2d1 | 2023-09-05 11:36:48 -0700 | [diff] [blame] | 16 | using sdbusplus::error::xyz::openbmc_project::common::InternalFailure; |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 17 | using sdbusplus::error::xyz::openbmc_project::common::InvalidArgument; |
Willy Tu | 523e2d1 | 2023-09-05 11:36:48 -0700 | [diff] [blame] | 18 | using sdbusplus::server::xyz::openbmc_project::network::EthernetInterface; |
| 19 | using sdbusplus::server::xyz::openbmc_project::network::IP; |
| 20 | using sdbusplus::server::xyz::openbmc_project::network::Neighbor; |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 21 | |
Johnathan Mantey | affadb5 | 2019-10-07 10:13:53 -0700 | [diff] [blame] | 22 | namespace cipher |
| 23 | { |
| 24 | |
| 25 | std::vector<uint8_t> getCipherList() |
| 26 | { |
| 27 | std::vector<uint8_t> cipherList; |
| 28 | |
| 29 | std::ifstream jsonFile(cipher::configFile); |
| 30 | if (!jsonFile.is_open()) |
| 31 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 32 | lg2::error("Channel Cipher suites file not found"); |
Johnathan Mantey | affadb5 | 2019-10-07 10:13:53 -0700 | [diff] [blame] | 33 | elog<InternalFailure>(); |
| 34 | } |
| 35 | |
| 36 | auto data = Json::parse(jsonFile, nullptr, false); |
| 37 | if (data.is_discarded()) |
| 38 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 39 | lg2::error("Parsing channel cipher suites JSON failed"); |
Johnathan Mantey | affadb5 | 2019-10-07 10:13:53 -0700 | [diff] [blame] | 40 | elog<InternalFailure>(); |
| 41 | } |
| 42 | |
| 43 | // Byte 1 is reserved |
| 44 | cipherList.push_back(0x00); |
| 45 | |
| 46 | for (const auto& record : data) |
| 47 | { |
| 48 | cipherList.push_back(record.value(cipher, 0)); |
| 49 | } |
| 50 | |
| 51 | return cipherList; |
| 52 | } |
| 53 | } // namespace cipher |
| 54 | |
| 55 | namespace ipmi |
| 56 | { |
| 57 | namespace transport |
| 58 | { |
| 59 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 60 | /** @brief Valid address origins for IPv4 */ |
| 61 | const std::unordered_set<IP::AddressOrigin> originsV4 = { |
| 62 | IP::AddressOrigin::Static, |
| 63 | IP::AddressOrigin::DHCP, |
| 64 | }; |
| 65 | |
Johnathan Mantey | b87034e | 2019-09-16 10:50:50 -0700 | [diff] [blame] | 66 | static constexpr uint8_t oemCmdStart = 192; |
Johnathan Mantey | b87034e | 2019-09-16 10:50:50 -0700 | [diff] [blame] | 67 | |
William A. Kennington III | c72f360 | 2023-10-19 03:51:37 -0700 | [diff] [blame] | 68 | // Checks if the ifname is part of the networkd path |
| 69 | // This assumes the path came from the network subtree PATH_ROOT |
| 70 | bool ifnameInPath(std::string_view ifname, std::string_view path) |
| 71 | { |
| 72 | constexpr auto rs = PATH_ROOT.size() + 1; // ROOT + separator |
| 73 | const auto is = rs + ifname.size(); // ROOT + sep + ifname |
| 74 | return path.size() > rs && path.substr(rs).starts_with(ifname) && |
| 75 | (path.size() == is || path[is] == '/'); |
| 76 | } |
| 77 | |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame^] | 78 | std::optional<ChannelParams> |
| 79 | maybeGetChannelParams(sdbusplus::bus_t& bus, uint8_t channel) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 80 | { |
| 81 | auto ifname = getChannelName(channel); |
| 82 | if (ifname.empty()) |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 83 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 84 | return std::nullopt; |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 85 | } |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 86 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 87 | // Enumerate all VLAN + ETHERNET interfaces |
George Liu | c1c7eac | 2024-02-04 17:24:19 +0800 | [diff] [blame] | 88 | std::vector<std::string> interfaces = {INTF_VLAN, INTF_ETHERNET}; |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame^] | 89 | ipmi::ObjectTree objs = |
| 90 | ipmi::getSubTree(bus, interfaces, std::string{PATH_ROOT}); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 91 | |
| 92 | ChannelParams params; |
| 93 | for (const auto& [path, impls] : objs) |
| 94 | { |
William A. Kennington III | c72f360 | 2023-10-19 03:51:37 -0700 | [diff] [blame] | 95 | if (!ifnameInPath(ifname, path)) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 96 | { |
| 97 | continue; |
| 98 | } |
| 99 | for (const auto& [service, intfs] : impls) |
| 100 | { |
| 101 | bool vlan = false; |
| 102 | bool ethernet = false; |
| 103 | for (const auto& intf : intfs) |
| 104 | { |
| 105 | if (intf == INTF_VLAN) |
| 106 | { |
| 107 | vlan = true; |
| 108 | } |
| 109 | else if (intf == INTF_ETHERNET) |
| 110 | { |
| 111 | ethernet = true; |
| 112 | } |
| 113 | } |
| 114 | if (params.service.empty() && (vlan || ethernet)) |
| 115 | { |
| 116 | params.service = service; |
| 117 | } |
| 118 | if (params.ifPath.empty() && !vlan && ethernet) |
| 119 | { |
| 120 | params.ifPath = path; |
| 121 | } |
| 122 | if (params.logicalPath.empty() && vlan) |
| 123 | { |
| 124 | params.logicalPath = path; |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | // We must have a path for the underlying interface |
| 130 | if (params.ifPath.empty()) |
| 131 | { |
| 132 | return std::nullopt; |
| 133 | } |
| 134 | // We don't have a VLAN so the logical path is the same |
| 135 | if (params.logicalPath.empty()) |
| 136 | { |
| 137 | params.logicalPath = params.ifPath; |
| 138 | } |
| 139 | |
| 140 | params.id = channel; |
| 141 | params.ifname = std::move(ifname); |
Willy Tu | 11d6889 | 2022-01-20 10:37:34 -0800 | [diff] [blame] | 142 | return params; |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 145 | ChannelParams getChannelParams(sdbusplus::bus_t& bus, uint8_t channel) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 146 | { |
| 147 | auto params = maybeGetChannelParams(bus, channel); |
| 148 | if (!params) |
| 149 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 150 | lg2::error("Failed to get channel params: {CHANNEL}", "CHANNEL", |
| 151 | channel); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 152 | elog<InternalFailure>(); |
| 153 | } |
| 154 | return std::move(*params); |
| 155 | } |
| 156 | |
| 157 | /** @brief Wraps the phosphor logging method to insert some additional metadata |
| 158 | * |
| 159 | * @param[in] params - The parameters for the channel |
| 160 | * ... |
| 161 | */ |
| 162 | template <auto level, typename... Args> |
| 163 | auto logWithChannel(const ChannelParams& params, Args&&... args) |
| 164 | { |
| 165 | return log<level>(std::forward<Args>(args)..., |
| 166 | entry("CHANNEL=%d", params.id), |
| 167 | entry("IFNAME=%s", params.ifname.c_str())); |
| 168 | } |
| 169 | template <auto level, typename... Args> |
| 170 | auto logWithChannel(const std::optional<ChannelParams>& params, Args&&... args) |
| 171 | { |
| 172 | if (params) |
| 173 | { |
| 174 | return logWithChannel<level>(*params, std::forward<Args>(args)...); |
| 175 | } |
| 176 | return log<level>(std::forward<Args>(args)...); |
| 177 | } |
| 178 | |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 179 | /** @brief Get / Set the Property value from phosphor-networkd EthernetInterface |
| 180 | */ |
| 181 | template <typename T> |
| 182 | static T getEthProp(sdbusplus::bus_t& bus, const ChannelParams& params, |
| 183 | const std::string& prop) |
| 184 | { |
| 185 | return std::get<T>(getDbusProperty(bus, params.service, params.logicalPath, |
| 186 | INTF_ETHERNET, prop)); |
| 187 | } |
| 188 | template <typename T> |
| 189 | static void setEthProp(sdbusplus::bus_t& bus, const ChannelParams& params, |
| 190 | const std::string& prop, const T& t) |
| 191 | { |
| 192 | return setDbusProperty(bus, params.service, params.logicalPath, |
| 193 | INTF_ETHERNET, prop, t); |
| 194 | } |
| 195 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 196 | /** @brief Determines the MAC of the ethernet interface |
| 197 | * |
| 198 | * @param[in] bus - The bus object used for lookups |
| 199 | * @param[in] params - The parameters for the channel |
| 200 | * @return The configured mac address |
| 201 | */ |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 202 | stdplus::EtherAddr getMACProperty(sdbusplus::bus_t& bus, |
| 203 | const ChannelParams& params) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 204 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 205 | auto prop = getDbusProperty(bus, params.service, params.ifPath, INTF_MAC, |
| 206 | "MACAddress"); |
| 207 | return stdplus::fromStr<stdplus::EtherAddr>(std::get<std::string>(prop)); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | /** @brief Sets the system value for MAC address on the given interface |
| 211 | * |
| 212 | * @param[in] bus - The bus object used for lookups |
| 213 | * @param[in] params - The parameters for the channel |
| 214 | * @param[in] mac - MAC address to apply |
| 215 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 216 | void setMACProperty(sdbusplus::bus_t& bus, const ChannelParams& params, |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 217 | stdplus::EtherAddr mac) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 218 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 219 | setDbusProperty(bus, params.service, params.ifPath, INTF_MAC, "MACAddress", |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 220 | stdplus::toStr(mac)); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 221 | } |
| 222 | |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 223 | void deleteObjectIfExists(sdbusplus::bus_t& bus, const std::string& service, |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 224 | const std::string& path) |
| 225 | { |
| 226 | if (path.empty()) |
| 227 | { |
| 228 | return; |
| 229 | } |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 230 | try |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 231 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 232 | auto req = bus.new_method_call(service.c_str(), path.c_str(), |
| 233 | ipmi::DELETE_INTERFACE, "Delete"); |
| 234 | bus.call_noreply(req); |
| 235 | } |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 236 | catch (const sdbusplus::exception_t& e) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 237 | { |
jayaprakash Mutyala | 84c49dc | 2020-05-18 23:12:13 +0000 | [diff] [blame] | 238 | if (strcmp(e.name(), |
| 239 | "xyz.openbmc_project.Common.Error.InternalFailure") != 0 && |
| 240 | strcmp(e.name(), "org.freedesktop.DBus.Error.UnknownObject") != 0) |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 241 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 242 | // We want to rethrow real errors |
| 243 | throw; |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 244 | } |
| 245 | } |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 246 | } |
| 247 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 248 | /** @brief Sets the address info configured for the interface |
| 249 | * If a previous address path exists then it will be removed |
| 250 | * before the new address is added. |
| 251 | * |
| 252 | * @param[in] bus - The bus object used for lookups |
| 253 | * @param[in] params - The parameters for the channel |
| 254 | * @param[in] address - The address of the new IP |
| 255 | * @param[in] prefix - The prefix of the new IP |
| 256 | */ |
| 257 | template <int family> |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 258 | void createIfAddr(sdbusplus::bus_t& bus, const ChannelParams& params, |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 259 | typename AddrFamily<family>::addr address, uint8_t prefix) |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 260 | { |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame^] | 261 | auto newreq = |
| 262 | bus.new_method_call(params.service.c_str(), params.logicalPath.c_str(), |
| 263 | INTF_IP_CREATE, "IP"); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 264 | std::string protocol = |
Willy Tu | 523e2d1 | 2023-09-05 11:36:48 -0700 | [diff] [blame] | 265 | sdbusplus::common::xyz::openbmc_project::network::convertForMessage( |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 266 | AddrFamily<family>::protocol); |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 267 | stdplus::ToStrHandle<stdplus::ToStr<typename AddrFamily<family>::addr>> tsh; |
| 268 | newreq.append(protocol, tsh(address), prefix, ""); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 269 | bus.call_noreply(newreq); |
| 270 | } |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 271 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 272 | /** @brief Trivial helper for getting the IPv4 address from getIfAddrs() |
| 273 | * |
| 274 | * @param[in] bus - The bus object used for lookups |
| 275 | * @param[in] params - The parameters for the channel |
| 276 | * @return The address and prefix if found |
| 277 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 278 | auto getIfAddr4(sdbusplus::bus_t& bus, const ChannelParams& params) |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 279 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 280 | return getIfAddr<AF_INET>(bus, params, 0, originsV4); |
| 281 | } |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 282 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 283 | /** @brief Reconfigures the IPv4 address info configured for the interface |
| 284 | * |
| 285 | * @param[in] bus - The bus object used for lookups |
| 286 | * @param[in] params - The parameters for the channel |
| 287 | * @param[in] address - The new address if specified |
| 288 | * @param[in] prefix - The new address prefix if specified |
| 289 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 290 | void reconfigureIfAddr4(sdbusplus::bus_t& bus, const ChannelParams& params, |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 291 | std::optional<stdplus::In4Addr> address, |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 292 | std::optional<uint8_t> prefix) |
| 293 | { |
| 294 | auto ifaddr = getIfAddr4(bus, params); |
| 295 | if (!ifaddr && !address) |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 296 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 297 | lg2::error("Missing address for IPv4 assignment"); |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 298 | elog<InternalFailure>(); |
| 299 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 300 | uint8_t fallbackPrefix = AddrFamily<AF_INET>::defaultPrefix; |
| 301 | if (ifaddr) |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 302 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 303 | fallbackPrefix = ifaddr->prefix; |
| 304 | deleteObjectIfExists(bus, params.service, ifaddr->path); |
| 305 | } |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 306 | auto addr = address.value_or(ifaddr->address); |
| 307 | if (addr != stdplus::In4Addr{}) |
Johnathan Mantey | cbfa6e1 | 2023-06-01 06:57:25 -0700 | [diff] [blame] | 308 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 309 | createIfAddr<AF_INET>(bus, params, addr, |
Johnathan Mantey | cbfa6e1 | 2023-06-01 06:57:25 -0700 | [diff] [blame] | 310 | prefix.value_or(fallbackPrefix)); |
| 311 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 312 | } |
| 313 | |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 314 | template <int family> |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame^] | 315 | std::optional<IfNeigh<family>> |
| 316 | findGatewayNeighbor(sdbusplus::bus_t& bus, const ChannelParams& params, |
| 317 | ObjectLookupCache& neighbors) |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 318 | { |
| 319 | auto gateway = getGatewayProperty<family>(bus, params); |
| 320 | if (!gateway) |
| 321 | { |
| 322 | return std::nullopt; |
| 323 | } |
| 324 | |
| 325 | return findStaticNeighbor<family>(bus, params, *gateway, neighbors); |
| 326 | } |
| 327 | |
| 328 | template <int family> |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame^] | 329 | std::optional<IfNeigh<family>> |
| 330 | getGatewayNeighbor(sdbusplus::bus_t& bus, const ChannelParams& params) |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 331 | { |
| 332 | ObjectLookupCache neighbors(bus, params, INTF_NEIGHBOR); |
| 333 | return findGatewayNeighbor<family>(bus, params, neighbors); |
| 334 | } |
| 335 | |
| 336 | template <int family> |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 337 | void reconfigureGatewayMAC(sdbusplus::bus_t& bus, const ChannelParams& params, |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 338 | stdplus::EtherAddr mac) |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 339 | { |
| 340 | auto gateway = getGatewayProperty<family>(bus, params); |
| 341 | if (!gateway) |
| 342 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 343 | lg2::error("Tried to set Gateway MAC without Gateway"); |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 344 | elog<InternalFailure>(); |
| 345 | } |
| 346 | |
| 347 | ObjectLookupCache neighbors(bus, params, INTF_NEIGHBOR); |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame^] | 348 | auto neighbor = |
| 349 | findStaticNeighbor<family>(bus, params, *gateway, neighbors); |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 350 | if (neighbor) |
| 351 | { |
| 352 | deleteObjectIfExists(bus, params.service, neighbor->path); |
| 353 | } |
| 354 | |
| 355 | createNeighbor<family>(bus, params, *gateway, mac); |
| 356 | } |
| 357 | |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 358 | /** @brief Deconfigures the IPv6 address info configured for the interface |
| 359 | * |
| 360 | * @param[in] bus - The bus object used for lookups |
| 361 | * @param[in] params - The parameters for the channel |
| 362 | * @param[in] idx - The address index to operate on |
| 363 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 364 | void deconfigureIfAddr6(sdbusplus::bus_t& bus, const ChannelParams& params, |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 365 | uint8_t idx) |
| 366 | { |
| 367 | auto ifaddr = getIfAddr<AF_INET6>(bus, params, idx, originsV6Static); |
| 368 | if (ifaddr) |
| 369 | { |
| 370 | deleteObjectIfExists(bus, params.service, ifaddr->path); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | /** @brief Reconfigures the IPv6 address info configured for the interface |
| 375 | * |
| 376 | * @param[in] bus - The bus object used for lookups |
| 377 | * @param[in] params - The parameters for the channel |
| 378 | * @param[in] idx - The address index to operate on |
| 379 | * @param[in] address - The new address |
| 380 | * @param[in] prefix - The new address prefix |
| 381 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 382 | void reconfigureIfAddr6(sdbusplus::bus_t& bus, const ChannelParams& params, |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 383 | uint8_t idx, stdplus::In6Addr address, uint8_t prefix) |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 384 | { |
| 385 | deconfigureIfAddr6(bus, params, idx); |
| 386 | createIfAddr<AF_INET6>(bus, params, address, prefix); |
| 387 | } |
| 388 | |
| 389 | /** @brief Converts the AddressOrigin into an IPv6Source |
| 390 | * |
| 391 | * @param[in] origin - The DBus Address Origin to convert |
| 392 | * @return The IPv6Source version of the origin |
| 393 | */ |
| 394 | IPv6Source originToSourceType(IP::AddressOrigin origin) |
| 395 | { |
| 396 | switch (origin) |
| 397 | { |
| 398 | case IP::AddressOrigin::Static: |
| 399 | return IPv6Source::Static; |
| 400 | case IP::AddressOrigin::DHCP: |
| 401 | return IPv6Source::DHCP; |
| 402 | case IP::AddressOrigin::SLAAC: |
| 403 | return IPv6Source::SLAAC; |
| 404 | default: |
| 405 | { |
Willy Tu | 523e2d1 | 2023-09-05 11:36:48 -0700 | [diff] [blame] | 406 | auto originStr = sdbusplus::common::xyz::openbmc_project::network:: |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 407 | convertForMessage(origin); |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 408 | lg2::error("Invalid IP::AddressOrigin conversion to IPv6Source, " |
| 409 | "origin: {ORIGIN}", |
| 410 | "ORIGIN", originStr); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 411 | elog<InternalFailure>(); |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | /** @brief Packs the IPMI message response with IPv6 address data |
| 417 | * |
| 418 | * @param[out] ret - The IPMI response payload to be packed |
| 419 | * @param[in] channel - The channel id corresponding to an ethernet interface |
| 420 | * @param[in] set - The set selector for determining address index |
| 421 | * @param[in] origins - Set of valid origins for address filtering |
| 422 | */ |
| 423 | void getLanIPv6Address(message::Payload& ret, uint8_t channel, uint8_t set, |
| 424 | const std::unordered_set<IP::AddressOrigin>& origins) |
| 425 | { |
| 426 | auto source = IPv6Source::Static; |
| 427 | bool enabled = false; |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 428 | stdplus::In6Addr addr{}; |
Johnathan Mantey | 5aae092 | 2021-10-21 13:05:36 -0700 | [diff] [blame] | 429 | uint8_t prefix{}; |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 430 | auto status = IPv6AddressStatus::Disabled; |
| 431 | |
| 432 | auto ifaddr = channelCall<getIfAddr<AF_INET6>>(channel, set, origins); |
| 433 | if (ifaddr) |
| 434 | { |
| 435 | source = originToSourceType(ifaddr->origin); |
Johnathan Mantey | 846af86 | 2021-10-21 12:48:54 -0700 | [diff] [blame] | 436 | enabled = (origins == originsV6Static); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 437 | addr = ifaddr->address; |
| 438 | prefix = ifaddr->prefix; |
| 439 | status = IPv6AddressStatus::Active; |
| 440 | } |
| 441 | |
| 442 | ret.pack(set); |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 443 | ret.pack(types::enum_cast<uint4_t>(source), uint3_t{}, enabled); |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 444 | ret.pack(stdplus::raw::asView<char>(addr)); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 445 | ret.pack(prefix); |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 446 | ret.pack(types::enum_cast<uint8_t>(status)); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 447 | } |
| 448 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 449 | /** @brief Gets the vlan ID configured on the interface |
| 450 | * |
| 451 | * @param[in] bus - The bus object used for lookups |
| 452 | * @param[in] params - The parameters for the channel |
| 453 | * @return VLAN id or the standard 0 for no VLAN |
| 454 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 455 | uint16_t getVLANProperty(sdbusplus::bus_t& bus, const ChannelParams& params) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 456 | { |
| 457 | // VLAN devices will always have a separate logical object |
| 458 | if (params.ifPath == params.logicalPath) |
| 459 | { |
| 460 | return 0; |
| 461 | } |
| 462 | |
| 463 | auto vlan = std::get<uint32_t>(getDbusProperty( |
| 464 | bus, params.service, params.logicalPath, INTF_VLAN, "Id")); |
| 465 | if ((vlan & VLAN_VALUE_MASK) != vlan) |
| 466 | { |
| 467 | logWithChannel<level::ERR>(params, "networkd returned an invalid vlan", |
| 468 | entry("VLAN=%" PRIu32, vlan)); |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 469 | elog<InternalFailure>(); |
| 470 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 471 | return vlan; |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 472 | } |
| 473 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 474 | /** @brief Deletes all of the possible configuration parameters for a channel |
| 475 | * |
| 476 | * @param[in] bus - The bus object used for lookups |
| 477 | * @param[in] params - The parameters for the channel |
| 478 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 479 | void deconfigureChannel(sdbusplus::bus_t& bus, ChannelParams& params) |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 480 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 481 | // Delete all objects associated with the interface |
George Liu | c1c7eac | 2024-02-04 17:24:19 +0800 | [diff] [blame] | 482 | ObjectTree objs = |
| 483 | ipmi::getSubTree(bus, std::vector<std::string>{DELETE_INTERFACE}, |
| 484 | std::string{PATH_ROOT}); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 485 | for (const auto& [path, impls] : objs) |
| 486 | { |
William A. Kennington III | c72f360 | 2023-10-19 03:51:37 -0700 | [diff] [blame] | 487 | if (!ifnameInPath(params.ifname, path)) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 488 | { |
| 489 | continue; |
| 490 | } |
| 491 | for (const auto& [service, intfs] : impls) |
| 492 | { |
| 493 | deleteObjectIfExists(bus, service, path); |
| 494 | } |
| 495 | // Update params to reflect the deletion of vlan |
| 496 | if (path == params.logicalPath) |
| 497 | { |
| 498 | params.logicalPath = params.ifPath; |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | // Clear out any settings on the lower physical interface |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 503 | setEthProp(bus, params, "DHCP4", false); |
| 504 | setEthProp(bus, params, "DHCP6", false); |
| 505 | setEthProp(bus, params, "IPv6AcceptRA", false); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 506 | } |
| 507 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 508 | /** @brief Creates a new VLAN on the specified interface |
| 509 | * |
| 510 | * @param[in] bus - The bus object used for lookups |
| 511 | * @param[in] params - The parameters for the channel |
| 512 | * @param[in] vlan - The id of the new vlan |
| 513 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 514 | void createVLAN(sdbusplus::bus_t& bus, ChannelParams& params, uint16_t vlan) |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 515 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 516 | if (vlan == 0) |
Richard Marian Thomaiyar | 75b480b | 2019-01-22 00:20:15 +0530 | [diff] [blame] | 517 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 518 | return; |
Richard Marian Thomaiyar | 75b480b | 2019-01-22 00:20:15 +0530 | [diff] [blame] | 519 | } |
| 520 | |
William A. Kennington III | c72f360 | 2023-10-19 03:51:37 -0700 | [diff] [blame] | 521 | auto req = bus.new_method_call(params.service.c_str(), PATH_ROOT.c_str(), |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 522 | INTF_VLAN_CREATE, "VLAN"); |
| 523 | req.append(params.ifname, static_cast<uint32_t>(vlan)); |
| 524 | auto reply = bus.call(req); |
| 525 | sdbusplus::message::object_path newPath; |
| 526 | reply.read(newPath); |
| 527 | params.logicalPath = std::move(newPath); |
Richard Marian Thomaiyar | 75b480b | 2019-01-22 00:20:15 +0530 | [diff] [blame] | 528 | } |
| 529 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 530 | /** @brief Performs the necessary reconfiguration to change the VLAN |
| 531 | * |
| 532 | * @param[in] bus - The bus object used for lookups |
| 533 | * @param[in] params - The parameters for the channel |
| 534 | * @param[in] vlan - The new vlan id to use |
| 535 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 536 | void reconfigureVLAN(sdbusplus::bus_t& bus, ChannelParams& params, |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 537 | uint16_t vlan) |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 538 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 539 | // Unfortunatetly we don't have built-in functions to migrate our interface |
| 540 | // customizations to new VLAN interfaces, or have some kind of decoupling. |
| 541 | // We therefore must retain all of our old information, setup the new VLAN |
| 542 | // configuration, then restore the old info. |
Nan Li | 3d0df91 | 2016-10-18 19:51:41 +0800 | [diff] [blame] | 543 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 544 | // Save info from the old logical interface |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 545 | bool dhcp4 = getEthProp<bool>(bus, params, "DHCP4"); |
| 546 | bool dhcp6 = getEthProp<bool>(bus, params, "DHCP6"); |
| 547 | bool ra = getEthProp<bool>(bus, params, "IPv6AcceptRA"); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 548 | ObjectLookupCache ips(bus, params, INTF_IP); |
| 549 | auto ifaddr4 = findIfAddr<AF_INET>(bus, params, 0, originsV4, ips); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 550 | std::vector<IfAddr<AF_INET6>> ifaddrs6; |
| 551 | for (uint8_t i = 0; i < MAX_IPV6_STATIC_ADDRESSES; ++i) |
| 552 | { |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame^] | 553 | auto ifaddr6 = |
| 554 | findIfAddr<AF_INET6>(bus, params, i, originsV6Static, ips); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 555 | if (!ifaddr6) |
| 556 | { |
| 557 | break; |
| 558 | } |
| 559 | ifaddrs6.push_back(std::move(*ifaddr6)); |
| 560 | } |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 561 | ObjectLookupCache neighbors(bus, params, INTF_NEIGHBOR); |
| 562 | auto neighbor4 = findGatewayNeighbor<AF_INET>(bus, params, neighbors); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 563 | auto neighbor6 = findGatewayNeighbor<AF_INET6>(bus, params, neighbors); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 564 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 565 | deconfigureChannel(bus, params); |
| 566 | createVLAN(bus, params, vlan); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 567 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 568 | // Re-establish the saved settings |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 569 | setEthProp(bus, params, "DHCP4", dhcp4); |
| 570 | setEthProp(bus, params, "DHCP6", dhcp6); |
| 571 | setEthProp(bus, params, "IPv6AcceptRA", ra); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 572 | if (ifaddr4) |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 573 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 574 | createIfAddr<AF_INET>(bus, params, ifaddr4->address, ifaddr4->prefix); |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 575 | } |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 576 | for (const auto& ifaddr6 : ifaddrs6) |
| 577 | { |
| 578 | createIfAddr<AF_INET6>(bus, params, ifaddr6.address, ifaddr6.prefix); |
| 579 | } |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 580 | if (neighbor4) |
| 581 | { |
| 582 | createNeighbor<AF_INET>(bus, params, neighbor4->ip, neighbor4->mac); |
| 583 | } |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 584 | if (neighbor6) |
| 585 | { |
| 586 | createNeighbor<AF_INET6>(bus, params, neighbor6->ip, neighbor6->mac); |
| 587 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 588 | } |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 589 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 590 | // We need to store this value so it can be returned to the client |
| 591 | // It is volatile so safe to store in daemon memory. |
| 592 | static std::unordered_map<uint8_t, SetStatus> setStatus; |
| 593 | |
| 594 | // Until we have good support for fixed versions of IPMI tool |
| 595 | // we need to return the VLAN id for disabled VLANs. The value is only |
| 596 | // used for verification that a disable operation succeeded and will only |
| 597 | // be sent if our system indicates that vlans are disabled. |
| 598 | static std::unordered_map<uint8_t, uint16_t> lastDisabledVlan; |
| 599 | |
| 600 | /** @brief Gets the set status for the channel if it exists |
| 601 | * Otherise populates and returns the default value. |
| 602 | * |
| 603 | * @param[in] channel - The channel id corresponding to an ethernet interface |
| 604 | * @return A reference to the SetStatus for the channel |
| 605 | */ |
| 606 | SetStatus& getSetStatus(uint8_t channel) |
| 607 | { |
| 608 | auto it = setStatus.find(channel); |
| 609 | if (it != setStatus.end()) |
| 610 | { |
| 611 | return it->second; |
| 612 | } |
| 613 | return setStatus[channel] = SetStatus::Complete; |
| 614 | } |
| 615 | |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 616 | /** @brief Unpacks the trivially copyable type from the message */ |
| 617 | template <typename T> |
| 618 | static T unpackT(message::Payload& req) |
| 619 | { |
| 620 | std::array<uint8_t, sizeof(T)> bytes; |
| 621 | if (req.unpack(bytes) != 0) |
| 622 | { |
| 623 | throw ccReqDataLenInvalid; |
| 624 | } |
| 625 | return stdplus::raw::copyFrom<T>(bytes); |
| 626 | } |
| 627 | |
| 628 | /** @brief Ensure the message is fully unpacked */ |
| 629 | static void unpackFinal(message::Payload& req) |
| 630 | { |
| 631 | if (!req.fullyUnpacked()) |
| 632 | { |
| 633 | throw ccReqDataTruncated; |
| 634 | } |
| 635 | } |
| 636 | |
Johnathan Mantey | b87034e | 2019-09-16 10:50:50 -0700 | [diff] [blame] | 637 | /** |
| 638 | * Define placeholder command handlers for the OEM Extension bytes for the Set |
| 639 | * LAN Configuration Parameters and Get LAN Configuration Parameters |
| 640 | * commands. Using "weak" linking allows the placeholder setLanOem/getLanOem |
| 641 | * functions below to be overridden. |
| 642 | * To create handlers for your own proprietary command set: |
| 643 | * Create/modify a phosphor-ipmi-host Bitbake append file within your Yocto |
| 644 | * recipe |
| 645 | * Create C++ file(s) that define IPMI handler functions matching the |
| 646 | * function names below (i.e. setLanOem). The default name for the |
| 647 | * transport IPMI commands is transporthandler_oem.cpp. |
| 648 | * Add: |
Johnathan Mantey | efe2668 | 2022-08-11 14:30:45 -0700 | [diff] [blame] | 649 | * EXTRA_OEMESON:append = "-Dtransport-oem=enabled" |
| 650 | * Create a do_configure:prepend()/do_install:append() method in your |
Johnathan Mantey | b87034e | 2019-09-16 10:50:50 -0700 | [diff] [blame] | 651 | * bbappend file to copy the file to the build directory. |
| 652 | * Add: |
| 653 | * PROJECT_SRC_DIR := "${THISDIR}/${PN}" |
| 654 | * # Copy the "strong" functions into the working directory, overriding the |
| 655 | * # placeholder functions. |
Johnathan Mantey | efe2668 | 2022-08-11 14:30:45 -0700 | [diff] [blame] | 656 | * do_configure:prepend(){ |
Johnathan Mantey | b87034e | 2019-09-16 10:50:50 -0700 | [diff] [blame] | 657 | * cp -f ${PROJECT_SRC_DIR}/transporthandler_oem.cpp ${S} |
| 658 | * } |
| 659 | * |
| 660 | * # Clean up after complilation has completed |
Johnathan Mantey | efe2668 | 2022-08-11 14:30:45 -0700 | [diff] [blame] | 661 | * do_install:append(){ |
Johnathan Mantey | b87034e | 2019-09-16 10:50:50 -0700 | [diff] [blame] | 662 | * rm -f ${S}/transporthandler_oem.cpp |
| 663 | * } |
| 664 | * |
| 665 | */ |
| 666 | |
| 667 | /** |
| 668 | * Define the placeholder OEM commands as having weak linkage. Create |
| 669 | * setLanOem, and getLanOem functions in the transporthandler_oem.cpp |
| 670 | * file. The functions defined there must not have the "weak" attribute |
| 671 | * applied to them. |
| 672 | */ |
| 673 | RspType<> setLanOem(uint8_t channel, uint8_t parameter, message::Payload& req) |
| 674 | __attribute__((weak)); |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame^] | 675 | RspType<message::Payload> |
| 676 | getLanOem(uint8_t channel, uint8_t parameter, uint8_t set, uint8_t block) |
| 677 | __attribute__((weak)); |
Johnathan Mantey | b87034e | 2019-09-16 10:50:50 -0700 | [diff] [blame] | 678 | |
Willy Tu | 11d6889 | 2022-01-20 10:37:34 -0800 | [diff] [blame] | 679 | RspType<> setLanOem(uint8_t, uint8_t, message::Payload& req) |
Johnathan Mantey | b87034e | 2019-09-16 10:50:50 -0700 | [diff] [blame] | 680 | { |
| 681 | req.trailingOk = true; |
| 682 | return response(ccParamNotSupported); |
| 683 | } |
| 684 | |
Willy Tu | 11d6889 | 2022-01-20 10:37:34 -0800 | [diff] [blame] | 685 | RspType<message::Payload> getLanOem(uint8_t, uint8_t, uint8_t, uint8_t) |
Johnathan Mantey | b87034e | 2019-09-16 10:50:50 -0700 | [diff] [blame] | 686 | { |
| 687 | return response(ccParamNotSupported); |
| 688 | } |
| 689 | |
Jian Zhang | cf19d14 | 2023-07-31 10:22:53 +0800 | [diff] [blame] | 690 | /** |
| 691 | * @brief is a valid LAN channel. |
| 692 | * |
| 693 | * This function checks whether the input channel is a valid LAN channel or not. |
| 694 | * |
| 695 | * @param[in] channel: the channel number. |
| 696 | * @return nullopt if the channel is invalid, false if the channel is not a LAN |
| 697 | * channel, true if the channel is a LAN channel. |
| 698 | **/ |
| 699 | std::optional<bool> isLanChannel(uint8_t channel) |
| 700 | { |
| 701 | ChannelInfo chInfo; |
| 702 | auto cc = getChannelInfo(channel, chInfo); |
| 703 | if (cc != ccSuccess) |
| 704 | { |
| 705 | return std::nullopt; |
| 706 | } |
| 707 | |
| 708 | return chInfo.mediumType == |
| 709 | static_cast<uint8_t>(EChannelMediumType::lan8032); |
| 710 | } |
| 711 | |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 712 | RspType<> setLanInt(Context::ptr ctx, uint4_t channelBits, uint4_t reserved1, |
| 713 | uint8_t parameter, message::Payload& req) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 714 | { |
vijayabharathix shetty | cc76925 | 2020-02-27 17:52:20 +0000 | [diff] [blame] | 715 | const uint8_t channel = convertCurrentChannelNum( |
| 716 | static_cast<uint8_t>(channelBits), ctx->channel); |
| 717 | if (reserved1 || !isValidChannel(channel)) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 718 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 719 | lg2::error("Set Lan - Invalid field in request"); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 720 | req.trailingOk = true; |
| 721 | return responseInvalidFieldRequest(); |
| 722 | } |
| 723 | |
Jian Zhang | cf19d14 | 2023-07-31 10:22:53 +0800 | [diff] [blame] | 724 | if (!isLanChannel(channel).value_or(false)) |
| 725 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 726 | lg2::error("Set Lan - Not a LAN channel"); |
Jian Zhang | cf19d14 | 2023-07-31 10:22:53 +0800 | [diff] [blame] | 727 | return responseInvalidFieldRequest(); |
| 728 | } |
| 729 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 730 | switch (static_cast<LanParam>(parameter)) |
| 731 | { |
| 732 | case LanParam::SetStatus: |
| 733 | { |
| 734 | uint2_t flag; |
| 735 | uint6_t rsvd; |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 736 | if (req.unpack(flag, rsvd) != 0) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 737 | { |
| 738 | return responseReqDataLenInvalid(); |
| 739 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 740 | unpackFinal(req); |
Johnathan Mantey | 4a15685 | 2019-12-11 13:47:43 -0800 | [diff] [blame] | 741 | if (rsvd) |
| 742 | { |
| 743 | return responseInvalidFieldRequest(); |
| 744 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 745 | auto status = static_cast<SetStatus>(static_cast<uint8_t>(flag)); |
| 746 | switch (status) |
| 747 | { |
| 748 | case SetStatus::Complete: |
| 749 | { |
| 750 | getSetStatus(channel) = status; |
| 751 | return responseSuccess(); |
| 752 | } |
| 753 | case SetStatus::InProgress: |
| 754 | { |
| 755 | auto& storedStatus = getSetStatus(channel); |
| 756 | if (storedStatus == SetStatus::InProgress) |
| 757 | { |
| 758 | return response(ccParamSetLocked); |
| 759 | } |
| 760 | storedStatus = status; |
| 761 | return responseSuccess(); |
| 762 | } |
| 763 | case SetStatus::Commit: |
| 764 | if (getSetStatus(channel) != SetStatus::InProgress) |
| 765 | { |
| 766 | return responseInvalidFieldRequest(); |
| 767 | } |
| 768 | return responseSuccess(); |
| 769 | } |
| 770 | return response(ccParamNotSupported); |
| 771 | } |
| 772 | case LanParam::AuthSupport: |
| 773 | { |
| 774 | req.trailingOk = true; |
| 775 | return response(ccParamReadOnly); |
| 776 | } |
| 777 | case LanParam::AuthEnables: |
| 778 | { |
| 779 | req.trailingOk = true; |
Johnathan Mantey | 76ce9c7 | 2019-11-14 14:41:46 -0800 | [diff] [blame] | 780 | return response(ccParamReadOnly); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 781 | } |
William A. Kennington III | aab2023 | 2018-11-19 18:20:39 -0800 | [diff] [blame] | 782 | case LanParam::IP: |
Hariharasubramanian R | 8395191 | 2016-01-20 07:06:36 -0600 | [diff] [blame] | 783 | { |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 784 | if (channelCall<getEthProp<bool>>(channel, "DHCP4")) |
Johnathan Mantey | 930104a | 2019-12-17 09:18:34 -0800 | [diff] [blame] | 785 | { |
| 786 | return responseCommandNotAvailable(); |
| 787 | } |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 788 | auto ip = unpackT<stdplus::In4Addr>(req); |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 789 | unpackFinal(req); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 790 | channelCall<reconfigureIfAddr4>(channel, ip, std::nullopt); |
| 791 | return responseSuccess(); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 792 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 793 | case LanParam::IPSrc: |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 794 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 795 | uint4_t flag; |
| 796 | uint4_t rsvd; |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 797 | if (req.unpack(flag, rsvd) != 0) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 798 | { |
| 799 | return responseReqDataLenInvalid(); |
| 800 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 801 | unpackFinal(req); |
Johnathan Mantey | 4a15685 | 2019-12-11 13:47:43 -0800 | [diff] [blame] | 802 | if (rsvd) |
| 803 | { |
| 804 | return responseInvalidFieldRequest(); |
| 805 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 806 | switch (static_cast<IPSrc>(static_cast<uint8_t>(flag))) |
| 807 | { |
| 808 | case IPSrc::DHCP: |
Johnathan Mantey | 6526536 | 2019-11-14 11:24:19 -0800 | [diff] [blame] | 809 | // The IPSrc IPMI command is only for IPv4 |
| 810 | // management. Modifying IPv6 state is done using |
| 811 | // a completely different Set LAN Configuration |
| 812 | // subcommand. |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 813 | channelCall<setEthProp<bool>>(channel, "DHCP4", true); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 814 | return responseSuccess(); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 815 | case IPSrc::Unspecified: |
| 816 | case IPSrc::Static: |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 817 | channelCall<setEthProp<bool>>(channel, "DHCP4", false); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 818 | return responseSuccess(); |
Rajashekar Gade Reddy | 8a860ea | 2019-12-24 11:31:19 +0530 | [diff] [blame] | 819 | case IPSrc::BIOS: |
| 820 | case IPSrc::BMC: |
Rajashekar Gade Reddy | 8a860ea | 2019-12-24 11:31:19 +0530 | [diff] [blame] | 821 | return responseInvalidFieldRequest(); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 822 | } |
| 823 | return response(ccParamNotSupported); |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 824 | } |
William A. Kennington III | aab2023 | 2018-11-19 18:20:39 -0800 | [diff] [blame] | 825 | case LanParam::MAC: |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 826 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 827 | auto mac = unpackT<stdplus::EtherAddr>(req); |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 828 | unpackFinal(req); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 829 | channelCall<setMACProperty>(channel, mac); |
| 830 | return responseSuccess(); |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 831 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 832 | case LanParam::SubnetMask: |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 833 | { |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 834 | if (channelCall<getEthProp<bool>>(channel, "DHCP4")) |
Johnathan Mantey | 930104a | 2019-12-17 09:18:34 -0800 | [diff] [blame] | 835 | { |
| 836 | return responseCommandNotAvailable(); |
| 837 | } |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 838 | auto pfx = stdplus::maskToPfx(unpackT<stdplus::In4Addr>(req)); |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 839 | unpackFinal(req); |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 840 | channelCall<reconfigureIfAddr4>(channel, std::nullopt, pfx); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 841 | return responseSuccess(); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 842 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 843 | case LanParam::Gateway1: |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 844 | { |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 845 | if (channelCall<getEthProp<bool>>(channel, "DHCP4")) |
Johnathan Mantey | 930104a | 2019-12-17 09:18:34 -0800 | [diff] [blame] | 846 | { |
| 847 | return responseCommandNotAvailable(); |
| 848 | } |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 849 | auto gateway = unpackT<stdplus::In4Addr>(req); |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 850 | unpackFinal(req); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 851 | channelCall<setGatewayProperty<AF_INET>>(channel, gateway); |
| 852 | return responseSuccess(); |
| 853 | } |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 854 | case LanParam::Gateway1MAC: |
| 855 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 856 | auto gatewayMAC = unpackT<stdplus::EtherAddr>(req); |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 857 | unpackFinal(req); |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 858 | channelCall<reconfigureGatewayMAC<AF_INET>>(channel, gatewayMAC); |
| 859 | return responseSuccess(); |
| 860 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 861 | case LanParam::VLANId: |
| 862 | { |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 863 | uint12_t vlanData; |
| 864 | uint3_t rsvd; |
| 865 | bool vlanEnable; |
Suryakanth Sekar | 8e8c8e2 | 2019-08-30 11:54:20 +0530 | [diff] [blame] | 866 | |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 867 | if (req.unpack(vlanData, rsvd, vlanEnable) != 0) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 868 | { |
| 869 | return responseReqDataLenInvalid(); |
| 870 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 871 | unpackFinal(req); |
Suryakanth Sekar | 8e8c8e2 | 2019-08-30 11:54:20 +0530 | [diff] [blame] | 872 | |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 873 | if (rsvd) |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 874 | { |
Suryakanth Sekar | 8e8c8e2 | 2019-08-30 11:54:20 +0530 | [diff] [blame] | 875 | return responseInvalidFieldRequest(); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 876 | } |
Suryakanth Sekar | 8e8c8e2 | 2019-08-30 11:54:20 +0530 | [diff] [blame] | 877 | |
| 878 | uint16_t vlan = static_cast<uint16_t>(vlanData); |
| 879 | |
| 880 | if (!vlanEnable) |
| 881 | { |
| 882 | lastDisabledVlan[channel] = vlan; |
| 883 | vlan = 0; |
| 884 | } |
Jayaprakash Mutyala | 0d1d7ad | 2024-06-19 10:19:33 +0000 | [diff] [blame] | 885 | else if (vlan == 0 || vlan == VLAN_VALUE_MASK) |
| 886 | { |
| 887 | return responseInvalidFieldRequest(); |
| 888 | } |
Suryakanth Sekar | 8e8c8e2 | 2019-08-30 11:54:20 +0530 | [diff] [blame] | 889 | |
jayaprakash Mutyala | 84c49dc | 2020-05-18 23:12:13 +0000 | [diff] [blame] | 890 | channelCall<reconfigureVLAN>(channel, vlan); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 891 | return responseSuccess(); |
| 892 | } |
| 893 | case LanParam::CiphersuiteSupport: |
| 894 | case LanParam::CiphersuiteEntries: |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 895 | case LanParam::IPFamilySupport: |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 896 | { |
| 897 | req.trailingOk = true; |
| 898 | return response(ccParamReadOnly); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 899 | } |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 900 | case LanParam::IPFamilyEnables: |
| 901 | { |
| 902 | uint8_t enables; |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 903 | if (req.unpack(enables) != 0) |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 904 | { |
| 905 | return responseReqDataLenInvalid(); |
| 906 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 907 | unpackFinal(req); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 908 | switch (static_cast<IPFamilyEnables>(enables)) |
| 909 | { |
| 910 | case IPFamilyEnables::DualStack: |
| 911 | return responseSuccess(); |
| 912 | case IPFamilyEnables::IPv4Only: |
| 913 | case IPFamilyEnables::IPv6Only: |
| 914 | return response(ccParamNotSupported); |
| 915 | } |
| 916 | return response(ccParamNotSupported); |
| 917 | } |
| 918 | case LanParam::IPv6Status: |
| 919 | { |
| 920 | req.trailingOk = true; |
| 921 | return response(ccParamReadOnly); |
| 922 | } |
| 923 | case LanParam::IPv6StaticAddresses: |
| 924 | { |
| 925 | uint8_t set; |
| 926 | uint7_t rsvd; |
| 927 | bool enabled; |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 928 | uint8_t prefix; |
| 929 | uint8_t status; |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 930 | if (req.unpack(set, rsvd, enabled) != 0) |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 931 | { |
| 932 | return responseReqDataLenInvalid(); |
| 933 | } |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 934 | auto ip = unpackT<stdplus::In6Addr>(req); |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 935 | if (req.unpack(prefix, status) != 0) |
| 936 | { |
| 937 | return responseReqDataLenInvalid(); |
| 938 | } |
| 939 | unpackFinal(req); |
Johnathan Mantey | 4a15685 | 2019-12-11 13:47:43 -0800 | [diff] [blame] | 940 | if (rsvd) |
| 941 | { |
| 942 | return responseInvalidFieldRequest(); |
| 943 | } |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 944 | if (enabled) |
| 945 | { |
Jiaqing Zhao | 6d4a44e | 2022-01-24 15:04:00 +0800 | [diff] [blame] | 946 | if (prefix < MIN_IPV6_PREFIX_LENGTH || |
| 947 | prefix > MAX_IPV6_PREFIX_LENGTH) |
| 948 | { |
| 949 | return responseParmOutOfRange(); |
| 950 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 951 | channelCall<reconfigureIfAddr6>(channel, set, ip, prefix); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 952 | } |
| 953 | else |
| 954 | { |
| 955 | channelCall<deconfigureIfAddr6>(channel, set); |
| 956 | } |
| 957 | return responseSuccess(); |
| 958 | } |
| 959 | case LanParam::IPv6DynamicAddresses: |
| 960 | { |
| 961 | req.trailingOk = true; |
| 962 | return response(ccParamReadOnly); |
| 963 | } |
| 964 | case LanParam::IPv6RouterControl: |
| 965 | { |
| 966 | std::bitset<8> control; |
Johnathan Mantey | 3b7a407 | 2021-01-26 14:24:53 -0800 | [diff] [blame] | 967 | constexpr uint8_t reservedRACCBits = 0xfc; |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 968 | if (req.unpack(control) != 0) |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 969 | { |
| 970 | return responseReqDataLenInvalid(); |
| 971 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 972 | unpackFinal(req); |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame^] | 973 | if (std::bitset<8> expected( |
| 974 | control & std::bitset<8>(reservedRACCBits)); |
Johnathan Mantey | 3b7a407 | 2021-01-26 14:24:53 -0800 | [diff] [blame] | 975 | expected.any()) |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 976 | { |
Johnathan Mantey | 3b7a407 | 2021-01-26 14:24:53 -0800 | [diff] [blame] | 977 | return response(ccParamNotSupported); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 978 | } |
Johnathan Mantey | 3b7a407 | 2021-01-26 14:24:53 -0800 | [diff] [blame] | 979 | |
| 980 | bool enableRA = control[IPv6RouterControlFlag::Dynamic]; |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 981 | channelCall<setEthProp<bool>>(channel, "IPv6AcceptRA", enableRA); |
| 982 | channelCall<setEthProp<bool>>(channel, "DHCP6", enableRA); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 983 | return responseSuccess(); |
| 984 | } |
| 985 | case LanParam::IPv6StaticRouter1IP: |
| 986 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 987 | auto gateway = unpackT<stdplus::In6Addr>(req); |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 988 | unpackFinal(req); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 989 | channelCall<setGatewayProperty<AF_INET6>>(channel, gateway); |
| 990 | return responseSuccess(); |
| 991 | } |
| 992 | case LanParam::IPv6StaticRouter1MAC: |
| 993 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 994 | auto mac = unpackT<stdplus::EtherAddr>(req); |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 995 | unpackFinal(req); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 996 | channelCall<reconfigureGatewayMAC<AF_INET6>>(channel, mac); |
| 997 | return responseSuccess(); |
| 998 | } |
| 999 | case LanParam::IPv6StaticRouter1PrefixLength: |
| 1000 | { |
| 1001 | uint8_t prefix; |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1002 | if (req.unpack(prefix) != 0) |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1003 | { |
| 1004 | return responseReqDataLenInvalid(); |
| 1005 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1006 | unpackFinal(req); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1007 | if (prefix != 0) |
| 1008 | { |
| 1009 | return responseInvalidFieldRequest(); |
| 1010 | } |
| 1011 | return responseSuccess(); |
| 1012 | } |
| 1013 | case LanParam::IPv6StaticRouter1PrefixValue: |
| 1014 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 1015 | unpackT<stdplus::In6Addr>(req); |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1016 | unpackFinal(req); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1017 | // Accept any prefix value since our prefix length has to be 0 |
| 1018 | return responseSuccess(); |
| 1019 | } |
jayaprakash Mutyala | b741b99 | 2019-12-02 17:29:09 +0000 | [diff] [blame] | 1020 | case LanParam::cipherSuitePrivilegeLevels: |
| 1021 | { |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1022 | uint8_t rsvd; |
jayaprakash Mutyala | b741b99 | 2019-12-02 17:29:09 +0000 | [diff] [blame] | 1023 | std::array<uint4_t, ipmi::maxCSRecords> cipherSuitePrivs; |
| 1024 | |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1025 | if (req.unpack(rsvd, cipherSuitePrivs)) |
jayaprakash Mutyala | b741b99 | 2019-12-02 17:29:09 +0000 | [diff] [blame] | 1026 | { |
| 1027 | return responseReqDataLenInvalid(); |
| 1028 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1029 | unpackFinal(req); |
jayaprakash Mutyala | b741b99 | 2019-12-02 17:29:09 +0000 | [diff] [blame] | 1030 | |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1031 | if (rsvd) |
jayaprakash Mutyala | b741b99 | 2019-12-02 17:29:09 +0000 | [diff] [blame] | 1032 | { |
| 1033 | return responseInvalidFieldRequest(); |
| 1034 | } |
| 1035 | |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame^] | 1036 | uint8_t resp = |
| 1037 | getCipherConfigObject(csPrivFileName, csPrivDefaultFileName) |
| 1038 | .setCSPrivilegeLevels(channel, cipherSuitePrivs); |
jayaprakash Mutyala | b741b99 | 2019-12-02 17:29:09 +0000 | [diff] [blame] | 1039 | if (!resp) |
| 1040 | { |
| 1041 | return responseSuccess(); |
| 1042 | } |
| 1043 | else |
| 1044 | { |
| 1045 | req.trailingOk = true; |
| 1046 | return response(resp); |
| 1047 | } |
| 1048 | } |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 1049 | } |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 1050 | |
PavanKumarIntel | 3771f5f | 2023-11-02 06:26:42 +0000 | [diff] [blame] | 1051 | if (parameter >= oemCmdStart) |
Johnathan Mantey | b87034e | 2019-09-16 10:50:50 -0700 | [diff] [blame] | 1052 | { |
| 1053 | return setLanOem(channel, parameter, req); |
| 1054 | } |
| 1055 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1056 | req.trailingOk = true; |
| 1057 | return response(ccParamNotSupported); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 1058 | } |
| 1059 | |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1060 | RspType<> setLan(Context::ptr ctx, uint4_t channelBits, uint4_t reserved1, |
| 1061 | uint8_t parameter, message::Payload& req) |
| 1062 | { |
| 1063 | try |
| 1064 | { |
| 1065 | return setLanInt(ctx, channelBits, reserved1, parameter, req); |
| 1066 | } |
| 1067 | catch (ipmi::Cc cc) |
| 1068 | { |
| 1069 | return response(cc); |
| 1070 | } |
| 1071 | catch (const sdbusplus::exception_t& e) |
| 1072 | { |
| 1073 | if (std::string_view{InvalidArgument::errName} == e.name()) |
| 1074 | { |
| 1075 | return responseInvalidFieldRequest(); |
| 1076 | } |
| 1077 | throw; |
| 1078 | } |
| 1079 | } |
| 1080 | |
vijayabharathix shetty | cc76925 | 2020-02-27 17:52:20 +0000 | [diff] [blame] | 1081 | RspType<message::Payload> getLan(Context::ptr ctx, uint4_t channelBits, |
| 1082 | uint3_t reserved, bool revOnly, |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1083 | uint8_t parameter, uint8_t set, uint8_t block) |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 1084 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1085 | message::Payload ret; |
| 1086 | constexpr uint8_t current_revision = 0x11; |
| 1087 | ret.pack(current_revision); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 1088 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1089 | if (revOnly) |
Suryakanth Sekar | e405440 | 2019-08-08 15:16:52 +0530 | [diff] [blame] | 1090 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1091 | return responseSuccess(std::move(ret)); |
Suryakanth Sekar | e405440 | 2019-08-08 15:16:52 +0530 | [diff] [blame] | 1092 | } |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 1093 | |
vijayabharathix shetty | cc76925 | 2020-02-27 17:52:20 +0000 | [diff] [blame] | 1094 | const uint8_t channel = convertCurrentChannelNum( |
| 1095 | static_cast<uint8_t>(channelBits), ctx->channel); |
| 1096 | if (reserved || !isValidChannel(channel)) |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 1097 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 1098 | lg2::error("Get Lan - Invalid field in request"); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1099 | return responseInvalidFieldRequest(); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 1100 | } |
| 1101 | |
Jian Zhang | cf19d14 | 2023-07-31 10:22:53 +0800 | [diff] [blame] | 1102 | if (!isLanChannel(channel).value_or(false)) |
| 1103 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 1104 | lg2::error("Set Lan - Not a LAN channel"); |
Jian Zhang | cf19d14 | 2023-07-31 10:22:53 +0800 | [diff] [blame] | 1105 | return responseInvalidFieldRequest(); |
| 1106 | } |
| 1107 | |
Johnathan Mantey | affadb5 | 2019-10-07 10:13:53 -0700 | [diff] [blame] | 1108 | static std::vector<uint8_t> cipherList; |
| 1109 | static bool listInit = false; |
| 1110 | if (!listInit) |
| 1111 | { |
| 1112 | try |
| 1113 | { |
| 1114 | cipherList = cipher::getCipherList(); |
| 1115 | listInit = true; |
| 1116 | } |
| 1117 | catch (const std::exception& e) |
Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 1118 | {} |
Johnathan Mantey | affadb5 | 2019-10-07 10:13:53 -0700 | [diff] [blame] | 1119 | } |
| 1120 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1121 | switch (static_cast<LanParam>(parameter)) |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 1122 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1123 | case LanParam::SetStatus: |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 1124 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1125 | SetStatus status; |
| 1126 | try |
| 1127 | { |
| 1128 | status = setStatus.at(channel); |
| 1129 | } |
| 1130 | catch (const std::out_of_range&) |
| 1131 | { |
| 1132 | status = SetStatus::Complete; |
| 1133 | } |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 1134 | ret.pack(types::enum_cast<uint2_t>(status), uint6_t{}); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1135 | return responseSuccess(std::move(ret)); |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 1136 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1137 | case LanParam::AuthSupport: |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 1138 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1139 | std::bitset<6> support; |
| 1140 | ret.pack(support, uint2_t{}); |
| 1141 | return responseSuccess(std::move(ret)); |
Tom Joseph | a30c8d3 | 2018-03-22 02:15:03 +0530 | [diff] [blame] | 1142 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1143 | case LanParam::AuthEnables: |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 1144 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1145 | std::bitset<6> enables; |
| 1146 | ret.pack(enables, uint2_t{}); // Callback |
| 1147 | ret.pack(enables, uint2_t{}); // User |
| 1148 | ret.pack(enables, uint2_t{}); // Operator |
| 1149 | ret.pack(enables, uint2_t{}); // Admin |
| 1150 | ret.pack(enables, uint2_t{}); // OEM |
| 1151 | return responseSuccess(std::move(ret)); |
William A. Kennington III | 39f94ef | 2018-11-19 22:36:16 -0800 | [diff] [blame] | 1152 | } |
William A. Kennington III | aab2023 | 2018-11-19 18:20:39 -0800 | [diff] [blame] | 1153 | case LanParam::IP: |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1154 | { |
| 1155 | auto ifaddr = channelCall<getIfAddr4>(channel); |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 1156 | stdplus::In4Addr addr{}; |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1157 | if (ifaddr) |
| 1158 | { |
| 1159 | addr = ifaddr->address; |
| 1160 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1161 | ret.pack(stdplus::raw::asView<char>(addr)); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1162 | return responseSuccess(std::move(ret)); |
| 1163 | } |
| 1164 | case LanParam::IPSrc: |
| 1165 | { |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 1166 | auto src = channelCall<getEthProp<bool>>(channel, "DHCP4") |
| 1167 | ? IPSrc::DHCP |
| 1168 | : IPSrc::Static; |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 1169 | ret.pack(types::enum_cast<uint4_t>(src), uint4_t{}); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1170 | return responseSuccess(std::move(ret)); |
| 1171 | } |
William A. Kennington III | aab2023 | 2018-11-19 18:20:39 -0800 | [diff] [blame] | 1172 | case LanParam::MAC: |
William A. Kennington III | 39f94ef | 2018-11-19 22:36:16 -0800 | [diff] [blame] | 1173 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 1174 | auto mac = channelCall<getMACProperty>(channel); |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1175 | ret.pack(stdplus::raw::asView<char>(mac)); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1176 | return responseSuccess(std::move(ret)); |
| 1177 | } |
| 1178 | case LanParam::SubnetMask: |
| 1179 | { |
| 1180 | auto ifaddr = channelCall<getIfAddr4>(channel); |
| 1181 | uint8_t prefix = AddrFamily<AF_INET>::defaultPrefix; |
| 1182 | if (ifaddr) |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 1183 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1184 | prefix = ifaddr->prefix; |
| 1185 | } |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 1186 | auto netmask = stdplus::pfxToMask<stdplus::In4Addr>(prefix); |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1187 | ret.pack(stdplus::raw::asView<char>(netmask)); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1188 | return responseSuccess(std::move(ret)); |
| 1189 | } |
| 1190 | case LanParam::Gateway1: |
| 1191 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 1192 | auto gateway = channelCall<getGatewayProperty<AF_INET>>(channel); |
| 1193 | ret.pack(stdplus::raw::asView<char>( |
| 1194 | gateway.value_or(stdplus::In4Addr{}))); |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1195 | return responseSuccess(std::move(ret)); |
| 1196 | } |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 1197 | case LanParam::Gateway1MAC: |
| 1198 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 1199 | stdplus::EtherAddr mac{}; |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 1200 | auto neighbor = channelCall<getGatewayNeighbor<AF_INET>>(channel); |
| 1201 | if (neighbor) |
| 1202 | { |
| 1203 | mac = neighbor->mac; |
| 1204 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1205 | ret.pack(stdplus::raw::asView<char>(mac)); |
William A. Kennington III | 4bbc3db | 2019-04-15 00:02:10 -0700 | [diff] [blame] | 1206 | return responseSuccess(std::move(ret)); |
| 1207 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1208 | case LanParam::VLANId: |
| 1209 | { |
| 1210 | uint16_t vlan = channelCall<getVLANProperty>(channel); |
| 1211 | if (vlan != 0) |
| 1212 | { |
| 1213 | vlan |= VLAN_ENABLE_FLAG; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 1214 | } |
| 1215 | else |
| 1216 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1217 | vlan = lastDisabledVlan[channel]; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 1218 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1219 | ret.pack(vlan); |
| 1220 | return responseSuccess(std::move(ret)); |
Adriana Kobylak | 342df10 | 2016-02-10 13:48:16 -0600 | [diff] [blame] | 1221 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1222 | case LanParam::CiphersuiteSupport: |
Johnathan Mantey | affadb5 | 2019-10-07 10:13:53 -0700 | [diff] [blame] | 1223 | { |
srikanta mondal | 1d8579c | 2020-04-15 17:13:25 +0000 | [diff] [blame] | 1224 | if (getChannelSessionSupport(channel) == |
| 1225 | EChannelSessSupported::none) |
| 1226 | { |
| 1227 | return responseInvalidFieldRequest(); |
| 1228 | } |
Johnathan Mantey | affadb5 | 2019-10-07 10:13:53 -0700 | [diff] [blame] | 1229 | if (!listInit) |
| 1230 | { |
| 1231 | return responseUnspecifiedError(); |
| 1232 | } |
| 1233 | ret.pack(static_cast<uint8_t>(cipherList.size() - 1)); |
| 1234 | return responseSuccess(std::move(ret)); |
| 1235 | } |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1236 | case LanParam::CiphersuiteEntries: |
Johnathan Mantey | affadb5 | 2019-10-07 10:13:53 -0700 | [diff] [blame] | 1237 | { |
srikanta mondal | 1d8579c | 2020-04-15 17:13:25 +0000 | [diff] [blame] | 1238 | if (getChannelSessionSupport(channel) == |
| 1239 | EChannelSessSupported::none) |
| 1240 | { |
| 1241 | return responseInvalidFieldRequest(); |
| 1242 | } |
Johnathan Mantey | affadb5 | 2019-10-07 10:13:53 -0700 | [diff] [blame] | 1243 | if (!listInit) |
| 1244 | { |
| 1245 | return responseUnspecifiedError(); |
| 1246 | } |
| 1247 | ret.pack(cipherList); |
| 1248 | return responseSuccess(std::move(ret)); |
| 1249 | } |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1250 | case LanParam::IPFamilySupport: |
| 1251 | { |
| 1252 | std::bitset<8> support; |
| 1253 | support[IPFamilySupportFlag::IPv6Only] = 0; |
| 1254 | support[IPFamilySupportFlag::DualStack] = 1; |
| 1255 | support[IPFamilySupportFlag::IPv6Alerts] = 1; |
| 1256 | ret.pack(support); |
| 1257 | return responseSuccess(std::move(ret)); |
| 1258 | } |
| 1259 | case LanParam::IPFamilyEnables: |
| 1260 | { |
| 1261 | ret.pack(static_cast<uint8_t>(IPFamilyEnables::DualStack)); |
| 1262 | return responseSuccess(std::move(ret)); |
| 1263 | } |
| 1264 | case LanParam::IPv6Status: |
| 1265 | { |
| 1266 | ret.pack(MAX_IPV6_STATIC_ADDRESSES); |
| 1267 | ret.pack(MAX_IPV6_DYNAMIC_ADDRESSES); |
| 1268 | std::bitset<8> support; |
| 1269 | support[IPv6StatusFlag::DHCP] = 1; |
| 1270 | support[IPv6StatusFlag::SLAAC] = 1; |
| 1271 | ret.pack(support); |
| 1272 | return responseSuccess(std::move(ret)); |
| 1273 | } |
| 1274 | case LanParam::IPv6StaticAddresses: |
| 1275 | { |
| 1276 | if (set >= MAX_IPV6_STATIC_ADDRESSES) |
| 1277 | { |
| 1278 | return responseParmOutOfRange(); |
| 1279 | } |
| 1280 | getLanIPv6Address(ret, channel, set, originsV6Static); |
| 1281 | return responseSuccess(std::move(ret)); |
| 1282 | } |
| 1283 | case LanParam::IPv6DynamicAddresses: |
| 1284 | { |
| 1285 | if (set >= MAX_IPV6_DYNAMIC_ADDRESSES) |
| 1286 | { |
| 1287 | return responseParmOutOfRange(); |
| 1288 | } |
| 1289 | getLanIPv6Address(ret, channel, set, originsV6Dynamic); |
| 1290 | return responseSuccess(std::move(ret)); |
| 1291 | } |
| 1292 | case LanParam::IPv6RouterControl: |
| 1293 | { |
| 1294 | std::bitset<8> control; |
Johnathan Mantey | 3b7a407 | 2021-01-26 14:24:53 -0800 | [diff] [blame] | 1295 | control[IPv6RouterControlFlag::Dynamic] = |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 1296 | channelCall<getEthProp<bool>>(channel, "IPv6AcceptRA"); |
Johnathan Mantey | 3b7a407 | 2021-01-26 14:24:53 -0800 | [diff] [blame] | 1297 | control[IPv6RouterControlFlag::Static] = 1; |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1298 | ret.pack(control); |
| 1299 | return responseSuccess(std::move(ret)); |
| 1300 | } |
| 1301 | case LanParam::IPv6StaticRouter1IP: |
| 1302 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 1303 | stdplus::In6Addr gateway{}; |
William A. Kennington III | a8a2e5f | 2023-06-21 17:50:01 -0700 | [diff] [blame] | 1304 | if (!channelCall<getEthProp<bool>>(channel, "IPv6AcceptRA")) |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1305 | { |
| 1306 | gateway = |
| 1307 | channelCall<getGatewayProperty<AF_INET6>>(channel).value_or( |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 1308 | stdplus::In6Addr{}); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1309 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1310 | ret.pack(stdplus::raw::asView<char>(gateway)); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1311 | return responseSuccess(std::move(ret)); |
| 1312 | } |
| 1313 | case LanParam::IPv6StaticRouter1MAC: |
| 1314 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 1315 | stdplus::EtherAddr mac{}; |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1316 | auto neighbor = channelCall<getGatewayNeighbor<AF_INET6>>(channel); |
| 1317 | if (neighbor) |
| 1318 | { |
| 1319 | mac = neighbor->mac; |
| 1320 | } |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 1321 | ret.pack(stdplus::raw::asView<char>(mac)); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1322 | return responseSuccess(std::move(ret)); |
| 1323 | } |
| 1324 | case LanParam::IPv6StaticRouter1PrefixLength: |
| 1325 | { |
Jian Zhang | 796e824 | 2024-02-01 14:07:34 +0800 | [diff] [blame] | 1326 | ret.pack(uint8_t{0}); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1327 | return responseSuccess(std::move(ret)); |
| 1328 | } |
| 1329 | case LanParam::IPv6StaticRouter1PrefixValue: |
| 1330 | { |
William A. Kennington III | 726f2bd | 2023-06-21 01:11:40 -0700 | [diff] [blame] | 1331 | ret.pack(stdplus::raw::asView<char>(stdplus::In6Addr{})); |
William A. Kennington III | 16064aa | 2019-04-13 17:44:53 -0700 | [diff] [blame] | 1332 | return responseSuccess(std::move(ret)); |
| 1333 | } |
jayaprakash Mutyala | b741b99 | 2019-12-02 17:29:09 +0000 | [diff] [blame] | 1334 | case LanParam::cipherSuitePrivilegeLevels: |
| 1335 | { |
| 1336 | std::array<uint4_t, ipmi::maxCSRecords> csPrivilegeLevels; |
| 1337 | |
| 1338 | uint8_t resp = |
| 1339 | getCipherConfigObject(csPrivFileName, csPrivDefaultFileName) |
| 1340 | .getCSPrivilegeLevels(channel, csPrivilegeLevels); |
| 1341 | if (!resp) |
| 1342 | { |
| 1343 | constexpr uint8_t reserved1 = 0x00; |
| 1344 | ret.pack(reserved1, csPrivilegeLevels); |
| 1345 | return responseSuccess(std::move(ret)); |
| 1346 | } |
| 1347 | else |
| 1348 | { |
| 1349 | return response(resp); |
| 1350 | } |
| 1351 | } |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 1352 | } |
| 1353 | |
PavanKumarIntel | 3771f5f | 2023-11-02 06:26:42 +0000 | [diff] [blame] | 1354 | if (parameter >= oemCmdStart) |
Johnathan Mantey | b87034e | 2019-09-16 10:50:50 -0700 | [diff] [blame] | 1355 | { |
| 1356 | return getLanOem(channel, parameter, set, block); |
| 1357 | } |
| 1358 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1359 | return response(ccParamNotSupported); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 1360 | } |
| 1361 | |
Jian Zhang | 23f4465 | 2022-03-17 17:13:10 +0800 | [diff] [blame] | 1362 | constexpr const char* solInterface = "xyz.openbmc_project.Ipmi.SOL"; |
| 1363 | constexpr const char* solPath = "/xyz/openbmc_project/ipmi/sol/"; |
| 1364 | constexpr const uint16_t solDefaultPort = 623; |
| 1365 | |
| 1366 | RspType<> setSolConfParams(Context::ptr ctx, uint4_t channelBits, |
Willy Tu | 11d6889 | 2022-01-20 10:37:34 -0800 | [diff] [blame] | 1367 | uint4_t /*reserved*/, uint8_t parameter, |
Jian Zhang | 23f4465 | 2022-03-17 17:13:10 +0800 | [diff] [blame] | 1368 | message::Payload& req) |
| 1369 | { |
| 1370 | const uint8_t channel = convertCurrentChannelNum( |
| 1371 | static_cast<uint8_t>(channelBits), ctx->channel); |
| 1372 | |
| 1373 | if (!isValidChannel(channel)) |
| 1374 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 1375 | lg2::error("Set Sol Config - Invalid channel in request"); |
Jian Zhang | 23f4465 | 2022-03-17 17:13:10 +0800 | [diff] [blame] | 1376 | return responseInvalidFieldRequest(); |
| 1377 | } |
| 1378 | |
| 1379 | std::string solService{}; |
| 1380 | std::string solPathWitheEthName = solPath + ipmi::getChannelName(channel); |
| 1381 | |
| 1382 | if (ipmi::getService(ctx, solInterface, solPathWitheEthName, solService)) |
| 1383 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 1384 | lg2::error("Set Sol Config - Invalid solInterface, service: {SERVICE}, " |
| 1385 | "object path: {OBJPATH}, interface: {INTERFACE}", |
| 1386 | "SERVICE", solService, "OBJPATH", solPathWitheEthName, |
| 1387 | "INTERFACE", solInterface); |
Jian Zhang | 23f4465 | 2022-03-17 17:13:10 +0800 | [diff] [blame] | 1388 | return responseInvalidFieldRequest(); |
| 1389 | } |
| 1390 | |
| 1391 | switch (static_cast<SolConfParam>(parameter)) |
| 1392 | { |
| 1393 | case SolConfParam::Progress: |
| 1394 | { |
| 1395 | uint8_t progress; |
| 1396 | if (req.unpack(progress) != 0 || !req.fullyUnpacked()) |
| 1397 | { |
| 1398 | return responseReqDataLenInvalid(); |
| 1399 | } |
| 1400 | |
| 1401 | if (ipmi::setDbusProperty(ctx, solService, solPathWitheEthName, |
| 1402 | solInterface, "Progress", progress)) |
| 1403 | { |
| 1404 | return responseUnspecifiedError(); |
| 1405 | } |
| 1406 | break; |
| 1407 | } |
| 1408 | case SolConfParam::Enable: |
| 1409 | { |
| 1410 | bool enable; |
| 1411 | uint7_t reserved2; |
| 1412 | |
| 1413 | if (req.unpack(enable, reserved2) != 0 || !req.fullyUnpacked()) |
| 1414 | { |
| 1415 | return responseReqDataLenInvalid(); |
| 1416 | } |
| 1417 | |
| 1418 | if (ipmi::setDbusProperty(ctx, solService, solPathWitheEthName, |
| 1419 | solInterface, "Enable", enable)) |
| 1420 | { |
| 1421 | return responseUnspecifiedError(); |
| 1422 | } |
| 1423 | break; |
| 1424 | } |
| 1425 | case SolConfParam::Authentication: |
| 1426 | { |
| 1427 | uint4_t privilegeBits{}; |
| 1428 | uint2_t reserved2{}; |
| 1429 | bool forceAuth = false; |
| 1430 | bool forceEncrypt = false; |
| 1431 | |
| 1432 | if (req.unpack(privilegeBits, reserved2, forceAuth, forceEncrypt) != |
| 1433 | 0 || |
| 1434 | !req.fullyUnpacked()) |
| 1435 | { |
| 1436 | return responseReqDataLenInvalid(); |
| 1437 | } |
| 1438 | |
| 1439 | uint8_t privilege = static_cast<uint8_t>(privilegeBits); |
Jonathan Doman | a48bf77 | 2023-05-26 17:54:57 -0700 | [diff] [blame] | 1440 | if (privilege < static_cast<uint8_t>(Privilege::User) || |
Jian Zhang | 23f4465 | 2022-03-17 17:13:10 +0800 | [diff] [blame] | 1441 | privilege > static_cast<uint8_t>(Privilege::Oem)) |
| 1442 | { |
| 1443 | return ipmi::responseInvalidFieldRequest(); |
| 1444 | } |
| 1445 | |
| 1446 | if (ipmi::setDbusProperty(ctx, solService, solPathWitheEthName, |
| 1447 | solInterface, "Privilege", privilege)) |
| 1448 | { |
| 1449 | return responseUnspecifiedError(); |
| 1450 | } |
| 1451 | |
| 1452 | if (ipmi::setDbusProperty(ctx, solService, solPathWitheEthName, |
| 1453 | solInterface, "ForceEncryption", |
| 1454 | forceEncrypt)) |
| 1455 | { |
| 1456 | return responseUnspecifiedError(); |
| 1457 | } |
| 1458 | |
| 1459 | if (ipmi::setDbusProperty(ctx, solService, solPathWitheEthName, |
| 1460 | solInterface, "ForceAuthentication", |
| 1461 | forceAuth)) |
| 1462 | { |
| 1463 | return responseUnspecifiedError(); |
| 1464 | } |
| 1465 | break; |
| 1466 | } |
| 1467 | case SolConfParam::Accumulate: |
| 1468 | { |
| 1469 | uint8_t interval; |
| 1470 | uint8_t threshold; |
| 1471 | if (req.unpack(interval, threshold) != 0 || !req.fullyUnpacked()) |
| 1472 | { |
| 1473 | return responseReqDataLenInvalid(); |
| 1474 | } |
| 1475 | |
| 1476 | if (threshold == 0) |
| 1477 | { |
| 1478 | return responseInvalidFieldRequest(); |
| 1479 | } |
| 1480 | |
| 1481 | if (ipmi::setDbusProperty(ctx, solService, solPathWitheEthName, |
| 1482 | solInterface, "AccumulateIntervalMS", |
| 1483 | interval)) |
| 1484 | { |
| 1485 | return responseUnspecifiedError(); |
| 1486 | } |
| 1487 | |
| 1488 | if (ipmi::setDbusProperty(ctx, solService, solPathWitheEthName, |
| 1489 | solInterface, "Threshold", threshold)) |
| 1490 | { |
| 1491 | return responseUnspecifiedError(); |
| 1492 | } |
| 1493 | break; |
| 1494 | } |
| 1495 | case SolConfParam::Retry: |
| 1496 | { |
| 1497 | uint3_t countBits; |
| 1498 | uint5_t reserved2; |
| 1499 | uint8_t interval; |
| 1500 | |
| 1501 | if (req.unpack(countBits, reserved2, interval) != 0 || |
| 1502 | !req.fullyUnpacked()) |
| 1503 | { |
| 1504 | return responseReqDataLenInvalid(); |
| 1505 | } |
| 1506 | |
| 1507 | uint8_t count = static_cast<uint8_t>(countBits); |
| 1508 | if (ipmi::setDbusProperty(ctx, solService, solPathWitheEthName, |
| 1509 | solInterface, "RetryCount", count)) |
| 1510 | { |
| 1511 | return responseUnspecifiedError(); |
| 1512 | } |
| 1513 | |
| 1514 | if (ipmi::setDbusProperty(ctx, solService, solPathWitheEthName, |
| 1515 | solInterface, "RetryIntervalMS", |
| 1516 | interval)) |
| 1517 | { |
| 1518 | return responseUnspecifiedError(); |
| 1519 | } |
| 1520 | break; |
| 1521 | } |
| 1522 | case SolConfParam::Port: |
| 1523 | { |
| 1524 | return response(ipmiCCWriteReadParameter); |
| 1525 | } |
| 1526 | case SolConfParam::NonVbitrate: |
| 1527 | case SolConfParam::Vbitrate: |
| 1528 | case SolConfParam::Channel: |
| 1529 | default: |
| 1530 | return response(ipmiCCParamNotSupported); |
| 1531 | } |
| 1532 | return responseSuccess(); |
| 1533 | } |
| 1534 | |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame^] | 1535 | RspType<message::Payload> getSolConfParams( |
| 1536 | Context::ptr ctx, uint4_t channelBits, uint3_t /*reserved*/, bool revOnly, |
| 1537 | uint8_t parameter, uint8_t /*set*/, uint8_t /*block*/) |
Jian Zhang | 23f4465 | 2022-03-17 17:13:10 +0800 | [diff] [blame] | 1538 | { |
| 1539 | message::Payload ret; |
| 1540 | constexpr uint8_t current_revision = 0x11; |
| 1541 | ret.pack(current_revision); |
| 1542 | if (revOnly) |
| 1543 | { |
| 1544 | return responseSuccess(std::move(ret)); |
| 1545 | } |
| 1546 | |
| 1547 | const uint8_t channel = convertCurrentChannelNum( |
| 1548 | static_cast<uint8_t>(channelBits), ctx->channel); |
| 1549 | |
| 1550 | if (!isValidChannel(channel)) |
| 1551 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 1552 | lg2::error("Get Sol Config - Invalid channel in request"); |
Jian Zhang | 23f4465 | 2022-03-17 17:13:10 +0800 | [diff] [blame] | 1553 | return responseInvalidFieldRequest(); |
| 1554 | } |
| 1555 | |
| 1556 | std::string solService{}; |
| 1557 | std::string solPathWitheEthName = solPath + ipmi::getChannelName(channel); |
| 1558 | |
| 1559 | if (ipmi::getService(ctx, solInterface, solPathWitheEthName, solService)) |
| 1560 | { |
George Liu | 32e8f5d | 2024-07-17 19:52:25 +0800 | [diff] [blame] | 1561 | lg2::error("Set Sol Config - Invalid solInterface, service: {SERVICE}, " |
| 1562 | "object path: {OBJPATH}, interface: {INTERFACE}", |
| 1563 | "SERVICE", solService, "OBJPATH", solPathWitheEthName, |
| 1564 | "INTERFACE", solInterface); |
Jian Zhang | 23f4465 | 2022-03-17 17:13:10 +0800 | [diff] [blame] | 1565 | return responseInvalidFieldRequest(); |
| 1566 | } |
| 1567 | |
| 1568 | switch (static_cast<SolConfParam>(parameter)) |
| 1569 | { |
| 1570 | case SolConfParam::Progress: |
| 1571 | { |
| 1572 | uint8_t progress; |
| 1573 | if (ipmi::getDbusProperty(ctx, solService, solPathWitheEthName, |
| 1574 | solInterface, "Progress", progress)) |
| 1575 | { |
| 1576 | return responseUnspecifiedError(); |
| 1577 | } |
| 1578 | ret.pack(progress); |
| 1579 | return responseSuccess(std::move(ret)); |
| 1580 | } |
| 1581 | case SolConfParam::Enable: |
| 1582 | { |
| 1583 | bool enable{}; |
| 1584 | if (ipmi::getDbusProperty(ctx, solService, solPathWitheEthName, |
| 1585 | solInterface, "Enable", enable)) |
| 1586 | { |
| 1587 | return responseUnspecifiedError(); |
| 1588 | } |
| 1589 | ret.pack(enable, uint7_t{}); |
| 1590 | return responseSuccess(std::move(ret)); |
| 1591 | } |
| 1592 | case SolConfParam::Authentication: |
| 1593 | { |
| 1594 | // 4bits, cast when pack |
| 1595 | uint8_t privilege; |
| 1596 | bool forceAuth = false; |
| 1597 | bool forceEncrypt = false; |
| 1598 | |
| 1599 | if (ipmi::getDbusProperty(ctx, solService, solPathWitheEthName, |
| 1600 | solInterface, "Privilege", privilege)) |
| 1601 | { |
| 1602 | return responseUnspecifiedError(); |
| 1603 | } |
| 1604 | |
| 1605 | if (ipmi::getDbusProperty(ctx, solService, solPathWitheEthName, |
| 1606 | solInterface, "ForceAuthentication", |
| 1607 | forceAuth)) |
| 1608 | { |
| 1609 | return responseUnspecifiedError(); |
| 1610 | } |
| 1611 | |
| 1612 | if (ipmi::getDbusProperty(ctx, solService, solPathWitheEthName, |
| 1613 | solInterface, "ForceEncryption", |
| 1614 | forceEncrypt)) |
| 1615 | { |
| 1616 | return responseUnspecifiedError(); |
| 1617 | } |
| 1618 | ret.pack(uint4_t{privilege}, uint2_t{}, forceAuth, forceEncrypt); |
| 1619 | return responseSuccess(std::move(ret)); |
| 1620 | } |
| 1621 | case SolConfParam::Accumulate: |
| 1622 | { |
| 1623 | uint8_t interval{}, threshold{}; |
| 1624 | |
| 1625 | if (ipmi::getDbusProperty(ctx, solService, solPathWitheEthName, |
| 1626 | solInterface, "AccumulateIntervalMS", |
| 1627 | interval)) |
| 1628 | { |
| 1629 | return responseUnspecifiedError(); |
| 1630 | } |
| 1631 | |
| 1632 | if (ipmi::getDbusProperty(ctx, solService, solPathWitheEthName, |
| 1633 | solInterface, "Threshold", threshold)) |
| 1634 | { |
| 1635 | return responseUnspecifiedError(); |
| 1636 | } |
| 1637 | ret.pack(interval, threshold); |
| 1638 | return responseSuccess(std::move(ret)); |
| 1639 | } |
| 1640 | case SolConfParam::Retry: |
| 1641 | { |
| 1642 | // 3bits, cast when cast |
| 1643 | uint8_t count{}; |
| 1644 | uint8_t interval{}; |
| 1645 | |
| 1646 | if (ipmi::getDbusProperty(ctx, solService, solPathWitheEthName, |
| 1647 | solInterface, "RetryCount", count)) |
| 1648 | { |
| 1649 | return responseUnspecifiedError(); |
| 1650 | } |
| 1651 | |
| 1652 | if (ipmi::getDbusProperty(ctx, solService, solPathWitheEthName, |
| 1653 | solInterface, "RetryIntervalMS", |
| 1654 | interval)) |
| 1655 | { |
| 1656 | return responseUnspecifiedError(); |
| 1657 | } |
| 1658 | ret.pack(uint3_t{count}, uint5_t{}, interval); |
| 1659 | return responseSuccess(std::move(ret)); |
| 1660 | } |
| 1661 | case SolConfParam::Port: |
| 1662 | { |
| 1663 | auto port = solDefaultPort; |
| 1664 | ret.pack(static_cast<uint16_t>(port)); |
| 1665 | return responseSuccess(std::move(ret)); |
| 1666 | } |
| 1667 | case SolConfParam::Channel: |
| 1668 | { |
| 1669 | ret.pack(channel); |
| 1670 | return responseSuccess(std::move(ret)); |
| 1671 | } |
| 1672 | case SolConfParam::NonVbitrate: |
Jonathan Doman | a48bf77 | 2023-05-26 17:54:57 -0700 | [diff] [blame] | 1673 | { |
| 1674 | uint64_t baudRate; |
| 1675 | uint8_t encodedBitRate = 0; |
| 1676 | if (ipmi::getDbusProperty( |
| 1677 | ctx, "xyz.openbmc_project.Console.default", |
| 1678 | "/xyz/openbmc_project/console/default", |
| 1679 | "xyz.openbmc_project.Console.UART", "Baud", baudRate)) |
| 1680 | { |
| 1681 | return ipmi::responseUnspecifiedError(); |
| 1682 | } |
| 1683 | switch (baudRate) |
| 1684 | { |
| 1685 | case 9600: |
| 1686 | encodedBitRate = 0x06; |
| 1687 | break; |
| 1688 | case 19200: |
| 1689 | encodedBitRate = 0x07; |
| 1690 | break; |
| 1691 | case 38400: |
| 1692 | encodedBitRate = 0x08; |
| 1693 | break; |
| 1694 | case 57600: |
| 1695 | encodedBitRate = 0x09; |
| 1696 | break; |
| 1697 | case 115200: |
| 1698 | encodedBitRate = 0x0a; |
| 1699 | break; |
| 1700 | default: |
| 1701 | break; |
| 1702 | } |
| 1703 | ret.pack(encodedBitRate); |
| 1704 | return responseSuccess(std::move(ret)); |
| 1705 | } |
Jian Zhang | 23f4465 | 2022-03-17 17:13:10 +0800 | [diff] [blame] | 1706 | case SolConfParam::Vbitrate: |
| 1707 | default: |
| 1708 | return response(ipmiCCParamNotSupported); |
| 1709 | } |
| 1710 | |
| 1711 | return response(ccParamNotSupported); |
| 1712 | } |
| 1713 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1714 | } // namespace transport |
| 1715 | } // namespace ipmi |
Ratan Gupta | 1247e0b | 2018-03-07 10:47:25 +0530 | [diff] [blame] | 1716 | |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1717 | void register_netfn_transport_functions() __attribute__((constructor)); |
Ratan Gupta | 1247e0b | 2018-03-07 10:47:25 +0530 | [diff] [blame] | 1718 | |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 1719 | void register_netfn_transport_functions() |
| 1720 | { |
William A. Kennington III | c514d87 | 2019-04-06 18:19:38 -0700 | [diff] [blame] | 1721 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnTransport, |
| 1722 | ipmi::transport::cmdSetLanConfigParameters, |
| 1723 | ipmi::Privilege::Admin, ipmi::transport::setLan); |
| 1724 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnTransport, |
| 1725 | ipmi::transport::cmdGetLanConfigParameters, |
Johnathan Mantey | 34698d5 | 2019-11-19 14:47:30 -0800 | [diff] [blame] | 1726 | ipmi::Privilege::Operator, ipmi::transport::getLan); |
Jian Zhang | 23f4465 | 2022-03-17 17:13:10 +0800 | [diff] [blame] | 1727 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnTransport, |
| 1728 | ipmi::transport::cmdSetSolConfigParameters, |
| 1729 | ipmi::Privilege::Admin, |
| 1730 | ipmi::transport::setSolConfParams); |
| 1731 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnTransport, |
| 1732 | ipmi::transport::cmdGetSolConfigParameters, |
| 1733 | ipmi::Privilege::User, |
| 1734 | ipmi::transport::getSolConfParams); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 1735 | } |