Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <string.h> |
| 3 | #include <stdint.h> |
Hariharasubramanian R | 8395191 | 2016-01-20 07:06:36 -0600 | [diff] [blame] | 4 | #include <arpa/inet.h> |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 5 | #include <string> |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 6 | #include <experimental/filesystem> |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 7 | |
Patrick Williams | 37af733 | 2016-09-02 21:21:42 -0500 | [diff] [blame] | 8 | #include "host-ipmid/ipmid-api.h" |
Patrick Williams | 53a360e | 2016-08-12 22:01:02 -0500 | [diff] [blame] | 9 | #include "ipmid.hpp" |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 10 | #include "transporthandler.hpp" |
| 11 | #include "utils.hpp" |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 12 | #include "net.hpp" |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 13 | |
| 14 | #include <phosphor-logging/log.hpp> |
| 15 | #include <phosphor-logging/elog-errors.hpp> |
| 16 | #include "xyz/openbmc_project/Common/error.hpp" |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 17 | |
Hariharasubramanian R | 8395191 | 2016-01-20 07:06:36 -0600 | [diff] [blame] | 18 | #define SYSTEMD_NETWORKD_DBUS 1 |
| 19 | |
| 20 | #ifdef SYSTEMD_NETWORKD_DBUS |
| 21 | #include <systemd/sd-bus.h> |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 22 | #include <mapper.h> |
Hariharasubramanian R | 8395191 | 2016-01-20 07:06:36 -0600 | [diff] [blame] | 23 | #endif |
| 24 | |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 25 | const int SIZE_MAC = 18; //xx:xx:xx:xx:xx:xx |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 26 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 27 | std::map<int, std::unique_ptr<struct ChannelConfig_t>> channelConfig; |
Hariharasubramanian R | 8395191 | 2016-01-20 07:06:36 -0600 | [diff] [blame] | 28 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 29 | using namespace phosphor::logging; |
| 30 | using namespace sdbusplus::xyz::openbmc_project::Common::Error; |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 31 | namespace fs = std::experimental::filesystem; |
Hariharasubramanian R | 8395191 | 2016-01-20 07:06:36 -0600 | [diff] [blame] | 32 | |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 33 | void register_netfn_transport_functions() __attribute__((constructor)); |
| 34 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 35 | struct ChannelConfig_t* getChannelConfig(int channel) |
| 36 | { |
| 37 | auto item = channelConfig.find(channel); |
| 38 | if (item == channelConfig.end()) |
| 39 | { |
| 40 | channelConfig[channel] = std::make_unique<struct ChannelConfig_t>(); |
| 41 | } |
| 42 | |
| 43 | return channelConfig[channel].get(); |
| 44 | } |
| 45 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 46 | // Helper Function to get IP Address/NetMask/Gateway/MAC Address from Network Manager or |
Nan Li | 3d0df91 | 2016-10-18 19:51:41 +0800 | [diff] [blame] | 47 | // Cache based on Set-In-Progress State |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 48 | ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data, int channel) |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 49 | { |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 50 | ipmi_ret_t rc = IPMI_CC_OK; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 51 | sdbusplus::bus::bus bus(ipmid_get_sd_bus_connection()); |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 52 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 53 | auto ethdevice = ipmi::network::ChanneltoEthernet(channel); |
| 54 | // if ethdevice is an empty string they weren't expecting this channel. |
| 55 | if (ethdevice.empty()) |
| 56 | { |
| 57 | // TODO: return error from getNetworkData() |
| 58 | return IPMI_CC_INVALID_FIELD_REQUEST; |
| 59 | } |
| 60 | auto ethIP = ethdevice + "/" + ipmi::network::IP_TYPE; |
| 61 | auto channelConf = getChannelConfig(channel); |
| 62 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 63 | try |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 64 | { |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 65 | switch (lan_param) |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 66 | { |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 67 | case LAN_PARM_IP: |
| 68 | { |
| 69 | std::string ipaddress; |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 70 | if (channelConf->lan_set_in_progress == SET_COMPLETE) |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 71 | { |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 72 | try |
| 73 | { |
Ratan Gupta | dd64620 | 2017-11-21 17:46:59 +0530 | [diff] [blame] | 74 | auto ipObjectInfo = ipmi::getIPObject( |
| 75 | bus, |
| 76 | ipmi::network::IP_INTERFACE, |
| 77 | ipmi::network::ROOT, |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 78 | ethIP); |
Ratan Gupta | dd64620 | 2017-11-21 17:46:59 +0530 | [diff] [blame] | 79 | |
| 80 | auto properties = ipmi::getAllDbusProperties( |
| 81 | bus, |
| 82 | ipObjectInfo.second, |
| 83 | ipObjectInfo.first, |
| 84 | ipmi::network::IP_INTERFACE); |
| 85 | |
| 86 | ipaddress = properties["Address"].get<std::string>(); |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 87 | } |
| 88 | // ignore the exception, as it is a valid condtion that |
| 89 | // system is not confiured with any ip. |
| 90 | catch (InternalFailure& e) |
| 91 | { |
| 92 | // nothing to do. |
| 93 | } |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 94 | } |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 95 | else if (channelConf->lan_set_in_progress == SET_IN_PROGRESS) |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 96 | { |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 97 | ipaddress = channelConf->ipaddr; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | inet_pton(AF_INET, ipaddress.c_str(), |
| 101 | reinterpret_cast<void*>(data)); |
| 102 | } |
| 103 | break; |
| 104 | |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 105 | case LAN_PARM_IPSRC: |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 106 | { |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 107 | std::string networkInterfacePath; |
| 108 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 109 | if (channelConf->lan_set_in_progress == SET_COMPLETE) |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 110 | { |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 111 | try |
| 112 | { |
| 113 | ipmi::ObjectTree ancestorMap; |
| 114 | // if the system is having ip object,then |
| 115 | // get the IP object. |
| 116 | auto ipObject = ipmi::getDbusObject( |
| 117 | bus, |
| 118 | ipmi::network::IP_INTERFACE, |
| 119 | ipmi::network::ROOT, |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 120 | ethIP); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 121 | |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 122 | // Get the parent interface of the IP object. |
| 123 | try |
| 124 | { |
| 125 | ipmi::InterfaceList interfaces; |
| 126 | interfaces.emplace_back( |
| 127 | ipmi::network::ETHERNET_INTERFACE); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 128 | |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 129 | ancestorMap = ipmi::getAllAncestors( |
| 130 | bus, |
| 131 | ipObject.first, |
| 132 | std::move(interfaces)); |
| 133 | } |
| 134 | catch (InternalFailure& e) |
| 135 | { |
| 136 | // if unable to get the parent interface |
| 137 | // then commit the error and return. |
| 138 | log<level::ERR>("Unable to get the parent interface", |
| 139 | entry("PATH=%s", ipObject.first.c_str()), |
| 140 | entry("INTERFACE=%s", |
| 141 | ipmi::network::ETHERNET_INTERFACE)); |
| 142 | break; |
| 143 | |
| 144 | } |
| 145 | // for an ip object there would be single parent |
| 146 | // interface. |
| 147 | networkInterfacePath = ancestorMap.begin()->first; |
| 148 | } |
| 149 | catch (InternalFailure& e) |
| 150 | { |
| 151 | // if there is no ip configured on the system,then |
| 152 | // get the network interface object. |
| 153 | auto networkInterfaceObject = ipmi::getDbusObject( |
| 154 | bus, |
| 155 | ipmi::network::ETHERNET_INTERFACE, |
| 156 | ipmi::network::ROOT, |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 157 | ethdevice); |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 158 | |
| 159 | networkInterfacePath = networkInterfaceObject.first; |
| 160 | } |
| 161 | |
| 162 | auto variant = ipmi::getDbusProperty( |
| 163 | bus, |
| 164 | ipmi::network::SERVICE, |
| 165 | networkInterfacePath, |
| 166 | ipmi::network::ETHERNET_INTERFACE, |
| 167 | "DHCPEnabled"); |
| 168 | |
| 169 | auto dhcpEnabled = variant.get<bool>(); |
| 170 | // As per IPMI spec 2=>DHCP, 1=STATIC |
| 171 | auto ipsrc = dhcpEnabled ? ipmi::network::IPOrigin::DHCP : |
| 172 | ipmi::network::IPOrigin::STATIC; |
| 173 | |
| 174 | memcpy(data, &ipsrc, ipmi::network::IPSRC_SIZE_BYTE); |
| 175 | } |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 176 | else if (channelConf->lan_set_in_progress == SET_IN_PROGRESS) |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 177 | { |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 178 | memcpy(data, &(channelConf->ipsrc), |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 179 | ipmi::network::IPSRC_SIZE_BYTE); |
| 180 | } |
| 181 | } |
| 182 | break; |
| 183 | |
| 184 | case LAN_PARM_SUBNET: |
| 185 | { |
| 186 | unsigned long mask {}; |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 187 | if (channelConf->lan_set_in_progress == SET_COMPLETE) |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 188 | { |
| 189 | try |
| 190 | { |
Ratan Gupta | dd64620 | 2017-11-21 17:46:59 +0530 | [diff] [blame] | 191 | auto ipObjectInfo = ipmi::getIPObject( |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 192 | bus, |
| 193 | ipmi::network::IP_INTERFACE, |
| 194 | ipmi::network::ROOT, |
| 195 | ipmi::network::IP_TYPE); |
| 196 | |
| 197 | auto properties = ipmi::getAllDbusProperties( |
| 198 | bus, |
| 199 | ipObjectInfo.second, |
| 200 | ipObjectInfo.first, |
| 201 | ipmi::network::IP_INTERFACE); |
| 202 | |
| 203 | auto prefix = properties["PrefixLength"].get<uint8_t>(); |
| 204 | mask = ipmi::network::MASK_32_BIT; |
| 205 | mask = htonl(mask << (ipmi::network::BITS_32 - prefix)); |
| 206 | } |
| 207 | // ignore the exception, as it is a valid condtion that |
| 208 | // system is not confiured with any ip. |
| 209 | catch (InternalFailure& e) |
| 210 | { |
| 211 | // nothing to do |
| 212 | } |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 213 | memcpy(data, &mask, ipmi::network::IPV4_ADDRESS_SIZE_BYTE); |
| 214 | } |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 215 | else if (channelConf->lan_set_in_progress == SET_IN_PROGRESS) |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 216 | { |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 217 | inet_pton(AF_INET, channelConf->netmask.c_str(), |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 218 | reinterpret_cast<void*>(data)); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | } |
| 222 | break; |
| 223 | |
| 224 | case LAN_PARM_GATEWAY: |
| 225 | { |
| 226 | std::string gateway; |
| 227 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 228 | if (channelConf->lan_set_in_progress == SET_COMPLETE) |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 229 | { |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 230 | try |
| 231 | { |
| 232 | auto systemObject = ipmi::getDbusObject( |
| 233 | bus, |
| 234 | ipmi::network::SYSTEMCONFIG_INTERFACE, |
| 235 | ipmi::network::ROOT); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 236 | |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 237 | auto systemProperties = ipmi::getAllDbusProperties( |
| 238 | bus, |
| 239 | systemObject.second, |
| 240 | systemObject.first, |
| 241 | ipmi::network::SYSTEMCONFIG_INTERFACE); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 242 | |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 243 | gateway = systemProperties["DefaultGateway"].get< |
| 244 | std::string>(); |
| 245 | } |
| 246 | // ignore the exception, as it is a valid condtion that |
| 247 | // system is not confiured with any ip. |
| 248 | catch (InternalFailure& e) |
| 249 | { |
| 250 | // nothing to do |
| 251 | } |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 252 | |
| 253 | } |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 254 | else if (channelConf->lan_set_in_progress == SET_IN_PROGRESS) |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 255 | { |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 256 | gateway = channelConf->gateway; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | inet_pton(AF_INET, gateway.c_str(), |
| 260 | reinterpret_cast<void*>(data)); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 261 | } |
| 262 | break; |
| 263 | |
| 264 | case LAN_PARM_MAC: |
| 265 | { |
| 266 | std::string macAddress; |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 267 | if (channelConf->lan_set_in_progress == SET_COMPLETE) |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 268 | { |
| 269 | auto macObjectInfo = ipmi::getDbusObject( |
| 270 | bus, |
| 271 | ipmi::network::MAC_INTERFACE, |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 272 | ipmi::network::ROOT, |
| 273 | ethdevice); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 274 | |
| 275 | auto variant = ipmi::getDbusProperty( |
| 276 | bus, |
| 277 | macObjectInfo.second, |
| 278 | macObjectInfo.first, |
| 279 | ipmi::network::MAC_INTERFACE, |
| 280 | "MACAddress"); |
| 281 | |
| 282 | macAddress = variant.get<std::string>(); |
| 283 | |
| 284 | } |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 285 | else if (channelConf->lan_set_in_progress == SET_IN_PROGRESS) |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 286 | { |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 287 | macAddress = channelConf->macAddress; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | sscanf(macAddress.c_str(), ipmi::network::MAC_ADDRESS_FORMAT, |
| 291 | (data), |
| 292 | (data + 1), |
| 293 | (data + 2), |
| 294 | (data + 3), |
| 295 | (data + 4), |
| 296 | (data + 5)); |
| 297 | } |
| 298 | break; |
| 299 | |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 300 | case LAN_PARM_VLAN: |
| 301 | { |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 302 | uint16_t vlanID {}; |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 303 | if (channelConf->lan_set_in_progress == SET_COMPLETE) |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 304 | { |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 305 | try |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 306 | { |
Ratan Gupta | dd64620 | 2017-11-21 17:46:59 +0530 | [diff] [blame] | 307 | auto ipObjectInfo = ipmi::getIPObject( |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 308 | bus, |
| 309 | ipmi::network::IP_INTERFACE, |
| 310 | ipmi::network::ROOT, |
| 311 | ipmi::network::IP_TYPE); |
| 312 | |
| 313 | vlanID = static_cast<uint16_t>( |
| 314 | ipmi::network::getVLAN(ipObjectInfo.first)); |
| 315 | |
| 316 | vlanID = htole16(vlanID); |
| 317 | |
| 318 | if (vlanID) |
| 319 | { |
| 320 | //Enable the 16th bit |
| 321 | vlanID |= htole16(ipmi::network::VLAN_ENABLE_MASK); |
| 322 | } |
| 323 | } |
| 324 | // ignore the exception, as it is a valid condtion that |
| 325 | // system is not confiured with any ip. |
| 326 | catch (InternalFailure& e) |
| 327 | { |
| 328 | // nothing to do |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | memcpy(data, &vlanID, ipmi::network::VLAN_SIZE_BYTE); |
| 332 | } |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 333 | else if (channelConf->lan_set_in_progress == SET_IN_PROGRESS) |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 334 | { |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 335 | memcpy(data, &(channelConf->vlanID), |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 336 | ipmi::network::VLAN_SIZE_BYTE); |
| 337 | } |
| 338 | } |
| 339 | break; |
| 340 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 341 | default: |
| 342 | rc = IPMI_CC_PARM_OUT_OF_RANGE; |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 343 | } |
| 344 | } |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 345 | catch (InternalFailure& e) |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 346 | { |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 347 | commit<InternalFailure>(); |
| 348 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
| 349 | return rc; |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 350 | } |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 351 | return rc; |
| 352 | } |
| 353 | |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 354 | ipmi_ret_t ipmi_transport_wildcard(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 355 | ipmi_request_t request, ipmi_response_t response, |
| 356 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 357 | { |
| 358 | printf("Handling TRANSPORT WILDCARD Netfn:[0x%X], Cmd:[0x%X]\n",netfn, cmd); |
| 359 | // Status code. |
Nan Li | 70aa8d9 | 2016-08-29 00:11:10 +0800 | [diff] [blame] | 360 | ipmi_ret_t rc = IPMI_CC_INVALID; |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 361 | *data_len = 0; |
| 362 | return rc; |
| 363 | } |
| 364 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 365 | struct set_lan_t |
| 366 | { |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 367 | uint8_t channel; |
| 368 | uint8_t parameter; |
| 369 | uint8_t data[8]; // Per IPMI spec, not expecting more than this size |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 370 | } __attribute__((packed)); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 371 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 372 | ipmi_ret_t ipmi_transport_set_lan(ipmi_netfn_t netfn, |
| 373 | ipmi_cmd_t cmd, |
| 374 | ipmi_request_t request, |
| 375 | ipmi_response_t response, |
| 376 | ipmi_data_len_t data_len, |
| 377 | ipmi_context_t context) |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 378 | { |
| 379 | ipmi_ret_t rc = IPMI_CC_OK; |
| 380 | *data_len = 0; |
Nan Li | 3d0df91 | 2016-10-18 19:51:41 +0800 | [diff] [blame] | 381 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 382 | char ipaddr[INET_ADDRSTRLEN]; |
| 383 | char netmask[INET_ADDRSTRLEN]; |
| 384 | char gateway[INET_ADDRSTRLEN]; |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 385 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 386 | auto reqptr = reinterpret_cast<const set_lan_t*>(request); |
| 387 | sdbusplus::bus::bus bus(ipmid_get_sd_bus_connection()); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 388 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 389 | // channel number is the lower nibble |
| 390 | int channel = reqptr->channel & CHANNEL_MASK; |
| 391 | auto ethdevice = ipmi::network::ChanneltoEthernet(channel); |
| 392 | if (ethdevice.empty()) |
| 393 | { |
| 394 | return IPMI_CC_INVALID_FIELD_REQUEST; |
| 395 | } |
| 396 | auto channelConf = getChannelConfig(channel); |
| 397 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 398 | switch (reqptr->parameter) |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 399 | { |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 400 | case LAN_PARM_IP: |
Hariharasubramanian R | 8395191 | 2016-01-20 07:06:36 -0600 | [diff] [blame] | 401 | { |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 402 | snprintf(ipaddr, INET_ADDRSTRLEN, ipmi::network::IP_ADDRESS_FORMAT, |
| 403 | reqptr->data[0], reqptr->data[1], |
| 404 | reqptr->data[2], reqptr->data[3]); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 405 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 406 | channelConf->ipaddr.assign(ipaddr); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 407 | } |
| 408 | break; |
| 409 | |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 410 | case LAN_PARM_IPSRC: |
| 411 | { |
| 412 | uint8_t ipsrc{}; |
| 413 | memcpy(&ipsrc, reqptr->data, ipmi::network::IPSRC_SIZE_BYTE); |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 414 | channelConf->ipsrc = static_cast<ipmi::network::IPOrigin>(ipsrc); |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 415 | } |
| 416 | break; |
| 417 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 418 | case LAN_PARM_MAC: |
| 419 | { |
| 420 | char mac[SIZE_MAC]; |
| 421 | |
| 422 | snprintf(mac, SIZE_MAC, ipmi::network::MAC_ADDRESS_FORMAT, |
| 423 | reqptr->data[0], |
| 424 | reqptr->data[1], |
| 425 | reqptr->data[2], |
| 426 | reqptr->data[3], |
| 427 | reqptr->data[4], |
| 428 | reqptr->data[5]); |
| 429 | |
| 430 | auto macObjectInfo = ipmi::getDbusObject( |
| 431 | bus, |
| 432 | ipmi::network::MAC_INTERFACE, |
| 433 | ipmi::network::ROOT, |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 434 | ethdevice); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 435 | |
| 436 | ipmi::setDbusProperty(bus, |
| 437 | macObjectInfo.second, |
| 438 | macObjectInfo.first, |
| 439 | ipmi::network::MAC_INTERFACE, |
| 440 | "MACAddress", |
| 441 | std::string(mac)); |
| 442 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 443 | channelConf->macAddress = mac; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 444 | } |
| 445 | break; |
| 446 | |
| 447 | case LAN_PARM_SUBNET: |
| 448 | { |
| 449 | snprintf(netmask, INET_ADDRSTRLEN, ipmi::network::IP_ADDRESS_FORMAT, |
| 450 | reqptr->data[0], reqptr->data[1], |
| 451 | reqptr->data[2], reqptr->data[3]); |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 452 | channelConf->netmask.assign(netmask); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 453 | } |
| 454 | break; |
| 455 | |
| 456 | case LAN_PARM_GATEWAY: |
| 457 | { |
| 458 | snprintf(gateway, INET_ADDRSTRLEN, ipmi::network::IP_ADDRESS_FORMAT, |
| 459 | reqptr->data[0], reqptr->data[1], |
| 460 | reqptr->data[2], reqptr->data[3]); |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 461 | channelConf->gateway.assign(gateway); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 462 | } |
| 463 | break; |
| 464 | |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 465 | case LAN_PARM_VLAN: |
| 466 | { |
| 467 | uint16_t vlan {}; |
| 468 | memcpy(&vlan, reqptr->data, ipmi::network::VLAN_SIZE_BYTE); |
| 469 | // We are not storing the enable bit |
| 470 | // We assume that ipmitool always send enable |
| 471 | // bit as 1. |
| 472 | vlan = le16toh(vlan); |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 473 | channelConf->vlanID = vlan; |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 474 | } |
| 475 | break; |
| 476 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 477 | case LAN_PARM_INPROGRESS: |
| 478 | { |
| 479 | if (reqptr->data[0] == SET_COMPLETE) |
| 480 | { |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 481 | channelConf->lan_set_in_progress = SET_COMPLETE; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 482 | |
| 483 | log<level::INFO>("Network data from Cache", |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 484 | entry("PREFIX=%s", channelConf->netmask.c_str()), |
| 485 | entry("ADDRESS=%s", channelConf->ipaddr.c_str()), |
| 486 | entry("GATEWAY=%s", channelConf->gateway.c_str()), |
| 487 | entry("VLAN=%d", channelConf->vlanID)); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 488 | |
| 489 | log<level::INFO>("Use Set Channel Access command to apply"); |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 490 | } |
| 491 | else if (reqptr->data[0] == SET_IN_PROGRESS) // Set In Progress |
| 492 | { |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 493 | channelConf->lan_set_in_progress = SET_IN_PROGRESS; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 494 | } |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 495 | } |
| 496 | break; |
| 497 | |
| 498 | default: |
| 499 | { |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 500 | rc = IPMI_CC_PARM_NOT_SUPPORTED; |
| 501 | } |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 502 | } |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 503 | |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 504 | return rc; |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 505 | } |
| 506 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 507 | struct get_lan_t |
| 508 | { |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 509 | uint8_t rev_channel; |
| 510 | uint8_t parameter; |
| 511 | uint8_t parameter_set; |
| 512 | uint8_t parameter_block; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 513 | } __attribute__((packed)); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 514 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 515 | ipmi_ret_t ipmi_transport_get_lan(ipmi_netfn_t netfn, |
| 516 | ipmi_cmd_t cmd, |
| 517 | ipmi_request_t request, |
| 518 | ipmi_response_t response, |
| 519 | ipmi_data_len_t data_len, |
| 520 | ipmi_context_t context) |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 521 | { |
| 522 | ipmi_ret_t rc = IPMI_CC_OK; |
| 523 | *data_len = 0; |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 524 | const uint8_t current_revision = 0x11; // Current rev per IPMI Spec 2.0 |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 525 | |
| 526 | get_lan_t *reqptr = (get_lan_t*) request; |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 527 | // channel number is the lower nibble |
| 528 | int channel = reqptr->rev_channel & CHANNEL_MASK; |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 529 | |
| 530 | if (reqptr->rev_channel & 0x80) // Revision is bit 7 |
| 531 | { |
| 532 | // Only current revision was requested |
| 533 | *data_len = sizeof(current_revision); |
| 534 | memcpy(response, ¤t_revision, *data_len); |
| 535 | return IPMI_CC_OK; |
| 536 | } |
| 537 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 538 | auto ethdevice = ipmi::network::ChanneltoEthernet(channel); |
| 539 | if (ethdevice.empty()) |
| 540 | { |
| 541 | return IPMI_CC_INVALID_FIELD_REQUEST; |
| 542 | } |
| 543 | auto channelConf = getChannelConfig(channel); |
| 544 | |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 545 | if (reqptr->parameter == LAN_PARM_INPROGRESS) |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 546 | { |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 547 | uint8_t buf[] = {current_revision, channelConf->lan_set_in_progress}; |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 548 | *data_len = sizeof(buf); |
| 549 | memcpy(response, &buf, *data_len); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 550 | } |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 551 | else if (reqptr->parameter == LAN_PARM_AUTHSUPPORT) |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 552 | { |
| 553 | uint8_t buf[] = {current_revision,0x04}; |
| 554 | *data_len = sizeof(buf); |
| 555 | memcpy(response, &buf, *data_len); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 556 | } |
Adriana Kobylak | e08fbc6 | 2016-02-09 16:17:23 -0600 | [diff] [blame] | 557 | else if (reqptr->parameter == LAN_PARM_AUTHENABLES) |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 558 | { |
| 559 | uint8_t buf[] = {current_revision,0x04,0x04,0x04,0x04,0x04}; |
| 560 | *data_len = sizeof(buf); |
| 561 | memcpy(response, &buf, *data_len); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 562 | } |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 563 | else if ((reqptr->parameter == LAN_PARM_IP) || |
| 564 | (reqptr->parameter == LAN_PARM_SUBNET) || |
| 565 | (reqptr->parameter == LAN_PARM_GATEWAY) || |
| 566 | (reqptr->parameter == LAN_PARM_MAC)) |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 567 | { |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 568 | uint8_t buf[ipmi::network::MAC_ADDRESS_SIZE_BYTE + 1] = {}; |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 569 | |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 570 | *data_len = sizeof(current_revision); |
| 571 | memcpy(buf, ¤t_revision, *data_len); |
| 572 | |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 573 | if (getNetworkData(reqptr->parameter, &buf[1], channel) == IPMI_CC_OK) |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 574 | { |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 575 | if (reqptr->parameter == LAN_PARM_MAC) |
| 576 | { |
| 577 | *data_len = sizeof(buf); |
| 578 | } |
| 579 | else |
| 580 | { |
| 581 | *data_len = ipmi::network::IPV4_ADDRESS_SIZE_BYTE + 1; |
| 582 | } |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 583 | memcpy(response, &buf, *data_len); |
Adriana Kobylak | 342df10 | 2016-02-10 13:48:16 -0600 | [diff] [blame] | 584 | } |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 585 | else |
Hariharasubramanian R | 8395191 | 2016-01-20 07:06:36 -0600 | [diff] [blame] | 586 | { |
tomjose | 26e1773 | 2016-03-03 08:52:51 -0600 | [diff] [blame] | 587 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
Hariharasubramanian R | 8395191 | 2016-01-20 07:06:36 -0600 | [diff] [blame] | 588 | } |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 589 | } |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 590 | else if (reqptr->parameter == LAN_PARM_VLAN) |
| 591 | { |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 592 | uint8_t buf[ipmi::network::VLAN_SIZE_BYTE + 1] = {}; |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 593 | |
| 594 | *data_len = sizeof(current_revision); |
| 595 | memcpy(buf, ¤t_revision, *data_len); |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 596 | if (getNetworkData(reqptr->parameter, &buf[1], channel) == IPMI_CC_OK) |
Ratan Gupta | 533d03b | 2017-07-30 10:39:22 +0530 | [diff] [blame] | 597 | { |
| 598 | *data_len = sizeof(buf); |
| 599 | memcpy(response, &buf, *data_len); |
| 600 | } |
| 601 | } |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 602 | else if (reqptr->parameter == LAN_PARM_IPSRC) |
| 603 | { |
| 604 | uint8_t buff[ipmi::network::IPSRC_SIZE_BYTE + 1] = {}; |
| 605 | *data_len = sizeof(current_revision); |
| 606 | memcpy(buff, ¤t_revision, *data_len); |
Patrick Venture | c7c1c3c | 2017-11-15 14:29:18 -0800 | [diff] [blame] | 607 | if (getNetworkData(reqptr->parameter, &buff[1], channel) == IPMI_CC_OK) |
Ratan Gupta | cc6cdbf | 2017-09-01 23:06:25 +0530 | [diff] [blame] | 608 | { |
| 609 | *data_len = sizeof(buff); |
| 610 | memcpy(response, &buff, *data_len); |
| 611 | } |
| 612 | } |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 613 | else |
| 614 | { |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 615 | log<level::ERR>("Unsupported parameter", |
| 616 | entry("PARAMETER=0x%x", reqptr->parameter)); |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 617 | rc = IPMI_CC_PARM_NOT_SUPPORTED; |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | return rc; |
| 621 | } |
| 622 | |
| 623 | void register_netfn_transport_functions() |
| 624 | { |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 625 | // <Wildcard Command> |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 626 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_TRANSPORT, IPMI_CMD_WILDCARD); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 627 | ipmi_register_callback(NETFUN_TRANSPORT, IPMI_CMD_WILDCARD, NULL, ipmi_transport_wildcard, |
| 628 | PRIVILEGE_USER); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 629 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 630 | // <Set LAN Configuration Parameters> |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 631 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_TRANSPORT, IPMI_CMD_SET_LAN); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 632 | ipmi_register_callback(NETFUN_TRANSPORT, IPMI_CMD_SET_LAN, NULL, ipmi_transport_set_lan, |
| 633 | PRIVILEGE_ADMIN); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 634 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 635 | // <Get LAN Configuration Parameters> |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 636 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_TRANSPORT, IPMI_CMD_GET_LAN); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 637 | ipmi_register_callback(NETFUN_TRANSPORT, IPMI_CMD_GET_LAN, NULL, ipmi_transport_get_lan, |
| 638 | PRIVILEGE_OPERATOR); |
Adriana Kobylak | 5d6481f | 2015-10-29 21:44:55 -0500 | [diff] [blame] | 639 | |
| 640 | return; |
| 641 | } |