Vernon Mauery | e7329c7 | 2018-10-08 12:05:16 -0700 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2018 Intel Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #pragma once |
| 17 | |
| 18 | #include <ipmid/api.hpp> |
| 19 | #include <ipmid/handler.hpp> |
| 20 | |
| 21 | namespace ipmi |
| 22 | { |
| 23 | |
| 24 | namespace impl |
| 25 | { |
| 26 | |
| 27 | // IPMI command handler registration implementation |
| 28 | bool registerHandler(int prio, NetFn netFn, Cmd cmd, Privilege priv, |
| 29 | ::ipmi::HandlerBase::ptr handler); |
| 30 | } // namespace impl |
| 31 | |
| 32 | /** |
| 33 | * @brief main IPMI handler registration function |
| 34 | * |
| 35 | * This function should be used to register all new-style IPMI handler |
| 36 | * functions. This function just passes the callback to makeHandler, which |
| 37 | * creates a new wrapper object that will automatically extract the appropriate |
| 38 | * parameters for the callback function as well as pack up the response. |
| 39 | * |
| 40 | * @param prio - priority at which to register; see api.hpp |
| 41 | * @param netFn - the IPMI net function number to register |
| 42 | * @param cmd - the IPMI command number to register |
| 43 | * @param priv - the IPMI user privilige required for this command |
| 44 | * @param handler - the callback function that will handle this request |
| 45 | * |
| 46 | * @return bool - success of registering the handler |
| 47 | */ |
| 48 | template <typename Handler> |
| 49 | bool registerHandler(int prio, NetFn netFn, Cmd cmd, Privilege priv, |
| 50 | Handler&& handler) |
| 51 | { |
| 52 | auto h = ipmi::makeHandler(std::forward<Handler>(handler)); |
| 53 | return impl::registerHandler(prio, netFn, cmd, priv, h); |
| 54 | } |
| 55 | |
| 56 | } // namespace ipmi |
| 57 | |
| 58 | #ifdef ALLOW_DEPRECATED_API |
| 59 | /** |
| 60 | * @brief legacy IPMI handler registration function |
| 61 | * |
| 62 | * This function should be used to register all legacy IPMI handler |
| 63 | * functions. This function just behaves just as the legacy registration |
| 64 | * mechanism did, silently replacing any existing handler with a new one. |
| 65 | * |
| 66 | * @param netFn - the IPMI net function number to register |
| 67 | * @param cmd - the IPMI command number to register |
| 68 | * @param context - ignored |
| 69 | * @param handler - the callback function that will handle this request |
| 70 | * @param priv - the IPMI user privilige required for this command |
| 71 | */ |
| 72 | // [[deprecated("Use ipmi::registerHandler() instead")]] |
| 73 | void ipmi_register_callback(ipmi_netfn_t netFn, ipmi_cmd_t cmd, |
| 74 | ipmi_context_t context, ipmid_callback_t handler, |
| 75 | ipmi_cmd_privilege_t priv); |
| 76 | |
| 77 | #endif /* ALLOW_DEPRECATED_API */ |
| 78 | |
| 79 | // IPMI 2.0 and DCMI 1.5 standard commands, namespaced by NetFn |
| 80 | // OEM and non-standard commands should be defined where they are used |
| 81 | namespace ipmi |
| 82 | { |
| 83 | namespace app |
| 84 | { |
| 85 | // 0x00 reserved |
| 86 | constexpr Cmd cmdGetDeviceId = 0x01; |
| 87 | constexpr Cmd cmdColdReset = 0x02; |
| 88 | constexpr Cmd cmdWarmReset = 0x03; |
| 89 | constexpr Cmd cmdGetSelfTestResults = 0x04; |
| 90 | constexpr Cmd cmdManufacturingTestOn = 0x05; |
| 91 | constexpr Cmd cmdSetAcpiPowerState = 0x06; |
| 92 | constexpr Cmd cmdGetAcpiPowerState = 0x07; |
| 93 | constexpr Cmd cmdGetDeviceGuid = 0x08; |
| 94 | constexpr Cmd cmdGetNetFnSupport = 0x09; |
| 95 | constexpr Cmd cmdGetCmdSupport = 0x0A; |
| 96 | constexpr Cmd cmdGetCmdSubFnSupport = 0x0B; |
| 97 | constexpr Cmd cmdGetConfigurableCmds = 0x0C; |
| 98 | constexpr Cmd cmdGetConfigurableCmdSubFns = 0x0D; |
| 99 | // 0x0E-0x21 unassigned |
| 100 | constexpr Cmd cmdResetWatchdogTimer = 0x22; |
| 101 | // 0x23 unassigned |
| 102 | constexpr Cmd cmdSetWatchdogTimer = 0x24; |
| 103 | constexpr Cmd cmdGetWatchdogTimer = 0x25; |
| 104 | // 0x26-0x2D unassigned |
| 105 | constexpr Cmd cmdSetBmcGlobalEnables = 0x2E; |
| 106 | constexpr Cmd cmdGetBmcGlobalEnables = 0x2F; |
| 107 | constexpr Cmd cmdClearMessageFlags = 0x30; |
| 108 | constexpr Cmd cmdGetMessageFlags = 0x31; |
| 109 | constexpr Cmd cmdEnableMessageChannelRcv = 0x32; |
| 110 | constexpr Cmd cmdGetMessage = 0x33; |
| 111 | constexpr Cmd cmdSendMessage = 0x34; |
| 112 | constexpr Cmd cmdReadEventMessageBuffer = 0x35; |
| 113 | constexpr Cmd cmdGetBtIfaceCapabilities = 0x36; |
| 114 | constexpr Cmd cmdGetSystemGuid = 0x37; |
| 115 | constexpr Cmd cmdGetChannelAuthCapabilities = 0x38; |
| 116 | constexpr Cmd cmdGetSessionChallenge = 0x39; |
| 117 | constexpr Cmd cmdActivateSession = 0x3A; |
| 118 | constexpr Cmd cmdSetSessionPrivilegeLevel = 0x3B; |
| 119 | constexpr Cmd cmdCloseSession = 0x3C; |
| 120 | constexpr Cmd cmdGetSessionInfo = 0x3D; |
| 121 | // 0x3E unassigned |
| 122 | constexpr Cmd cmdGetAuthCode = 0x3F; |
| 123 | constexpr Cmd cmdSetChannelAccess = 0x40; |
| 124 | constexpr Cmd cmdGetChannelAccess = 0x41; |
| 125 | constexpr Cmd cmdGetChannelInfoCommand = 0x42; |
| 126 | constexpr Cmd cmdSetUserAccessCommand = 0x43; |
| 127 | constexpr Cmd cmdGetUserAccessCommand = 0x44; |
| 128 | constexpr Cmd cmdSetUserName = 0x45; |
| 129 | constexpr Cmd cmdGetUserNameCommand = 0x46; |
| 130 | constexpr Cmd cmdSetUserPasswordCommand = 0x47; |
| 131 | constexpr Cmd cmdActivatePayload = 0x48; |
| 132 | constexpr Cmd cmdDeactivatePayload = 0x49; |
| 133 | constexpr Cmd cmdGetPayloadActivationStatus = 0x4A; |
| 134 | constexpr Cmd cmdGetPayloadInstanceInfo = 0x4B; |
| 135 | constexpr Cmd cmdSetUserPayloadAccess = 0x4C; |
| 136 | constexpr Cmd cmdGetUserPayloadAccess = 0x4D; |
| 137 | constexpr Cmd cmdGetChannelPayloadSupport = 0x4E; |
| 138 | constexpr Cmd cmdGetChannelPayloadVersion = 0x4F; |
| 139 | constexpr Cmd cmdGetChannelOemPayloadInfo = 0x50; |
| 140 | // 0x51 unassigned |
| 141 | constexpr Cmd cmdMasterWriteRead = 0x52; |
| 142 | // 0x53 unassigned |
| 143 | constexpr Cmd cmdGetChannelCipherSuites = 0x54; |
| 144 | constexpr Cmd cmdSuspendResumePayloadEnc = 0x55; |
| 145 | constexpr Cmd cmdSetChannelSecurityKeys = 0x56; |
| 146 | constexpr Cmd cmdGetSystemIfCapabilities = 0x57; |
| 147 | constexpr Cmd cmdSetSystemInfoParameters = 0x58; |
| 148 | constexpr Cmd cmdGetSystemInfoParameters = 0x59; |
| 149 | // 0x5A-0x5F unassigned |
| 150 | constexpr Cmd cmdSetCommandEnables = 0x60; |
| 151 | constexpr Cmd cmdGetCommandEnables = 0x61; |
| 152 | constexpr Cmd cmdSetCommandSubFnEnables = 0x62; |
| 153 | constexpr Cmd cmdGetCommandSubFnEnables = 0x63; |
| 154 | constexpr Cmd cmdGetOemNetFnIanaSupport = 0x64; |
| 155 | // 0x65-0xff unassigned |
| 156 | } // namespace app |
| 157 | |
| 158 | namespace chassis |
| 159 | { |
| 160 | constexpr Cmd cmdGetChassisCapabilities = 0x00; |
| 161 | constexpr Cmd cmdGetChassisStatus = 0x01; |
| 162 | constexpr Cmd cmdChassisControl = 0x02; |
| 163 | constexpr Cmd cmdChassisReset = 0x03; |
| 164 | constexpr Cmd cmdChassisIdentify = 0x04; |
| 165 | constexpr Cmd cmdSetChassisCapabilities = 0x05; |
| 166 | constexpr Cmd cmdSetPowerRestorePolicy = 0x06; |
| 167 | constexpr Cmd cmdGetSystemRestartCause = 0x07; |
| 168 | constexpr Cmd cmdSetSystemBootOptions = 0x08; |
| 169 | constexpr Cmd cmdGetSystemBootOptions = 0x09; |
| 170 | constexpr Cmd cmdSetFrontPanelButtonEnables = 0x0A; |
| 171 | constexpr Cmd cmdSetPowerCycleInterval = 0x0B; |
| 172 | // 0x0C-0x0E unassigned |
| 173 | constexpr Cmd cmdGetPohCounter = 0x0F; |
| 174 | // 0x10-0xFF unassigned |
| 175 | } // namespace chassis |
| 176 | |
| 177 | namespace sensor_event |
| 178 | { |
| 179 | constexpr Cmd cmdSetEventReceiver = 0x00; |
| 180 | constexpr Cmd cmdGetEventReceiver = 0x01; |
| 181 | constexpr Cmd cmdPlatformEvent = 0x02; |
| 182 | // 0x03-0x0F unassigned |
| 183 | constexpr Cmd cmdGetPefCapabilities = 0x10; |
| 184 | constexpr Cmd cmdArmPefPostponeTimer = 0x11; |
| 185 | constexpr Cmd cmdSetPefConfigurationParams = 0x12; |
| 186 | constexpr Cmd cmdGetPefConfigurationParams = 0x13; |
| 187 | constexpr Cmd cmdSetLastProcessedEventId = 0x14; |
| 188 | constexpr Cmd cmdGetLastProcessedEventId = 0x15; |
| 189 | constexpr Cmd cmdAlertImmediate = 0x16; |
| 190 | constexpr Cmd cmdPetAcknowledge = 0x17; |
| 191 | constexpr Cmd cmdGetDeviceSdrInfo = 0x20; |
| 192 | constexpr Cmd cmdGetDeviceSdr = 0x21; |
| 193 | constexpr Cmd cmdReserveDeviceSdrRepository = 0x22; |
| 194 | constexpr Cmd cmdGetSensorReadingFactors = 0x23; |
| 195 | constexpr Cmd cmdSetSensorHysteresis = 0x24; |
| 196 | constexpr Cmd cmdGetSensorHysteresis = 0x25; |
| 197 | constexpr Cmd cmdSetSensorThreshold = 0x26; |
| 198 | constexpr Cmd cmdGetSensorThreshold = 0x27; |
| 199 | constexpr Cmd cmdSetSensorEventEnable = 0x28; |
| 200 | constexpr Cmd cmdGetSensorEventEnable = 0x29; |
| 201 | constexpr Cmd cmdRearmSensorEvents = 0x2A; |
| 202 | constexpr Cmd cmdGetSensorEventStatus = 0x2B; |
| 203 | constexpr Cmd cmdGetSensorReading = 0x2D; |
| 204 | constexpr Cmd cmdSetSensorType = 0x2E; |
| 205 | constexpr Cmd cmdGetSensorType = 0x2F; |
| 206 | constexpr Cmd cmdSetSensorReadingAndEvtSts = 0x30; |
| 207 | // 0x31-0xFF unassigned |
| 208 | } // namespace sensor_event |
| 209 | |
| 210 | namespace storage |
| 211 | { |
| 212 | // 0x00-0x0F unassigned |
| 213 | constexpr Cmd cmdGetFruInventoryAreaInfo = 0x10; |
| 214 | constexpr Cmd cmdReadFruData = 0x11; |
| 215 | constexpr Cmd cmdWriteFruData = 0x12; |
| 216 | // 0x13-0x1F unassigned |
| 217 | constexpr Cmd cmdGetSdrRepositoryInfo = 0x20; |
| 218 | constexpr Cmd cmdGetSdrRepositoryAllocInfo = 0x21; |
| 219 | constexpr Cmd cmdReserveSdrRepository = 0x22; |
| 220 | constexpr Cmd cmdGetSdr = 0x23; |
| 221 | constexpr Cmd cmdAddSdr = 0x24; |
| 222 | constexpr Cmd cmdPartialAddSdr = 0x25; |
| 223 | constexpr Cmd cmdDeleteSdr = 0x26; |
| 224 | constexpr Cmd cmdClearSdrRepository = 0x27; |
| 225 | constexpr Cmd cmdGetSdrRepositoryTime = 0x28; |
| 226 | constexpr Cmd cmdSetSdrRepositoryTime = 0x29; |
| 227 | constexpr Cmd cmdEnterSdrRepoUpdateMode = 0x2A; |
| 228 | constexpr Cmd cmdExitSdrReposUpdateMode = 0x2B; |
| 229 | constexpr Cmd cmdRunInitializationAgent = 0x2C; |
| 230 | // 0x2D-0x3F unassigned |
| 231 | constexpr Cmd cmdGetSelInfo = 0x40; |
| 232 | constexpr Cmd cmdGetSelAllocationInfo = 0x41; |
| 233 | constexpr Cmd cmdReserveSel = 0x42; |
| 234 | constexpr Cmd cmdGetSelEntry = 0x43; |
| 235 | constexpr Cmd cmdAddSelEntry = 0x44; |
| 236 | constexpr Cmd cmdPartialAddSelEntry = 0x45; |
| 237 | constexpr Cmd cmdDeleteSelEntry = 0x46; |
| 238 | constexpr Cmd cmdClearSel = 0x47; |
| 239 | constexpr Cmd cmdGetSelTime = 0x48; |
| 240 | constexpr Cmd cmdSetSelTime = 0x49; |
| 241 | constexpr Cmd cmdGetAuxiliaryLogStatus = 0x5A; |
| 242 | constexpr Cmd cmdSetAuxiliaryLogStatus = 0x5B; |
| 243 | constexpr Cmd cmdGetSelTimeUtcOffset = 0x5C; |
| 244 | constexpr Cmd cmdSetSelTimeUtcOffset = 0x5D; |
| 245 | // 0x5E-0xFF unassigned |
| 246 | } // namespace storage |
| 247 | |
| 248 | namespace transport |
| 249 | { |
| 250 | constexpr Cmd cmdSetLanConfigParameters = 0x01; |
| 251 | constexpr Cmd cmdGetLanConfigParameters = 0x02; |
| 252 | constexpr Cmd cmdSuspendBmcArps = 0x03; |
| 253 | constexpr Cmd cmdGetIpUdpRmcpStatistics = 0x04; |
| 254 | constexpr Cmd cmdSetSerialModemConfig = 0x10; |
| 255 | constexpr Cmd cmdGetSerialModemConfig = 0x11; |
| 256 | constexpr Cmd cmdSetSerialModemMux = 0x12; |
| 257 | constexpr Cmd cmdGetTapResponseCodes = 0x13; |
| 258 | constexpr Cmd cmdSetPppUdpProxyTransmitData = 0x14; |
| 259 | constexpr Cmd cmdGetPppUdpProxyTransmitData = 0x15; |
| 260 | constexpr Cmd cmdSendPppUdpProxyPacket = 0x16; |
| 261 | constexpr Cmd cmdGetPppUdpProxyReceiveData = 0x17; |
| 262 | constexpr Cmd cmdSerialModemConnActive = 0x18; |
| 263 | constexpr Cmd cmdCallback = 0x19; |
| 264 | constexpr Cmd cmdSetUserCallbackOptions = 0x1A; |
| 265 | constexpr Cmd cmdGetUserCallbackOptions = 0x1B; |
| 266 | constexpr Cmd cmdSetSerialRoutingMux = 0x1C; |
| 267 | constexpr Cmd cmdSolActivating = 0x20; |
| 268 | constexpr Cmd cmdSetSolConfigParameters = 0x21; |
| 269 | constexpr Cmd cmdGetSolConfigParameters = 0x22; |
| 270 | constexpr Cmd cmdForwardedCommand = 0x30; |
| 271 | constexpr Cmd cmdSetForwardedCommands = 0x31; |
| 272 | constexpr Cmd cmdGetForwardedCommands = 0x32; |
| 273 | constexpr Cmd cmdEnableForwardedCommands = 0x33; |
| 274 | } // namespace transport |
| 275 | |
| 276 | namespace bridge |
| 277 | { |
| 278 | constexpr Cmd cmdGetBridgeState = 0x00; |
| 279 | constexpr Cmd cmdSetBridgeState = 0x01; |
| 280 | constexpr Cmd cmdGetIcmbAddress = 0x02; |
| 281 | constexpr Cmd cmdSetIcmbAddress = 0x03; |
| 282 | constexpr Cmd cmdSetBridgeProxyAddress = 0x04; |
| 283 | constexpr Cmd cmdGetBridgeStatistics = 0x05; |
| 284 | constexpr Cmd cmdGetIcmbCapabilities = 0x06; |
| 285 | constexpr Cmd cmdClearBridgeStatistics = 0x08; |
| 286 | constexpr Cmd cmdGetBridgeProxyAddress = 0x09; |
| 287 | constexpr Cmd cmdGetIcmbConnectorInfo = 0x0A; |
| 288 | constexpr Cmd cmdGetIcmbConnectionId = 0x0B; |
| 289 | constexpr Cmd cmdSendIcmbConnectionId = 0x0C; |
| 290 | constexpr Cmd cmdPrepareForDiscovery = 0x10; |
| 291 | constexpr Cmd cmdGetAddresses = 0x11; |
| 292 | constexpr Cmd cmdSetDiscovered = 0x12; |
| 293 | constexpr Cmd cmdGetChassisDeviceId = 0x13; |
| 294 | constexpr Cmd cmdSetChassisDeviceId = 0x14; |
| 295 | constexpr Cmd cmdBridgeRequest = 0x20; |
| 296 | constexpr Cmd cmdBridgeMessage = 0x21; |
| 297 | // 0x22-0x2F unassigned |
| 298 | constexpr Cmd cmdGetEventCount = 0x30; |
| 299 | constexpr Cmd cmdSetEventDestination = 0x31; |
| 300 | constexpr Cmd cmdSetEventReceptionState = 0x32; |
| 301 | constexpr Cmd cmdSendIcmbEventMessage = 0x33; |
| 302 | constexpr Cmd cmdGetEventDestination = 0x34; |
| 303 | constexpr Cmd cmdGetEventReceptionState = 0x35; |
| 304 | // 0xC0-0xFE OEM Commands |
| 305 | constexpr Cmd cmdErrorReport = 0xFF; |
| 306 | } // namespace bridge |
| 307 | |
| 308 | namespace dcmi |
| 309 | { |
| 310 | constexpr Cmd cmdGetDcmiCapabilitiesInfo = 0x01; |
| 311 | constexpr Cmd cmdGetPowerReading = 0x02; |
| 312 | constexpr Cmd cmdGetPowerLimit = 0x03; |
| 313 | constexpr Cmd cmdSetPowerLimit = 0x04; |
| 314 | constexpr Cmd cmdActDeactivatePwrLimit = 0x05; |
| 315 | constexpr Cmd cmdGetAssetTag = 0x06; |
| 316 | constexpr Cmd cmdGetDcmiSensorInfo = 0x07; |
| 317 | constexpr Cmd cmdSetAssetTag = 0x08; |
| 318 | constexpr Cmd cmdGetMgmtCntlrIdString = 0x09; |
| 319 | constexpr Cmd cmdSetMgmtCntlrIdString = 0x0A; |
| 320 | constexpr Cmd cmdSetThermalLimit = 0x0B; |
| 321 | constexpr Cmd cmdGetThermalLimit = 0x0C; |
| 322 | constexpr Cmd cmdGetTemperatureReadings = 0x10; |
| 323 | constexpr Cmd cmdSetDcmiConfigParameters = 0x12; |
| 324 | constexpr Cmd cmdGetDcmiConfigParameters = 0x13; |
| 325 | } // namespace dcmi |
| 326 | |
| 327 | } // namespace ipmi |